AliRoot Core  edcc906 (edcc906)
TestEMCALDigit.C
Go to the documentation of this file.
1 
15 #if !defined(__CINT__) || defined(__MAKECINT__)
16 
17 //Root include files
18 #include <Riostream.h>
19 #include <TClonesArray.h>
20 #include <TGeoManager.h>
21 
22 //AliRoot include files
23 #include "AliRun.h"
24 #include "AliRunLoader.h"
25 #include "AliEMCALLoader.h"
26 #include "AliEMCAL.h"
27 #include "AliEMCALDigit.h"
28 #include "AliEMCALGeometry.h"
29 
30 #endif
31 
39 void TestEMCALDigit(Float_t ampMin = 6, Bool_t printMC = kFALSE, Bool_t printGeo = kFALSE)
40 {
41  //
42  // Get EMCAL Detector and Geometry.
43  //
45 
46  if (rl == 0x0)
47  cout<<"Can not instatiate the Run Loader"<<endl;
48 
49  rl->LoadgAlice();//Needed to get geometry
50 
51  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
52  (rl->GetDetectorLoader("EMCAL"));
53 
55  if(printGeo)
56  {
57  TGeoManager::Import("geometry.root");
58 
59  AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry
60 
61  if(alirun)
62  {
63  AliEMCAL * emcal = (AliEMCAL*) alirun->GetDetector("EMCAL");
64  geom = emcal->GetGeometry();
65  }
66 
67  if (geom == 0) cout<<"Did not get geometry from EMCALLoader"<<endl;
68  // else geom->PrintGeometry();
69  }
70 
71  // Load Digits
72  rl->LoadDigits("EMCAL");
73 
74  // Get maximum number of events
75  Int_t maxevent = rl->GetNumberOfEvents();
76  cout<<"Number of events "<<maxevent<<endl;
77  //maxevent = 10 ;
78 
79  Int_t iEvent = -1 ;
80  Float_t amp = -1 ;
81  Float_t time = -1 ;
82  Int_t id = -1 ;
83  Int_t iSupMod = 0 ;
84  Int_t iTower = 0 ;
85  Int_t iIphi = 0 ;
86  Int_t iIeta = 0 ;
87  Int_t iphi = 0 ;
88  Int_t ieta = 0 ;
89  Int_t nprimaries = 0 ;
90  Int_t nparents = 0 ;
91  Int_t type = -1;
92 
93  AliEMCALDigit * dig;
94 
95  for ( iEvent=0; iEvent<maxevent; iEvent++)
96  {
97  cout << " ======> Event " << iEvent << endl ;
98  // Load Event
99  rl->GetEvent(iEvent);
100 
101  // Fill array of digits
102  TClonesArray *digits = emcalLoader->Digits();
103 
104  // Get digits from the list
105  for(Int_t idig = 0; idig< digits->GetEntries();idig++)
106  {
107 
108  //cout<<">> idig "<<idig<<endl;
109 
110  dig = static_cast<AliEMCALDigit *>(digits->At(idig)) ;
111 
112  if(!dig)
113  {
114  printf("Digit null pointer\n");
115  continue;
116  }
117 
118  //
119  // Basic digit parameters
121  id = dig->GetId() ; // cell (digit) absolute Id. number.
122  amp = dig->GetAmplitude(); // amplitude in cell (digit).
123  time = dig->GetTime()*1.e9; // time of creation of digit after collision.
124  type = dig->GetType();
125 
126  if(amp < ampMin) continue ;
127 
128  printf("*** Cell ID %d, Amplitude %4.2f, Time %4.2f, Type %d\n",id,amp,time,type);
129 
130  //
131  // MC
132  //
133  if(printMC)
134  {
135  nprimaries = dig->GetNprimary() ;
136  nparents = dig->GetNiparent() ;
137 
138 
139  if ( nprimaries > 0 || nparents > 0) printf("N primary %d; N parent %d\n", nprimaries, nparents);
140 
141  if(nprimaries > 0)
142  {
143  for(Int_t iprim = 0; iprim < nprimaries; iprim++)
144  printf(" \t primary %d, label %d, edep %2.3f\n", iprim, dig->GetPrimary(iprim+1), dig->GetDEPrimary(iprim+1));
145  }
146 
147  if(nparents > 0)
148  {
149  for(Int_t ipar = 0; ipar < nparents; ipar++)
150  printf("\t parent %d, label %d, edep %2.3f\n", ipar , dig->GetIparent(ipar +1), dig->GetDEParent (ipar +1));
151  }
152  }
153 
154  //
155  // Geometry methods
156  //
157  if( printGeo && geom)
158  {
159  // Get SM number and in module (4x4 cells) indexes
160  geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
161  // Get tower cell indexes from SM number and module
162  geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
163  iIphi, iIeta,iphi,ieta);
164 
165  printf("Super module number %d; Module: number %d; eta %d, phi %d; Cell/Tower: eta %d, phi %d\n",
166  iSupMod,iTower,iIeta,iIphi,ieta,iphi);
167 
168  }
169  }
170  }
171 
172 }
173 
Int_t LoadgAlice()
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
static const TString & GetDefaultEventFolderName()
Definition: AliConfig.h:58
Float_t GetDEParent(Int_t index) const
Definition: AliRun.h:27
Float_t GetTime(void) const
Definition: AliEMCALDigit.h:64
Int_t LoadDigits(Option_t *detectors="all", Option_t *opt="READ")
AliLoader * GetDetectorLoader(const char *detname)
void TestEMCALDigit(Float_t ampMin=6, Bool_t printMC=kFALSE, Bool_t printGeo=kFALSE)
EMCal digits object.
Definition: AliEMCALDigit.h:30
TClonesArray * Digits()
Int_t GetIparent(Int_t index) const
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
Int_t GetNprimary() const
Definition: AliEMCALDigit.h:57
Float_t GetDEPrimary(Int_t index) const
virtual AliEMCALGeometry * GetGeometry() const
Definition: AliEMCAL.cxx:466
Int_t GetNumberOfEvents()
Int_t GetType() const
Definition: AliEMCALDigit.h:69
Base Class for EMCAL description.
Definition: AliEMCAL.h:35
Int_t GetEvent(Int_t evno)
Int_t GetPrimary(Int_t index) const
Int_t GetId() const
Definition: AliDigitNew.h:23
AliDetector * GetDetector(const char *name) const
Definition: AliRun.cxx:200
Int_t GetNiparent() const
Definition: AliEMCALDigit.h:60
TEveGeoShape * geom
Definition: tpc_tracks.C:10
Float_t GetAmplitude() const
Definition: AliEMCALDigit.h:55
EMCal geometry, singleton.
AliRun * GetAliRun() const