AliRoot Core  edcc906 (edcc906)
TestEMCALHit.C
Go to the documentation of this file.
1 
12 #if !defined(__CINT__) || defined(__MAKECINT__)
13 
14 //Root include files
15 #include <Riostream.h>
16 #include <TClonesArray.h>
17 #include <TGeoManager.h>
18 
19 //AliRoot include files
20 #include "AliRun.h"
21 #include "AliRunLoader.h"
22 #include "AliEMCALLoader.h"
23 #include "AliEMCAL.h"
24 #include "AliEMCALHit.h"
25 #include "AliEMCALGeometry.h"
26 
27 #endif
28 
33 {
34  // Getting EMCAL Detector and Geometry.
35 
37 
38  if (rl == 0x0)
39  cout<<"Can not instatiate the Run Loader"<<endl;
40 
41  rl->LoadgAlice();//Needed to get geometry
42 
43  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
44  (rl->GetDetectorLoader("EMCAL"));
45 
46  TGeoManager::Import("geometry.root");
47 
48  AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry
49 
51  if(alirun)
52  {
53  AliEMCAL * emcal = (AliEMCAL*)alirun->GetDetector("EMCAL");
54  geom = emcal->GetGeometry();
55  }
56 
57  if (geom == 0) cout<<"Did not get geometry from EMCALLoader"<<endl;
58  //else geom->PrintGeometry();
59 
60  //Load Hits
61  rl->LoadHits("EMCAL");
62 
63  //Get maximum number of events
64  Int_t maxevent = rl->GetNumberOfEvents();
65  cout<<"Number of events "<<maxevent<<endl;
66  //maxevent = 8000 ;
67 
68  AliEMCALHit * hit;
69  TClonesArray *hits = 0;
70 
71  for (Int_t iEvent=0; iEvent<maxevent; iEvent++)
72  {
73  //cout << " ======> Event " << iEvent <<endl ;
74  // Load Event
75  rl->GetEvent(iEvent);
76  Float_t elos=-1;
77  Float_t time = -1 ;
78  Int_t id = -1 ;
79  Int_t iSupMod = 0 ;
80  Int_t iTower = 0 ;
81  Int_t iIphi = 0 ;
82  Int_t iIeta = 0 ;
83  Int_t iphi = 0 ;
84  Int_t ieta = 0 ;
85 
86  cout << " ======> Event " << iEvent << endl;
87 
88  // Get hits from the list
89  // Hits are stored in different branches in the hits Tree,
90  // first get the branch and then access the hits in the branch
91  TTree *treeH = emcalLoader->TreeH();
92  if (!treeH)
93  {
94  printf("TreeH not available!\n");
95  continue;
96  }
97 
98  // TreeH exists, get the branch
99  Int_t nTrack = treeH->GetEntries(); // TreeH has array of hits for every primary
100  TBranch * branchH = treeH->GetBranch("EMCAL");
101  branchH->SetAddress(&hits);
102 
103  for (Int_t iTrack = 0; iTrack < nTrack; iTrack++)
104  {
105  branchH->GetEntry(iTrack);
106 
107  // Now get the hits in this branch
108  Int_t nHit = hits->GetEntriesFast();
109  for(Int_t ihit = 0; ihit < nHit;ihit++)
110  {
111  hit = static_cast<AliEMCALHit *>(hits->At(ihit));//hits->At(ihit) ;
112 
113  if(!hit)
114  {
115  cout<<"Hit pointer 0x0"<<endl;
116  continue;
117  }
118 
119  id = hit->GetId() ; // cell (hit) label
120  elos = hit->GetEnergy(); // amplitude in cell (hit)
121  time = hit->GetTime(); // time of creation of hit after collision
122 
123  cout<<"Hit ID "<<id<<" ELoss "<<elos;
124 
125  // Geometry methods
126  if(geom)
127  {
128  geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
129 
130  // Gives SuperModule and Tower numbers
131  geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
132  iIphi, iIeta,iphi,ieta);
133  //Gives label of cell in eta-phi position per each supermodule
134  // cout<< "SModule "<<iSupMod<<"; Tower "<<iTower <<"; Eta "<<iIeta
135  //<<"; Phi "<<iIphi<<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl;
136  cout<< "; SModule "<<iSupMod<<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl;
137  }//geom?
138  }//hit loop
139  }// track loop
140  }//event loop
141 }
142 
Int_t LoadgAlice()
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
static const TString & GetDefaultEventFolderName()
Definition: AliConfig.h:58
void TestEMCALHit()
Definition: TestEMCALHit.C:32
Definition: AliRun.h:27
AliLoader * GetDetectorLoader(const char *detname)
Int_t GetId(void) const
Definition: AliEMCALHit.h:44
Give access to hits, digits, recpoints arrays and OCDB.
static AliRunLoader * Open(const char *filename="galice.root", const char *eventfoldername=AliConfig::GetDefaultEventFolderName(), Option_t *option="READ")
void GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, Int_t &iphi, Int_t &ieta) const
EMCal hits object.
Definition: AliEMCALHit.h:24
Bool_t GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi, Int_t &nIeta) const
virtual AliEMCALGeometry * GetGeometry() const
Definition: AliEMCAL.cxx:466
Int_t GetNumberOfEvents()
Base Class for EMCAL description.
Definition: AliEMCAL.h:35
Int_t GetEvent(Int_t evno)
TTree * TreeH() const
Definition: AliLoader.h:83
Int_t LoadHits(Option_t *detectors="all", Option_t *opt="READ")
AliDetector * GetDetector(const char *name) const
Definition: AliRun.cxx:200
Float_t GetEnergy(void) const
Definition: AliEMCALHit.h:41
TEveGeoShape * geom
Definition: tpc_tracks.C:10
Float_t GetTime(void) const
Definition: AliEMCALHit.h:54
EMCal geometry, singleton.
AliRun * GetAliRun() const