AliRoot Core  edcc906 (edcc906)
TestEMCALRecPoint.C
Go to the documentation of this file.
1 
13 #if !defined(__CINT__) || defined(__MAKECINT__)
14 
15 //Root include files
16 #include <Riostream.h>
17 #include <TClonesArray.h>
18 #include <TGeoManager.h>
19 #include <TParticle.h>
20 
21 //AliRoot include files
22 #include "AliStack.h"
23 #include "AliRun.h"
24 #include "AliRunLoader.h"
25 #include "AliGeomManager.h"
26 #include "AliEMCALLoader.h"
27 #include "AliEMCAL.h"
28 #include "AliEMCALRecPoint.h"
29 #include "AliEMCALGeometry.h"
30 
31 #endif
32 
38 void TestEMCALRecPoint(Bool_t readKine = kFALSE)
39 {
40  //
41  // Getting EMCAL Detector and Geometry.
42  //
44 
45  if (rl == 0x0)
46  cout<<"Can not instatiate the Run Loader"<<endl;
47 
48  rl->LoadgAlice(); // Needed to get geometry, kinematics
49 
50  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
51  (rl->GetDetectorLoader("EMCAL"));
52 
53  //TGeoManager::Import("geometry.root");
54  AliGeomManager::LoadGeometry("geometry.root");
55 
56  AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry
57 
59  if(alirun)
60  {
61  AliEMCAL * emcal = (AliEMCAL*)alirun->GetDetector("EMCAL");
62  geom = emcal->GetGeometry();
63  }
64  else
65  {
66  cout<<"alirun not available, instantiate"<<endl;
67  geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM") ;
68  }
69 
70  // Load RecPoints
71  rl->LoadRecPoints("EMCAL");
72 
73  // Load Kinematics if MC
74  if(readKine)
75  rl->LoadKinematics();
76 
77  // Get maximum number of events
78  Int_t maxevent = rl->GetNumberOfEvents();
79  cout<<"Number of events "<<maxevent<<endl;
80 
81  Int_t iEvent = -1 ;
82  Int_t iprim = -1 ;
83  Float_t energy = -1 ;
84  TVector3 gpos ;
85  Float_t lmb[2] = {0,0};
86  Int_t nlm = -1;
87 
88  AliEMCALRecPoint * rp;
89  for ( iEvent=0; iEvent<maxevent; iEvent++)
90  {
91  cout << "======> Event " << iEvent << endl ;
92 
93  // Load Event
94  rl->GetEvent(iEvent);
95 
96  // In case of simulation get stack with kinematics
97  AliStack *sta= 0x0;
98  if(readKine) sta = rl->Stack();
99 
100  //
101  // Fill array of rec. points
102  //
103  TObjArray *rpoints ;//= emcalLoader->RecPoints();
104 
105  TTree *treeR = emcalLoader->TreeR();
106  TBranch * branchR = treeR->GetBranch("EMCALECARP");
107  branchR->SetAddress(&rpoints);
108  branchR->GetEntry(0);
109 
110  if(!rpoints->GetEntries()) continue;
111 
112  cout<<"Number of RecPoints "<<rpoints->GetEntries()<<endl;
113 
114  //
115  // Get recpoints from the list
116  //
117  for(Int_t irp = 0; irp< rpoints->GetEntries();irp++)
118  {
119  rp = static_cast<AliEMCALRecPoint *>(rpoints->At(irp)) ;
120  //rp = emcalLoader->RecPoint(irp);
121 
122  if(!rp)
123  {
124  cout<<"Null rec point!"<<endl;
125  continue;
126  }
127 
128  //
129  // Basic parameters
130  //
131  energy = rp->GetEnergy(); // Cluster energy
132  nlm = rp->GetNExMax(); // Number of local maxima
133 
134  rp->GetGlobalPosition(gpos); // Global ALICE xyz position
135  rp->GetElipsAxis(lmb); // Shower shape
136 
137  printf("\t RP %d, Energy %2.3f; Phi %2.1f, Eta %2.2f; "
138  "Shower shape l0 %2.2f, l1 %2.2f; NLM %d\n",
139  irp,energy,gpos.Phi()*TMath::RadToDeg(),gpos.Eta(),lmb[0],lmb[1],nlm);
140 
141  //
142  // MC
143  //
144  Int_t primMult = 0;
145  Int_t *primaries = rp->GetPrimaries(primMult);
146  Int_t parMult = 0;
147  Int_t *parents = rp->GetParents (parMult );
148 
149  printf("\t MC: N primaries %d, N parents %d\n",primMult,parMult);
150 
151  //if ( !sta ) continue;
152 
153  for (Int_t ipr=0; ipr < primMult; ipr++)
154  {
155  printf("\t \t primary %d, index %d\n",ipr,primaries[ipr]);
156 
157  if(readKine)
158  {
159  if ( primaries[ipr] < 0 ) continue ;
160 
161  TParticle *primary = sta->Particle(primaries[ipr]);
162  if(primary) printf("\t \t Primary: E %2.2f, Phi %2.2f, eta %2.2f\n",
163  primary->Energy(),primary->Phi()*TMath::RadToDeg(),primary->Eta());
164  }
165  } // primary
166 
167  for (Int_t ipa = 0; ipa < parMult; ipa++)
168  {
169  printf("\t \t parent %d, index %d\n",ipa,parents[ipa]);
170 
171  if(readKine)
172  {
173  if ( parents[ipa] < 0 ) continue ;
174 
175  TParticle *primary = sta->Particle(primaries[ipa]);
176  if(primary) printf("\t \t Primary: E %2.2f, Phi %2.2f, eta %2.2f\n",
177  primary->Energy(),primary->Phi()*TMath::RadToDeg(),primary->Eta());
178  }
179  } // parents
180 
181  } // rp loop
182 
183  } // event loop
184 }
185 
Int_t LoadgAlice()
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
static const TString & GetDefaultEventFolderName()
Definition: AliConfig.h:58
Definition: AliRun.h:27
#define TObjArray
AliLoader * GetDetectorLoader(const char *detname)
virtual Float_t GetEnergy() const
Short_t GetNExMax(void) 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")
TTree * TreeR() const
Definition: AliLoader.h:89
Int_t LoadRecPoints(Option_t *detectors="all", Option_t *opt="READ")
EMCal rec_points object.
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)
TParticle * Particle(Int_t id, Bool_t useInEmbedding=kFALSE)
Definition: AliStack.cxx:688
virtual void GetGlobalPosition(TVector3 &gpos) const
virtual Int_t * GetParents(Int_t &number) const
void TestEMCALRecPoint(Bool_t readKine=kFALSE)
AliDetector * GetDetector(const char *name) const
Definition: AliRun.cxx:200
static AliEMCALGeometry * GetInstance()
TEveGeoShape * geom
Definition: tpc_tracks.C:10
static void LoadGeometry(const char *geomFileName=NULL)
EMCal geometry, singleton.
virtual Int_t * GetPrimaries(Int_t &number) const
virtual void GetElipsAxis(Float_t *lambda) const
Int_t LoadKinematics(Option_t *option="READ")
AliRun * GetAliRun() const
AliStack * Stack() const
Definition: AliRunLoader.h:95