]>
Commit | Line | Data |
---|---|---|
c9b2f104 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | // Implementation version v1 of the EMCAL particle identifier | |
20 | ||
21 | //*-- Author: Yves Schutz (SUBATECH) | |
22 | // | |
23 | // --- ROOT system --- | |
d64c959b | 24 | //#include "TROOT.h" |
c9b2f104 | 25 | #include "TTree.h" |
c9b2f104 | 26 | #include "TBenchmark.h" |
c9b2f104 | 27 | #include "TSystem.h" |
88cb7938 | 28 | |
29 | // --- Standard library --- | |
30 | ||
31 | // --- AliRoot header files --- | |
c9b2f104 | 32 | #include "AliEMCALPIDv1.h" |
c9b2f104 | 33 | #include "AliEMCALTrackSegment.h" |
c9b2f104 | 34 | #include "AliEMCALRecParticle.h" |
c9b2f104 | 35 | #include "AliEMCALGetter.h" |
88cb7938 | 36 | |
37 | ClassImp( AliEMCALPIDv1) | |
c9b2f104 | 38 | |
39 | //____________________________________________________________________________ | |
40 | AliEMCALPIDv1::AliEMCALPIDv1():AliEMCALPID() | |
41 | { | |
42 | // default ctor | |
88cb7938 | 43 | |
c9b2f104 | 44 | InitParameters() ; |
45 | fDefaultInit = kTRUE ; | |
88cb7938 | 46 | |
47 | } | |
c9b2f104 | 48 | |
88cb7938 | 49 | //____________________________________________________________________________ |
50 | AliEMCALPIDv1::AliEMCALPIDv1(const AliEMCALPIDv1 & pid ):AliEMCALPID(pid) | |
51 | { | |
52 | // ctor | |
53 | InitParameters() ; | |
54 | Init() ; | |
55 | ||
c9b2f104 | 56 | } |
57 | ||
58 | //____________________________________________________________________________ | |
88cb7938 | 59 | AliEMCALPIDv1::AliEMCALPIDv1(const TString alirunFileName, const TString eventFolderName):AliEMCALPID(alirunFileName, eventFolderName) |
c9b2f104 | 60 | { |
61 | //ctor with the indication on where to look for the track segments | |
62 | ||
63 | InitParameters() ; | |
c9b2f104 | 64 | Init() ; |
65 | fDefaultInit = kFALSE ; | |
66 | ||
67 | } | |
68 | ||
69 | //____________________________________________________________________________ | |
70 | AliEMCALPIDv1::~AliEMCALPIDv1() | |
71 | { | |
72 | // dtor | |
c9b2f104 | 73 | } |
74 | ||
75 | //____________________________________________________________________________ | |
76 | const TString AliEMCALPIDv1::BranchName() const | |
77 | { | |
88cb7938 | 78 | |
79 | return GetName() ; | |
c9b2f104 | 80 | } |
81 | ||
82 | //____________________________________________________________________________ | |
83 | void AliEMCALPIDv1::Init() | |
84 | { | |
85 | // Make all memory allocations that are not possible in default constructor | |
86 | // Add the PID task to the list of EMCAL tasks | |
87 | ||
c9b2f104 | 88 | |
88cb7938 | 89 | AliEMCALGetter * gime = AliEMCALGetter::Instance(GetTitle(), fEventFolderName.Data()) ; |
c9b2f104 | 90 | |
88cb7938 | 91 | if ( !gime->PID() ) |
92 | gime->PostPID(this) ; | |
c9b2f104 | 93 | } |
94 | ||
95 | //____________________________________________________________________________ | |
96 | void AliEMCALPIDv1::InitParameters() | |
97 | { | |
d64c959b | 98 | // Initialize the parameters |
c9b2f104 | 99 | fRecParticlesInRun = 0 ; |
100 | fNEvent = 0 ; | |
101 | fRecParticlesInRun = 0 ; | |
c9b2f104 | 102 | } |
103 | ||
104 | //____________________________________________________________________________ | |
105 | ||
106 | void AliEMCALPIDv1::Exec(Option_t * option) | |
107 | { | |
108 | //Steering method | |
88cb7938 | 109 | |
c9b2f104 | 110 | if(strstr(option,"tim")) |
111 | gBenchmark->Start("EMCALPID"); | |
112 | ||
113 | if(strstr(option,"print")) { | |
114 | Print("") ; | |
115 | return ; | |
116 | } | |
88cb7938 | 117 | AliEMCALGetter * gime = AliEMCALGetter::Instance() ; |
118 | ||
7b8d3392 | 119 | if (fLastEvent == -1) |
120 | fLastEvent = gime->MaxEvent() - 1 ; | |
121 | else | |
122 | fLastEvent = TMath::Min(fLastEvent,gime->MaxEvent()); | |
123 | Int_t nEvents = fLastEvent - fFirstEvent + 1; | |
124 | ||
c9b2f104 | 125 | Int_t ievent ; |
126 | ||
127 | ||
7b8d3392 | 128 | for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) { |
88cb7938 | 129 | gime->Event(ievent,"TR") ; |
130 | if(gime->TrackSegments() && //Skip events, where no track segments made | |
131 | gime->TrackSegments()->GetEntriesFast()) { | |
132 | MakeRecParticles() ; | |
9e5d2067 | 133 | WriteRecParticles(); |
88cb7938 | 134 | if(strstr(option,"deb")) |
135 | PrintRecParticles(option) ; | |
136 | //increment the total number of rec particles per run | |
137 | fRecParticlesInRun += gime->RecParticles()->GetEntriesFast() ; | |
138 | } | |
c9b2f104 | 139 | } |
c9b2f104 | 140 | if(strstr(option,"tim")){ |
141 | gBenchmark->Stop("EMCALPID"); | |
fdebddeb | 142 | printf("Exec: took %f seconds for PID %f seconds per event", |
c9b2f104 | 143 | gBenchmark->GetCpuTime("EMCALPID"), |
7b8d3392 | 144 | gBenchmark->GetCpuTime("EMCALPID")/nEvents) ; |
c9b2f104 | 145 | } |
88cb7938 | 146 | |
147 | Unload(); | |
c9b2f104 | 148 | } |
149 | ||
150 | //____________________________________________________________________________ | |
151 | void AliEMCALPIDv1::MakeRecParticles(){ | |
152 | ||
153 | // Makes a RecParticle out of a TrackSegment | |
154 | ||
88cb7938 | 155 | AliEMCALGetter * gime = AliEMCALGetter::Instance() ; |
156 | TObjArray * aECARecPoints = gime->ECARecPoints() ; | |
c9b2f104 | 157 | TClonesArray * trackSegments = gime->TrackSegments() ; |
fdebddeb | 158 | if ( !aECARecPoints || !trackSegments ) { |
c9b2f104 | 159 | Fatal("MakeRecParticles", "RecPoints or TrackSegments not found !") ; |
160 | } | |
161 | TClonesArray * recParticles = gime->RecParticles() ; | |
162 | recParticles->Clear(); | |
163 | ||
164 | TIter next(trackSegments) ; | |
165 | AliEMCALTrackSegment * ts ; | |
166 | Int_t index = 0 ; | |
167 | AliEMCALRecParticle * rp ; | |
168 | while ( (ts = (AliEMCALTrackSegment *)next()) ) { | |
169 | ||
170 | new( (*recParticles)[index] ) AliEMCALRecParticle() ; | |
171 | rp = (AliEMCALRecParticle *)recParticles->At(index) ; | |
172 | rp->SetTrackSegment(index) ; | |
173 | rp->SetIndexInList(index) ; | |
174 | ||
88cb7938 | 175 | AliEMCALTowerRecPoint * eca = 0 ; |
176 | if(ts->GetECAIndex()>=0) | |
177 | eca = dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(ts->GetECAIndex())) ; | |
c9b2f104 | 178 | |
179 | // Now set type (reconstructed) of the particle | |
180 | ||
181 | // Choose the cluster energy range | |
182 | ||
88cb7938 | 183 | if (!eca) { |
184 | Fatal("MakeRecParticles", "-> emcal(%d) = %d", ts->GetECAIndex(), eca ) ; | |
c9b2f104 | 185 | } |
186 | ||
88cb7938 | 187 | Float_t e = eca->GetEnergy() ; |
c9b2f104 | 188 | |
189 | Float_t lambda[2] ; | |
88cb7938 | 190 | eca->GetElipsAxis(lambda) ; |
c9b2f104 | 191 | |
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). | |
195 | ||
d64c959b | 196 | Float_t spher = 0. ; |
197 | Float_t emaxdtotal = 0. ; | |
c9b2f104 | 198 | |
199 | if((lambda[0]+lambda[1])!=0) | |
d64c959b | 200 | spher=fabs(lambda[0]-lambda[1])/(lambda[0]+lambda[1]); |
c9b2f104 | 201 | |
d64c959b | 202 | emaxdtotal=eca->GetMaximalEnergy()/eca->GetEnergy(); |
c9b2f104 | 203 | } |
204 | ||
205 | // Float_t time = ecal->GetTime() ; | |
206 | ||
207 | //Set momentum, energy and other parameters | |
88cb7938 | 208 | Float_t enca = e; |
c9b2f104 | 209 | TVector3 dir(0., 0., 0.) ; |
88cb7938 | 210 | dir.SetMag(enca) ; |
211 | rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),enca) ; | |
c9b2f104 | 212 | rp->SetCalcMass(0); |
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); | |
220 | index++ ; | |
221 | } | |
222 | ||
223 | } | |
224 | ||
225 | //____________________________________________________________________________ | |
9e5d2067 | 226 | void AliEMCALPIDv1:: Print(Option_t * /*option*/) const |
c9b2f104 | 227 | { |
228 | // Print the parameters used for the particle type identification | |
229 | ||
fdebddeb | 230 | printf("Print: =============== AliEMCALPID1 ================") ; |
88cb7938 | 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() ) ; | |
c9b2f104 | 234 | } |
235 | ||
7b8d3392 | 236 | //____________________________________________________________________________ |
237 | void AliEMCALPIDv1::Print() const | |
238 | { | |
239 | // Print the parameters used for the particle type identification | |
240 | ||
241 | Info("Print", "=============== AliEMCALPIDv1 ================") ; | |
242 | } | |
243 | ||
c9b2f104 | 244 | //____________________________________________________________________________ |
245 | void AliEMCALPIDv1::PrintRecParticles(Option_t * option) | |
246 | { | |
247 | // Print table of reconstructed particles | |
248 | ||
88cb7938 | 249 | AliEMCALGetter *gime = AliEMCALGetter::Instance() ; |
c9b2f104 | 250 | |
88cb7938 | 251 | TClonesArray * recParticles = gime->RecParticles() ; |
c9b2f104 | 252 | |
fdebddeb | 253 | printf("\nevent %i", gAlice->GetEvNumber()); |
254 | printf(" found %i", recParticles->GetEntriesFast()); | |
255 | printf(" RecParticles\n"); | |
c9b2f104 | 256 | |
257 | if(strstr(option,"all")) { // printing found TS | |
fdebddeb | 258 | printf("\n PARTICLE Index \n"); |
c9b2f104 | 259 | |
260 | Int_t index ; | |
261 | for (index = 0 ; index < recParticles->GetEntries() ; index++) { | |
262 | AliEMCALRecParticle * rp = (AliEMCALRecParticle * ) recParticles->At(index) ; | |
fdebddeb | 263 | printf("\n"); |
264 | printf(rp->Name().Data()); | |
265 | printf(" %i", rp->GetIndexInList()); | |
266 | printf(" %i", rp->GetType()); | |
c9b2f104 | 267 | } |
268 | } | |
c9b2f104 | 269 | } |
270 | ||
88cb7938 | 271 | //____________________________________________________________________________ |
272 | void AliEMCALPIDv1::Unload() | |
273 | { | |
d64c959b | 274 | // Unloads RecPoints, TrackSegments and RecParticles from the folder |
88cb7938 | 275 | AliEMCALGetter * gime = AliEMCALGetter::Instance() ; |
276 | gime->EmcalLoader()->UnloadRecPoints() ; | |
277 | gime->EmcalLoader()->UnloadTracks() ; | |
278 | gime->EmcalLoader()->UnloadRecParticles() ; | |
279 | } | |
280 | ||
281 | //____________________________________________________________________________ | |
9e5d2067 | 282 | void AliEMCALPIDv1::WriteRecParticles() |
88cb7938 | 283 | { |
d64c959b | 284 | // Write RecParticles array to file |
88cb7938 | 285 | AliEMCALGetter *gime = AliEMCALGetter::Instance() ; |
286 | ||
287 | TClonesArray * recParticles = gime->RecParticles() ; | |
288 | recParticles->Expand(recParticles->GetEntriesFast() ) ; | |
289 | TTree * treeP = gime->TreeP() ; | |
c9b2f104 | 290 | |
88cb7938 | 291 | |
292 | ||
293 | //First rp | |
294 | Int_t bufferSize = 32000 ; | |
295 | TBranch * rpBranch = treeP->Branch("EMCALRP",&recParticles,bufferSize); | |
296 | rpBranch->SetTitle(BranchName()); | |
297 | ||
298 | rpBranch->Fill() ; | |
299 | ||
300 | gime->WriteRecParticles("OVERWRITE"); | |
301 | gime->WritePID("OVERWRITE"); | |
302 | ||
303 | } | |
c9b2f104 | 304 |