StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SimplePicoDstAnalyzer.C
1 
7 void SimplePicoDstAnalyzer( const char* file = "data/auau200.picoDst.root" ) {
8 
9  // Set input file
10  TFile *f = new TFile( file );
11  if ( !f ) { std::cout << "no file found" << std::endl; return; }
12  // Set TTree
13  TTree *T = f->Get("PicoDst");
14  if ( !T ) { std::cout << "no PicoDst tree found" << std::endl; return; }
15 
16  // Turn on/off branches
17  T->SetBranchStatus("*", 0);
18  T->SetBranchStatus("Event", 1);
19  T->SetBranchStatus("Event.*", 1);
20  T->SetBranchStatus("Track", 1);
21  T->SetBranchStatus("Track.*", 1);
22  T->SetMakeClass(1);
23 
24  // Retrieve number of events
25  Long64_t nentries = T->GetEntriesFast();
26  std::cout << "entries: " << nentries << std::endl;
27 
28  Int_t Event_;
29  Int_t Event_mRunId[1];
30  Int_t Event_mEventId[1];
31  UShort_t Event_mNumberOfGlobalTracks[1];
32 
33  Int_t Track_;
34  Float_t Track_mOrigin_mX1[10000];
35  Float_t Track_mOrigin_mX2[10000];
36  Float_t Track_mOrigin_mX3[10000];
37 
38  // Set up branches to read
39  T->SetBranchAddress("Event", &Event_ );
40  T->SetBranchAddress("Event.mRunId", Event_mRunId );
41  T->SetBranchAddress("Event.mEventId", Event_mEventId );
42  T->SetBranchAddress("Event.mNumberOfGlobalTracks", Event_mNumberOfGlobalTracks );
43 
44  T->SetBranchAddress("Track", &Track_ );
45  T->SetBranchAddress("Track.mOrigin.mX1", Track_mOrigin_mX1 );
46  T->SetBranchAddress("Track.mOrigin.mX2", Track_mOrigin_mX2 );
47  T->SetBranchAddress("Track.mOrigin.mX3", Track_mOrigin_mX3 );
48 
49  Long64_t ientry = 0;
50 
51  std::cout << "getting entry " << ientry << std::endl;
52 
53  // Load values for the current event
54  Long64_t nbytes = T->GetEntry( ientry );
55 
56  std::cout << "entry received" << std::endl;
57  std::cout << "Run ID: " << Event_mRunId[0] << std::endl;
58  std::cout << "Event ID: " << Event_mEventId[0] << std::endl;
59  std::cout << "num tracks: " << Track_ << std::endl;
60 
61  std::cout << "Track 0: "
62  << Track_mOrigin_mX1[0] << ", "
63  << Track_mOrigin_mX2[0] << ", "
64  << Track_mOrigin_mX3[0]
65  << std::endl;
66 
67  std::cout << "Track 1: "
68  << Track_mOrigin_mX1[1] << ", "
69  << Track_mOrigin_mX2[1] << ", "
70  << Track_mOrigin_mX3[1]
71  << std::endl;
72 
73  // Print info for the turned on branches
74  T->Show(0);
75 }