StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
readGammaTree.C
1 class StGammaEvent;
2 
3 TFile *file = 0;
4 TTree *tree = 0;
5 
6 StGammaEvent *event = 0;
7 
8 const Float_t rootS = 200.0;
9 
10 void readGammaTree( const Char_t *fname = "gamma_tree.root" )
11 {
12  gROOT->LoadMacro("StRoot/StGammaMaker/macros/loadGammaLibs.C");
13  loadGammaLibs();
14 
15  file = new TFile(fname);
16  tree = (TTree*)file->Get("gammas");
17  event = new StGammaEvent();
18  tree->SetBranchAddress("GammaEvent",&event);
19 
20 
21  for ( Long64_t i=0;i<tree->GetEntries();i++ )
22  {
23  tree->GetEntry(i);
24 
25  Int_t run = event->runNumber();
26  Int_t eventid = event->eventNumber();
27  Int_t nc = event->numberOfCandidates();
28  UShort_t flags = event->flags();
29  Float_t sumPt = event->sumPt(-2.5,2.5);
30  Float_t sumTrackPt = event->sumTrackPt(-2.5,2.5);
31  Float_t sumTowerPt = event->sumTowerPt(-2.5,2.5);
32 
33  std::cout << "-------------------------------------------------------------" << std::endl;
34  std::cout << "run = " << run << std::endl;
35  std::cout << "event = " << eventid << std::endl;
36  std::cout << "flags = " << Form("0x%X",flags) << std::endl;
37  std::cout << "pt sum = " << sumPt << std::endl;
38  std::cout << " + tracks = " << sumTrackPt << std::endl;
39  std::cout << " + towers = " << sumTowerPt << std::endl;
40 
41  std::cout << "printing n candidates = " << nc << std::endl;
42  for ( Int_t ic = 0; ic < nc; ic++ )
43  {
44  StGammaCandidate *candidate = event->candidate(ic);
45  if ( !candidate ) continue;
46 
47  // identity
48  Int_t gammaId = candidate->id();
49  Int_t caloId = candidate->detectorId();
50 
51  // kinematics
52  Float_t pt = candidate->momentum().Perp();
53  Float_t eta = candidate->momentum().Eta();
54  Float_t phi = candidate->momentum().Phi();
55  Float_t xf = candidate->momentum().Z() / rootS;
56 
57  // isolation energy sums at three different radii
58  Float_t iso4 = candidate->sumPt(0.4);
59  Float_t iso5 = candidate->sumPt(0.5);
60  Float_t iso7 = candidate->sumPt(0.7);
61 
62  Int_t ntracks4 = candidate->numberOfTracks(0.4);
63  Int_t ntowers4 = candidate->numberOfTowers(0.4);
64  Int_t ntracks5 = candidate->numberOfTracks(0.5);
65  Int_t ntowers5 = candidate->numberOfTowers(0.5);
66  Int_t ntracks7 = candidate->numberOfTracks(0.7);
67  Int_t ntowers7 = candidate->numberOfTowers(0.7);
68 
69  Int_t ntracks = candidate->numberOfMyTracks();
70  Int_t ntowers = candidate->numberOfMyTowers();
71 
72  std::cout << " ++++++++++++++++++++++++++++++++";
73  std::cout << " id=" << gammaId <<std::endl;
74  std::cout << " calo=" << caloId << std::endl;
75  std::cout << " pt="<<pt << " eta="<<eta<<" phi="<<phi << std::endl;
76  std::cout << " ntowers=" << ntowers << " ntracks="<<ntracks<<std::endl;
77 
78  std::cout << " iso4="<<iso4<<" iso5="<<iso5<<" iso7="<<iso7<<std::endl;
79  std::cout << " ntr4="<<ntracks4<<" ntr5="<<ntracks5<<" ntr7="<<ntracks7<<std::endl;
80  std::cout << " ntw4="<<ntowers4<<" ntw5="<<ntowers5<<" ntw7="<<ntowers7<<std::endl;
81 
82  Int_t nu = candidate->numberOfSmdu();
83  Int_t nv = candidate->numberOfSmdv();
84  std::cout << "nu="<<nu<<" nv="<<nv<<std::endl;
85 
86 
87 
88  }
89 
90 
91  }
92 
93 
94 }
Float_t sumTrackPt(Float_t eta_min=-2.5, Float_t eta_max=+2.5) const
Returns track+tower pT in eta range.
Float_t sumTowerPt(Float_t eta_min=-2.5, Float_t eta_max=+2.5) const
Returns track pT in eta range.
UShort_t flags() const
Event flags (see above)
Definition: StGammaEvent.h:51
StGammaCandidate * candidate(Int_t i) const
Return ith strip.
Definition: StGammaEvent.h:71