The ROOT System A Data Access Analysis Framework

  • Slides: 40
Download presentation
The ROOT System A Data Access & Analysis Framework Graphics 3 -4 -5 June

The ROOT System A Data Access & Analysis Framework Graphics 3 -4 -5 June 2003 René Brun/EP http: //root. cern. ch ROOT courses 1

The Graphics libraries Basic principles TPad, list of primitives Painting, Picking 2 -D, 3

The Graphics libraries Basic principles TPad, list of primitives Painting, Picking 2 -D, 3 -D primitives ROOT courses 2

R. Brun LCG ROOT corses 3

R. Brun LCG ROOT corses 3

ROOT libs R O O T CERNLIB ls -l $ROOTSYS/lib 203856 lib. ASImage. so

ROOT libs R O O T CERNLIB ls -l $ROOTSYS/lib 203856 lib. ASImage. so 1273308 lib. Cint. so 5658143 lib. Core. so 419481 lib. EG. so 152912 lib. EGPythia. so 160874 lib. EGPythia 6. so 162181 lib. EGVenus. so 326000 lib. GX 11. so 183065 lib. GX 11 TTF. so 2306421 lib. Geom. so 158895 lib. Geom. Painter. so 1019977 lib. Gpad. so 1602106 lib. Graf. so 1028762 lib. Graf 3 d. so 3669409 lib. Gui. so 1605344 lib. Hbook. so 1940222 lib. Hist. so 332268 lib. Hist. Painter. so 114970 lib. Html. so ls -l /cern/pro/lib 167670 lib. MC. so 580851 lib. Matrix. so 319945 lib. Minuit. so 268321 lib. My. SQL. so 21981 lib. New. so 88438 lib. Pg. SQL. so 336736 lib. Physics. so 196318 lib. Postscript. so 576691 lib. Proof. so 681086 lib. RFIO. so 2017467 lib. RGL. so 177657 lib. Rint. so 35410 lib. SRPAuth. so 1120731 lib. Table. so 312785 lib. Thread. so 1067715 lib. Tree. so 356186 lib. Tree. Player. so 409350 lib. Tree. Viewer. so 155664 lib. X 3 d. so 1434404 1046944 4981896 2002460 11849762 4350440 libgraf. X 11. a libgraflib. a libkernlib. a libmathlib. a libpacklib. a libpawlib. a TOTAL = 25. 2 MBytes TOTAL = 30. 7 MBytes R. Brun LCG ROOT corses 4

Gui/Graphics strategy High level pad graphics User/Root GUI and Graphics classes Applications see only

Gui/Graphics strategy High level pad graphics User/Root GUI and Graphics classes Applications see only Abstract Interfaces TVirtual. Pad Low level screen graphics and GUI TGWin 32 R. Brun LCG TVirtual. X TGQt TG? ? ROOT corses TGX 11 TPad TGWin 32 GDK 5

Coordinate Systems n Pixel coordinates [0, 32000] (TVirtual. X) n n NDC (Normalized Device

Coordinate Systems n Pixel coordinates [0, 32000] (TVirtual. X) n n NDC (Normalized Device Coordinates) n n n [0, 1], (0, 0) at bottom left corner System used for annotations Normal User coordinates (TVirtual. Pad) n n n (0, 0) at top left corner Linear/Log scale in x, y, z Can switch between lin/log scale without calling Draw again. TVirtual. Pad/TPad have functions to convert between systems R. Brun LCG ROOT corses 6

TPad: main graphics container Root > TLine line(. 1, . 9, . 6) Root

TPad: main graphics container Root > TLine line(. 1, . 9, . 6) Root > line. Draw() Root > TText text(. 5, . 2, ”Hello”) Root > text. Draw() Hello The Draw function adds the object to the list of primitives of the current pad. If no pad exists, a pad is automatically created with a default range [0, 1]. When the pad needs to be drawn or redrawn, the object Paint function is called. R. Brun LCG ROOT corses Only objects deriving from TObject may be drawn in a pad Root Objects or User objects 7

TPad hierarchy A primitive in the pad can be another pad. canvas The top

TPad hierarchy A primitive in the pad can be another pad. canvas The top level pad is a TCanvas. pad 1 a A pad has an associate pixmap. Painting is in the pixmap. When the pad must be redrawn, the pixmap is flushed to the window pad 1 pad 2 pad 3 The pixmap is flushed when the pad is declared “modified” and TPad: : Update called R. Brun LCG ROOT corses 8

R. Brun LCG ROOT corses 9

R. Brun LCG ROOT corses 9

Canvas pixmaps 1200 x 800 Need Help? Scroll bars 600 x 400 R. Brun

Canvas pixmaps 1200 x 800 Need Help? Scroll bars 600 x 400 R. Brun LCG ROOT corses 10

Saving a pad/canvas n A pad/canvas may be saved in many formats using the

Saving a pad/canvas n A pad/canvas may be saved in many formats using the GUI menu or via TPad: : Save. As n n n R. Brun LCG canvas. C : a C++ script is automatically generated. The canvas may be generated again via. x canvas. C canvas. ps(eps) Postscript or encapsulated ps canvas. svg : scalable vector graphics canvas. gif canvas. root: keep objects in a compressed and portable format. ROOT corses 11

Graphics in Batch mode n n No changes required to your program X 11

Graphics in Batch mode n n No changes required to your program X 11 libs are not loaded Can produce output with. ps, . eps, . svg, . root example: n canvas. Saves. As(“file. ps”) R. Brun LCG ROOT corses 12

Picking- Graphics event loop TCanvas: : Handle. Input manages the event loop. When the

Picking- Graphics event loop TCanvas: : Handle. Input manages the event loop. When the mouse moves to a pad, TPad: : Pick is called . TPad: : Pick loops on all primitives in the pad, calling their function Distanceto. Primitive. The selected object is the one with the smallest distance. Activate the tool bar option “Show. Event. Status” to understand the behaviour. R. Brun LCG ROOT corses 13

Picking- Graphics event loop When an object has been selected by Distanceto. Primitive, its

Picking- Graphics event loop When an object has been selected by Distanceto. Primitive, its Execute. Event function is called . The result of Execute. Event is object dependent. The cursor changes shape to suggest possible actions : grow/shrink/move box, rotation, etc. Pressing the right mouse button on an object shows its context menu. R. Brun LCG ROOT corses 14

The Graphics Event Loop n The ROOT event handler supports: n n n Foreign

The Graphics Event Loop n The ROOT event handler supports: n n n Foreign systems (eg Inventor, X 3 d. . ) can easily be integrated in the ROOT loop. n n keyboard interrupts system signals X 11, Xt, Xm events Sockets interrupts Special messages (shared memory, threads. . ) ROOT will dispatch the foreign events using Timers. Signals and Slots like in Qt n R. Brun LCG Qt and ROOT can work together ROOT corses 15

Basic Primitives TLine TArrow TEllipse TButton TBox TDiamond TCurvy. Line TText TPave TMarker TPaves.

Basic Primitives TLine TArrow TEllipse TButton TBox TDiamond TCurvy. Line TText TPave TMarker TPaves. Text TCrown TPave. Label TCurly. Arc TPoly. Line TLatex R. Brun LCG ROOT corses 16

The Graphics Editor See HELP button to use the graphics editor R. Brun LCG

The Graphics Editor See HELP button to use the graphics editor R. Brun LCG ROOT corses 17

Graphics attributes Most Root classes derive from very light weight data objects classes like

Graphics attributes Most Root classes derive from very light weight data objects classes like TAtt. Line, TAtt. Fill, TAtt. Marker, TAtt. Text R. Brun LCG ROOT corses 18

Annotations, Paves quarks. C R. Brun LCG ROOT corses 19

Annotations, Paves quarks. C R. Brun LCG ROOT corses 19

Full Late. X support on screen and postscript latex 3. C Formula or diagrams

Full Late. X support on screen and postscript latex 3. C Formula or diagrams can be edited with the mouse Feynman. C TCurly. Arc TCurly. Line TWavy. Line and other building blocks for Feynmann diagrams R. Brun LCG ROOT corses 20

Graphs TGraph. Errors(n, x, y, ex, ey) TGraph(n, x, y) gerrors 2. C TCut.

Graphs TGraph. Errors(n, x, y, ex, ey) TGraph(n, x, y) gerrors 2. C TCut. G(n, x, y) TMulti. Graph TGraph. Asymm. Errors(n, x, y, exl, exh, eyl, eyh) R. Brun LCG ROOT corses 21

Graphs R. Brun LCG zdemo. C ROOT corses 22

Graphs R. Brun LCG zdemo. C ROOT corses 22

Graphics : 1, 2, 3 -D functions Fitting. Demo. C surfaces. C n TF

Graphics : 1, 2, 3 -D functions Fitting. Demo. C surfaces. C n TF 3 f 3(“f 3”, ”sin(x*x+y*y+z*z-36)”, -2, 2, -2, 2); f 3 ->Draw(); R. Brun LCG ROOT corses 23

TGaxis gaxis. C R. Brun LCG ROOT corses 24

TGaxis gaxis. C R. Brun LCG ROOT corses 24

Adding dynamic objects to a pad A TExec object may be added to the

Adding dynamic objects to a pad A TExec object may be added to the pad. Its Paint function call any CINT command. Dynamic. Slice. C R. Brun LCG ROOT corses 25

Using Timers with graphics Double_t pi = TMath: : Pi(); TF 2 *f 2;

Using Timers with graphics Double_t pi = TMath: : Pi(); TF 2 *f 2; Float_t t = 0; Float_t phi = 30; void anim() { g. Style->Set. Frame. Fill. Color(42); TCanvas *c 1 = new TCanvas("c 1"); c 1 ->Set. Fill. Color(17); f 2 = new TF 2("f 2", "sin(2*x)*sin(2*y)*[0]", 0, pi); f 2 ->Set. Parameter(0, 1); f 2 ->Set. Npx(15); f 2 ->Set. Npy(15); f 2 ->Set. Maximum(1); f 2 ->Set. Minimum(-1); f 2 ->Draw("surf 1"); TTimer *timer = new TTimer(20); timer->Set. Command("Animate()"); timer->Turn. On(); } void Animate() { t += 0. 05*pi; f 2 ->Set. Parameter(0, TMath: : Cos(t)); phi += 2; g. Pad->Set. Phi(phi); g. Pad->Modified(); g. Pad->Update(); } R. Brun LCG anim. C Every 20 milliseconds: -Modify the function parameter -Change the view angle ROOT corses 26

More on Timers with Graphics { // run the dancing Hello World Hello hello;

More on Timers with Graphics { // run the dancing Hello World Hello hello; // run the analog clock Aclock; // run the Tetris game Tetris tetris; } The 3 canvases run in parallel games. C R. Brun LCG ROOT corses 27

GUI User example Example of GUI based on ROOT tools Each element is clickable

GUI User example Example of GUI based on ROOT tools Each element is clickable R. Brun LCG ROOT corses 28

GUI Examples R. Brun LCG ROOT corses 29

GUI Examples R. Brun LCG ROOT corses 29

Graphical User Interface Ex: ZEUS event display Input modes Option tabs Status information R.

Graphical User Interface Ex: ZEUS event display Input modes Option tabs Status information R. Brun LCG Canvas Pads ROOT corses Zoom controls Object information 30

Fish-eye View R. Brun LCG ROOT corses 31

Fish-eye View R. Brun LCG ROOT corses 31

TASImage classes New set of image processing classes. The TImage class is the abstract

TASImage classes New set of image processing classes. The TImage class is the abstract image base class and TASImage is the concrete implementation using the lib. After. Image imaging library of Sasha Vasko <sasha@aftercode. net>. A large part of the development was done by Reiner Rohlfs from the ISDC based on a set of astrophysics user requirements. The image class allows for the reading and writing of images in different formats, several image manipulations (scaling, tiling, merging, etc. ) and displaying in pads. The size of the image on the screen does not depend on the original size of the image but on the size of the pad. Therefore it is very easy to resize the image on the screen by resizing the pad. Galaxy_image. C Rose_image. C R. Brun LCG ROOT corses 32

3 -D Graphics n Basic primitives n n Geant primitives n n TPoly. Line

3 -D Graphics n Basic primitives n n Geant primitives n n TPoly. Line 3 D, TPoly. Marker 3 D, THelix, TMarker 3 DBox, TAxis 3 D Support for all Geant 3 volumes + a few new volume types TBRIK, TCONE, TCONS, TCTUB, TELTU, TGTRA, THYPE, TPARA, TPCON, TPGON, TSPHE, TTUBS, TTRAP, TTRD 1, TTRD 2, TXTRU Geometry package Rendering with: n n R. Brun LCG TPad X 3 D (very fast. Unix only. Good on networks) Open. GL Open. Inventor (new addition in 3. 01) ROOT corses 33

Some detectors in ROOT geometry R. Brun LCG ROOT corses 34

Some detectors in ROOT geometry R. Brun LCG ROOT corses 34

Alice R. Brun LCG 3 million nodes ROOT corses 35

Alice R. Brun LCG 3 million nodes ROOT corses 35

R. Brun LCG ROOT corses 36

R. Brun LCG ROOT corses 36

Interfaces with other systems n Root. Python interface by Pere Mato n n Java.

Interfaces with other systems n Root. Python interface by Pere Mato n n Java. Root by Subir Sarkar n n http: //sarkar. home. cern. ch/sarkar/jroot/main. html The ROOT interface to Mathematica n n http: //root. cern. ch/root/R 2002/Program. html http: //mathroot. sourceforge. net and many more, see; n R. Brun LCG http: //root. cern. ch/root/Ex. Applications. html ROOT corses 37

(Pere Mato) TObject. Wrap TObject TClass. Wrap TClass TMethod. Wrap TMethod TCArray. Wrap TROOTWrap

(Pere Mato) TObject. Wrap TObject TClass. Wrap TClass TMethod. Wrap TMethod TCArray. Wrap TROOTWrap Root. Module R. Brun LCG ROOT corses CINT Python interpreter Boost. Python Root. Python Other ROOT Libraries 38

Java. Root http: //sarkar. home. cern. ch/sarkar/jroot/main. html Extend Java with Root libraries Ø

Java. Root http: //sarkar. home. cern. ch/sarkar/jroot/main. html Extend Java with Root libraries Ø Ø Java gets a matured Histograming API, Fitting and Physics analysis classes, a HEP specific Socket programming API Root reaches an even wider audience, finds a number of interpreter and scripting environments that are (re)implemented in Java (Jython, Bean. Shell etc. ) Jython Bean. Shell Net. Rexx Jacl R. Brun LCG J A V A ROOT corses R O O T J N I 39

CINT vs Java/Python/Jython CINT: 280 Rootmarks JAVA: 105 Rootmarks JYTHON: 52 Rootmarks R. Brun

CINT vs Java/Python/Jython CINT: 280 Rootmarks JAVA: 105 Rootmarks JYTHON: 52 Rootmarks R. Brun LCG ROOT corses 40