1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
19 // Implementation version v1 of the EMCAL particle identifier
21 //*-- Author: Yves Schutz (SUBATECH)
23 // --- ROOT system ---
31 #include "TBenchmark.h"
34 // --- Standard library ---
36 // --- AliRoot header files ---
38 #include "AliGenerator.h"
40 #include "AliEMCALPIDv1.h"
41 #include "AliEMCALClusterizerv1.h"
42 #include "AliEMCALTrackSegment.h"
43 #include "AliEMCALTrackSegmentMakerv1.h"
44 #include "AliEMCALRecParticle.h"
45 #include "AliEMCALGeometry.h"
46 #include "AliEMCALGetter.h"
48 ClassImp( AliEMCALPIDv1)
50 //____________________________________________________________________________
51 AliEMCALPIDv1::AliEMCALPIDv1():AliEMCALPID()
56 fDefaultInit = kTRUE ;
60 //____________________________________________________________________________
61 AliEMCALPIDv1::AliEMCALPIDv1(const AliEMCALPIDv1 & pid ):AliEMCALPID(pid)
69 //____________________________________________________________________________
70 AliEMCALPIDv1::AliEMCALPIDv1(const TString alirunFileName, const TString eventFolderName):AliEMCALPID(alirunFileName, eventFolderName)
72 //ctor with the indication on where to look for the track segments
76 fDefaultInit = kFALSE ;
80 //____________________________________________________________________________
81 AliEMCALPIDv1::~AliEMCALPIDv1()
86 //____________________________________________________________________________
87 const TString AliEMCALPIDv1::BranchName() const
93 //____________________________________________________________________________
94 void AliEMCALPIDv1::Init()
96 // Make all memory allocations that are not possible in default constructor
97 // Add the PID task to the list of EMCAL tasks
100 AliEMCALGetter * gime = AliEMCALGetter::Instance(GetTitle(), fEventFolderName.Data()) ;
103 gime->PostPID(this) ;
106 //____________________________________________________________________________
107 void AliEMCALPIDv1::InitParameters()
110 fRecParticlesInRun = 0 ;
112 fRecParticlesInRun = 0 ;
115 //____________________________________________________________________________
117 void AliEMCALPIDv1::Exec(Option_t * option)
121 if(strstr(option,"tim"))
122 gBenchmark->Start("EMCALPID");
124 if(strstr(option,"print")) {
128 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
130 Int_t nevents = gime->MaxEvent() ;
134 for(ievent = 0; ievent < nevents; ievent++){
135 gime->Event(ievent,"TR") ;
136 if(gime->TrackSegments() && //Skip events, where no track segments made
137 gime->TrackSegments()->GetEntriesFast()) {
140 if(strstr(option,"deb"))
141 PrintRecParticles(option) ;
142 //increment the total number of rec particles per run
143 fRecParticlesInRun += gime->RecParticles()->GetEntriesFast() ;
146 if(strstr(option,"tim")){
147 gBenchmark->Stop("EMCALPID");
148 Info("Exec", "took %f seconds for PID %f seconds per event",
149 gBenchmark->GetCpuTime("EMCALPID"),
150 gBenchmark->GetCpuTime("EMCALPID")/nevents) ;
156 //____________________________________________________________________________
157 void AliEMCALPIDv1::MakeRecParticles(){
159 // Makes a RecParticle out of a TrackSegment
161 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
162 TObjArray * aECARecPoints = gime->ECARecPoints() ;
163 TObjArray * aPRERecPoints = gime->PRERecPoints() ;
164 TObjArray * aHCARecPoints = gime->HCARecPoints() ;
165 TClonesArray * trackSegments = gime->TrackSegments() ;
166 if ( !aECARecPoints || !aPRERecPoints || !aHCARecPoints || !trackSegments ) {
167 Fatal("MakeRecParticles", "RecPoints or TrackSegments not found !") ;
169 TClonesArray * recParticles = gime->RecParticles() ;
170 recParticles->Clear();
172 TIter next(trackSegments) ;
173 AliEMCALTrackSegment * ts ;
175 AliEMCALRecParticle * rp ;
176 while ( (ts = (AliEMCALTrackSegment *)next()) ) {
178 new( (*recParticles)[index] ) AliEMCALRecParticle() ;
179 rp = (AliEMCALRecParticle *)recParticles->At(index) ;
180 rp->SetTrackSegment(index) ;
181 rp->SetIndexInList(index) ;
183 AliEMCALTowerRecPoint * eca = 0 ;
184 if(ts->GetECAIndex()>=0)
185 eca = dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(ts->GetECAIndex())) ;
187 AliEMCALTowerRecPoint * pre = 0 ;
188 if(ts->GetPREIndex()>=0)
189 pre = dynamic_cast<AliEMCALTowerRecPoint *>(aPRERecPoints->At(ts->GetPREIndex())) ;
191 AliEMCALTowerRecPoint * hca = 0 ;
192 if(ts->GetHCAIndex()>=0)
193 hca = dynamic_cast<AliEMCALTowerRecPoint *>(aHCARecPoints->At(ts->GetHCAIndex())) ;
195 // Now set type (reconstructed) of the particle
197 // Choose the cluster energy range
200 Fatal("MakeRecParticles", "-> emcal(%d) = %d", ts->GetECAIndex(), eca ) ;
203 Float_t e = eca->GetEnergy() ;
206 eca->GetElipsAxis(lambda) ;
208 if((lambda[0]>0.01) && (lambda[1]>0.01)){
209 // Looking PCA. Define and calculate the data (X),
210 // introduce in the function X2P that gives the components (P).
213 Float_t Emaxdtotal = 0. ;
215 if((lambda[0]+lambda[1])!=0)
216 Spher=fabs(lambda[0]-lambda[1])/(lambda[0]+lambda[1]);
218 Emaxdtotal=eca->GetMaximalEnergy()/eca->GetEnergy();
221 // Float_t time = ecal->GetTime() ;
223 //Set momentum, energy and other parameters
225 TVector3 dir(0., 0., 0.) ;
227 rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),enca) ;
229 rp->Name(); //If photon sets the particle pdg name to gamma
230 rp->SetProductionVertex(0,0,0,0);
231 rp->SetFirstMother(-1);
232 rp->SetLastMother(-1);
233 rp->SetFirstDaughter(-1);
234 rp->SetLastDaughter(-1);
235 rp->SetPolarisation(0,0,0);
241 //____________________________________________________________________________
242 void AliEMCALPIDv1:: Print(Option_t * /*option*/) const
244 // Print the parameters used for the particle type identification
246 Info("Print", "=============== AliEMCALPID1 ================") ;
247 printf("Making PID\n");
248 printf(" Pricipal analysis file from 0.5 to 100 %s\n", fFileName.Data() ) ;
249 printf(" Name of parameters file %s\n", fFileNamePar.Data() ) ;
252 //____________________________________________________________________________
253 void AliEMCALPIDv1::PrintRecParticles(Option_t * option)
255 // Print table of reconstructed particles
257 AliEMCALGetter *gime = AliEMCALGetter::Instance() ;
259 TClonesArray * recParticles = gime->RecParticles() ;
262 message = "\nevent " ;
263 message += gAlice->GetEvNumber() ;
264 message += " found " ;
265 message += recParticles->GetEntriesFast();
266 message += " RecParticles\n" ;
268 if(strstr(option,"all")) { // printing found TS
269 message += "\n PARTICLE Index \n" ;
272 for (index = 0 ; index < recParticles->GetEntries() ; index++) {
273 AliEMCALRecParticle * rp = (AliEMCALRecParticle * ) recParticles->At(index) ;
275 message += rp->Name().Data() ;
277 message += rp->GetIndexInList() ;
279 message += rp->GetType() ;
282 Info("Print", message.Data() ) ;
285 //____________________________________________________________________________
286 void AliEMCALPIDv1::Unload()
288 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
289 gime->EmcalLoader()->UnloadRecPoints() ;
290 gime->EmcalLoader()->UnloadTracks() ;
291 gime->EmcalLoader()->UnloadRecParticles() ;
294 //____________________________________________________________________________
295 void AliEMCALPIDv1::WriteRecParticles()
298 AliEMCALGetter *gime = AliEMCALGetter::Instance() ;
300 TClonesArray * recParticles = gime->RecParticles() ;
301 recParticles->Expand(recParticles->GetEntriesFast() ) ;
302 TTree * treeP = gime->TreeP() ;
307 Int_t bufferSize = 32000 ;
308 TBranch * rpBranch = treeP->Branch("EMCALRP",&recParticles,bufferSize);
309 rpBranch->SetTitle(BranchName());
313 gime->WriteRecParticles("OVERWRITE");
314 gime->WritePID("OVERWRITE");