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 ---
26 #include "TBenchmark.h"
29 // --- Standard library ---
31 // --- AliRoot header files ---
32 #include "AliEMCALPIDv1.h"
33 #include "AliEMCALTrackSegment.h"
34 #include "AliEMCALRecParticle.h"
35 #include "AliEMCALGetter.h"
37 ClassImp( AliEMCALPIDv1)
39 //____________________________________________________________________________
40 AliEMCALPIDv1::AliEMCALPIDv1():AliEMCALPID()
45 fDefaultInit = kTRUE ;
49 //____________________________________________________________________________
50 AliEMCALPIDv1::AliEMCALPIDv1(const AliEMCALPIDv1 & pid ):AliEMCALPID(pid)
58 //____________________________________________________________________________
59 AliEMCALPIDv1::AliEMCALPIDv1(const TString alirunFileName, const TString eventFolderName):AliEMCALPID(alirunFileName, eventFolderName)
61 //ctor with the indication on where to look for the track segments
65 fDefaultInit = kFALSE ;
69 //____________________________________________________________________________
70 AliEMCALPIDv1::~AliEMCALPIDv1()
75 //____________________________________________________________________________
76 const TString AliEMCALPIDv1::BranchName() const
82 //____________________________________________________________________________
83 void AliEMCALPIDv1::Init()
85 // Make all memory allocations that are not possible in default constructor
86 // Add the PID task to the list of EMCAL tasks
89 AliEMCALGetter * gime = AliEMCALGetter::Instance(GetTitle(), fEventFolderName.Data()) ;
95 //____________________________________________________________________________
96 void AliEMCALPIDv1::InitParameters()
98 // Initialize the parameters
99 fRecParticlesInRun = 0 ;
101 fRecParticlesInRun = 0 ;
104 //____________________________________________________________________________
106 void AliEMCALPIDv1::Exec(Option_t * option)
110 if(strstr(option,"tim"))
111 gBenchmark->Start("EMCALPID");
113 if(strstr(option,"print")) {
117 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
119 if (fLastEvent == -1)
120 fLastEvent = gime->MaxEvent() - 1 ;
122 fLastEvent = TMath::Min(fLastEvent,gime->MaxEvent());
123 Int_t nEvents = fLastEvent - fFirstEvent + 1;
128 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
129 gime->Event(ievent,"TR") ;
130 if(gime->TrackSegments() && //Skip events, where no track segments made
131 gime->TrackSegments()->GetEntriesFast()) {
134 if(strstr(option,"deb"))
135 PrintRecParticles(option) ;
136 //increment the total number of rec particles per run
137 fRecParticlesInRun += gime->RecParticles()->GetEntriesFast() ;
140 if(strstr(option,"tim")){
141 gBenchmark->Stop("EMCALPID");
142 printf("Exec: took %f seconds for PID %f seconds per event",
143 gBenchmark->GetCpuTime("EMCALPID"),
144 gBenchmark->GetCpuTime("EMCALPID")/nEvents) ;
150 //____________________________________________________________________________
151 void AliEMCALPIDv1::MakeRecParticles(){
153 // Makes a RecParticle out of a TrackSegment
155 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
156 TObjArray * aECARecPoints = gime->ECARecPoints() ;
157 TClonesArray * trackSegments = gime->TrackSegments() ;
158 if ( !aECARecPoints || !trackSegments ) {
159 Fatal("MakeRecParticles", "RecPoints or TrackSegments not found !") ;
161 TClonesArray * recParticles = gime->RecParticles() ;
162 recParticles->Clear();
164 TIter next(trackSegments) ;
165 AliEMCALTrackSegment * ts ;
167 AliEMCALRecParticle * rp ;
168 while ( (ts = (AliEMCALTrackSegment *)next()) ) {
170 new( (*recParticles)[index] ) AliEMCALRecParticle() ;
171 rp = (AliEMCALRecParticle *)recParticles->At(index) ;
172 rp->SetTrackSegment(index) ;
173 rp->SetIndexInList(index) ;
175 AliEMCALTowerRecPoint * eca = 0 ;
176 if(ts->GetECAIndex()>=0)
177 eca = dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(ts->GetECAIndex())) ;
179 // Now set type (reconstructed) of the particle
181 // Choose the cluster energy range
184 Fatal("MakeRecParticles", "-> emcal(%d) = %d", ts->GetECAIndex(), eca ) ;
187 Float_t e = eca->GetEnergy() ;
190 eca->GetElipsAxis(lambda) ;
192 if((lambda[0]>0.01) && (lambda[1]>0.01)){
193 // Looking PCA. Define and calculate the data (X),
194 // introduce in the function X2P that gives the components (P).
197 Float_t emaxdtotal = 0. ;
199 if((lambda[0]+lambda[1])!=0)
200 spher=fabs(lambda[0]-lambda[1])/(lambda[0]+lambda[1]);
202 emaxdtotal=eca->GetMaximalEnergy()/eca->GetEnergy();
205 // Float_t time = ecal->GetTime() ;
207 //Set momentum, energy and other parameters
209 TVector3 dir(0., 0., 0.) ;
211 rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),enca) ;
213 rp->Name(); //If photon sets the particle pdg name to gamma
214 rp->SetProductionVertex(0,0,0,0);
215 rp->SetFirstMother(-1);
216 rp->SetLastMother(-1);
217 rp->SetFirstDaughter(-1);
218 rp->SetLastDaughter(-1);
219 rp->SetPolarisation(0,0,0);
225 //____________________________________________________________________________
226 void AliEMCALPIDv1:: Print(Option_t * /*option*/) const
228 // Print the parameters used for the particle type identification
230 printf("Print: =============== AliEMCALPID1 ================") ;
231 printf("Making PID\n");
232 printf(" Pricipal analysis file from 0.5 to 100 %s\n", fFileName.Data() ) ;
233 printf(" Name of parameters file %s\n", fFileNamePar.Data() ) ;
236 //____________________________________________________________________________
237 void AliEMCALPIDv1::Print() const
239 // Print the parameters used for the particle type identification
241 Info("Print", "=============== AliEMCALPIDv1 ================") ;
244 //____________________________________________________________________________
245 void AliEMCALPIDv1::PrintRecParticles(Option_t * option)
247 // Print table of reconstructed particles
249 AliEMCALGetter *gime = AliEMCALGetter::Instance() ;
251 TClonesArray * recParticles = gime->RecParticles() ;
253 printf("\nevent %i", gAlice->GetEvNumber());
254 printf(" found %i", recParticles->GetEntriesFast());
255 printf(" RecParticles\n");
257 if(strstr(option,"all")) { // printing found TS
258 printf("\n PARTICLE Index \n");
261 for (index = 0 ; index < recParticles->GetEntries() ; index++) {
262 AliEMCALRecParticle * rp = (AliEMCALRecParticle * ) recParticles->At(index) ;
264 printf(rp->Name().Data());
265 printf(" %i", rp->GetIndexInList());
266 printf(" %i", rp->GetType());
271 //____________________________________________________________________________
272 void AliEMCALPIDv1::Unload()
274 // Unloads RecPoints, TrackSegments and RecParticles from the folder
275 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
276 gime->EmcalLoader()->UnloadRecPoints() ;
277 gime->EmcalLoader()->UnloadTracks() ;
278 gime->EmcalLoader()->UnloadRecParticles() ;
281 //____________________________________________________________________________
282 void AliEMCALPIDv1::WriteRecParticles()
284 // Write RecParticles array to file
285 AliEMCALGetter *gime = AliEMCALGetter::Instance() ;
287 TClonesArray * recParticles = gime->RecParticles() ;
288 recParticles->Expand(recParticles->GetEntriesFast() ) ;
289 TTree * treeP = gime->TreeP() ;
294 Int_t bufferSize = 32000 ;
295 TBranch * rpBranch = treeP->Branch("EMCALRP",&recParticles,bufferSize);
296 rpBranch->SetTitle(BranchName());
300 gime->WriteRecParticles("OVERWRITE");
301 gime->WritePID("OVERWRITE");