EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
draw.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file draw.cxx
1 //
2 // draw.cxx
3 //
4 // Created by TB on 6/13/11.
5 // Copyright 2011 BNL. All rights reserved.
6 //
7 // Example of a simple analysis using TTree::Draw() statements.
8 
9 void draw(const TString inputFile ) {
10 
11  // When you use only TTree::Draw() you can ignore errors like these:
12  //Warning in <TClass::TClass>: no dictionary for class EventBase is available
13  //Warning in <TClass::TClass>: no dictionary for class Particle is available
14  // ROOT doesn't need the listed dictionary files to access the data.
15  TFile file(inputFile, "READ");
16 
17  // The TTree is named EICTree
18  TTree* tree(NULL );
19  file.GetObject("EICTree", tree );
20  if(! tree) return; // Oops!
21 
22  TCanvas* canvas = new TCanvas;
23  canvas->Divide(2, 1);
24 
25  canvas->cd(1);
26  // For event-wise quantities you don't need to prepend "event." to the
27  // Draw() statement string; ROOT will automatically resolve it:
28  tree->Draw("QSquared"); // Equivalent to "event.QSquared"
29 
30  canvas->cd(2);
31  // Similarly you don't need to prepend "event.particles." to access particle
32  // variables.
33  tree->Draw("pt"); // Equivalent to "event.particles.pt".
34 }