User's Guide May 2018
Total Page:16
File Type:pdf, Size:1020Kb
User’s Guide May 2018 2 Contents Preface 11 1 Introduction 13 1.1 The ROOT forum............................................... 13 1.2 Contact Information.............................................. 13 1.3 Conventions Used in This Book........................................ 14 1.4 The Framework................................................. 14 1.5 Installing ROOT................................................ 15 1.6 The Organization of the ROOT Framework................................. 16 1.7 How to Find More Information........................................ 21 2 Getting Started 25 2.1 Setting the Environment Variables...................................... 25 2.2 Start and Quit a ROOT Session....................................... 26 2.3 Using the GUI................................................. 27 2.4 The ROOT Command Line.......................................... 37 2.5 Conventions................................................... 39 2.6 Global Variables................................................ 41 2.7 Environment Setup............................................... 42 2.8 Converting from PAW to ROOT....................................... 44 3 Histograms 45 3.1 The Histogram Classes............................................. 45 3.2 Creating Histograms.............................................. 45 3.3 Bin Numbering................................................. 47 3.4 Filling Histograms............................................... 47 3.5 Random Numbers and Histograms...................................... 48 3.6 Adding, Dividing, and Multiplying...................................... 49 3.7 Projections................................................... 49 3.8 Drawing Histograms.............................................. 50 3.9 Making a Copy of an Histogram....................................... 72 3.10 Normalizing Histograms............................................ 72 3.11 Saving/Reading Histograms to/from a File................................. 72 3.12 Miscellaneous Operations........................................... 72 3.13 Alphanumeric Bin Labels........................................... 73 3 4 CONTENTS 3.14 Histogram Stacks................................................ 75 3.15 TH2Poly..................................................... 76 3.16 Profile Histograms............................................... 77 3.17 Iso Surfaces................................................... 81 3.18 3D Implicit Functions............................................. 81 3.19 TPie....................................................... 81 3.20 The User Interface for Histograms...................................... 83 4 Graphs 91 4.1 TGraph..................................................... 91 4.2 Superimposing Two Graphs.......................................... 95 4.3 Graphs with Error Bars............................................ 96 4.4 Graphs with Asymmetric Error Bars..................................... 97 4.5 Graphs with Asymmetric Bent Errors.................................... 98 4.6 TGraphPolar.................................................. 99 4.7 TGraph Exclusion Zone............................................ 101 4.8 TGraphQQ................................................... 102 4.9 TMultiGraph.................................................. 103 4.10 TGraph2D................................................... 104 4.11 TGraph2DErrors................................................ 106 4.12 Fitting a Graph................................................. 106 4.13 Setting the Graph’s Axis Title........................................ 108 4.14 Zooming a Graph................................................ 108 4.15 The User Interface for Graphs......................................... 109 5 Fitting Histograms 111 5.1 The Fit Method................................................ 111 5.2 The TF1 function class............................................. 112 5.3 Configuring the Fit............................................... 115 5.4 Example of fit: Combining Functions..................................... 117 5.5 Result of the fit................................................. 118 5.6 The Fit Panel.................................................. 120 5.7 New ROOT::Fit classes............................................ 123 5.8 The Minimization packages.......................................... 130 5.9 MINUIT (Old TMInuit Version)....................................... 130 5.10 Minuit2 Package................................................ 133 5.11 FUMILI Minimization Package........................................ 133 5.12 Neural Networks................................................ 134 6 A Little C++ 141 6.1 Classes, Methods and Constructors...................................... 141 6.2 Inheritance and Data Encapsulation..................................... 142 6.3 Creating Objects on the Stack and Heap................................... 143 CONTENTS 5 7 The C++ Interpreter Cling 147 7.1 The ROOT Prompt.............................................. 147 7.2 Feeding Sources Files To ROOT: C++ Scripts............................... 149 7.3 C++ Extensions To Ease Scripting...................................... 150 7.4 ACLiC: Compiling Scripts Into Libraries................................... 151 7.5 Classes Defined By Scripts........................................... 155 7.6 Inspecting Objects............................................... 156 8 Object Ownership 159 8.1 Ownership by Current Directory (gDirectory)................................ 159 8.2 Ownership by the Master TROOT Object (gROOT)............................ 160 8.3 Ownership by Other Objects......................................... 161 8.4 Ownership by the User............................................. 161 9 Graphics and the Graphical User Interface 163 9.1 Drawing Objects................................................ 163 9.2 Interacting with Graphical Objects...................................... 163 9.3 Graphical Containers: Canvas and Pad.................................... 168 9.4 Graphical Objects............................................... 175 9.5 Axis....................................................... 190 9.6 Graphical Objects Attributes......................................... 202 9.7 The Graphics Editor.............................................. 209 9.8 Copy and Paste................................................. 210 9.9 Legends..................................................... 213 9.10 The PostScript Interface............................................ 215 9.11 The PDF Interface............................................... 219 9.12 Create or Modify a Style............................................ 219 9.13 3D Viewers................................................... 221 10 Folders and Tasks 237 10.1 Folders...................................................... 238 10.2 Why Use Folders?............................................... 239 10.3 How to Use Folders............................................... 239 10.4 Tasks...................................................... 242 10.5 Execute and Debug Tasks........................................... 245 11 Input/Output 247 11.1 The Physical Layout of ROOT Files..................................... 247 11.2 The Logical ROOT File: TFile and TKey.................................. 251 11.3 Streamers.................................................... 262 11.4 Pointers and References in Persistency.................................... 267 11.5 Schema Evolution............................................... 271 11.6 Compression and Performance........................................ 280 11.7 Remotely Access to ROOT Files via a rootd................................. 280 11.8 Reading ROOT Files via Apache Web Server................................ 282 11.9 XML Interface................................................. 283 6 CONTENTS 12 Trees 285 12.1 Why Should You Use a Tree?......................................... 285 12.2 A Simple TTree................................................. 285 12.3 Show an Entry with TTree::Show....................................... 286 12.4 Print the Tree Structure with TTree::Print................................. 287 12.5 Scan a Variable the Tree with TTree::Scan.................................. 287 12.6 The Tree Viewer................................................ 287 12.7 Creating and Saving Trees........................................... 289 12.8 Branches..................................................... 293 12.9 Adding a Branch to Hold a List of Variables................................. 293 12.10Adding a TBranch to Hold an Object.................................... 294 12.11Adding a Branch with a Folder........................................ 297 12.12Adding a Branch with a Collection...................................... 297 12.13Examples for Writing and Reading Trees................................... 297 12.14Example 1: A Tree with Simple Variables.................................. 298 12.15Example 2: A Tree with a C Structure.................................... 301 12.16Example 3: Adding Friends to Trees..................................... 306 12.17Example 4: A Tree with an Event Class................................... 309 12.18Example 5: Import an ASCII File into a TTree............................... 314 12.19Trees in Analysis................................................ 314 12.20Simple Analysis Using TTree::Draw..................................... 314 12.21Using TTree::MakeClass...........................................