Docsity

ROOT user guida 5.12, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
Users Guide 5.12
July, 2006
Comments to: [email protected]
______________________________________________________________________________________
The ROOT Users Guide:
Authors: René Brun (CERN), Fons Rademakers (CERN), Philippe Canal (FNAL), Ilka Antcheva (CERN),
Damir Buskulic (LAPP)
Editor: Ilka Antcheva
Special Thanks to: Nick West (Oxford), Elaine Lyons, Suzanne Panacek and Andrey Kubarovsky (FNAL)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download ROOT user guida 5.12 and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Users Guide 5.

Comments to: [email protected], 2006

The ROOT Users Guide: ______________________________________________________________________________________

Special Thanks to: Nick West (Oxford), Elaine Lyons, Suzanne Panacek and Andrey Kubarovsky (FNAL)Editor: Ilka AntchevaDamir Buskulic (LAPP) Authors: René Brun (CERN), Fons Rademakers (CERN), Philippe Canal (FNAL), Ilka Antcheva (CERN),

July 2006 v5.

Preface

i

Masaharu Goto developers. Here we would like to thank our main co-developers and contributors:precisely how ROOT is being developed. Over the last five years, many of our "customers" became co-success. The essence of that method is: "release early, release often and listen to your customers". This isanalyzed in his paper "The Cathedral and the Bazaar" the development method that makes Linux such aROOT. We estimate the current user base to be around several thousand people. In 1997, Eric Raymondto analyze data. In the other sciences as well as the medical and financial industries, many people are usingbeing used in all major High Energy and Nuclear Physics laboratories around the world to monitor, to store andSince its first public release at the end of 1995, ROOT has enjoyed an ever-increasing popularity. Currently it isenough confidence in the new technologies to decide to continue the development. Thus was born ROOT.faster and more efficient than the well-known FORTRAN based HBOOK histogramming package. This gave usplatform using a specific compiler. Finally, after about four months we had a histogramming package that wasrewrite of the package without templates since we could only compile the version with templates on one singlepackage using the, at that time, very new template features of C++. Again, a few weeks later we had anotherfew weeks, we had our first histogramming package in C++. A few weeks later we had a rewrite of the samelearn a new programming environment than to use it to write a program that can solve a real problem. After asuitability of these relatively new techniques for scientific programming. We knew that there is no better way to In late 1994, we decided to learn and investigate Object Oriented programming and C++ to better judge the Preface

(^) wrote the CINT C++ interpreter that became an essential part of ROOT. Despite being 8 time

Andrei zones ahead of us, we have the feeling he has been sitting in the room next door since 1995. (^) and (^) Mihaela Gheata

(^) (Alice collaboration) are co-authors of the ROOT geometry classes and Virtual

Olivier Couet Monte-Carlo. They have been working with the ROOT team since 2000.

, who after a successful development and maintenance of PAW, has joined the ROOT team in

Ilka Antcheva 2000 and has been working on the graphics sub-system.

(^) has been working on the Graphical User Interface classes. She is also responsible for this latest

Bertrand Bellenot edition of the Users Guide with a better style, improved index and several new chapters (since 2002).

(^) has been developing and maintaining the Win32GDK version of ROOT. Bertrand has also

Valeriy Onoutchin many other contributions like the nice RootShower example (since 2001).

(^) has been working on several ROOT packages, in particular the graphics sub-system for

Gerri Ganis Windows and the GUI Builder (since 2000). (^) has been working on the authentication procedures to be used by the root daemons and the

Maarten Ballintijn PROOF system (since 2002).

(^) (MIT) is one of the main developers of the PROOF sub-system (since 1995).

Valeri Fine (^) (now at BNL) ported ROOT to Windows and contributed largely to the 3-D graphics. He is currently

Victor Perevoztchikov working on the Qt layer of ROOT (since 1995).

(^) (BNL) worked on key elements of the I/O system, in particular the improved support for

Nenad Buncic STL collections (1997-2001).

(^) developed the HTML documentation generation system and integrated the X3D viewer inside

Suzanne Panacek ROOT (1995-1997).

(^) was the author of the first version of this User’s Guide and very active in preparing tutorials

Axel Naumann and giving lectures about ROOT (1999-2002).

(^) has been developing further the HTML Reference Guide and helps in porting ROOT under

Anna Kreshuk Windows (cygwin/gcc implementation) (since 2000).

(^) has developed the Linear Fitter and Robust Fitter classes as well as many functions in TMath,

Richard Maunder TF1, TGraph (since 2005).

(^) has contributed to the GL viewer classes (since 2004).

Timur Pocheptsov

(^) has contributed to the GL viewer classes and GL in pad classes (since 2004).

Sergei Linev (^) has developed the XML driver and the TSQLFile classes (since 2003).

Stefan Roiser

(^) has been contributing to the reflex and cintex packages (since 2005).

Lorenzo Moneta

(^) has been contributing the MathCore, MathMore, Smatrix & Minuit2 packages (since 2005).

Wim Lavrijsen

(^) is the author of the PyRoot package (since 2004).

Further we would like to thank all the people mentioned in the

$ROOTSYS/README/CREDITS

(^) file for their

Happy ROOTing!contributions, and finally, everybody who gave comments, reported bugs and provided fixes.

Geneva, July 2006Rene Brun & Fons Rademakers

July 2006 v5.

Table of Contents

v

The User Interface for Graphs .................................................................... 61Zooming a Graph ........................................................................................ 60Setting the Graph's Axis Title..................................................................... 59Fitting a Graph............................................................................................ 59TGraph2DErrors ......................................................................................... 59TGraph2D ................................................................................................... 57TMultiGraph ............................................................................................... 57TGraphQQ .................................................................................................. 56TGraph Exclusion Zone.............................................................................. 55 Graphs with Asymmetric Bent Errors......................................................... 54

(^5) Fitting Histograms

63

Fit with a User-Defined Function ............................................................... 64Fit with a Predefined Function.................................................................... 64The Fit Method ........................................................................................... 63 The Fit Panel............................................................................................... 63

Creating a TF1 with a User Function ........................................... 65Creating a TF1 with Parameters ................................................... 64Creating a TF1 with a Formula..................................................... 64

The Minimization Package ......................................................................... 70Fit Statistics ................................................................................................ 69Associated Errors........................................................................................ 69Access to the Fit Parameters and Results.................................................... 69Associated Function.................................................................................... 69Combining Functions.................................................................................. 67Adding Functions to the List....................................................................... 67Example: Fitting Multiple Sub Ranges....................................................... 66Fitting Sub Ranges...................................................................................... 66Fixing and Setting Bounds for Parameters ................................................. 66

Reliability of Minuit Error Estimates ........................................... 71How to Get the Right Answer from Minuit.................................. 71The Transformation of Limited Parameters.................................. 70Basic Concepts of Minuit ............................................................. 70

Neural Networks......................................................................................... 73FUMILI Minimization Package.................................................................. 72

Examples ...................................................................................... 75Using the Network........................................................................ 74Learning Methods......................................................................... 74The MLP....................................................................................... 73Introduction .................................................................................. 73

(^6) A Little C++

77

Inheritance and Data Encapsulation............................................................ 77 Classes, Methods and Constructors ............................................................ 77

Data Encapsulation....................................................................... 78Method Overriding ....................................................................... 78

Creating Objects on the Stack and Heap..................................................... 79

(^7) CINT the C++ Interpreter

81

The ROOT Script Processor ....................................................................... 83The ROOT Command Line Interface ......................................................... 82 What is CINT? ............................................................................................ 81

Executing a Script from a Script................................................... 85Named Scripts .............................................................................. 84Un-named Scripts ......................................................................... 83

ACLiC - The Automatic Compiler of Libraries for CINT.......................... 89ROOT/CINT Extensions to C++ ................................................................ 88Inspecting Objects....................................................................................... 87Debugging Scripts....................................................................................... 87A Script Containing a Class Definition....................................................... 86Resetting the Interpreter Environment........................................................ 85

vi

Table of Contents

July 2006 v5.

Moving between Interpreter and Compiler................................... 91Intermediate Steps and Files......................................................... 91Dictionary Generation .................................................................. 90Setting the Include Path................................................................ 90 Usage ............................................................................................ 89

(^8) Object Ownership

93

Ownership by the Master TROOT Object (gROOT).................................. 93 Ownership by Current Directory (gDirectory)............................................ 93

Access to the Collection Contents ................................................ 94The Collection of Specials............................................................ 94

Ownership by the User ............................................................................... 94Ownership by Other Objects....................................................................... 94

The kMustCleanup Bit.................................................................. 95The kCanDelete Bit ...................................................................... 94

(^9) Graphics and the Graphical User Interface

97

Interacting with Graphical Objects ............................................................. 97 Drawing Objects ......................................................................................... 97

Executing Events when a Cursor Passes on Top of an Object.... 100Context Menus: the Right Mouse Button ..................................... 98Selecting Objects .......................................................................... 98Moving, Resizing and Modifying Objects.................................... 97

Graphical Containers: Canvas and Pad..................................................... 101

Locking the Pad.......................................................................... 106WaitPrimitive method ................................................................ 105Setting the Log Scale.................................................................. 105Making a Pad Transparent.......................................................... 105Updating the Pad ........................................................................ 104Dividing a Pad into Sub-pads ..................................................... 104Converting between Coordinates Systems ................................. 103The Coordinate Systems of a Pad............................................... 102The Global Pad: gPad................................................................. 101

Graphical Objects ..................................................................................... 106

Sliders......................................................................................... 114Text in a Pad............................................................................... 113Mathematical Symbols ............................................................... 110Greek Letters .............................................................................. 110Text and Latex Mathematical Expressions................................. 109Curly and Wavy Lines for Feynman Diagrams .......................... 108Markers....................................................................................... 107Rectangles .................................................................................. 107Circles and Ellipses .................................................................... 107Lines, Arrows and Polylines....................................................... 106

Axis........................................................................................................... 115

Axis Examples............................................................................ 121Axis with Time Units ................................................................. 118Labels ......................................................................................... 116Orientation of Tick Marks on Axis............................................. 116Drawing Axis Independently of Graphs or Histograms ............. 116Zooming the Axis ....................................................................... 116Setting the Number of Divisions ................................................ 115Axis Options and Characteristics................................................ 115Axis Title.................................................................................... 115

Graphical Objects Attributes..................................................................... 124

Color and Color Palettes............................................................. 127Fill Attributes ............................................................................. 126Line Attributes............................................................................ 126Text Attributes............................................................................ 124

The Graphics Editor.................................................................................. 128

TAxisEditor ................................................................................ 128

July 2006 v5.

Table of Contents

vii

TPadEditor.................................................................................. 129

Copy and Paste ......................................................................................... 129

Programmatically ....................................................................... 130Using the GUI............................................................................. 129

The PostScript Interface............................................................................ 131Legends..................................................................................................... 130

Writing Several Canvases to the Same PostScript File .............. 132Special Characters ...................................................................... 132

3D Viewers ............................................................................................... 136Create or Modify a Style........................................................................... 134

Common 3D Viewer Architecture.............................................. 142The X3D Viewer ........................................................................ 142The GL Viewer........................................................................... 136Invoking a 3D viewer ................................................................. 136

(^10) Folders and Tasks

149

How to Use Folders .................................................................................. 150Why Use Folders?..................................................................................... 149 Folders ...................................................................................................... 149

Reading Data from a Folder (Consumer) ................................... 150Posting Data to a Folder (Producer) ........................................... 150Creating a Folder Hierarchy ....................................................... 150

Execute and Debug Tasks......................................................................... 152Tasks......................................................................................................... 151

(^11) Input/Output

153

The Physical Layout of ROOT Files......................................................... 153

File Recovery.............................................................................. 156The List of Keys and the List of Free Blocks ............................. 156The Class Description List (StreamerInfo List).......................... 155The Histogram Records .............................................................. 155The Top Directory Description................................................... 154The File Header .......................................................................... 154

The Logical ROOT File: TFile and TKey ................................................ 157

Subdirectories and Navigation.................................................... 163Retrieving Objects from Disk..................................................... 163A TFile Object Going Out of Scope ........................................... 163Saving Collections to Disk ......................................................... 163Saving Objects to Disk ............................................................... 162Histograms and the Current Directory........................................ 162Saving Histograms to Disk ......................................................... 161Objects in Memory and Objects on Disk.................................... 159The Current Directory ................................................................ 159Viewing the Logical File Contents ............................................. 158

Streamers .................................................................................................. 165

Streaming a TClonesArray ......................................................... 168Ignore Object Streamers ............................................................. 168Writing Objects .......................................................................... 167Streamers with Special Additions............................................... 166Prevent Splitting (//|| )................................................................. 166Variable Length Array................................................................ 166The Pointer to Objects (//->)....................................................... 166Transient Data Members (//!) ..................................................... 166Automatically Generated Streamers ........................................... 165

Pointers and References in Persistency..................................................... 168

Array of TRef ............................................................................. 171Action on Demand...................................................................... 170How Does It Work?.................................................................... 169Using TRef ................................................................................. 169Motivation for the TRef Class .................................................... 169Streaming C++ Pointers ............................................................. 168

viii

Table of Contents

July 2006 v5.

Schema Evolution ..................................................................................... 171

Example: MakeProject ............................................................... 174Building Class Definitions with the StreamerInfo...................... 174Manual Schema Evolution.......................................................... 174Automatic Schema Evolution..................................................... 173Optimized StreamerInfo ............................................................. 173Example: TH1 StreamerInfo ...................................................... 173The TStreamerElement Class ..................................................... 172The TStreamerInfo Class............................................................ 172

Remotely Access to ROOT Files via a rootd ............................................ 177Compression and Performance ................................................................. 177Migrating to ROOT 3 ............................................................................... 176

Command Line Arguments for rootd ......................................... 179Starting rootd via inetd ............................................................... 178The rootd Daemon...................................................................... 178A Simple Session........................................................................ 178Remote Authentication ............................................................... 177TNetFile URL............................................................................. 177

Reading ROOT Files via Apache Web Server.......................................... 179

Using the General Open Function of TFile ................................ 179

XML Interface .......................................................................................... 180

(^12) Trees

181

Creating and Saving Trees........................................................................ 185The Tree Viewer ....................................................................................... 183Scan a Variable the Tree with TTree::Scan .............................................. 183Print the Tree Structure with TTree::Print ................................................ 182Show an Entry with TTree::Show............................................................. 182A Simple TTree ........................................................................................ 181 Why Should You Use a Tree? .................................................................. 181

Indexing a Tree........................................................................... 186User Info Attached to a TTree Object ........................................ 186Size of TTree in the File ............................................................. 186Trees with Circular Buffers ........................................................ 186Autosave..................................................................................... 186Tree and TRef Objects................................................................ 185Creating a Tree from a Folder Hierarchy.................................... 185

Adding a TBranch to Hold an Object ....................................................... 188Adding a Branch to Hold a List of Variables............................................ 187Branches ................................................................................................... 187

Identical Branch Names.............................................................. 190Adding a Branch to Hold a TClonesArray ................................. 190Exempt a Data Member from Splitting ...................................... 190Setting the Split-level ................................................................. 189

Example 1: A Tree with Simple Variables ............................................... 191Examples for Writing and Reading Trees................................................. 191Adding a Branch with a Collection........................................................... 190Adding a Branch with a Folder................................................................. 190

Reading the Tree......................................................................... 193Viewing the Tree ........................................................................ 192Writing the Tree ......................................................................... 191

Example 2: A Tree with a C Structure...................................................... 194

Analysis ...................................................................................... 197Writing the Tree ......................................................................... 195

Example 3: Adding Friends to Trees ........................................................ 198

TTree::AddFriend....................................................................... 199Adding a Branch to an Existing Tree ......................................... 198

Example 4: A Tree with an Event Class ................................................... 201

Writing the Tree ......................................................................... 202The Track Class.......................................................................... 202The EventHeader Class .............................................................. 201The Event Class.......................................................................... 201

July 2006 v5.

Table of Contents

xi

TVector3 ................................................................................................... 285 The Physics Vector Classes ...................................................................... 285

Transformation from Rotated Frame .......................................... 287Rotation by TRotation Class....................................................... 287Rotation around a Vector............................................................ 286Rotation around Axes ................................................................. 286Angle between Two Vectors ...................................................... 286Scalar and Vector Products......................................................... 286Related Vectors .......................................................................... 286Arithmetic / Comparison ............................................................ 286Other Coordinates....................................................................... 286Declaration / Access to the Components .................................... 285

TRotation .................................................................................................. 287

Rotation of TVector3.................................................................. 288Compound Rotations .................................................................. 288Inverse Rotation.......................................................................... 288Rotation of Local Axes............................................................... 288Rotation around Arbitrary Axis .................................................. 287Rotation around Axes ................................................................. 287Declaration, Access, Comparisons ............................................. 287

TLorentzVector......................................................................................... 288

Miscellaneous............................................................................. 290Rotations..................................................................................... 290Lorentz Boost ............................................................................. 290Magnitude/Invariant mass, beta, gamma, scalar product............ 290Arithmetic and Comparison Operators....................................... 289Vector Components in Non-Cartesian Coordinates.................... 289Access to Components................................................................ 289Declaration ................................................................................. 288

TLorentzRotation...................................................................................... 291

Physics Vector Example............................................................. 292Transformation of a TLorentzVector.......................................... 292Transformations of a Lorentz Rotation....................................... 291Access to the Matrix Components/Comparisons........................ 291Declaration ................................................................................. 291

(^19) The Geometry Package

293

Quick Start: Creating the “world”............................................................ 293

Example 2: A Geometrical Hierarchy Look and Feel ................ 294Example 1: Creating the World .................................................. 293

Materials and Tracking Media .................................................................. 296

User Interface for Handling Materials and Media ...................... 297Tracking Media .......................................................................... 296Elements, Materials and Mixtures .............................................. 296

Shapes....................................................................................................... 297

Parametric Shapes ...................................................................... 310Dividing Shapes.......................................................................... 310Creating Shapes .......................................................................... 310Navigation Methods Performed By Shapes................................ 309Composite Shapes ...................................................................... 307Primitive Shapes......................................................................... 298Units ........................................................................................... 298

Geometry Creation.................................................................................... 311

Ownership of Geometry Objects ................................................ 320Geometrical Transformations ..................................................... 318Creating and Positioning Volumes ............................................. 313The Volume Hierarchy ............................................................... 311

Navigation and Tracking .......................................................................... 321

Checking the Current State......................................................... 322Initializing the State.................................................................... 321Initializing the Direction............................................................. 321Initializing the Starting Point...................................................... 321

xii

Table of Contents

July 2006 v5.

Creating and Visualizing Tracks ................................................ 326Navigation Queries..................................................................... 324 Saving and Restoring the Current State...................................... 323

Checking the Geometry ............................................................................ 327

Graphical Checking Methods ..................................................... 329The Overlap Checker.................................................................. 327

The Drawing Package............................................................................... 329

Ray Tracing ................................................................................ 331Visualization Settings and Attributes ......................................... 330Drawing Volumes and Hierarchies of Volumes ......................... 330

Navigation Algorithms ............................................................................. 332Geometry I/O ............................................................................................ 332

Finding the Distance to Next Crossed Boundary........................ 334Finding the State Corresponding to a Location (x,y,z)............... 333

Geometry Graphical User Interface .......................................................... 336

How to Create a Valid Geometry with Geometry Editors.......... 340Editing Volumes......................................................................... 339Creation of New Objects ............................................................ 339Editing Existing Objects............................................................. 338The Geometry Manager Editor................................................... 337Editing a Geometry..................................................................... 337

(^20) Python and Ruby Interfaces

341

PyROOT Overview................................................................................... 341

Using Your Own Classes............................................................ 350Working with Trees.................................................................... 348Use of Python Functions............................................................. 347Performance................................................................................ 347Memory Handling ...................................................................... 346Using PyROOT .......................................................................... 343Installation .................................................................................. 342Access to Python from ROOT.................................................... 342Access to ROOT from Python.................................................... 341Glue-ing Applications ................................................................ 341

How to Use ROOT with Ruby.................................................................. 352

Building and Installing the Ruby Module................................... 352

(^21) The Tutorials and Tests

355

$ROOTSYS/test ....................................................................................... 355 $ROOTSYS/tutorials ................................................................................ 355

Event

(^) – An Example of a ROOT Application ............................ 356

stress

(^) - Test and Benchmark....................................................... 358

guitest

(^) – A Graphical User Interface .......................................... 359

(^22) Example Analysis

361

Script......................................................................................................... 363 Explanation ............................................................................................... 361

(^23) Networking

367

A Server with Multiple Sockets................................................................ 368Closing the Connection............................................................................. 368Sending Objects over the Network ........................................................... 367 Setting-up a Connection............................................................................ 367

(^24) Threads

369

Threads and Processes .............................................................................. 369

The Initial Thread ....................................................................... 369Thread Properties........................................................................ 369Process Properties....................................................................... 369

July 2006 v5.

Table of Contents

xiii

Implementation of Threads in ROOT ....................................................... 369

TThread in More Details ............................................................ 371TThread for Pedestrians.............................................................. 370Classes ........................................................................................ 370Installation .................................................................................. 370

Advanced TThread: Launching a Method in a Thread ............................. 373

Known Problems ........................................................................ 374

Glossary .................................................................................................... 374The Signals of ROOT ............................................................................... 374

(^25) PROOF: Parallel Processing

377

System Architecture.................................................................................. 377

(^26) Writing a Graphical User Interface

379

A Simple Example .................................................................................... 380TVirtualX.................................................................................................. 379Widgets and Frames.................................................................................. 379 The ROOT GUI Classes ........................................................................... 379

A Standalone Version................................................................. 383

Widgets Overview .................................................................................... 385

Frames ........................................................................................ 386TGWindow................................................................................. 386TGWidget................................................................................... 385TGObject .................................................................................... 385

The Widgets in Details ............................................................................. 394Event Processing: Signals and Slots ......................................................... 390Layout Management ................................................................................. 388

Embedded Canvas ...................................................................... 407TGCanvas, ViewPort and Container .......................................... 406Splitters....................................................................................... 405Status Bar ................................................................................... 404Static Widgets............................................................................. 404Progress Bars.............................................................................. 403Triple Slider................................................................................ 403Sliders......................................................................................... 402Combo Boxes ............................................................................. 402List Boxes................................................................................... 401Toolbar ....................................................................................... 399Menus ......................................................................................... 398Number Entries........................................................................... 397Text Entries ................................................................................ 396Buttons........................................................................................ 394

The ROOT Graphics Editor (GED) .......................................................... 408

Editor Design Elements .............................................................. 408Object Editors............................................................................. 408

(^27) ROOT/Qt Integration Interfaces

411

Qt-ROOT Implementation of TVirtualX Interface (BNL) ....................... 411

Applications................................................................................ 412Installation .................................................................................. 411

GSI QtROOT ............................................................................................ 417

main() ......................................................................................... 419Create a New Project in the Designer......................................... 418

(^28) Automatic HTML Documentation

421

(^29) Appendix A: Install and Build ROOT

423

Choosing a Version................................................................................... 423Installing ROOT ....................................................................................... 423 ROOT Copyright and Licensing Agreement: ........................................... 423

xiv

Table of Contents

July 2006 v5.

Installing the Source ................................................................................. 424 Installing Precompiled Binaries................................................................ 424

More Build Options.................................................................... 424Installing and Building the Source from a Compressed File ...... 424

Documentation to Download .................................................................... 425

(^30) Index

427

July 2006 v5.

Table of Figures

xvii

Figure 26-4 Histogram, pad and axis editors .......................................................... 408Figure 26-3 The layout classes hierarchy................................................................ 389Figure 26-2 The GUI classes hierarchy................................................................... 386Figure 26-1 Widgets created by ROOT GUI classes .............................................. 385Figure 25-1 The Multi-tier structure of a PROOF cluster ....................................... 377Figure 23-1 Server - Client setting-up and closing the connection ......................... 368Figure 21-1 Native GUI widgets............................................................................. 360Figure 19-43 Volume visualisation settings and division interface for volumes .... 339Figure 19-42 Setting volume properties and modifying volume hierarchy............. 339Figure 19-41 Editors for shapes, materials, media, matrices................................... 338Figure 19-40 Selection dialogs for different TGeo objects ..................................... 338Figure 19-39 Accessing/creating different categories of editable objects............... 337Figure 19-38 The geometry manager editor............................................................ 337Figure 19-37 Finding the distance to the next crossed boundary ............................ 335Figure 19-36 Finding the location of a point in the geometry hierarchy................. 334Figure 19-35 Navigation in the geometry hierarchy ............................................... 333Figure 19-34 Ray-tracing example with box-clipping ............................................ 332Figure 19-33 Ray-traced view in a pad ................................................................... 331Figure 19-32 Random rays...................................................................................... 329Figure 19-31 Random points................................................................................... 329Figure 19-30 Safety computation checking............................................................. 329Figure 19-29 Overlap checking............................................................................... 328Figure 19-28 Extruding volumes............................................................................. 327Figure 19-27 Assemblies of volumes...................................................................... 318Figure 19-26 A geometry hierarchy in memory...................................................... 312Figure 19-25 A composite shape example .............................................................. 309Figure 19-24 Internal representation for composite shapes..................................... 308Figure 19-23 Representation of A+B+C ................................................................. 308Figure 19-22 The composite shapes structure......................................................... 307Figure 19-21 TGeoXtru Class................................................................................. 306Figure 19-20 TGeoPgon Class ................................................................................ 306Figure 19-19 TGeoPcon Class ................................................................................ 305Figure 19-18 TGeoParaboloid Class ....................................................................... 305Figure 19-17 TGeoTorus Class ............................................................................... 304Figure 19-16 TGeoSphere Class ............................................................................. 304Figure 19-15 TGeoConeSeg Class.......................................................................... 303Figure 19-14 TGeoCone Class................................................................................ 303Figure 19-13 TGeoHype Class................................................................................ 302Figure 19-12 TGeoEltu Class.................................................................................. 302Figure 19-11 TGeoCtub Class ................................................................................ 302Figure 19-10 TGeoTubeSeg Class .......................................................................... 301Figure 19-9 TGeoTube Class .................................................................................. 301Figure 19-8 TGeoArb8 class................................................................................... 301Figure 19-7 TGeoGtra class .................................................................................... 300 Figure 19-6 TGeoTrap Class................................................................................... 300

July 2006 v5.

Introduction

(^1) and post your suggestion or even implementation onthe features you are looking for, and if you have found a hole, you are encouraged to participate in the dialogprogram in different ways. By now, after ten years, the age of ROOT is quite mature. Most likely, you will findto pound on, report bugs, and contribute possible fixes. More users find more bugs, because they stress theIn the bazaar view, software is released early and frequently to expose it to thousands of eager co-developersuseful and they have started to use it also.the true and tested technologies physics has invented. In this way, other fields and industries have found ROOTfields and industry follow close behind as they acquiring more and more data over time. They are ready to useWhen it comes to storing and mining large amount of data, physics plows the way with its Terabytes, but otherbecoming co-developers.conversation between users and developers with the line between the two blurring at times and the usersappropriate, useful, and over time refined and very powerful. The development of ROOT is a continuoustalent of the user community. The result is that physicists developed ROOT for themselves; this made it specific,by Eric S. Raymond. It means a liberal, informal development style that heavily relies on the diverse and deepROOT was, and still is, developed in the "Bazaar style", a term from the book "The Cathedral and the Bazaar"Japan. It is an independent product, which ROOT is using for the command line and script processor.One cannot mention ROOT without mentioning CINT, its C++ interpreter. CINT was created by Masa Goto innext generation data analysis.amount of data, around 10 Terabytes per run. This rate provided the ideal environment to develop and test theROOT was developed in the context of the NA49 experiment at CERN. NA49 has generated an impressiveDesign, and René and Fons were ready to take advantage of it.At the same time, computer science had made leaps of progress especially in the area of Object Orientedmagnitude larger than anything seen before.not scale up to the challenges offered by the Large Hadron Collider, where the data is a few orders ofthe twenty-year-old FORTRAN libraries had reached their limits. Although still very popular, these tools couldand simulation packages. They had lead successful projects such as PAW, PIAF, and GEANT, and they knew In the mid 1990's, René Brun and Fons Rademakers had many years of experience developing interactive tools Introduction

(^) roottalk , the ROOT mailing list.

The ROOT Mailing Lists The roottalk (^) was the very first active ROOT mailing list. People can subscribe to it by registering at the

ROOT web site: http://root.cern.ch/root/Registration.phtml. The

(^) RootTalk (^) Forum (^) http://root.cern.ch/phpBB2/

has been gradually replaced this mailing list since September 2003. The

(^) RootTalk (^) Forum is a web-based

If you have a question, it is likely that it has been asked, answered, and stored in thenews group with about 10 discussion sub-units.

(^) roottalk (^) or (^) RootTalk

sending a mail to the Forum archives. Please use the search engine to see if your question has already been answered before

(^) roottalk (^) list or post a topic in the Forum.

You can browse the

(^) roottalk (^) archives at: http://root.cern.ch/root/roottalk/AboutRootTalk.html. You can send

your question without subscribing to: [email protected]

Contact Information questions, and suggestions to theadditional topics or on the topics that need more documentation. Please send your comments, corrections,chapter or add to a section, please contact [email protected]. We count on you to send us suggestions oncould accept this in order to have the expert explain what they know best. If you would like to contribute a Several authors wrote this book and you may see a "change of voice" from one chapter to the next. We felt we

(^) rootdoc (^) list: [email protected]

“Threads”, and “PROOF: Parallel Processing”.looking for special topics may find these chapters useful: see “Networking”, “Writing a Graphical User Interface”,functionality and progresses in complexity reaching the specialized topics at the end. The experienced userWe attempt to give the user insight into the many capabilities of ROOT. The book begins with the elementary

Introduction

July 2006 v5.

Conventions Used in This Book intfloat y = 5.;float x = 3.;cout << " Hello" << endl;^ {To show source code in scripts or source files:^ We tried to follow a style convention for the sake of clarity. The styles in used are described below. cout <<" x = "<<x<<" y = "<<y<<" i = "<<i<< endl; (^) i = 101; ROOT prompt has a line number ( To show the ROOT command line, we show the ROOT prompt without numbers. In the interactive system, the}

root[12] ); for the sake of simplicity, the line numbers are left off. Bold

monotype font indicates the ROOT class names as

(^) TObject , (^) TClass , and text for you to enter at verbatim.

root[] (^) TLine l

root[] (^) l.Print()

TLine (^) X1=0.000000 Y1=0.000000 X2=0.000000 Y2=0.

Italic bold monotype font indicates a global variable, for example

(^) gDirectory

. (^) We also used the italic font to

highlight the comments

(^) in the code listing.

can be replaced with any library in theWhen a variable term is used, it is shown between angled brackets. In the example below the variable term

$ROOTSYS

(^) directory: (^) $ROOTSYS//inc.

The Framework Programming What Is a Framework? framework and then why it is an object-oriented framework.There are two key words in this definition, object oriented and framework. First, we explain what we mean by a ROOT is an object-oriented framework aimed at solving the data analysis challenges of high-energy physics. (^) inside (^) a (^) framework

(^) is a (^) little (^) like (^) living (^) in a (^) city. (^) Plumbing, (^) electricity, (^) telephone, (^) and

more commonly used components of ROOT:If you are interested in doing physics, a good HEP framework will save you much work. Below is a list of thelearn the framework interfaces, which in this analogy is the same as learning how to use a telephone.to it, as you are constraint to use the routing algorithm provided by your telephone service. You also have toof HEP specific utilities such as histograms and fitting. The drawback of a framework is that you are constrainedI/O and graphics, are provided. In addition, ROOT being a HEP analysis framework, it provides a large selectiontime. In software engineering, it is much the same way. In a framework, the basic utilities and services, such asbefore you can use the phone to communicate with your collaborators and have a drink of water at the sameeveryone to build his or her own airport. You see you will be very busy building the infrastructure (or framework)cannot build a commercial airport on your patch of land. From a global perspective, it would make no sense forneed to route the wires to your home. In addition, you cannot build some things yourself. For example, youand water, you will have to build a road and dig a well. To have services like telephone and electricity you willProgramming outside of a framework may be compared to living in the country. In order to have transportationphone to communicate with your collaborators to solve your domain specific problems.switching system, are transparent to you as the user. You do not care; you are only interested in using theswitches, electrical outlets, and telephones. The details, for example, the routing algorithm of the phonetransportation are services provided by the city. In your house, you have interfaces to the services such as light

Command Line Interpreter

Histograms and Fitting

Writing a Graphical User Interface

2D Graphics

Input/Output

Collection Classes

Script Processor

There are also less commonly used components, as:

3D Graphics

Parallel Processing (PROOF)

Run Time Type Identification (RTTI)

Socket and Network Communication

Threads

July 2006 v5.

Introduction

  • (^) libCint.so

(^) is the C++ interpreter (

CINT

  • (^) libCore.so

(^) is the Base classes

  • (^) libEG.so

(^) is the abstract event generator interface classes

  • (^) *libEGPythia.so

(^) is the Pythia5 event generator interface

  • (^) *libEGPythia6.so

(^) is the Pythia6 event generator interface

  • (^) libEGVenus.so

(^) is the Venus event generator interface

  • (^) libGpad.so

(^) is the pad and canvas classes which depend on low level graphics

  • (^) libGraf.so

(^) is the 2D graphics primitives (can be used independent of

(^) libGpad.so )

  • (^) libGraf3d.so

(^) is the 3D graphics primitives

  • (^) libGui.so

(^) is the GUI classes (depend on low level graphics)

  • (^) libGeom.so

(^) is the geometry package classes

  • (^) libGeomPainter.so

(^) is the geometry package visualization classes

  • (^) libGX11.so

(^) is the low level graphics interface to the X11 system

  • (^) *libGX11TTF.so

(^) is an add on library to

(^) libGX11.so

(^) providing TrueType fonts

  • (^) libHbook.so

(^) is for interface ROOT - HBOOK

  • (^) libHist.so

(^) is the histogram classes

  • (^) libHistPainter.so

(^) is the histogram painting classes

  • (^) libHtml.so

(^) is the HTML documentation generation system

  • (^) libMatrix.so

(^) is the matrix and vector manipulation

  • (^) libMinuit.so

(^) is the MINUIT fitter

  • (^) libNew.so

(^) is the special global new/delete, provides extra memory checking and interface for

  • (^) libPhysics.soshared memory (optional)

(^) is the physics quantity manipulation classes (

TLorentzVector

, etc.)

  • (^) libPostScript.so

(^) is the PostScript interface

  • (^) libProof.so

(^) is the parallel ROOT Facility classes

  • (^) *libRFIO.so

(^) is the interface to CERN RFIO remote I/O system.

  • (^) *libRGL.so

(^) is the interface to OpenGL.

  • (^) libPython.so

(^) the interface to Python

  • (^) libRuby.so

(^) the interface to Ruby

  • (^) libRint.so

(^) is the interactive interface to ROOT (provides command prompt)

  • (^) *libThread.so

(^) is the interface to

(^) TThread (^) classes

  • (^) libTree.so

(^) is the (^) TTree (^) object container system

  • (^) libTreePlayer.so

(^) is the (^) TTree (^) drawing classes

  • (^) libTreeViewer.so

(^) is the graphical

(^) TTree (^) query interface

  • (^) libX3d.so

(^) is the (^) X3D (^) system used for fast 3D display

(libCore.socode for the task at hand rather than having to include all libraries or one monolithic chunk. The core library The libraries are designed and organized to minimize dependencies, such that you can include just enough Library Dependencies

) contains the essentials; it needs to be included for all ROOT applications.

In the Figure 1-1 you see that

(^) libCore.so

(^) is made up of base classes, container classes, meta information

The CINT library (the ROOT files.classes, networking classes, operating system specific classes, and the ZIP algorithm used for compression of

libCint.so ) is also needed in all ROOT applications, but it can be used independently of

the (^) libCore , in case you only need the C++ interpreter and not the ROOT. That is the reason these two

libraries are separate. A program referencing only the

(^) TObject (^) only needs (^) libCore (^) and (^) libCint

. This

needs the core (A batch program that does not have a graphic display, which creates, fills, and saves histograms and trees, onlyincludes the ability to read and write ROOT objects, and there are no dependencies on graphics, or the GUI.

libCore (^) and (^) libCint ), (^) libHist (^) and (^) libTree

. If other libraries are needed, ROOT loads

them dynamically. For example if the

(^) TreeViewer (^) is used, (^) libTreePlayer

(^) and all libraries the

(^) TreePlayer

box has an arrow to, are loaded also. In this case:

(^) Gui , (^) GPad , (^) Graf3d , (^) Graf , (^) HistPainter

, (^) Hist , and

Tree

. The difference between

(^) libHist (^) and libHistPainter

(^) is that the former needs to be explicitly linked

example of a dynamically linked library isnot automatic. Of course, if one wants to access an automatic library directly, it has to be explicitly linked. AnIn the diagram, the green boxes outside of the core are automatically loaded libraries, and the white ones areand the latter will be loaded automatically at runtime when needed.

(^) Minuit

. To create and fill histograms you need to link

(^) libHist.so .

If the code has a call to fit the histogram, the "fitter" will check that

(^) Minuit (^) is already loaded and if not it will

dynamically load it.

Introduction

July 2006 v5.

We see these source files:cut, the examples in this directory are compiled and run to test the new release's backward compatibility. The test directory contains a set of examples that represent all areas of the framework. When a new release is $ROOTSYS/test information about how to build and run the examples.The more experienced user can jump to chapter “The Tutorials and Tests” to find more explicit and specificthe new user we recommend reading the chapters: “Histograms” and “Input/Output” before trying the examples. The tutorials directory contains many example scripts. They assume some basic knowledge of ROOT, and for $ROOTSYS/tutorials Figure 1-2 ROOT libraries dependencies

hsimple.cxx

(^) - Simple test program that creates and saves some histograms

MainEvent.cxx

(^) - Simple test program that creates a ROOT tree object and fills it with some

simple structures but also with complete histograms. This program uses the files

(^) Event.cxx ,

EventCint.cxx

(^) and (^) Event.h

. (^) An (^) example (^) of a (^) procedure (^) to link this program (^) is in

bind_Event

. Note that the

(^) Makefile (^) invokes the (^) rootcint (^) utility to generate the CINT

interface (^) EventCint.cxx

.

Event.cxx (^) - implementation for classes Event and Track

minexam.cxx

(^) - simple test program to test data fitting

tcollex.cxx

(^) - example usage of the ROOT collection classes

tcollbm.cxx

(^) - benchmarks of ROOT collection classes

tstring.cxx

(^) - example usage of the ROOT string class

vmatrix.cxx

(^) - verification program for the

(^) TMatrix (^) class

vvector.cxx

(^) - verification program for the

(^) TVector (^) class

vlazy.cxx (^) - verification program for lazy matrices

hworld.cxx (^) - small program showing basic graphics

guitest.cxx

(^) - example usage of the ROOT GUI classes

Hello.cxx (^) - dancing text example

Aclock.cxx (^) - an analog clock (a la X

(^) xclock )

Tetris.cxx (^) - the famous Tetris game (using ROOT basic graphics)

stress.cxx (^) - important ROOT stress testing program

July 2006 v5.

Introduction

The $ROOTSYS/test

(^) directory is a gold mine of ROOT-wisdom nuggets, and we encourage you to explore and

Tests” has instructions on how to build all the programs and it goes over the examplesexploit it. We recommend the new users to read the chapter “Getting Started”. The chapter “The Tutorials and

(^) Event (^) and stress .

The (^) include $ROOTSYS/include (^) directory contains all header files. It is especially important because the header files contain the

you also get a directory for each library with the corresponding header and source files, located in the The directories we explored above are available when downloading the binaries. When downloading the source $ROOTSYS/ class definitions.

(^) inc (^) and

src subdirectories. To see what classes are in a library, you can check the

(^) /inc

(^) directory for the

list of class definitions. For example, the physics library

(^) libPhysics.so

(^) contains these class definitions:

TVector3.h CVS,LinkDef.h,TLorentzRotation.h,TLorentzVector.h,TRotation.h,TVector2.h, > ls -m $ROOTSYS/physics/inc

How to Find More Information applications.The ROOT web site contains in addition to this tutorials, "How To's", a list of publications and examplethe parent class page by clicking on the class name. If you want more details, you can even see the source.class description, and an explanation of each method. It shows the class inheritance tree and lets you jump toThe class index web pages can be found at http://root.cern.ch/root/html/ClassIndex.html. Each page contains alatest official release of ROOT.documentation, so each class is explicitly documented on its own web page, which is always up to date with the The ROOT web site has up to date documentation. The ROOT source code automatically generates this

July 2006 v5.

Getting Started

The following components comprise the canvas window: Figure 2-1 A canvas with drawing

object in the canvas.^ •^ Editor frame - responds dynamically and presents the user interface according to the selected^ •^ Status bar – displays descriptive messages about the selected object.^ •^ Canvas – an area to draw objects.^ •^ Tool bar – has buttons for global and drawing operations; such as arrow, ellipse, latex, pad, etc.^ •^ Menu bar – contains main menus for global operations with files, print, clear canvas, inspect, etc.

File Menu^ At the top of the canvas window are File, Edit, View, Options, Inspect, Classes and Help menus. Main Menus and Toolbar

  • (^) New Canvas

: creates a new canvas window in the current ROOT session.

  • (^) Open… : popup a dialog to open a file.
  • (^) Close Canvas

: close the canvas window.

  • (^) Save : save the drawing of the current canvas in a format selectable from
  • (^) Save As… formats such as PostScript, GIF, JPEG, C macro file, root file.the submenu. The current canvas name is used as a file name for various

: popup a dialog for saving the current canvas drawing in a new

  • (^) Print filename. : popup a dialog to print the current canvas drawing
  • (^) Quit ROOT

: exit the ROOT session

become active in the near future. There is only one active menu entry in the Edit menu. The others menu entries will be implemented and will Edit Menu

  • (^) Clear: (^) delete all objects in the canvas or in the selected pad according to the selected entry in the

submenu.

View Menu

  • (^) Editor : toggles the view of the editor. If it is selected activates and shows up
  • (^) Toolbar the object’s attributes.object, the editor loads the corresponding user interface for easy change ofthe editor on the left side of the canvas window. According to the selected : toggles the view of the toolbar. If it is selected activates and shows
  • (^) Status Bar for helping users.used commands and for graphics primitive drawing. Tool tips are providedup the toolbar. It contains buttons for easy and fast access to most frequently

: toggles the view of the status bar. If it is selected, the status bar

Getting Started

July 2006 v5.

moving the mouse (such as the object’s name, the object’s type, its coordinates, etc.). below the canvas window shows up. There the identification of the objects is displayed when

Colors : creates a new canvas showing the color palette.

Markers : creates a new canvas showing the various marker styles.

Iconify : create the canvas window icon, does not close the canvas

View With... : If the last selected pad contains a 3-d structure, a new canvas is created with a 3-D

image can be interactively rotated, zoomed in wire-frame, solid, hidden line or stereo mode.picture according to the selection made from the cascaded menu: X3D or OpenGL. The 3-D

Options Menu

Auto Resize Canvas

: turns auto-resize of the canvas on/off:

ON – the canvas fits to the window when changing the window size;

OFF – the canvas stays fixed when changing the window size.

Resize Canvas

: resizes and fits the canvas to the window size.

Move Opaque

: if selected, graphics objects are moved in opaque

reasonably fast workstation or response time.them. The option opaque produces the best effect but it requires amode; otherwise, only the outline of objects is drawn when moving

Resize Opaque

: if selected, graphics objects are resized in opaque

them.mode; otherwise, only the outline of objects is drawn when resizing

Interrupt : interrupts the current drawing process.

Refresh : redraws the canvas contents.

Pad Auto Exec

: executes the list of

(^) TExecs (^) in the current pad.

Statistics : toggles the display of the histogram statistics box.

Histogram Title

: toggles the display of the histogram title.

Fit Parameters

: toggles the display of the histogram or graph fit parameters.

Can Edit Histogram

: enables/disables the possibility to edit histogram bin contents.

Inspect Menu

ROOT : inspects the top-level

(^) gROOT (^) object (in a new canvas).

Start Browser : starts a new object browser (in a separate window).

GUI Builder : starts the GUI builder application (in a separate window).

Classes Menu

Classes : starts the ClassTree viewer that draws inheritance tree for a list of classes.

Help Menu

Canvas: (^) help on canvas as a whiteboard area for drawing.

Menus : help on canvas menus.

Graphics Editor

: help on primitives’ drawing and objects’ editor.

Browser : help on the ROOT objects’ and files’ browser.

Objects : help on DrawClass, Inspect and Dump context menu items.

PostScript : help on how to print a canvas to a PostScript file format.

About ROOT : pops up the ROOT Logo with the version number.

The following menu shortcuts and utilities are available from the toolbar: Toolbar Redraw the canvas. Interrupts the current drawing process. Popup the Print dialog. Popup the Save As… dialog. Popup the Open File dialog. Create a new canvas window.

July 2006 v5.

Getting Started

Inspect the (^) gROOT (^) object.

Create a new objects’ browser.

provided for helping your choice.You can create the following graphical objects using the toolbar buttons for primitive drawing. Tool tips are An Arc or circle

: Click on the center of the arc, and then move the mouse. A rubber band circle is shown.

Click again with the left button to freeze the arc. A Line : Click with the left button at the point where you want to start the line, then move the mouse and

click again with the left button to freeze the line. An Arrow: (^) Click with the left button at the point where you want to start the arrow, then move the mouse

and click again with the left button to freeze the arrow. A Diamond : Click with the left button and freeze again with the left button. The editor draws a rubber band

box to suggest the outline of the diamond. An Ellipse : Proceed like for an arc. You can grow/shrink the ellipse by pointing to the sensitive points. They

A Pad ellipse and dragging it to its new position.ellipse context menu, you have selected a fill area color, you can move a filled-ellipse by pointing inside theare highlighted. You can move the ellipse by clicking on the ellipse, but not on the sensitive points. If, with the : Click with the left button and freeze again with the left button. The editor draws a rubber band box to

suggest the outline of the pad. A PaveLabel : Proceed like for a pad. Type the text of label and finish with a carriage return. The text will

appear in the box. A Pave Text : (^) Proceed like for a pad. You can then click on the

(^) TPaveText (^) object with the right mouse

button and select the option

(^) InsertText .

Paves Text : Proceed like for a

(^) TPaveText .

A Poly Line : Click with the left button for the first point, move the moose, click again with the left button for

to the new point position.a new point. Close the poly-line with a double click. To edit one vertex point, pick it with the left button and drag A Curly Line : Proceed as for the arrow or line. Once done, click with the third button to change the

characteristics of the curly line, like transform it to wave, change the wavelength, etc. A Curly Arc : Proceed like for an ellipse. The first click is located at the position of the center, the second

and maximum angle to make an arc that is not closed, etc.third button to change the characteristics, like transform it to wavy, change the wavelength, set the minimumclick at the position of the arc beginning. Once done, one obtains a curly ellipse, for which one can click with the A Text/Latex string

: Click with the left button where you want to draw the text and then type in the text

terminated by carriage return. All

(^) TLatex (^) expressions are valid. To move the text or formula, point on it keeping

respectively. If you position the mouse near the bottom-end of the text, you can rotate it.the mouse to the first top-third part of the string, then move the mouse up or down to grow or shrink the textthe left mouse button pressed and drag the text to its new position. You can grow/shrink the text if you position A Marker : Click with the left button where to place the marker. The marker can be modified by using the

method (^) SetMarkerStyle()

(^) of (^) TSystem .

A Graphical Cut

: Click with the left button on each point of a polygon delimiting the selected area. Close

the cut by double clicking on the last point. A

(^) TCutG (^) object is created. It can be used as a selection for a

TTree ::Draw

. You can get a pointer to this object with:

Once you are happy with your picture, you can select the TCutG cut = (TCutG*)gPad->GetPrimitive("CUTG")

(^) Save (^) as canvas.C (^) item in the canvas File menu.

The ROOT graphics editor loads the corresponding object editor The Editor Frame works if you have other objects not drawn with the graphics editor (histograms for example).This will automatically generate a script with the C++ statements corresponding to the picture. This facility also

(^) objEditor (^) according to the selected object

obj in the canvas respecting the class inheritance. An object in the canvas is selected after the left mouse click on it. For example, if the selected object is

(^) TAxis , the TAxisEditor

(^) will shows up in the editor frame giving

the possibility for changing different axis attributes.

Getting Started

July 2006 v5.

The graphics editor can be:

appears for easer navigation.If the user interface needs more space then the height of the canvas window, a vertical scroll barinterface. The name of the selected object is displayed on the top of the editor frame in red color.canvas window allowing users to edit the attributes of the selected object via provided userthe canvas window after been activated via View menu / Editor. It appears on the left side if theEmbedded – connected only with the canvas in the application window that appears on the left of

attributes for backward compatibility, but there will be a unique entry in the near future.session. It can be activated via the context menu entries for setting line, fill, text and markerGlobal – has own application window and can be connected to any created canvas in a ROOT

The user interface for the following classes is available in ROOT v.4.04:

(^) TAttLine , (^) TAttFill , (^) TAttMarker

,

TAttText , (^) TArrow , (^) TAxis , (^) TCurlyArc , (^) TCurlyLine

, (^) TFrame , (^) TH , (^) TH , (^) TGraph , (^) TPad , (^) TCanvas ,

TPaveStats

. For more details, see “The Graphics Editor”, “The User Interface for Histograms”, “The User

creates an object named Object oriented programming introduces objects, which have data members and methods. The next line Classes, Methods and Constructors Interface for Graphs”.

(^) f1 (^) of the class

(^) TF (^) that is a one-dimensional function. The type of an object is called

constructor.a class. The object itself is called an instance of a class. When a method builds an object, it is called a

July 2006 v5.

Getting Started

Pads are numbered from left to right and from top to bottom. Each new pad created by

(^) TCanvas ::Divide()

has a name, which is the name of the canvas followed by _1, _2, etc. To apply the method

(^) cd() (^) to the third

root[]pad, you would write:

  • MyC_3->cd() Third pad will be selected since you called

(^) TPad ::cd() (^) for the object (^) MyC_

. ROOT will find the

pad that was named (^) MyC_ (^) when (^) you (^) typed (^) it (^) on (^) the command (^) line (^) (see (^) ROOT/CINT

Extensions to C++).

WinNT.*.Print.Command: # Printer settings. Both print parameters can be set via the new Print.Command and Print.Printer rootrc resources as follows:command and the printer name. The Print command in the canvas File menu pops-up a print dialog where the user can specify a preferred print Printing the Canvas (Yes/No). The user choice is saved for the next time the Save As… dialog shows up. If the Ovewrite check box is not selected, a message dialog appears asking the user to overwrite the file Figure 2-5 The SaveAs... dialog choice to show or suppress the confirmation message for overwriting an existing file.All supported file types can be saved via File menu / SaveAs…. This dialog gives awith the same name without a warning.files from the list. Please note that saving the canvas this way will overwrite the file Using the File menu / Save cascade menu users can save the canvas as one of the Saving the Canvas

AcroRd32.exe

Unix.*.Print.Command:

xprint -P%p %f

Print.Printer:

32-rb205-hp

Print.Directory:

If the (^) %p and (^) %f (^) are specified as a part of the print command, they will be replaced by the specified printer

canvas toolbar (activated via View menu/Toolbar).name and the file name. All other parameters will be kept as they are written. A print button is available in the

The ROOT Command Line

  1. CINT commands start with “ We have briefly touched on how to use the command line. There are different types of commands.

root[] (^) .?

//this command will list all the CINT commands

root[]. L

//load [filename]

root[] (^) .x

//load and execute [filename]

  1. SHELL commands start with “

.!” for example:

root[] (^) .! ls

root[] 3. C++ commands follow C++ syntax (almost) (^) *TBrowser b = new TBrowser()

Getting Started

July 2006 v5.

a single left curly bracket {, and to end it you must type a single right curly bracket You can use the command line to execute multi-line commands. To begin a multi-line command you must type Multi-line Commands

(^) }. For example:

root[] (^) {

end with '}'>

(^) Int_t j = 0;

end with '}'>

(^) for (Int_t i = 0; i < 3; i++)

end with '}'>

(^) {

end with '}'>

(^) j= j + i;

end with '}'>

(^) cout << "i = " << i << ", j = " << j << endl;

end with '}'>

(^) }

end with '}'>

(^) }

users to complete the command line. For example, if we do not know anything about the The interpreter knows all the classes, functions, variables, and user defined types. This enables ROOT to help Helpful Hints for Command Line Typing “ROOT/CINT Extensions to C++”. We should say that some things are not standard C++. The CINT interpreter has several extensions. See CINT Extensions unmanageable, you may want to start with a script instead. It is more convenient to edit a script than the command line, and if your multi line commands are gettingi = 2, j = 3i = 1, j = 1 i = 0, j = 0

(^) TLine (^) class, the Tab

feature helps us to get a list of all classes starting with

(^) TL (where (^) (^) means type the Tab

(^) key).

root[] (^) l = new TL

To list the different constructors and parameters forTLazyMatrixDTLazyMatrixTListIterTListTLegendTLegendEntryTLatexTLineTLeafSTLeafObjectTLeafITLeafFTLeafDTLeafCTLeafB TLeaf

(^) TLine (^) use the (^) (^) key as follows:

root[] (^) l = new TLine(

The meta-characters below can be used in a regular expression: Regular Expression TLine TLine(const TLine& line)TLine TLine(Double_t x1,Double_t y1,Double_t x2,Double_t y2) TLine TLine()

'^' (^) start-of-line anchor

'$' (^) end-of-line anchor

'.' (^) matches any character

'[' (^) start a character class

']’ end a character class

'^’ negates character class if first character

'*’ (^) Kleene (^) closure (matches 0 or more)

'+’ Positive closure (1 or more)

Optional closure (0 or 1)

July 2006 v5.

Getting Started

When using wildcards the regular expression is assumed to be preceded by a '

^' (BOL) and terminated by '

(EOL). All ' *' (closures) are assumed to be preceded by a '

.', i.e. any character, except slash _

/_. Its special

treatment allows the easy matching of pathnames. For example,

(^) *.root (^) will match (^) aap.root , but not

pipo/aap.root

The escape characters are:

\ backslash

\b backspace

\f form feed

\n new line

\r carriage return

\s space

\t tab

\e ASCII ESC character ('\033')

\DDD

number formed of 1-3 octal digits

\xDD number formed of 1-2 hex digits

^C

C = any letter. Control code

The class (^) TRegexp (^) can be used to create a regular expression from an input string. If

(^) wildcard (^) is true then

The method finds the first occurrence of the regular expression in the Ssiz_t Index(const TString& string,Ssiz_t* len,Ssiz_t i) const Regular expression and wildcards can be easily used in methods like: TRegexp(const char *re, Bool_t wildcard)the input string contains a wildcard expression.

(^) string (^) and returns its position.

Conventions need to use these. These are the coding conventions:convention you want but if you are going to submit some code for inclusion into the ROOT sources, you willdealing with and enable you to understand the code better and quicker. Of course, you can use whateverconsistency throughout the source code. Learning these will help you identify what type of information you are From the first days of ROOT development, it was decided to use a set of coding conventions. This allows a Coding Conventions In this paragraph, we will explain some of the conventions used in ROOT source and examples.

  • (^) Classes begin with

T :

TLine , (^) TTree

  • (^) Non-class types end with

(^) _t :

Int_t

  • (^) Data members begin with

(^) f :

fTree

  • (^) Member functions begin with a capital:

Loop()

  • (^) Constants begin with

(^) k :

kInitialSize, kRed

  • (^) Global variables begin with

(^) g :

gEnv

  • (^) Static data members begin with

(^) fg :

fgTokenClient

  • (^) Enumeration types begin with

E :

EColorLevel

  • (^) Locals and parameters begin with a lower case:

(^) nbytes

  • (^) Getters and setters begin with

(^) Get (^) and Set : (^) SetLast (), (^) GetFirst ()

Different machines may have different lengths for the same type. The most famous example is the Machine Independent Types

(^) int (^) type. It

use these pre defined types in ROOT:may be 16 bits on some old machines and 32 bits on some newer ones. To ensure the size of your variables,

  • (^) Char_t

Signed Character 1 byte

  • (^) UChar_t

Unsigned Character 1 byte

  • (^) Short_t

Signed Short integer 2 bytes

  • (^) UShort_t

Unsigned Short integer 2 bytes

  • (^) Int_t

Signed integer 4 bytes

  • (^) UInt_t

Unsigned integer 4 bytes

  • (^) Long64_t

Portable signed long integer 8 bytes

  • (^) ULong64_t

Portable unsigned long integer 8 bytes

Getting Started

July 2006 v5.

Float_t

Float 4 bytes

Double_t

Float 8 bytes

Double32_t

Double 8 bytes in memory, written as a Float 4 bytes

Bool_t

Boolean (0=false, 1=true)

If you do not want to save a variable on disk, you can use

(^) int (^) or (^) Int_t , the result will be the same and the

In ROOT, almost all classes inherit from a common base class called TObject interpreter or the compiler will treat them in exactly the same way.

(^) TObject

. This kind of architecture is also

used in the Java language. The

(^) TObject (^) class provides default behavior and protocol for all objects in the

TObject classes and consequently it ensures the consistency of the whole system. See "The Role of TObject".ROOT system. The main advantage of this approach is that it enforces the common behavior of the derived

-^ provides protocol, i.e. (abstract) member functions, for: Object I/O ( Read() , (^) Write())

Error handling (

Warning() , (^) Error() , (^) SysError()

, (^) Fatal())

Sorting ( IsSortable()

, (^) Compare() , (^) IsEqual() , (^) Hash())

Inspection ( Dump() , (^) Inspect() )

Printing ( Print())

Drawing ( Draw() , (^) Paint() , (^) ExecuteEvent())

Bit handling ( SetBit() , (^) TestBit() )

Memory allocation (operator

(^) new and delete

, (^) IsOnHeap())

Access to meta information (

IsA() , (^) InheritsFrom())

Object browsing (

Browse() , (^) IsFolder())

Global Variables ROOT has a set of global variables that apply to the session. For example,

(^) gDirectory

(^) always holds the

current directory, and

(^) gStyle (^) holds the current style. All global variables begin with “

g ” followed by a capital

The single instance of gROOT letter.

TROOT

(^) is accessible via the global

(^) gROOT (^) and holds information relative to the current

session. By using the

(^) gROOT (^) pointer, you get the access to every object created in a ROOT program. The

TROOT

(^) object has several lists pointing to the main ROOT objects. During a ROOT session, the

(^) gROOT (^) keeps a

series of collections to manage objects. They can be accessed via

(^) gROOT ::GetListOf…

(^) methods.

These methods return agROOT->GetListOfMessageHandlers()gROOT->GetListOfBrowsers()gROOT->GetListOfGeometries()gROOT->GetListOfSpecials()gROOT->GetListOfFunctions()gROOT->GetListOfStyles()gROOT->GetListOfCanvases()gROOT->GetListOfSockets()gROOT->GetListOfMappedFiles()gROOT->GetListOfFiles()gROOT->GetListOfGlobalFunctions()gROOT->GetListOfGlobals()gROOT->GetListOfTypes()gROOT->GetListOfColors() gROOT->GetListOfClasses()

(^) TSeqCollection

, meaning a collection of objects, and they can be used to do list

the (^) TCollection operations such as finding an object, or traversing the list and calling a method for each of the members. See

(^) class description for the full set of methods supported for a collection.

For example, to find a canvas called

(^) c you can do :

root[] (^) gROOT->GetListOfCanvases()->FindObject("c1")

This returns a pointer to a

(^) TObject , and before you can use it as a canvas you need to cast it to a

(^) TCanvas *.