AliRoot Core  edcc906 (edcc906)
TestEMCALSDigit.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 "AliEMCALDigit.h"
25 #include "AliEMCALGeometry.h"
26 
27 #endif
28 
33 {
34 
35  // Getting EMCAL Detector and Geometry.
36 
38 
39  if (rl == 0x0)
40  cout<<"Can not instatiate the Run Loader"<<endl;
41 
42  rl->LoadgAlice();//Needed to get geometry
43 
44  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
45  (rl->GetDetectorLoader("EMCAL"));
46 
47  TGeoManager::Import("geometry.root");
48 
49  AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry
50 
52  if(alirun)
53  {
54  AliEMCAL * emcal = (AliEMCAL*)alirun->GetDetector("EMCAL");
55  geom = emcal->GetGeometry();
56  }
57 
58  if (geom == 0)
59  cout<<"Did not get geometry from EMCALLoader"<<endl;
60  else
61  geom->PrintGeometry();
62 
63  //Load Digits
64  rl->LoadSDigits("EMCAL");
65 
66  //Get maximum number of events
67  Int_t maxevent = rl->GetNumberOfEvents();
68  cout<<"Number of events "<<maxevent<<endl;
69  //maxevent = 10 ;
70 
71  Int_t iEvent = -1 ;
72  Float_t amp = -1 ;
73  Float_t time = -1 ;
74  Int_t id = -1 ;
75  Int_t iSupMod = 0 ;
76  Int_t iTower = 0 ;
77  Int_t iIphi = 0 ;
78  Int_t iIeta = 0 ;
79  Int_t iphi = 0 ;
80  Int_t ieta = 0 ;
81  AliEMCALDigit * dig;
82 
83  for ( iEvent=0; iEvent<maxevent; iEvent++)
84  {
85  cout << " ======> Event " << iEvent << endl ;
86  //Load Event
87  rl->GetEvent(iEvent);
88 
89  // Fill array of digits
90  TClonesArray *digits = emcalLoader->SDigits();
91 
92  // Get digits from the list
93  for(Int_t idig = 0; idig< digits->GetEntries();idig++)
94  {
95  //cout<<">> idig "<<idig<<endl;
96  dig = static_cast<AliEMCALDigit *>(digits->At(idig)) ;
97 
98  if(!dig)
99  {
100  printf("Digit null pointer\n");
101  continue;
102  }
103 
104  id = dig->GetId() ; // cell (digit) label
105  amp = dig->GetAmplitude(); // amplitude in cell (digit)
106  time = dig->GetTime(); // time of creation of digit after collision
107 
108  cout<<"Cell ID "<<id<<" Amp "<<amp<<endl;//" time "<<time<<endl;
109 
110  // Geometry methods
111  if(geom)
112  {
113  geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
114  //Gives SuperModule and Tower numbers
115  geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
116  iIphi, iIeta,iphi,ieta);
117  //Gives label of cell in eta-phi position per each supermodule
118  cout<< "SModule "<<iSupMod<<"; Tower "<<iTower <<"; Eta "<<iIeta
119  <<"; Phi "<<iIphi<<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl;
120  }
121  } // sdigit loop
122  } // event loop
123 }
124 
Int_t LoadgAlice()
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
static const TString & GetDefaultEventFolderName()
Definition: AliConfig.h:58
Definition: AliRun.h:27
Float_t GetTime(void) const
Definition: AliEMCALDigit.h:64
Int_t LoadSDigits(Option_t *detectors="all", Option_t *opt="READ")
TClonesArray * SDigits()
AliLoader * GetDetectorLoader(const char *detname)
void TestEMCALSDigit()
EMCal digits object.
Definition: AliEMCALDigit.h:30
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
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)
Int_t GetId() const
Definition: AliDigitNew.h:23
AliDetector * GetDetector(const char *name) const
Definition: AliRun.cxx:200
TEveGeoShape * geom
Definition: tpc_tracks.C:10
Float_t GetAmplitude() const
Definition: AliEMCALDigit.h:55
EMCal geometry, singleton.
AliRun * GetAliRun() const