]>
Commit | Line | Data |
---|---|---|
6a40c29e | 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 v2 of the PHOS particle identifier | |
20 | // Particle identification based on the | |
21 | // - RCPV: distance from CPV recpoint to EMCA recpoint. | |
22 | // - TOF | |
23 | // - PCA: Principal Components Analisis.. | |
24 | // The identified particle has an identification number corresponding | |
25 | // to a 3 bits number: | |
26 | // -Bit 0: bit set if RCPV > fCpvEmcDistance | |
27 | // -Bit 1: bit set if TOF < fTimeGate | |
28 | // -Bit 2: bit set if Principal Components are | |
29 | // inside an ellipse defined by fX_center, fY_center, fA, fB, fAngle | |
30 | // | |
31 | // | |
32 | // use case: | |
33 | // root [0] AliPHOSPIDv2 * p1 = new AliPHOSPIDv2("galice.root") | |
34 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
35 | // root [1] p1->SetIdentificationMethod("disp ellipse") | |
36 | // root [2] p1->ExecuteTask() | |
5bf7ace9 | 37 | // root [3] AliPHOSPIDv2 * p2 = new AliPHOSPIDv2("galice1.root","v2") |
6a40c29e | 38 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
5bf7ace9 | 39 | // // reading headers from file galice1.root and create RecParticles with title v2 |
40 | // TrackSegments and RecPoints with title "v2" are used | |
6a40c29e | 41 | // // set file name for the branch RecParticles |
5bf7ace9 | 42 | // root [4] p2->ExecuteTask("deb all time") |
6a40c29e | 43 | // // available options |
44 | // // "deb" - prints # of reconstructed particles | |
45 | // // "deb all" - prints # and list of RecParticles | |
46 | // // "time" - prints benchmarking results | |
47 | // | |
5bf7ace9 | 48 | // root [5] AliPHOSPIDv2 * p3 = new AliPHOSPIDv2("galice1.root","v2","v0") |
49 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
50 | // // reading headers from file galice1.root and create RecParticles with title v2 | |
51 | // RecPoints and TrackSegments with title "v0" are used | |
52 | // root [6] p3->ExecuteTask() | |
6a40c29e | 53 | //*-- Author: Yves Schutz (SUBATECH) & Gines Martinez (SUBATECH) & |
54 | // Gustavo Conesa April 2002 | |
55 | ||
56 | // --- ROOT system --- | |
57 | #include "TROOT.h" | |
58 | #include "TTree.h" | |
59 | #include "TFile.h" | |
60 | #include "TF2.h" | |
61 | #include "TFormula.h" | |
62 | #include "TCanvas.h" | |
63 | #include "TFolder.h" | |
64 | #include "TSystem.h" | |
65 | #include "TBenchmark.h" | |
66 | #include "TEllipse.h" | |
67 | #include "TPrincipal.h" | |
68 | // --- Standard library --- | |
69 | ||
70 | #include <iostream.h> | |
71 | #include <iomanip.h> | |
72 | ||
73 | // --- AliRoot header files --- | |
74 | ||
75 | #include "AliRun.h" | |
76 | #include "AliGenerator.h" | |
77 | #include "AliPHOS.h" | |
78 | #include "AliPHOSPIDv2.h" | |
79 | #include "AliPHOSClusterizerv1.h" | |
80 | #include "AliPHOSTrackSegment.h" | |
81 | #include "AliPHOSTrackSegmentMakerv1.h" | |
82 | #include "AliPHOSRecParticle.h" | |
83 | #include "AliPHOSGeometry.h" | |
84 | #include "AliPHOSGetter.h" | |
85 | ||
86 | ClassImp( AliPHOSPIDv2) | |
87 | ||
88 | //____________________________________________________________________________ | |
89 | AliPHOSPIDv2::AliPHOSPIDv2():AliPHOSPID() | |
90 | { | |
91 | // default ctor | |
92 | ||
93 | fHeaderFileName = "" ; | |
94 | fTrackSegmentsTitle= "" ; | |
95 | fRecPointsTitle = "" ; | |
96 | fRecParticlesTitle = "" ; | |
97 | fRecParticlesInRun = 0 ; | |
98 | fClusterizer = 0 ; | |
99 | fTSMaker = 0 ; | |
5bf7ace9 | 100 | fFrom = "" ; |
6a40c29e | 101 | |
102 | } | |
103 | ||
104 | //____________________________________________________________________________ | |
5bf7ace9 | 105 | AliPHOSPIDv2::AliPHOSPIDv2(const char * headerFile,const char * name, const char * from) : AliPHOSPID(headerFile, name) |
6a40c29e | 106 | { |
107 | //ctor with the indication on where to look for the track segments | |
108 | ||
109 | fHeaderFileName = GetTitle() ; | |
110 | fTrackSegmentsTitle = GetName() ; | |
111 | fRecPointsTitle = GetName() ; | |
112 | fRecParticlesTitle = GetName() ; | |
113 | TString tempo(GetName()) ; | |
114 | tempo.Append(":") ; | |
115 | tempo.Append(Version()) ; | |
116 | SetName(tempo) ; | |
117 | fRecParticlesInRun = 0 ; | |
5bf7ace9 | 118 | if ( from == 0 ) |
119 | fFrom = name ; | |
120 | else | |
121 | fFrom = from ; | |
6a40c29e | 122 | Init() ; |
123 | ||
124 | } | |
125 | ||
126 | //____________________________________________________________________________ | |
127 | AliPHOSPIDv2::~AliPHOSPIDv2() | |
128 | { | |
129 | delete [] fX; | |
130 | delete [] fP; | |
131 | } | |
132 | ||
133 | ||
134 | //____________________________________________________________________________ | |
135 | Float_t AliPHOSPIDv2::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSRecPoint * cpv, Option_t * Axis)const | |
136 | { | |
137 | // Calculates the distance between the EMC RecPoint and the PPSD RecPoint | |
138 | ||
139 | const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; | |
140 | TVector3 vecEmc ; | |
141 | TVector3 vecCpv ; | |
142 | ||
143 | emc->GetLocalPosition(vecEmc) ; | |
144 | cpv->GetLocalPosition(vecCpv) ; | |
145 | if(emc->GetPHOSMod() == cpv->GetPHOSMod()){ | |
146 | ||
147 | // Correct to difference in CPV and EMC position due to different distance to center. | |
148 | // we assume, that particle moves from center | |
149 | Float_t dCPV = geom->GetIPtoOuterCoverDistance(); | |
150 | Float_t dEMC = geom->GetIPtoCrystalSurface() ; | |
151 | dEMC = dEMC / dCPV ; | |
152 | vecCpv = dEMC * vecCpv - vecEmc ; | |
153 | if (Axis == "X") return vecCpv.X(); | |
154 | if (Axis == "Y") return vecCpv.Y(); | |
155 | if (Axis == "Z") return vecCpv.Z(); | |
156 | if (Axis == "R") return vecCpv.Mag(); | |
157 | } | |
158 | ||
159 | return 100000000 ; | |
160 | } | |
161 | //____________________________________________________________________________ | |
162 | void AliPHOSPIDv2::SetEllipseParameters(Float_t x, Float_t y,Float_t a, Float_t b,Float_t angle) | |
163 | { | |
164 | fX_center = x ; | |
165 | fY_center = y ; | |
166 | fA = a ; | |
167 | fB = b ; | |
168 | fAngle = angle ; | |
169 | } | |
170 | ||
171 | //____________________________________________________________________________ | |
172 | Int_t AliPHOSPIDv2::GetPrincipalSign(Double_t* P )const | |
173 | { | |
174 | //This method gives if the PCA of the particle are inside a defined ellipse | |
175 | ||
176 | Int_t prinsign; | |
177 | Double_t fDx = 0. ; | |
178 | Double_t fDelta = 0. ; | |
179 | Double_t fY = 0. ; | |
180 | Double_t fY_1 = 0. ; | |
181 | Double_t fY_2 = 0. ; | |
182 | Double_t fPi = TMath::Pi() ; | |
183 | Double_t fCos_Theta = TMath::Cos(fPi*fAngle/180.) ; | |
184 | Double_t fSin_Theta = TMath::Sin(fPi*fAngle/180.) ; | |
185 | ||
186 | fDx = P[0] - fX_center ; | |
187 | fDelta = 4.*fA*fA*fA*fB* (fA*fA*fCos_Theta*fCos_Theta + fB*fB*fSin_Theta*fSin_Theta - fDx*fDx) ; | |
188 | if (fDelta < 0.) | |
189 | {prinsign=0;} | |
190 | ||
191 | else if (fDelta == 0.) | |
192 | { | |
193 | fY = fCos_Theta*fSin_Theta*(fA*fA - fB*fB)*fDx / (fA*fA*fCos_Theta*fCos_Theta + | |
194 | fB*fB*fSin_Theta*fSin_Theta) ; | |
195 | fY += fY_center ; | |
196 | if(P[1]==fY ) | |
197 | {prinsign=1;} | |
198 | else | |
199 | {prinsign=0;} | |
200 | } | |
201 | else | |
202 | { | |
203 | fY_1 = (fCos_Theta*fSin_Theta*(fA*fA - fB*fB) *fDx + | |
204 | TMath::Sqrt(fDelta)/2.)/(fA*fA*fCos_Theta*fCos_Theta + fB*fB*fSin_Theta*fSin_Theta) ; | |
205 | fY_2 = (fCos_Theta*fSin_Theta*(fA*fA - fB*fB) *fDx - | |
206 | TMath::Sqrt(fDelta)/2.)/(fA*fA*fCos_Theta*fCos_Theta + fB*fB*fSin_Theta*fSin_Theta) ; | |
207 | fY_1 += fY_center ; | |
208 | fY_2 += fY_center ; | |
209 | if ((P[1]<=fY_1) && (P[1]>=fY_2)) | |
210 | {prinsign=1;} | |
211 | else | |
212 | {prinsign=0;} | |
213 | } | |
214 | return prinsign; | |
215 | } | |
216 | //____________________________________________________________________________ | |
217 | void AliPHOSPIDv2::Exec(Option_t * option) | |
218 | { | |
219 | //Steering method | |
220 | ||
221 | if( strcmp(GetName(), "")== 0 ) | |
222 | Init() ; | |
223 | ||
224 | if(strstr(option,"tim")) | |
225 | gBenchmark->Start("PHOSPID"); | |
226 | ||
227 | if(strstr(option,"print")) { | |
228 | Print("") ; | |
229 | return ; | |
230 | } | |
231 | ||
5bf7ace9 | 232 | cout << gDirectory->GetName() << endl ; |
233 | ||
6a40c29e | 234 | gAlice->GetEvent(0) ; |
5bf7ace9 | 235 | |
6a40c29e | 236 | //check, if the branch with name of this" already exits? |
237 | TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; | |
238 | TIter next(lob) ; | |
239 | TBranch * branch = 0 ; | |
240 | Bool_t phospidfound = kFALSE, pidfound = kFALSE ; | |
241 | ||
242 | TString taskName(GetName()) ; | |
243 | taskName.Remove(taskName.Index(Version())-1) ; | |
244 | ||
245 | while ( (branch = (TBranch*)next()) && (!phospidfound || !pidfound) ) { | |
246 | if ( (strcmp(branch->GetName(), "PHOSPID")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) | |
247 | phospidfound = kTRUE ; | |
248 | ||
249 | else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) | |
250 | pidfound = kTRUE ; | |
251 | } | |
252 | ||
253 | if ( phospidfound || pidfound ) { | |
254 | cerr << "WARNING: AliPHOSPIDv2::Exec -> RecParticles and/or PIDtMaker branch with name " | |
255 | << taskName.Data() << " already exits" << endl ; | |
256 | return ; | |
257 | } | |
258 | ||
259 | Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; | |
260 | Int_t ievent ; | |
5bf7ace9 | 261 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
6a40c29e | 262 | for(ievent = 0; ievent < nevents; ievent++){ |
5bf7ace9 | 263 | gime->Event(ievent,"RA") ; |
264 | ||
6a40c29e | 265 | MakeRecParticles() ; |
266 | ||
267 | WriteRecParticles(ievent); | |
268 | ||
269 | if(strstr(option,"deb")) | |
270 | PrintRecParticles(option) ; | |
271 | ||
272 | //increment the total number of rec particles per run | |
5bf7ace9 | 273 | fRecParticlesInRun += gime->RecParticles(taskName)->GetEntriesFast() ; |
6a40c29e | 274 | |
275 | } | |
276 | ||
277 | if(strstr(option,"tim")){ | |
278 | gBenchmark->Stop("PHOSPID"); | |
279 | cout << "AliPHOSPID:" << endl ; | |
280 | cout << " took " << gBenchmark->GetCpuTime("PHOSPID") << " seconds for PID " | |
281 | << gBenchmark->GetCpuTime("PHOSPID")/nevents << " seconds per event " << endl ; | |
282 | cout << endl ; | |
283 | } | |
284 | ||
285 | } | |
286 | //____________________________________________________________________________ | |
287 | void AliPHOSPIDv2::Init() | |
288 | { | |
289 | // Make all memory allocations that are not possible in default constructor | |
290 | // Add the PID task to the list of PHOS tasks | |
291 | ||
292 | if ( strcmp(GetTitle(), "") == 0 ) | |
293 | SetTitle("galice.root") ; | |
294 | ||
295 | TString taskName(GetName()) ; | |
296 | taskName.Remove(taskName.Index(Version())-1) ; | |
297 | ||
298 | fCpvEmcDistance = 4.0 ; | |
299 | fTimeGate = 0.162e-7 ; | |
300 | ||
301 | //PCA | |
302 | fX = new double[7]; // Data for the PCA | |
303 | fP = new double[7]; // Eigenvalues of the PCA | |
304 | fFileName = "$ALICE_ROOT/PHOS/PCA8pa15_0.5-100.root" ; | |
305 | TFile f( fFileName.Data(), "read" ) ; | |
306 | fPrincipal = dynamic_cast<TPrincipal*> (f.Get("principal")) ; | |
5bf7ace9 | 307 | f.Close() ; |
6a40c29e | 308 | // Ellipse parameters |
309 | fX_center = 2.0 ; | |
310 | fY_center = -0.35 ; | |
311 | ||
312 | fA = 1.9 ; | |
313 | fB = 1.0 ; | |
314 | fAngle = -60. ; | |
315 | ||
5bf7ace9 | 316 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), fFrom.Data()) ; |
317 | ||
318 | gime->SetRecParticlesTitle(taskName) ; | |
6a40c29e | 319 | if ( gime == 0 ) { |
320 | cerr << "ERROR: AliPHOSPIDv2::Init -> Could not obtain the Getter object !" << endl ; | |
321 | return ; | |
322 | } | |
323 | ||
324 | gime->PostPID(this) ; | |
325 | // create a folder on the white board //YSAlice/WhiteBoard/RecParticles/PHOS/recparticlesName | |
326 | gime->PostRecParticles(taskName.Data() ) ; | |
327 | ||
328 | } | |
329 | ||
330 | //____________________________________________________________________________ | |
331 | void AliPHOSPIDv2::MakeRecParticles(){ | |
332 | ||
333 | // Makes a RecParticle out of a TrackSegment | |
5bf7ace9 | 334 | |
6a40c29e | 335 | TString taskName(GetName()) ; |
336 | taskName.Remove(taskName.Index(Version())-1) ; | |
5bf7ace9 | 337 | |
6a40c29e | 338 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
5bf7ace9 | 339 | TObjArray * emcRecPoints = gime->EmcRecPoints(fFrom) ; |
340 | TObjArray * cpvRecPoints = gime->CpvRecPoints(fFrom) ; | |
341 | TClonesArray * trackSegments = gime->TrackSegments(fFrom) ; | |
342 | if ( !emcRecPoints || !cpvRecPoints || !trackSegments ) { | |
343 | cerr << "ERROR: AliPHOSPIDv2::MakeRecParticles -> RecPoints or TrackSegments with name " | |
344 | << fFrom << " not found ! " << endl ; | |
345 | abort() ; | |
346 | } | |
6a40c29e | 347 | TClonesArray * recParticles = gime->RecParticles(taskName) ; |
348 | recParticles->Clear(); | |
349 | ||
350 | ||
351 | TIter next(trackSegments) ; | |
352 | AliPHOSTrackSegment * ts ; | |
353 | Int_t index = 0 ; | |
354 | AliPHOSRecParticle * rp ; | |
355 | ||
356 | while ( (ts = (AliPHOSTrackSegment *)next()) ) { | |
357 | ||
358 | new( (*recParticles)[index] ) AliPHOSRecParticle() ; | |
359 | rp = (AliPHOSRecParticle *)recParticles->At(index) ; | |
360 | rp->SetTraskSegment(index) ; | |
361 | rp->SetIndexInList(index) ; | |
362 | ||
363 | AliPHOSEmcRecPoint * emc = 0 ; | |
364 | if(ts->GetEmcIndex()>=0) | |
365 | emc = (AliPHOSEmcRecPoint *) emcRecPoints->At(ts->GetEmcIndex()) ; | |
366 | ||
367 | AliPHOSRecPoint * cpv = 0 ; | |
368 | if(ts->GetCpvIndex()>=0) | |
369 | cpv = (AliPHOSRecPoint *) cpvRecPoints->At(ts->GetCpvIndex()) ; | |
370 | ||
371 | //set momentum and energy first | |
372 | Float_t e = emc->GetEnergy() ; | |
373 | TVector3 dir = GetMomentumDirection(emc,cpv) ; | |
374 | dir.SetMag(e) ; | |
375 | ||
376 | rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),e) ; | |
377 | rp->SetCalcMass(0); | |
378 | ||
379 | //now set type (reconstructed) of the particle | |
380 | ||
381 | // Looking at the CPV detector. If RCPV grater than fCpvEmcDistance, first bit 1. | |
382 | if(cpv) | |
383 | if(GetDistance(emc, cpv, "R") > fCpvEmcDistance ) | |
384 | rp->SetPIDBit(0); | |
385 | ||
386 | //Looking the TOF. If TOF smaller than gate, second bit 1. | |
387 | if(emc->GetTime()< fTimeGate) | |
388 | rp->SetPIDBit(1); | |
389 | ||
390 | ||
391 | //Loking PCA. Define and calculate the data (X) introduce in the function | |
392 | //X2P that gives the components (P). | |
393 | Float_t fSpher = 0. ; | |
394 | Float_t fEmaxdtotal = 0. ; | |
395 | Float_t lambda[2] ; | |
396 | ||
397 | emc->GetElipsAxis(lambda) ; | |
398 | if((lambda[0]+lambda[1])!=0) fSpher=fabs(lambda[0]-lambda[1])/(lambda[0]+lambda[1]); | |
399 | ||
400 | fEmaxdtotal=emc->GetMaximalEnergy()/emc->GetEnergy(); | |
401 | ||
402 | fX[0] = lambda[0]; //cout <<" lambda0 "<<fX[0]; | |
403 | fX[1] = lambda[1]; //cout <<" lambda1 "<<fX[1]; | |
404 | fX[2] = emc->GetDispersion(); // cout <<" disper "<<fX[2]; | |
405 | fX[3] = fSpher; // cout <<" spher "<<fX[3]; | |
406 | fX[4] = emc->GetMultiplicity(); // cout <<" mult "<<fX[4]; | |
407 | fX[5] = fEmaxdtotal; // cout <<" emax "<<fX[5]; | |
408 | fX[6] = emc->GetCoreEnergy(); // cout <<" core "<<fX[5]<< endl ; | |
409 | ||
410 | // cout<<"Principal "<<fPrincipal<<endl; | |
411 | fPrincipal->X2P(fX,fP); | |
412 | ||
413 | //If we are inside the ellipse, third bit 1 | |
414 | if(GetPrincipalSign(fP)== 1) | |
415 | rp->SetPIDBit(2) ; | |
416 | ||
417 | ||
418 | rp->SetProductionVertex(0,0,0,0); | |
419 | rp->SetFirstMother(-1); | |
420 | rp->SetLastMother(-1); | |
421 | rp->SetFirstDaughter(-1); | |
422 | rp->SetLastDaughter(-1); | |
423 | rp->SetPolarisation(0,0,0); | |
424 | index++ ; | |
425 | } | |
426 | ||
427 | } | |
428 | ||
429 | //____________________________________________________________________________ | |
430 | void AliPHOSPIDv2:: Print(Option_t * option) const | |
431 | { | |
432 | // Print the parameters used for the particle type identification | |
433 | cout << "=============== AliPHOSPID1 ================" << endl ; | |
434 | cout << "Making PID "<< endl ; | |
435 | cout << " Headers file: " << fHeaderFileName.Data() << endl ; | |
436 | cout << " RecPoints branch title: " << fRecPointsTitle.Data() << endl ; | |
437 | cout << " TrackSegments Branch title: " << fTrackSegmentsTitle.Data() << endl ; | |
438 | cout << " RecParticles Branch title " << fRecParticlesTitle.Data() << endl; | |
439 | cout << "with parameters: " << endl ; | |
440 | cout << " Maximal EMC - CPV distance (cm) " << fCpvEmcDistance << endl ; | |
441 | cout << " Time Gate used: " << fTimeGate << endl ; | |
442 | cout << " Principal Ellipse Parameters " << endl ; | |
443 | cout << " Ellipse center (x,y) (" << fX_center<<","<<fY_center<<")"<< endl; | |
444 | cout << " Ellipse focus (a,b) (" << fA<<","<<fB<<")"<< endl; | |
445 | cout << " Ellipse angle " << fAngle<< endl; | |
446 | cout << "============================================" << endl ; | |
447 | } | |
448 | ||
449 | //____________________________________________________________________________ | |
450 | void AliPHOSPIDv2::WriteRecParticles(Int_t event) | |
451 | { | |
452 | ||
453 | AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; | |
454 | TString taskName(GetName()) ; | |
455 | taskName.Remove(taskName.Index(Version())-1) ; | |
456 | TClonesArray * recParticles = gime->RecParticles(taskName) ; | |
457 | recParticles->Expand(recParticles->GetEntriesFast() ) ; | |
458 | ||
459 | //Make branch in TreeR for RecParticles | |
460 | char * filename = 0; | |
461 | if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name | |
462 | filename = new char[strlen(gAlice->GetBaseFile())+20] ; | |
463 | sprintf(filename,"%s/PHOS.Reco.root",gAlice->GetBaseFile()) ; | |
464 | } | |
465 | ||
466 | TDirectory *cwd = gDirectory; | |
467 | ||
468 | //First rp | |
469 | Int_t bufferSize = 32000 ; | |
470 | TBranch * rpBranch = gAlice->TreeR()->Branch("PHOSRP",&recParticles,bufferSize); | |
471 | rpBranch->SetTitle(fRecParticlesTitle); | |
472 | if (filename) { | |
473 | rpBranch->SetFile(filename); | |
474 | TIter next( rpBranch->GetListOfBranches()); | |
475 | TBranch * sb ; | |
476 | while ((sb=(TBranch*)next())) { | |
477 | sb->SetFile(filename); | |
478 | } | |
479 | cwd->cd(); | |
480 | } | |
481 | ||
482 | //second, pid | |
483 | Int_t splitlevel = 0 ; | |
484 | AliPHOSPIDv2 * pid = this ; | |
485 | TBranch * pidBranch = gAlice->TreeR()->Branch("AliPHOSPID","AliPHOSPIDv2",&pid,bufferSize,splitlevel); | |
486 | pidBranch->SetTitle(fRecParticlesTitle.Data()); | |
487 | if (filename) { | |
488 | pidBranch->SetFile(filename); | |
489 | TIter next( pidBranch->GetListOfBranches()); | |
490 | TBranch * sb ; | |
491 | while ((sb=(TBranch*)next())) { | |
492 | sb->SetFile(filename); | |
493 | } | |
494 | cwd->cd(); | |
495 | } | |
496 | ||
497 | rpBranch->Fill() ; | |
498 | pidBranch->Fill() ; | |
499 | ||
500 | gAlice->TreeR()->Write(0,kOverwrite) ; | |
501 | //pidBranch->Write(0,kOverwrite) ; | |
502 | ||
503 | delete [] filename ; | |
504 | } | |
505 | ||
506 | //____________________________________________________________________________ | |
507 | TVector3 AliPHOSPIDv2::GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSRecPoint * cpv)const | |
508 | { | |
509 | // Calculates the momentum direction: | |
510 | // 1. if only a EMC RecPoint, direction is given by IP and this RecPoint | |
511 | // 2. if a EMC RecPoint and CPV RecPoint, direction is given by the line through the 2 recpoints | |
512 | // However because of the poor position resolution of PPSD the direction is always taken as if we were | |
513 | // in case 1. | |
514 | ||
515 | TVector3 dir(0,0,0) ; | |
516 | ||
517 | TVector3 emcglobalpos ; | |
518 | TMatrix dummy ; | |
519 | ||
520 | emc->GetGlobalPosition(emcglobalpos, dummy) ; | |
521 | ||
522 | ||
523 | dir = emcglobalpos ; | |
524 | dir.SetZ( -dir.Z() ) ; // why ? | |
525 | dir.SetMag(1.) ; | |
526 | ||
527 | //account correction to the position of IP | |
528 | Float_t xo,yo,zo ; //Coordinates of the origin | |
529 | gAlice->Generator()->GetOrigin(xo,yo,zo) ; | |
530 | TVector3 origin(xo,yo,zo); | |
531 | dir = dir - origin ; | |
532 | ||
533 | return dir ; | |
534 | } | |
535 | //____________________________________________________________________________ | |
536 | void AliPHOSPIDv2::PrintRecParticles(Option_t * option) | |
537 | { | |
538 | // Print table of reconstructed particles | |
539 | ||
540 | AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; | |
541 | ||
542 | TString taskName(GetName()) ; | |
543 | taskName.Remove(taskName.Index(Version())-1) ; | |
544 | TClonesArray * recParticles = gime->RecParticles(taskName) ; | |
545 | ||
546 | cout << "AliPHOSPIDv2: event "<<gAlice->GetEvNumber() << endl ; | |
547 | cout << " found " << recParticles->GetEntriesFast() << " RecParticles " << endl ; | |
548 | ||
549 | if(strstr(option,"all")) { // printing found TS | |
550 | ||
551 | cout << " PARTICLE " | |
552 | << " Index " << endl ; | |
553 | ||
554 | Int_t index ; | |
555 | for (index = 0 ; index < recParticles->GetEntries() ; index++) { | |
556 | AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) recParticles->At(index) ; | |
557 | ||
558 | Text_t particle[11]; | |
559 | switch(rp->GetType()) { | |
560 | case AliPHOSFastRecParticle::kCHARGEDHASLOW: | |
561 | strcpy(particle, "CHARGED HA SLOW") ; | |
562 | break ; | |
563 | case AliPHOSFastRecParticle::kNEUTRALHASLOW: | |
564 | strcpy(particle, "NEUTRAL HA SLOW"); | |
565 | break ; | |
566 | case AliPHOSFastRecParticle::kCHARGEDHAFAST: | |
567 | strcpy(particle, "CHARGED HA FAST") ; | |
568 | break ; | |
569 | case AliPHOSFastRecParticle::kNEUTRALHAFAST: | |
570 | strcpy(particle, "NEUTRAL HA FAST"); | |
571 | break; | |
572 | case AliPHOSFastRecParticle::kCHARGEDEMSLOW: | |
573 | strcpy(particle, "CHARGED EM SLOW") ; | |
574 | break ; | |
575 | case AliPHOSFastRecParticle::kNEUTRALEMSLOW: | |
576 | strcpy(particle, "NEUTRAL EM SLOW"); | |
577 | break ; | |
578 | case AliPHOSFastRecParticle::kCHARGEDEMFAST: | |
579 | strcpy(particle, "CHARGED EM FAST") ; | |
580 | break ; | |
581 | case AliPHOSFastRecParticle::kNEUTRALEMFAST: | |
582 | strcpy( particle, "NEUTRAL EM FAST"); | |
583 | break; | |
584 | } | |
585 | ||
586 | cout << setw(10) << particle << " " | |
587 | << setw(5) << rp->GetIndexInList() << " " <<endl; | |
588 | ||
589 | } | |
590 | cout << "-------------------------------------------" << endl ; | |
591 | } | |
592 | ||
593 | } | |
594 | ||
595 | ||
596 |