V0.05 ROOT 102 ROOT is an object oriented HEP analysis framework.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Joe Foster Visualizing Data with ROOT Joe Foster University of Manchester.
Must-Know ROOT Class I/O/TGraph/Tntuple/Ttree/…. 1.
ROOT Root Commands and CINT Functions and Fitting (The Tree Viewer)
Why ROOT?. ROOT ROOT: is an object_oriented frame work aimed at solving the data analysis challenges of high energy physics Object _oriented: by encapsulation,
The Assembly Language Level
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Road Map Introduction to object oriented programming. Classes
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
FunctionsFunctions Systems Programming. Systems Programming: Functions 2 Functions   Simple Function Example   Function Prototype and Declaration.
Guide To UNIX Using Linux Third Edition
FunctionsFunctions Systems Programming Concepts. Functions   Simple Function Example   Function Prototype and Declaration   Math Library Functions.
ROOT courses1 The ROOT System A Data Access & Analysis Framework February 2003 Ren é Brun/EP Trees.
Sept 11, 2003ROOT Day1, Suzanne Panacek39 ROOT An object oriented HEP analysis framework. Day 1.
ROOT An object oriented HEP analysis framework.. Computing in Physics Physics = experimental science =>Experiments (e.g. at CERN) Planning phase Physics.
Data Structures Using C++ 2E Chapter 7 Stacks. Data Structures Using C++ 2E2 Objectives Learn about stacks Examine various stack operations Learn how.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
Introduction to Hall-D Software February 27, 2009 David Lawrence - JLab.
2 Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during insertions and deletions Linked list is able to.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 4: Linked Lists Data Abstraction & Problem Solving with.
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
09-Jun-2005J. Adamczewski1 C++ course 2005 The ROOT framework 2.
21-Apr-2005J. Adamczewski1 DVEE C++ course 2005 The ROOT framework 1: Introduction.
Chapter 6: User-Defined Functions
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Pointers OVERVIEW.
ROOT Tutorial An object oriented HEP data analysis framework Presented by Dimitri Bourilkov University of Florida UltraLight Workshop, June 2005, FIU,
10/31/2015PHYS 3446 DØ Data Analysis with ROOT Venkat (for Dr.Yu)
More About Objects and Methods Chapter 5. Outline Programming with Methods Static Methods and Static Variables Designing Methods Overloading Constructors.
Introduction to ROOT Practical Part Jan Fiete Grosse-Oetringhaus, CERN PH/ALICE Summer Student Lectures th July.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
CHEP 2013, Amsterdam Reading ROOT files in a browser ROOT I/O IN JAVASCRIPT B. Bellenot, CERN, PH-SFT B. Linev, GSI, CS-EE.
Persistent Object References in ROOT1 Persistent Object References in ROOT I/O Status & Proposal CMS-ROOT meeting CERN- November 27 Ren é Brun ftp://root.cern.ch/root/refs.ppt.
ROOT Tutorials - Session 51 ROOT Tutorials – Session 5 Dictionary Generation, rootcint, Simple I/O, Hands-on Fons Rademakers.
STAR Schema Evolution Implementation in ROOT I/O V. Perevoztchikov Brookhaven National Laboratory,USA.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessor Midterm Review Lecture 7 Feb 17, 2004.
TTree::Draw What is it trying to be? Where is it going?
General Purpose ROOT Utilities Victor Perevoztchikov, BNL.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
9/28/2005Philippe Canal, ROOT Workshop TTree / SQL Philippe Canal (FNAL) 2005 Root Workshop.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Postgraduate Computing Lectures PAW 1 PAW: Physicist Analysis Workstation What is PAW? –A tool to display and manipulate data. Learning PAW –See ref. in.
The Preprocessor Directives Introduction Preprocessing – Occurs before program compiled Inclusion of external files Definition of symbolic constants.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
ROOT Workshop M.Frank LHCb/CERN Improvements in the I/O Area (*)  General I/O related improvements  Tree related issues  Plans (*) I present.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
S.Linev: Go4 - J.Adamczewski, H.G.Essel, S.Linev ROOT 2005 New development in Go4.
Trees: New Developments1 Trees: New Developments Folders and Tasks ROOT Workshop 2001 June 13 FNAL Ren é Brun CERN
ROOT-CORE Team 1 Philippe Canal Markus Frank I/O Basic I/O, RDBMS interfaces, Trees.
FUNCTIONS (CONT). Midterm questions (21-30) 21. The underscore can be used anywhere in an identifier. 22. The keyword void is a data type in C. 23. Floating.
Go4 Workshop J.Adamczewski-Musch, S.Linev Go4 advanced features.
ROOT: Functions & Fitting Harinder Singh Bawa California State University Fresno.
Joe Foster 1 This talk extends the one I gave in 2006 called Visualizing Data with ROOT. –
HYDRA Framework. Setup of software environment Setup of software environment Using the documentation Using the documentation How to compile a program.
V0.02 The ROOT Collection Classes. V Collection Classes Group of related objects TObjects or descendants from TObject Abstract base class TCollection.
ROOT – úvodní přednáška a cvičení Jiří Chudoba,
ROOT1 Hands-on Sami Kama. S.Kama ROOT1 Hands-On ISTAPP2011 Dogus Univ.07/02/ Download root file from indico.
ROOT: Functions & Fitting
Introduction to ROOT Practical Part
ROOT Class Day 3 An Object Oriented Data Analysis Framework Day 3
ROOT Class Day 2 An Object Oriented Data Analysis Framework Lecture 2
Tonga Institute of Higher Education
Zooming on ROOT files and Containers
Introduction to ROOT (2/2) Practical Part
The ROOT framework 1: Introduction
ROOT Support and Developments at FNAL
Makefiles, GDB, Valgrind
Presentation transcript:

V0.05 ROOT 102 ROOT is an object oriented HEP analysis framework

V ROOT contacts at Fermi –Philippe Canal, x2545 –Peter Malzacher, x6510 –Suzanne Panacek, x8334

V What We Will Cover Today Macros –Fitting –I/O –Analysis CINT –Command line –Debugging –Environment

V Class Schedule Session 1: Functions and Fitting –Function Objects (TF1) –Fitting Session 2: Building ROOT Trees –Files, Trees, and Branches –5 Steps to build a TTree –Exercise #1 Break

V Class Schedule Session 3: Putting Trees to Work –Using Trees in Analysis –Exercise #2 Session 4: More about CINT –Environment settings –CINT debugging –Exercise #3 Session 5: For real Experts –How to add your own root classes –Script compiler

V Session1: Functions and Fitting Function Objects (TF1) –Three constructors for TF1 –User Defined Functions Fitting –Fit() –Fitting with a user defined function –Fitting subranges and combining functions –Demonstration of background and signal function

V Function Objects (TF1) Built in function objects –see this link for a full list of built in functions –use the Fit Panel Creating your own function objects –TF1, TF2, TF3 –Three Signatures for the TF1 constructor

V TF1 Constructors 1. A C++ like expression using x with a fixed set of operators and functions defined in TFormula TF1 *f1 = new TF1("f1", "sin(x)/x",0,10); f1->Draw(); TF1 *f2 = new TF1("f2","f1 * 2",0,10);

V TF1 Constructors (cont.) 2. Same as the previous TF1 with Parameters Call the constructor with parameter indices TF1 *f1 = new TF1 ("f1","[0] *x*sin( [1] *x)",-3,3); Set the parameters explicitly f1->SetParameter(0,10); f1->SetParameter(1,5); f1->Draw();

V TF1 Constructors (cont.) 3. Use a defined function Define a function Double_t MyFunction(Double_t *x, Double_t *par){ Float_t xx =x[0]; Double_t val= TMath::Abs(par[0]*sin(par[1]*xx)/xx); return val; } TF1 constructor TF1 *f1 = new TF1("f1",MyFunction,0,10,2); NOTE: The 2 is the number of parameters in MyFunction. Set the parameters f1->SetParameters(2,1);

V Fitting To fit a histogram: ->Fit(" "); TF1 *f1 = new TF1 ("f1","[0] *x*sin([1]*x)",-3,3); f1->SetParameters(10,5); aHistogram->Fit("f1");

V Fitting Example: fitting a histogram with user defined function. Step 1. Define the function: Double_t MyFunction (Double_t *x, Double_t *par) { Double_t arg= 0; if (par[2]) arg = (x[0] - par[1])/par[2]; Double_t fitval = par[0] * TMath::Exp(-0.5*arg*arg); return fitval; }

V Fitting (cont.) Step 2. TF1 constructor TF1 *aFunction = new TF1("MyGaus", MyFunction, -5,5,3); Step 3. Set initial value of the parameters aFunction->SetParameters(5000, h->GetMean(), h->GetRMS()); Step 4. Fit and draw the histogram h->Fit("MyGaus");

V Fitting Subranges Define the range in the TF1 constructor. TF1 *g1 = new TF1("g1", "gaus", 85,95); Use "R" option in the Fit() method. h->Fit("g1", "R");

V Combining Functions Add two functions with "+" operator. Assign the parameters for each contributing function.

V Combining Functions y(E) = a 1 + a 2 E + a 3 E 2 + A P (  / 2  )/( (E-  ) 2 + (  /2) 2 ) backgroundlorenzianPeak par[0] = a 1 par[0] = A P par[1] = a 2 par[1] =  par[2] = a 3 par[2] =  fitFunction = background (x, par ) + lorenzianPeak (x, &par[3]) par[0] = a 1 par[1] = a 2 par[2] = a 3 par[3] = A p par[4] =  par[5] = 

V Fitting Demo Look at FittingDemo.C fitf.C Run FittingDemo.C More info on fitting:

V Session1: Functions and Fitting Summary Functions Objects (TF1) –Three constructors for TF1 –User Defined Functions Fitting –Fit() –Fitting with a user defined function –Fitting subranges and combining functions –Demonstration of background and signal function

V Session 2: Building ROOT Trees Overview of –ROOT Files –Trees –Branches 5 Steps to build a TTree Demonstration Building a tree with an object. Exercise #1

V ROOT Files (TFile) When a ROOT file is opened it becomes the current directory. Histograms and trees are automatically saved in the file. When the file is closed the histogram and tree objects associated with the file are deleted. Any object derived from TObject can be written to a ROOT file. It has to be added explicitly.

V ROOT Trees (TTree) Storing large number of entries. Hierarchy of branches and leaves. Reading selective branches Use TTree::AutoSave() to save the tree.

V ROOT Branches (TBranch) Independent of each other Can be written to different files Three kinds of branches: –simple structure or list of variables –any object (TObject) –a TClonesArray

V Five Steps to Build a Tree Steps: 1. Create a TFile 2. Create a TTree 3. Add TBranch to the TTree 4. Fill the tree 5. Write the file

V Step 1: Create a TFile Object The TFile constructor –file name (i.e. " AFile.root ") –option: NEW, CREATE, RECREATE, UPDATE, or READ –file title, shown in the root browser –compression level 0-9, defaults to 1. TFile *hfile = new TFile("AFile.root","RECREATE","Example");

V Step 2: Create a TTree Object A tree is a list of branches. The TTree Constructor: –Tree Name (e.g. "T") –Tree Title –Maximum total size of buffers kept in memory (defaults to 64 MB) TTree *tree = new TTree("T","A ROOT tree");

V Step 3: Adding Branches with an Object Branch name Class name Object (descendant of TObject) Buffer size (default = 32,000) Split level (default = 1) Event *event = new Event(); tree->Branch ("EventBranch","Event",&event,64000,1);

V Splitting a Branch Setting the split level (default = 1) Split level = 0Split level = 1 Example : tree->Branch("EvBr","Event",&ev,64000,0);

V Adding Branches with a List of Variables Branch name Address: the address of the first item of a structure. Leaflist: all variable names and types Example TBranch *b = tree->Branch ("Ev_Branch",&event, "ntrack/I:nseg:nvtex:flag/i:temp/F");

V Adding Branches with a TClonesArray Branch name Clones array Buffer size Split level (default = 1) Example: tree->Branch( "Track_B",&Track,64000,1);

V Step 4: Fill the Tree Create a for loop Create Event objects. Call the Fill method for the tree. tree->Fill()

V Step 5: Write the File The TFile::Write() –Writes Histograms and Trees –Write is needed to write file header hfile->Write();

V Demonstration: 5 steps to build a Tree BuildTreeDemo.C –create "AFile.root" –2 nd Type of Branch, crated with a class name and split..X BuildTreeDemo.C –One tree called "T" –One branch for each data member of Event. –recursive split (see Track)

V Session 2: Building ROOT Trees Summary Overview of –ROOT Files –Trees –Branches 5 Steps to build a TTree Demonstration building a tree with an object

V Exercises #1 Write a macro (ABCWrite.C) that creates a tree from the floating numbers in the ASCII file ABC.txt. The tree should contain 2 branches. The first branch has three variables (a,b,c). The second branch has one variable p=sqrt(a*a + b*b + c*c). Write the tree to a file called ABC.root. ABC.txt can be found at: www-pat.fnal.gov/root/102/ABC.txt www-pat.fnal.gov/root/102/ABC.txt

V Session 3: Putting Trees to Work Using Trees in Analysis –From the command line –Using MakeClass –Using Chains Exercise #2

V Using Trees in Analysis The TTree::Draw() Parameters: 1. expressions for x,y,z myTree->Draw("ntrack"); myTree->Draw("sqrt(ntrack): ntrack");

V Using Trees in Analysis (cont.) The TTree::Draw() Parameters: 2. selection 3. draw option 4. number of entries myTree->Draw("sqrt(ntrack): ntrack", "temp > 20.8"); myTree ->Draw("sqrt(ntrack): ntrack", "temp >20.8","surf2");

V Using Trees in Analysis (cont.) If the Branch was created with an object and was not split we can still use the Draw() method. myTree->Draw("event.GetNtrack()"); event = branch name GetNtrack() = a method of the object on the branch.

V Histograms and Lists The TTree::Draw() parameters continued: - saving the histogram myTree ->Draw(" ntrack >> myHisto"); myHisto->Draw(); - saving an event list myTree ->Draw(">> myList","ntrack>0"); myList->Print("all") - using an event list myTree ->SetEventList(myList); myTree ->Draw("ntrack");

V Information about the TTree Contents After executing the Draw command, we can get information about the TTree: –GetSelectedRows() Returns the number of entries accepted by the selection expression. –GetV1(), GetV2(), GetV3() returns a pointer to the float array of the first, second, or third variable (x,y,z) –GetW()

V Introducing MakeClass Draw() is powerful and quick. What if you would like to plot the masses of all oppositely charged pairs of tracks? You need a loop over all events, find all pairs of tracks, and calculate the required quantities. ROOT provides MakeClass to do this.

V Using MakeClass Scenario: We would like to do selective plotting. For simplicity we choose to plot only the first 100 tracks of each entry. We have a ROOT file with a tree with one branch which has leaves of type "Event". The designer has made the class definition available in the shared library libEvent.so and given you the header file Event.h.

V Event.h Event has –a TClonesArray of Tracks –GetNtrack() method –much more … Track has –a GetPx() method –much more...

V Using MakeClass() 1. Load the shared library root [0].L libEvent.so 2. Load the root file root [1] TFile *f = new TFile ("EventOB.root "); 3. Call MakeClass root [2] T->MakeClass("MyClass"); - creates MyClass.C and MyClass.h - where does T come from?

V Using MakeClass() MyClass.h and MyClass.C –MyClass.h –contains the class definition of "MyClass" –MyTree.C –contains the class implementation of "MyClass"

V Loading and Using MyClass.C Load the macro and create a MyClass object: root [0].L libEvent.so root [1].L MyClass.C root [2] MyClass *m = new MyClass ();

V GetEntry() MyClass::GetEntry() root [3] m->GetEntry(1); root [4] m->event->GetNtrack() (Int_t)597 root [5] m->GetEntry(2); root [6] m->event->GetNtrack() (Int_t)606

V Loop() MyClass::Loop () root [6] m->Loop(); Bytes read: Bytes read: Bytes read: Bytes read: Bytes read: Bytes read:

V Expanding Loop() Modifying MyClass::Loop() 1. Create a Track object Track *track = 0; 2. Create two histograms TH1F *myHisto = new TH1F( "myHisto","fPx",100,-5,5); TH1F *smallHisto = new TH1F( "small","fPx 100",100,-5,5);

V Expanding Loop() (cont.) 3. In Event loop, get the event branch b_event->GetEntry(i); 4. And get the number of tracks n_Tracks = event->GetNtrack(); 6. Add track loop for (Int_t j = 0; j < n_Tracks; j++){ track = (Track*) event->GetTracks()->At(j);

V Expanding Loop() (cont.) 7. Fill the first histogram with Px myHisto->Fill(track->GetPx()); 8. Add an if statement for the first 100 tracks if (j < 100){ smallHisto->Fill(track->GetPx()); } 9. Outside of the Event loop, draw the histograms myHisto->Draw(); smallHisto->Draw("Same");

V Expanding Loop() (cont.).L libEvent.so.L MyClass.C MyClass *m = new MyClass(); m->Loop()

V Chains Scenario: Perform an analysis using multiple ROOT files. All files are of the same structure and have the same tree.

V Chains (cont.) TChain::Add() root [3] TChain chain("T"); root [4] chain.Add("Event.root") root [5] chain.Draw("fTracks.fPx") root [6] myCanvas->cd(2); root [7] chain.Add("Event50.root") root [8] chain.Draw("fTracks.fPx")

V Chains (cont.) TChain::GetListOf… To see the files that are chained chain.GetListOfFiles()->Print() List the branches and leaves of the chain. chain.GetListOfBranches()->Print() chain.GetListOfLeaves()->Print() TChain::Merge() To merge the files in a chain and write them to a new file : chain.Merge("all.root")

V Demo: Changing "MyClass" to use a Chain 1. Changing MyClassChain.h –Change TTree to TChain –Use Add() to add the files to the chain 2. Changing MyClassChain.C –TTree to TChain

V Demo: Changing "MyClass" 3. Load and execute MyClassChain.C

V Session 3 Summary Putting Trees to Work Using Trees in Analysis –From the command line using TTree::Draw() –Using MakeClass and Loop() –Using Chains

V Exercise #2 Use MakeClass on the ABC.root file and call the class "ABC". Modify the loop to draw a histogram of the last 100 entries of p.

V Session 4: More about CINT Coding Conventions Global Variables Environment Settings CINT Debugging –Stepping –Setting breakpoints –Inspecting

V Coding Conventions Based on Taligent Classes begin with T TTree, TBrowser Non-class types end with _t Int_t Data members begin with ffTree Member functions begin with a capital Loop() Constants begin with k kInitialSize, kRed Static variables begin with g gEnv Static data members begin with fg fgTokenClient

V Coding Conventions (cont.) Enumeration types begin with E EColorLevel Locals and parameters begin with a lower casenbytes Getters and setters begin with Get, Set, or Is (boolean) SetLast(), GetFirst(), IsDone()

V TObject: The Mother of all Root objects Defines protocol and default behavior for all objects in ROOT. –I/O –Inspection –Printing –Drawing –TObjects can be stored in collection classes.

V gROOT gROOT->Reset(); gROOT->GetListOf (); gROOT->LoadMacro(); gROOT->Time(); gROOT->ProcessLine()

V gROOT->FindObject( ) smallHisto is the Variable Name small is the Object Name. TH1F *smallHisto = new TH1F ("small","fPx 100",100,-5,5); gROOT->FindObject("smallHisto") (class TObject*)0x0 // null pointer gROOT->FindObject("small") (class TObject*)0x104c7528 FindObject needs the Object Name.

V gROOT->FindObject() cont. FindObject returns a pointer to TObject. Need to cast it to call class methods. This generates an error: gROOT->FindObject("small")->GetBinContent(2) This is OK: gROOT->FindObject("small")->ClassName() TH1F* histo=(TH1F*) gROOT->FindObject("small") histo->GetBinContent(2)

V gROOT->FindObject() cont. Due to CINT magic this is also OK: TH1F *smallHisto = new TH1F ("small","fPx 100",100,-5,5); small->GetBinContent(2); CINT implicitly executes a FindObject("small") Casts it to the correct class Creates a variable called "small" of the correct class Warning: This will not work in compiled code!

V Global Variables (cont.) gRandom gRandom->Gaus(1,2) You can replace the random generator with your own: delete gRandom; gRandom = new TRandom2(0); //seed=0 gFile gFile->GetName() gDirectory gDirectory->GetName() gSystem gSystem->HostName()

V Environment Settings Find the current settings –gEnv->Print().rootrc –looks first in current directory –second in ~ ($HOME) –third in $ROOTSYS

V Environment Settings (cont.) The.rootrc file: The Macro Path Unix.*.Root.MacroPath:.:$(HOME)/myRootMacros Options in rootrc Root.ShowPath: false History File $HOME/.root_hist Automatically Executing Macros rootlogon.C rootlogoff.C rootalias.C

V Command Line Options > root -/? Usage: root [-l] [-b] [-n] [-q] [file1.C... fileN.C] Options: -b : run in batch mode without graphics -n : do not execute logon and logoff macros as specified in.rootrc -q : exit after processing command line macro files -l : do not show splash screen

V CINT Commands [expression] evaluates the expression root[3] 3*4 (int)12.files show loaded source files.class [name] show class definition.g prints all objects in the root session.ls ls on current directory.pwdlist the current directory, canvas, and style.

V Demo on CINT Commands.class root [0].L libEvent.so root [1].class Event.g root [2].g... 0x104c7560 Event e, size=56 0x0 private: Int_t fNtrack 0x0 private: Int_t fNseg 0x0 private: Int_t fNvertex...

V CINT Extensions to C++ 1. Declaration can be omitted f = new TFile("Event.root") 2. "." notation rather than "->" f.ls() 3. Search for an object TH1F *smallHisto = new TH1F ("small","fPx 100",100,-5,5); small->Draw(); Warning: These will not work in compiled code!

V CINT Types

V CINT Multi-line Command Start with "{" For example: root [9] { end with '}'> Int_t j = 0; end with '}'> for (Int_t i = 0; i < 3; i++) end with '}'> { end with '}'> j= j + i; end with '}'> cout <<"i = " <<i<<", j = " <<j<<endl; end with '}'> } i = 0, j = 0 i = 1, j = 1 i = 2, j = 3

V Debugging: Stepping.s set the step mode to step into function.S set the step mode to go over function or loop.e continue to end of the function.c continue to next breakpoint.c 45 continue to line 45.p print the value of var

V Debugging: Breakpoints.trace MyClass prints the executing code to window.deltrace MyClass removes the trace.break MyClass breaks at each method of MyClass.delbreak MyClass removes the break.b 34 sets a break point at line 34.db 34 removes the break point at line 34

V Debugging: Inspecting DrawClass() Draws the inheritance tree Inspect() Draw the current contents of an object Dump() Lists the current contents of an object gDebug = 1 Prints debugging information

V Demonstration: CINT commands DrawClass() and Dump(): root [0].L libEvent.so root [1] Event e root [2] e->DrawClass() root [2] e->Dump() FindObject(): root [3] f = TFile("AFile.root") root [4].ls root [5] gROOT->FindObject("T") root [6] T

V Summary of Session 4: More about CINT Coding Conventions Global Variables Environment Settings CINT Debugging –Stepping –Setting breakpoints –Inspecting

V Exercise #3 Download Ex3.C Ex3.h and Ex3.root from the website: Use the CINT debugger to step through the Loop() method of the Ex3.C macro. Find the values of nentries, and the value of "p" when "i = 122".

V Session 5: For the real Expert Adding your own class Script compiler

V Adding your own class to ROOT Step 1: define your classes. Step 2: ClassDef(ClassName,ClassVersionID) ClassImp(ClassName)

V ClassDef and ClassImp ClassDef and ClassImp are needed for 1. RTTI (run time type identification) : root[0].class prints the members and functions of the class root[0] ->ClassName() returns the name of object's class 2. I/O Streamer method needed for writing to ROOT files and Trees.

V rootcint Step 3: create a LinkDef.h file. Step 4: call rootcint in the Makefile to create a CINT dictionary. EventDict.cxx Event.h EventLinkDef.h $(ROOTSYS)/bin/rootcint -f EventDict.cxx -c Event.h EventLinkDef.h For more information: $ROOTSYS/test/Makefile, Event.cxx, and Event.h

V The Script Compiler A ROOT enhancement developed at Fermi (by Philippe Canal) Advantages : – syntax checking – speed of execution – full C++ feature set Disadvantages: –load each C++ shared library once the –shared library (.so) is temporary

V Demonstration of the Script Compiler.L ScriptCompilerDemo.C++ or gSystem->CompileMacro("ScriptCompilerDemo.C"); root [0] gROOT->Time() root [1].L ScriptCompilerDemo.C++ root [2].files root [3] Demo() Compare performance with CINT root [0] gROOT->Time() root [1].L ScriptCompilerDemo.C root [3] Demo()

V Adding Your Class With the Script Compiler Step 1: Write the class definition in a separate file. Step 2: Add the ClassDef and ClassImp macro calls to the class definition. Step 3: Load the class with the script compiler. In another script: gSystem->CompileMacro("ABCClass.C"); or from the command line: root[0].L ABCClass.C++ For an example see ABCWriteClass.C and ABCClass.C

V Wrap up Questions ? Feedback Forms More information: www-pat.fnal.gov/root/