Root Users Guide a 4

630
ROOT User’s Guide May 2013

Transcript of Root Users Guide a 4

  • ROOT Users Guide

    May 2013

  • 2

  • Contents

    Preface 5

    1 Introduction 7

    1.1 The ROOT Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    1.2 Contact Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.3 Conventions Used in This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.4 The Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.4.1 What Is a Framework? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.4.2 Why Object-Oriented? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    1.5 Installing ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    1.6 The Organization of the ROOT Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    1.6.1 $ROOTSYS/bin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    1.6.2 $ROOTSYS/lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    1.6.3 $ROOTSYS/tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    1.6.4 $ROOTSYS/test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    1.6.5 $ROOTSYS/include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    1.6.6 $ROOTSYS/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    1.7 How to Find More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    1.7.1 Class Reference Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    2 Getting Started 19

    2.1 Setting the Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    2.2 Start and Quit a ROOT Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    2.3 Using the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    2.3.1 Main Menus and Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    2.3.2 The Editor Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    2.3.3 Classes, Methods and Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    2.3.4 User Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    2.3.5 Building a Multi-pad Canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    2.3.6 Saving the Canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    2.3.7 Printing the Canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    2.4 The ROOT Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    2.4.1 Multi-line Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    2.4.2 CINT Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    2.4.3 Helpful Hints for Command Line Typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    3

  • 4 CONTENTS

    2.4.4 Regular Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    2.5 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    2.5.1 Coding Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    2.5.2 Machine Independent Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    2.5.3 TObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    2.6 Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    2.6.1 gROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.6.2 gFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.6.3 gDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.6.4 gPad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.6.5 gRandom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.6.6 gEnv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    2.7 Environment Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    2.7.1 Logon and Logoff Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.7.2 History File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.7.3 Tracking Memory Leaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.7.4 Memory Checker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.8 Converting from PAW to ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    2.8.1 Converting HBOOK/PAW Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    3 Histograms 39

    3.1 The Histogram Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    3.2 Creating Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    3.2.1 Constant or Variable Bin Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    3.3 Bin Numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3.3.1 Convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3.3.2 Re-binning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3.4 Filling Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3.4.1 Automatic Re-binning Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    3.5 Random Numbers and Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    3.6 Adding, Dividing, and Multiplying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    3.7 Projections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    3.8 Drawing Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    3.8.1 Setting the Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    3.8.2 Draw Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    3.8.3 Drawing a Sub-range of a 2-D Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    3.8.4 Superimposing Histograms with Different Scales . . . . . . . . . . . . . . . . . . . . . . . . . . 62

    3.8.5 Statistics Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    3.8.6 Setting Line, Fill, Marker, and Text Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    3.8.7 Setting Tick Marks on the Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

    3.8.8 Giving Titles to the X, Y and Z Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

    3.9 Making a Copy of an Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

    3.10 Normalizing Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

  • CONTENTS 5

    3.11 Saving/Reading Histograms to/from a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

    3.12 Miscellaneous Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

    3.13 Alphanumeric Bin Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

    3.13.1 Option 1: SetBinLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

    3.13.2 Option 2: Fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    3.13.3 Option 3: TTree::Draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    3.13.4 Sort Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    3.14 Histogram Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    3.15 TH2Poly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    3.16 Profile Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    3.16.1 Build Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

    3.16.2 Drawing a Profile without Error Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    3.16.3 Create a Profile from a 2D Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    3.16.4 Create a Histogram from a Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    3.16.5 Generating a Profile from a TTree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    3.16.6 2D Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    3.17 Iso Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

    3.18 3D Implicit Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

    3.19 TPie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

    3.20 The User Interface for Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

    3.20.1 TH1Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

    3.20.2 TH2Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

    4 Graphs 83

    4.1 TGraph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    4.1.1 Graph Draw Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    4.2 Superimposing Two Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

    4.3 Graphs with Error Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

    4.4 Graphs with Asymmetric Error Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

    4.5 Graphs with Asymmetric Bent Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    4.6 TGraphPolar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    4.7 TGraph Exclusion Zone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    4.8 TGraphQQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    4.8.1 Two Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    4.8.2 One Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

    4.9 TMultiGraph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

    4.10 TGraph2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

    4.11 TGraph2DErrors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

    4.12 Fitting a Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

    4.13 Setting the Graphs Axis Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

    4.14 Zooming a Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

    4.15 The User Interface for Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

  • 6 CONTENTS

    5 Fitting Histograms 103

    5.1 The Fit Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

    5.2 Fit with a Predefined Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

    5.3 Fit with a User-Defined Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

    5.3.1 Creating a TF1 with a Formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

    5.3.2 Creating a TF1 with Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

    5.3.3 Creating a TF1 with a User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

    5.4 Fixing and Setting Parameters Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

    5.5 Fitting Sub Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

    5.6 The Fit Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

    5.6.1 Function Choice and Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

    5.6.2 Fitter Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

    5.6.3 Draw Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

    5.6.4 Print Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

    5.6.5 Command Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

    5.7 Fitting Multiple Sub Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

    5.8 Adding Functions to the List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

    5.9 Combining Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

    5.10 Associated Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

    5.11 Access to the Fit Parameters and Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

    5.12 Associated Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

    5.13 Fit Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

    5.14 The Minimization Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

    5.14.1 Basic Concepts of Minuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

    5.14.2 The Transformation of Limited Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

    5.14.3 How to Get the Right Answer from Minuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

    5.14.4 Reliability of Minuit Error Estimates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

    5.15 FUMILI Minimization Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

    5.16 Neural Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

    5.16.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

    5.16.2 The MLP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    5.16.3 Learning Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    5.16.4 Using the Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

    5.16.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

    6 A Little C++ 123

    6.1 Classes, Methods and Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

    6.2 Inheritance and Data Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

    6.2.1 Method Overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

    6.2.2 Data Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

    6.3 Creating Objects on the Stack and Heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

  • CONTENTS 7

    7 CINT the C++ Interpreter 129

    7.1 What is CINT? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

    7.2 The ROOT Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

    7.3 The ROOT Script Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

    7.3.1 Un-named Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

    7.3.2 Named Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

    7.3.3 Executing a Script from a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

    7.4 Resetting the Interpreter Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

    7.5 A Script Containing a Class Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

    7.6 Debugging Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

    7.7 Inspecting Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

    7.8 ROOT/CINT Extensions to C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

    7.9 ACLiC - The Automatic Compiler of Libraries for CINT . . . . . . . . . . . . . . . . . . . . . . . . . . 139

    7.9.1 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

    7.9.2 Setting the Include Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

    7.9.3 Dictionary Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

    7.9.4 Intermediate Steps and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    7.9.5 Moving between Interpreter and Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    7.10 Reflex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

    7.10.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

    7.10.2 Selecting Types And Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

    7.10.3 Genreflex and Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

    7.10.4 GCCXML Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

    7.10.5 Reflex API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

    7.10.6 Cintex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

    8 Object Ownership 149

    8.1 Ownership by Current Directory (gDirectory) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

    8.2 Ownership by the Master TROOT Object (gROOT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

    8.2.1 The Collection of Specials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

    8.2.2 Access to the Collection Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

    8.3 Ownership by Other Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    8.4 Ownership by the User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    8.4.1 The kCanDelete Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    8.4.2 The kMustCleanup Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

    9 Graphics and the Graphical User Interface 153

    9.1 Drawing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    9.2 Interacting with Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    9.2.1 Moving, Resizing and Modifying Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

    9.2.2 Selecting Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

    9.2.3 Context Menus: the Right Mouse Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

    9.2.4 Executing Events when a Cursor Passes on Top of an Object . . . . . . . . . . . . . . . . . . . 157

  • 8 CONTENTS

    9.3 Graphical Containers: Canvas and Pad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

    9.3.1 The Global Pad: gPad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

    9.3.2 The Coordinate Systems of a Pad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

    9.3.3 Converting between Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

    9.3.4 Dividing a Pad into Sub-pads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

    9.3.5 Updating the Pad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    9.3.6 Making a Pad Transparent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    9.3.7 Setting the Log Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    9.3.8 WaitPrimitive method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

    9.3.9 Locking the Pad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

    9.4 Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

    9.4.1 Lines, Arrows and Polylines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

    9.4.2 Circles and Ellipses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

    9.4.3 Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

    9.4.4 Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

    9.4.5 Curly and Wavy Lines for Feynman Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

    9.4.6 Text and Latex Mathematical Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

    9.4.7 Greek Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

    9.4.8 Mathematical Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

    9.4.9 Text in a Pad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

    9.4.10 The TeX Processor TMathText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

    9.5 Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

    9.5.1 Axis Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

    9.5.2 Axis Options and Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

    9.5.3 Setting the Number of Divisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

    9.5.4 Zooming the Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

    9.5.5 Drawing Axis Independently of Graphs or Histograms . . . . . . . . . . . . . . . . . . . . . . . 181

    9.5.6 Orientation of Tick Marks on Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

    9.5.7 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

    9.5.8 Axis with Time Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

    9.5.9 Axis Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

    9.6 Graphical Objects Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

    9.6.1 Text Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

    9.6.2 Line Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    9.6.3 Fill Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    9.6.4 Color and Color Palettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    9.7 The Graphics Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

    9.7.1 TAxisEditor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

    9.7.2 TPadEditor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

    9.8 Copy and Paste . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

    9.8.1 Using the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

    9.8.2 Programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

    9.9 Legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

  • CONTENTS 9

    9.10 The PostScript Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

    9.10.1 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

    9.10.2 Writing Several Canvases to the Same PostScript File . . . . . . . . . . . . . . . . . . . . . . . 206

    9.11 Create or Modify a Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

    9.12 3D Viewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

    9.12.1 Invoking a 3D viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

    9.12.2 The GL Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

    9.12.3 The X3D Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

    9.12.4 Common 3D Viewer Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

    10 Folders and Tasks 227

    10.1 Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    10.2 Why Use Folders? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    10.3 How to Use Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    10.3.1 Creating a Folder Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    10.3.2 Posting Data to a Folder (Producer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

    10.3.3 Reading Data from a Folder (Consumer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

    10.4 Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

    10.5 Execute and Debug Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

    11 Input/Output 235

    11.1 The Physical Layout of ROOT Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

    11.1.1 The File Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

    11.1.2 The Top Directory Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

    11.1.3 The Histogram Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

    11.1.4 The Class Description List (StreamerInfo List) . . . . . . . . . . . . . . . . . . . . . . . . . . . 238

    11.1.5 The List of Keys and the List of Free Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

    11.1.6 File Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

    11.2 The Logical ROOT File: TFile and TKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240

    11.2.1 Viewing the Logical File Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

    11.2.2 The Current Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

    11.2.3 Objects in Memory and Objects on Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

    11.2.4 Saving Histograms to Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

    11.2.5 Histograms and the Current Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

    11.2.6 Saving Objects to Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

    11.2.7 Saving Collections to Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

    11.2.8 A TFile Object Going Out of Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

    11.2.9 Retrieving Objects from Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

    11.2.10Subdirectories and Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

    11.3 Streamers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

    11.3.1 Automatically Generated Streamers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

    11.3.2 Transient Data Members (//!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

    11.3.3 The Pointer to Objects (//->) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

  • 10 CONTENTS

    11.3.4 Variable Length Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

    11.3.5 Double32_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

    11.3.6 Prevent Splitting (//|| ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

    11.3.7 Streamers with Special Additions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

    11.3.8 Writing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

    11.3.9 Ignore Object Streamers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

    11.3.10Streaming a TClonesArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

    11.4 Pointers and References in Persistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

    11.4.1 Streaming C++ Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

    11.4.2 Motivation for the TRef Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

    11.4.3 Using TRef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

    11.4.4 How Does It Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

    11.4.5 Action on Demand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258

    11.4.6 Array of TRef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    11.5 Schema Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    11.5.1 The TStreamerInfo Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

    11.5.2 The TStreamerElement Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

    11.5.3 Example: TH1 StreamerInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

    11.5.4 Optimized StreamerInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

    11.5.5 Automatic Schema Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

    11.5.6 Manual Schema Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

    11.5.7 Building Class Definitions with the StreamerInfo . . . . . . . . . . . . . . . . . . . . . . . . . . 263

    11.5.8 Example: MakeProject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

    11.6 Migrating to ROOT 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

    11.7 Compression and Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

    11.8 Remotely Access to ROOT Files via a rootd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

    11.8.1 TNetFile URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

    11.8.2 Remote Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

    11.8.3 A Simple Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

    11.8.4 The rootd Daemon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

    11.8.5 Starting rootd via inetd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

    11.8.6 Command Line Arguments for rootd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

    11.9 Reading ROOT Files via Apache Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

    11.9.1 Using the General Open Function of TFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

    11.10XML Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

    12 Trees 271

    12.1 Why Should You Use a Tree? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

    12.2 A Simple TTree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

    12.3 Show an Entry with TTree::Show . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

    12.4 Print the Tree Structure with TTree::Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

    12.5 Scan a Variable the Tree with TTree::Scan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

    12.6 The Tree Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

  • CONTENTS 11

    12.7 Creating and Saving Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

    12.7.1 Creating a Tree from a Folder Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

    12.7.2 Tree and TRef Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

    12.7.3 Autosave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

    12.7.4 Trees with Circular Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

    12.7.5 Size of TTree in the File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

    12.7.6 User Info Attached to a TTree Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

    12.7.7 Indexing a Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

    12.8 Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

    12.9 Adding a Branch to Hold a List of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

    12.10Adding a TBranch to Hold an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

    12.10.1Setting the Split-level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

    12.10.2Exempt a Data Member from Splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

    12.10.3Adding a Branch to Hold a TClonesArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

    12.10.4 Identical Branch Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

    12.11Adding a Branch with a Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

    12.12Adding a Branch with a Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

    12.13Examples for Writing and Reading Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

    12.14Example 1: A Tree with Simple Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

    12.14.1Writing the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

    12.14.2Viewing the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

    12.14.3Reading the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286

    12.15Example 2: A Tree with a C Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

    12.15.1Writing the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

    12.15.2Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

    12.16Example 3: Adding Friends to Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    12.16.1Adding a Branch to an Existing Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    12.16.2TTree::AddFriend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    12.17Example 4: A Tree with an Event Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

    12.17.1The Event Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

    12.17.2The EventHeader Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

    12.17.3The Track Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

    12.17.4Writing the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

    12.17.5Reading the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

    12.18Example 5: Import an ASCII File into a TTree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

    12.19Trees in Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

    12.20Simple Analysis Using TTree::Draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

    12.20.1Using Selection with TTree:Draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301

    12.20.2Using TCut Objects in TTree::Draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301

    12.20.3Accessing the Histogram in Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

    12.20.4Using Draw Options in TTree::Draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

    12.20.5Superimposing Two Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

    12.20.6Setting the Range in TTree::Draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

  • 12 CONTENTS

    12.20.7TTree::Draw Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

    12.20.8Multiple variables visualisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311

    12.20.9Using TTree::Scan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

    12.20.10TEventList and TEntryList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

    12.20.11Filling a Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

    12.21Using TTree::MakeClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

    12.21.1Creating a Class with MakeClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

    12.21.2MyClass.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

    12.21.3MyClass.C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

    12.21.4Modifying MyClass::Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

    12.21.5Loading MyClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

    12.22Using TTree::MakeSelector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

    12.22.1Performance Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330

    12.23Impact of Compression on I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330

    12.24Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

    12.24.1TChain::AddFriend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

    13 Math Libraries in ROOT 333

    13.1 TMath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

    13.2 Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

    13.2.1 TRandom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

    13.2.2 TRandom1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

    13.2.3 TRandom2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

    13.2.4 TRandom3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

    13.2.5 Seeding the Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

    13.2.6 Examples of Using the Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

    13.2.7 Random Number Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

    13.2.8 UNURAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

    13.2.9 Performances of Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

    13.3 MathCore Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

    13.4 Generic Vectors for 2, 3 and 4 Dimensions (GenVector) . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

    13.4.1 Main Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

    13.4.2 Example: 3D Vector Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

    13.4.3 Example: 3D Point Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

    13.4.4 Example: LorentzVector Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

    13.4.5 Example: Vector Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

    13.4.6 Example with External Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

    13.5 MathMore Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

    13.6 Mathematical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

    13.6.1 Special Functions in MathCore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

    13.6.2 Special Functions in MathMore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

    13.6.3 Probability Density Functions (PDF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352

    13.6.4 Cumulative Distribution Functions (CDF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

  • CONTENTS 13

    13.7 Linear Algebra: SMatrix Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354

    13.7.1 Example: Vector Class (SVector) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354

    13.7.2 Example: Matrix Class (SMatrix) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

    13.7.3 Example: Matrix and Vector Functions and Operators . . . . . . . . . . . . . . . . . . . . . . . 358

    13.7.4 Matrix and Vector Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

    13.8 Minuit2 Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

    13.9 ROOT Statistics Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

    13.9.1 Classes for Computing Limits and Confidence Levels . . . . . . . . . . . . . . . . . . . . . . . . 360

    13.9.2 Specialized Classes for Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

    13.9.3 Multi-variate Analysis Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

    14 Linear Algebra in ROOT 363

    14.1 Overview of Matrix Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

    14.2 Matrix Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

    14.2.1 Accessing Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

    14.2.2 Setting Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366

    14.3 Creating and Filling a Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366

    14.4 Matrix Operators and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368

    14.4.1 Arithmetic Operations between Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368

    14.4.2 Arithmetic Operations between Matrices and Real Numbers . . . . . . . . . . . . . . . . . . . . 368

    14.4.3 Comparisons and Boolean Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368

    14.4.4 Matrix Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

    14.4.5 Miscellaneous Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

    14.5 Matrix Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

    14.5.1 View Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

    14.5.2 View Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

    14.6 Matrix Decompositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

    14.6.1 Tolerances and Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

    14.6.2 Condition number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

    14.6.3 LU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

    14.6.4 Bunch-Kaufman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

    14.6.5 Cholesky . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376

    14.6.6 QRH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376

    14.6.7 SVD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376

    14.7 Matrix Eigen Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376

    14.8 Speed Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

    15 Adding a Class 379

    15.1 The Role of TObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

    15.1.1 Introspection, Reflection and Run Time Type Identification . . . . . . . . . . . . . . . . . . . . 379

    15.1.2 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

    15.1.3 Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    15.1.4 Paint/Draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

  • 14 CONTENTS

    15.1.5 Clone/DrawClone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    15.1.6 Browse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    15.1.7 SavePrimitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    15.1.8 GetObjectInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    15.1.9 IsFolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    15.1.10Bit Masks and Unique ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    15.2 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

    15.2.1 Template Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

    15.3 The Default Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

    15.4 rootcint: The CINT Dictionary Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

    15.4.1 Dictionaries for STL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

    15.5 Adding a Class with a Shared Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

    15.5.1 The LinkDef.h File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

    15.6 Adding a Class with ACLiC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392

    16 Collection Classes 395

    16.1 Understanding Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

    16.1.1 General Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

    16.1.2 Determining the Class of Contained Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396

    16.1.3 Types of Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396

    16.1.4 Ordered Collections (Sequences) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396

    16.2 Iterators: Processing a Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397

    16.3 Foundation Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397

    16.4 A Collectable Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

    16.5 The TIter Generic Iterator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

    16.6 The TList Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400

    16.6.1 Iterating Over a TList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400

    16.7 The TObjArray Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401

    16.8 TClonesArray An Array of Identical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

    16.8.1 The Idea Behind TClonesArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

    16.9 Template Containers and STL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

    17 Physics Vectors 405

    17.1 The Physics Vector Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

    17.2 TVector3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

    17.2.1 Declaration / Access to the Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406

    17.2.2 Other Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406

    17.2.3 Arithmetic / Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

    17.2.4 Related Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

    17.2.5 Scalar and Vector Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

    17.2.6 Angle between Two Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

    17.2.7 Rotation around Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

    17.2.8 Rotation around a Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

  • CONTENTS 15

    17.2.9 Rotation by TRotation Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

    17.2.10Transformation from Rotated Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

    17.3 TRotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

    17.3.1 Declaration, Access, Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

    17.3.2 Rotation around Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

    17.3.3 Rotation around Arbitrary Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

    17.3.4 Rotation of Local Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

    17.3.5 Inverse Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

    17.3.6 Compound Rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

    17.3.7 Rotation of TVector3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

    17.4 TLorentzVector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

    17.4.1 Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

    17.4.2 Access to Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

    17.4.3 Vector Components in Non-Cartesian Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . 411

    17.4.4 Arithmetic and Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411

    17.4.5 Magnitude/Invariant mass, beta, gamma, scalar product . . . . . . . . . . . . . . . . . . . . . . 411

    17.4.6 Lorentz Boost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

    17.4.7 Rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

    17.4.8 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

    17.5 TLorentzRotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    17.5.1 Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    17.5.2 Access to the Matrix Components/Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    17.5.3 Transformations of a Lorentz Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    17.5.4 Transformation of a TLorentzVector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

    17.5.5 Physics Vector Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

    18 The Geometry Package 415

    18.1 Quick Start: Creating the world . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

    18.1.1 Example 1: Creating the World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

    18.1.2 Example 2: A Geometrical Hierarchy Look and Feel . . . . . . . . . . . . . . . . . . . . . . . . 416

    18.2 Materials and Tracking Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

    18.2.1 Elements, Materials and Mixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

    18.2.2 Radionuclides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420

    18.2.3 Tracking Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

    18.2.4 User Interface for Handling Materials and Media . . . . . . . . . . . . . . . . . . . . . . . . . . 423

    18.3 Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

    18.3.1 Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

    18.3.2 Primitive Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

    18.3.3 Composite Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

    18.3.4 Navigation Methods Performed By Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

    18.3.5 Creating Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

    18.3.6 Dividing Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

    18.3.7 Parametric Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

  • 16 CONTENTS

    18.4 Geometry Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

    18.4.1 The Volume Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444

    18.4.2 Creating and Positioning Volumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446

    18.4.3 Geometrical Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

    18.4.4 Ownership of Geometry Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

    18.5 Navigation and Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456

    18.5.1 TGeoNavigator Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456

    18.5.2 Initializing the Starting Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456

    18.5.3 Initializing the Direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457

    18.5.4 Initializing the State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457

    18.5.5 Checking the Current State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457

    18.5.6 Saving and Restoring the Current State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459

    18.5.7 Navigation Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459

    18.5.8 Creating and Visualizing Tracks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

    18.6 Checking the Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

    18.6.1 The Overlap Checker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464

    18.6.2 Graphical Checking Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

    18.7 The Drawing Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

    18.7.1 Drawing Volumes and Hierarchies of Volumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

    18.7.2 Visualization Settings and Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470

    18.7.3 Ray Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471

    18.8 Representing Misalignments of the Ideal Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472

    18.8.1 Physical Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472

    18.9 Geometry I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474

    18.9.1 GDML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

    18.10Navigation Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

    18.10.1Finding the State Corresponding to a Location (x,y,z) . . . . . . . . . . . . . . . . . . . . . . . 475

    18.10.2Finding the Distance to Next Crossed Boundary . . . . . . . . . . . . . . . . . . . . . . . . . . 476

    18.11Geometry Graphical User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480

    18.11.1Editing a Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480

    18.11.2The Geometry Manager Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483

    18.11.3Editing Existing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484

    18.11.4Creation of New Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

    18.11.5Editing Volumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

    18.11.6How to Create a Valid Geometry with Geometry Editors . . . . . . . . . . . . . . . . . . . . . 491

    19 Python and Ruby Interfaces 493

    19.1 PyROOT Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493

    19.1.1 Glue-ing Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493

    19.1.2 Access to ROOT from Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494

    19.1.3 Access to Python from ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494

    19.1.4 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

    19.1.5 Using PyROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

  • CONTENTS 17

    19.1.6 Memory Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499

    19.1.7 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500

    19.1.8 Use of Python Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500

    19.1.9 Working with Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502

    19.1.10Using Your Own Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504

    19.2 How to Use ROOT with Ruby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504

    19.2.1 Building and Installing the Ruby Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505

    20 The Tutorials and Tests 507

    20.1 $ROOTSYS/tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507

    20.2 $ROOTSYS/test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507

    20.2.1 Event - An Example of a ROOT Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509

    20.2.2 stress - Test and Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514

    20.2.3 guitest - A Graphical User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515

    21 Example Analysis 517

    21.1 Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517

    21.2 Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520

    22 Networking 525

    22.1 Setting-up a Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525

    22.2 Sending Objects over the Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525

    22.3 Closing the Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526

    22.4 A Server with Multiple Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526

    23 Threads 529

    23.1 Threads and Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529

    23.1.1 Process Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529

    23.1.2 Thread Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529

    23.1.3 The Initial Thread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530

    23.2 Implementation of Threads in ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530

    23.2.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530

    23.2.2 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530

    23.2.3 TThread for Pedestrians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530

    23.2.4 TThread in More Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531

    23.3 Advanced TThread: Launching a Method in a Thread . . . . . . . . . . . . . . . . . . . . . . . . . . . 534

    23.3.1 Known Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535

    23.4 The Signals of ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535

    23.5 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536

    24 PROOF: Parallel Processing 539

  • 18 CONTENTS

    25 Writing a Graphical User Interface 54125.1 The ROOT GUI Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54125.2 Widgets and Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54125.3 TVirtualX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54225.4 A Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542

    25.4.1 A Standalone Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54625.5 Widgets Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548

    25.5.1 TGObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54825.5.2 TGWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54825.5.3 TGWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54925.5.4 Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550

    25.6 Layout Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55325.7 Event Processing: Signals and Slots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55425.8 Widgets in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559

    25.8.1 Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55925.8.2 Text Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56225.8.3 Number Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56325.8.4 Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56525.8.5 Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56725.8.6 List Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56825.8.7 Combo Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57025.8.8 Sliders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57025.8.9 Triple Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57125.8.10Progress Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57125.8.11Static Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57225.8.12Status Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57325.8.13Splitters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57325.8.14TGCanvas, ViewPort and Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57525.8.15Embedded Canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576

    25.9 The ROOT Graphics Editor (GED) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57625.9.1 Object Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57725.9.2 Editor Design Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577

    25.10Drag and Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57925.10.1Drag and Drop Data Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57925.10.2Handling Drag and Drop Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580

    26 ROOT/Qt Integration Interfaces 58326.1 Qt-ROOT Implementation of TVirtualX Interface (BNL) . . . . . . . . . . . . . . . . . . . . . . . . . 583

    26.1.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58326.1.2 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58426.1.3 TQtWidget Class, Qt Signals / Slots and TCanvas Interface . . . . . . . . . . . . . . . . . . . . 591

    26.2 GSI QtROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59326.2.1 Create a New Project in the Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59526.2.2 main() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595

  • CONTENTS 19

    27 Automatic HTML Documentation 597

    27.1 Reference Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597

    27.1.1 Product and Module Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598

    27.2 Converting Sources (and Other Files) to HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598

    27.3 Special Documentation Elements: Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598

    27.3.1 Latex Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599

    27.3.2 Macro Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599

    27.4 Customizing HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

    27.4.1 Referencing Documentation for other Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

    27.4.2 Search Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

    27.4.3 ViewCVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

    27.4.4 Wiki Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

    27.5 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

    28 Appendix A: Install and Build ROOT 601

    28.1 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601

    28.2 Installing ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601

    28.3 Choosing a Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601

    28.4 Installing Precompiled Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601

    28.5 Installing the Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602

    28.5.1 Installing and Building the Source from a Compressed File . . . . . . . . . . . . . . . . . . . . 602

    28.5.2 More Build Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602

    28.6 File system.rootrc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603

    28.6.1 TCanvas Specific Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605

    28.6.2 THtml Specific Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606

    28.6.3 GUI Specific Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607

    28.6.4 TBrowser Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608

    28.6.5 TRint Specific Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608

    28.6.6 ACLiC Specific Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609

    28.6.7 PROOF Related Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609

    28.7 Documentation to Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613

  • 20 CONTENTS

  • Preface

    Draft, November 2000 - version 0.6.2In late 1994, we decided to learn and investigate Object Oriented programmingand C++ to better judge the suitability of these relatively new techniques for scientific programming. We knew thatthere is no better way to learn a new programming environment than to use it to write a program that can solve a realproblem. After a few weeks, we had our first histogramming package in C++. A few weeks later we had a rewrite ofthe same package using the, at that time, very new template features of C++. Again, a few weeks later we had anotherrewrite of the package without templates since we could only compile the version with templates on one single platformusing a specific compiler. Finally, after about four months we had a histogramming package that was faster and moreefficient than the well-known FORTRAN based HBOOK histogramming package. This gave us enough confidence inthe new technologies to decide to continue the development. Thus was born ROOT. Since its first public release at theend of 1995, ROOT has enjoyed an ever-increasing popularity. Currently it is being used in all major High Energyand Nuclear Physics laboratories around the world to monitor, to store and to analyse data. In the other sciences aswell as the medical and financial industries, many people are using ROOT. We estimate the current user base to bearound several thousand people. In 1997, Eric Raymond analysed in his paper The Cathedral and the Bazaar thedevelopment method that makes Linux such a success. The essence of that method is: release early, release oftenand listen to your customers. This is precisely how ROOT is being developed. Over the last five years, many of ourcustomers became co-developers. Here we would like to thank our main co-developers and contributors:

    Masaharu Goto wrote the CINT C++ interpreter that became an essential part of ROOT. Despite being 8 timezones ahead of us, we have the feeling he has been sitting in the room next door since 1995.

    Andrei and Mihaela Gheata (Alice collaboration) are co-authors of the ROOT geometry classes and VirtualMonte-Carlo. They have been working with the ROOT team since 2000.

    Olivier Couet, who after a successful development and maintenance of PAW, has joined the ROOT team in 2000 andhas been working on the graphics sub-system.

    Ilka Antcheva has been working on the Graphical User Interface classes. She is also responsible for this latest editionof the Users Guide with a better style, improved index and several new chapters (since 2002).

    Bertrand Bellenot has been developing and maintaining the Win32GDK version of ROOT. Bertrand has also manyother contributions like the nice RootShower example (since 2001).

    Valeriy Onoutchin has been working on several ROOT packages, in particular the graphics sub-system for Windowsand the GUI Builder (since 2000).

    Gerri Ganis has been working on the authentication procedures to be used by the root daemons and the PROOFsystem (since 2002).

    Maarten Ballintijn (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 currentlyworking on the Qt layer of ROOT (since 1995).

    Victor Perevoztchikov (BNL) worked on key elements of the I/O system, in particular the improved support forSTL collections (1997-2001).

    Nenad Buncic developed the HTML documentation generation system and integrated the X3D viewer inside ROOT(1995-1997).

    Suzanne Panacek was the author of the first version of this Users Guide and very active in preparing tutorials andgiving lectures about ROOT (1999-2002).

    Axel Naumann has been developing further the HTML Reference Guide and helps in porting ROOT under Windows(cygwin/gcc implementation) (since 2000).

    Anna Kreshuk has developed the Linear Fitter and Robust Fitter classes as well as many functions in TMath, TF1,TGraph (since 2005).

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

    21

  • 22 CONTENTS

    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 contributions,and finally, everybody who gave comments, reported bugs and provided fixes.

    Happy ROOTing!

    Rene Brun & Fons Rademakers

    Geneva, July 2007

  • Chapter 1

    Introduction

    In the mid 1990s, Ren Brun and Fons Rademakers had many years of experience developing interactive tools andsimulation packages. They had lead successful projects such as PAW, PIAF, and GEANT, and they knew PAW thetwenty-year-old FORTRAN libraries had reached their limits. Although still very popular, these tools could not scaleup to the challenges offered by the Large Hadron Collider, where the data is a few orders of magnitude larger thananything seen before.

    At the same time, computer science had made leaps of progress especially in the area of Object Oriented Design, andRen and Fons were ready to take advantage of it.

    ROOT was developed in the context of the NA49 experiment at CERN. NA49 has generated an impressive amount ofdata, around 10 Terabytes per run. This rate provided the ideal environment to develop and test the next generationdata analysis.

    One cannot mention ROOT without mentioning CINT, its C++ interpreter. CINT was created by Masa Goto inJapan. It is an independent product, which ROOT is using for the command line and script processor.

    ROOT was, and still is, developed in the Bazaar style, a term from the book The Cathedral and the Bazaar byEric S. Raymond. It means a liberal, informal development style that heavily relies on the diverse and deep talent ofthe user community. The result is that physicists developed ROOT for themselves; this made it specific, appropriate,useful, and over time refined and very powerful. The development of ROOT is a continuous conversation between usersand developers with the line between the two blurring at times and the users becoming co-developers.

    When it comes to storing and mining large amount of data, physics plows the way with its Terabytes, but other fieldsand industry follow close behind as they acquiring more and more data over time. They are ready to use the true andtested technologies physics has invented. In this way, other fields and industries have found ROOT useful and theyhave started to use it also.

    In the bazaar view, software is released early and frequently to expose it to thousands of eager co-developers to poundon, report bugs, and contribute possible fixes. More users find more bugs, because they stress the program in differentways. By now, after ten years, the age of ROOT is quite mature. Most likely, you will find the features you are lookingfor, and if you have found a hole, you are encouraged to participate in the dialog and post your suggestion or evenimplementation on roottalk, the ROOT mailing list.

    1.1 The ROOT Mailing Lists

    The roottalk was the very first active ROOT mailing list. mailing list People can subscribe to it by registering at theROOT web site: http://root.cern.ch/root/Registration.phtml. The RootTalk Forum http://root.cern.ch/phpBB3/ hasbeen gradually replaced this mailing list since September 2003. The RootTalk Forum is a web-based news group withabout 10 discussion sub-units.

    If you have a question, it is likely that it has been asked, answered, and stored in the roottalk or RootTalk Forumarchives. Please use the search engine to see if your question has already been answered before sending a mail to theroottalk 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 yourquestion without subscribing to: [email protected]

    23

  • 24 CHAPTER 1. INTRODUCTION

    1.2 Contact Information

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

    We attempt to give the user insight into the many capabilities of ROOT. The book begins with the elementaryfunctionality and progresses in complexity reaching the specialized topics at the end. The experienced user looking forspecial topics may find these chapters useful: see Networking, Writing a Graphical User Interface, Threads,