]>
Commit | Line | Data |
---|---|---|
6ad0bfa0 | 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 | ||
b2a60966 | 16 | /* $Id$ */ |
17 | ||
6ad0bfa0 | 18 | //_________________________________________________________________________ |
b2a60966 | 19 | // Implementation version v1 of the PHOS particle identifier |
7acf6008 | 20 | // Particle identification based on the |
21 | // - CPV information, | |
a4e98857 | 22 | // - Preshower information (in MIXT or GPS2 geometries) |
7acf6008 | 23 | // - shower width. |
a4e98857 | 24 | // |
25 | // CPV or Preshower clusters should be closer in PHOS plane than fCpvEmcDistance (in cm). | |
26 | // This parameter can be set by method SetCpvtoEmcDistanceCut(Float_t cut) | |
7acf6008 | 27 | // |
28 | // One can set desirable ID method by the function SetIdentificationMethod(option). | |
a4e98857 | 29 | // Presently the following options can be used together or separately : |
7acf6008 | 30 | // - "disp": use dispersion cut on shower width |
31 | // (width can be set by method SetDispersionCut(Float_t cut) | |
a4e98857 | 32 | // - "ell" : use cut on the axis of the ellipse, drawn around shower |
7acf6008 | 33 | // (this cut can be changed by SetShowerProfileCut(char* formula), |
34 | // where formula - any function of two variables f(lambda[0],lambda[1]). | |
35 | // Shower is considered as EM if f() > 0 ) | |
36 | // One can visualize current cuts calling method PlotDispersionCuts(). | |
37 | // | |
a4e98857 | 38 | // use case: |
39 | // root [0] AliPHOSPIDv1 * p1 = new AliPHOSPIDv1("galice.root") | |
40 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
41 | // root [1] p1->SetIdentificationMethod("disp ellipse") | |
42 | // root [2] p1->ExecuteTask() | |
43 | // root [3] AliPHOSPIDv1 * p2 = new AliPHOSPIDv1("galice1.root","ts1") | |
44 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
7acf6008 | 45 | // // reading headers from file galice1.root and TrackSegments |
46 | // // with title "ts1" | |
a4e98857 | 47 | // root [4] p2->SetRecParticlesBranch("rp1") |
7acf6008 | 48 | // // set file name for the branch RecParticles |
a4e98857 | 49 | // root [5] p2->ExecuteTask("deb all time") |
7acf6008 | 50 | // // available options |
51 | // // "deb" - prints # of reconstructed particles | |
52 | // // "deb all" - prints # and list of RecParticles | |
53 | // // "time" - prints benchmarking results | |
54 | // | |
55 | //*-- Author: Yves Schutz (SUBATECH) & Gines Martinez (SUBATECH) & | |
56 | // Dmitri Peressounko (SUBATECH & Kurchatov Institute) | |
57 | // Complitely redesined by Dmitri Peressounko, March 2001 | |
6ad0bfa0 | 58 | |
59 | // --- ROOT system --- | |
7acf6008 | 60 | #include "TROOT.h" |
61 | #include "TTree.h" | |
62 | #include "TFile.h" | |
63 | #include "TF2.h" | |
64 | #include "TFormula.h" | |
65 | #include "TCanvas.h" | |
66 | #include "TFolder.h" | |
67 | #include "TSystem.h" | |
68 | #include "TBenchmark.h" | |
6ad0bfa0 | 69 | // --- Standard library --- |
70 | ||
de9ec31b | 71 | #include <iostream.h> |
7acf6008 | 72 | #include <iomanip.h> |
6ad0bfa0 | 73 | |
74 | // --- AliRoot header files --- | |
75 | ||
7acf6008 | 76 | #include "AliRun.h" |
77 | #include "AliGenerator.h" | |
78 | #include "AliPHOS.h" | |
26d4b141 | 79 | #include "AliPHOSPIDv1.h" |
7acf6008 | 80 | #include "AliPHOSClusterizerv1.h" |
6ad0bfa0 | 81 | #include "AliPHOSTrackSegment.h" |
7acf6008 | 82 | #include "AliPHOSTrackSegmentMakerv1.h" |
6ad0bfa0 | 83 | #include "AliPHOSRecParticle.h" |
84 | ||
26d4b141 | 85 | ClassImp( AliPHOSPIDv1) |
6ad0bfa0 | 86 | |
1cb7c1ee | 87 | //____________________________________________________________________________ |
88 | AliPHOSPIDv1::AliPHOSPIDv1():AliPHOSPID() | |
89 | { | |
a4e98857 | 90 | // default ctor |
7acf6008 | 91 | fIsInitialized = kFALSE ; |
92 | } | |
93 | ||
94 | //____________________________________________________________________________ | |
95 | AliPHOSPIDv1::AliPHOSPIDv1(const char * headeFile,const char * tsBranchTitle):AliPHOSPID() | |
96 | { | |
a4e98857 | 97 | //ctor with the indication on where to look for the track segments |
dd5c4038 | 98 | |
7acf6008 | 99 | fHeaderFileName = headeFile ; |
100 | ||
101 | fTSTitle = tsBranchTitle ; | |
102 | ||
103 | SetName("AliPHOSPID") ; | |
104 | SetTitle("version1") ; | |
105 | ||
106 | TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data() ) ; | |
107 | ||
108 | if(file == 0){ | |
f035f6ce | 109 | if(fHeaderFileName.Contains("rfio")) // if we read file using HPSS |
110 | file = TFile::Open(fHeaderFileName.Data(),"update") ; | |
111 | else | |
112 | file = new TFile(fHeaderFileName.Data(),"update") ; | |
7acf6008 | 113 | gAlice = (AliRun *) file->Get("gAlice") ; |
114 | } | |
115 | ||
116 | AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; | |
117 | fGeom = AliPHOSGeometry::GetInstance(phos->GetGeometry()->GetName(),phos->GetGeometry()->GetTitle() ); | |
118 | ||
119 | fTrackSegments = new TClonesArray("AliPHOSTrackSegment",1) ; | |
120 | fTSMaker = 0 ; | |
121 | fEmcRecPoints = new TObjArray(1) ; | |
122 | fCpvRecPoints = new TObjArray(1) ; | |
123 | fClusterizer = 0 ; | |
124 | fRecParticles = new TClonesArray("AliPHOSRecParticle",100) ; | |
125 | ||
126 | fFormula = new TFormula("LambdaCuts","(x>1)*(x<3)*(y>0)*(y<x)") ; | |
127 | ||
128 | // add Task to //root/Tasks folder | |
129 | TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; | |
dd5c4038 | 130 | TTask * phostasks = (TTask*)(roottasks->GetListOfTasks()->FindObject("PHOS")); |
131 | phostasks->Add(this) ; | |
7acf6008 | 132 | |
133 | fDispersion = 2.0; | |
134 | fCpvEmcDistance = 3.0 ; | |
135 | fIsInitialized = kTRUE ; | |
136 | ||
137 | } | |
138 | //____________________________________________________________________________ | |
139 | AliPHOSPIDv1::~AliPHOSPIDv1() | |
140 | { | |
a4e98857 | 141 | //dtor |
7acf6008 | 142 | } |
143 | //____________________________________________________________________________ | |
144 | void AliPHOSPIDv1::Init() | |
145 | { | |
a4e98857 | 146 | // Make all memory allocations that are not possible in default constructor |
7acf6008 | 147 | if(!fIsInitialized){ |
148 | if(fHeaderFileName.IsNull()) | |
149 | fHeaderFileName = "galice.root" ; | |
150 | ||
151 | TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data() ) ; | |
152 | ||
153 | if(file == 0){ | |
154 | file = new TFile(fHeaderFileName.Data(),"update") ; | |
155 | gAlice = (AliRun *) file->Get("gAlice") ; | |
156 | } | |
157 | ||
158 | AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; | |
159 | fGeom = AliPHOSGeometry::GetInstance(phos->GetGeometry()->GetName(),phos->GetGeometry()->GetTitle() ); | |
160 | ||
161 | fTrackSegments = new TClonesArray("AliPHOSTrackSegment",1) ; | |
162 | fTSMaker = new AliPHOSTrackSegmentMakerv1() ; | |
163 | fEmcRecPoints = new TObjArray(1) ; | |
164 | fCpvRecPoints = new TObjArray(1) ; | |
165 | fClusterizer = new AliPHOSClusterizerv1() ; | |
166 | fRecParticles = new TClonesArray("AliPHOSRecParticle",100) ; | |
167 | ||
168 | fFormula = new TFormula("LambdaCuts","(x>1)*(x<2.5)*(y>0)*(y<x)") ; | |
169 | ||
170 | // add Task to //root/Tasks folder | |
171 | TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; | |
dd5c4038 | 172 | TTask * phostasks = (TTask*)(roottasks->GetListOfTasks()->FindObject("PHOS")); |
173 | phostasks->Add(this) ; | |
7acf6008 | 174 | |
175 | fDispersion = 2.0; | |
176 | fCpvEmcDistance = 3.0 ; | |
177 | ||
178 | fIsInitialized = kTRUE ; | |
179 | } | |
1cb7c1ee | 180 | } |
7acf6008 | 181 | //____________________________________________________________________________ |
182 | Bool_t AliPHOSPIDv1::ReadTrackSegments() | |
183 | { | |
f035f6ce | 184 | // Reads TrackSegments an extracts the title of the RecPoints |
a4e98857 | 185 | // branch from which TS were made of. |
f035f6ce | 186 | // Then reads both TrackSegments and RecPoints. |
7acf6008 | 187 | |
f035f6ce | 188 | //Fist read Track Segment Branch and extract RecPointsBranch from fTSMaker |
7acf6008 | 189 | fTrackSegments->Clear() ; |
190 | fEmcRecPoints->Clear() ; | |
191 | fCpvRecPoints->Clear() ; | |
192 | fRecParticles->Clear() ; | |
193 | ||
194 | gAlice->GetEvent(fNEvent) ; | |
195 | ||
196 | TTree * treeR = gAlice->TreeR() ; | |
197 | ||
198 | if(treeR==0){ | |
199 | char treeName[20]; | |
200 | sprintf(treeName,"TreeR%d",fNEvent); | |
201 | cout << "Error in AliPHOSClusterizerv1 : no "<<treeName << endl ; | |
202 | cout << " Do nothing " << endl ; | |
203 | return kFALSE ; | |
204 | } | |
205 | ||
206 | //first read TSMaker branch and extract information about RecPoints Branches | |
207 | TBranch * tsMakerBranch = 0; | |
208 | TBranch * tsBranch = 0; | |
209 | ||
210 | TObjArray * branches = treeR->GetListOfBranches() ; | |
211 | Int_t ibranch; | |
212 | Bool_t tsMakerNotFound = kTRUE ; | |
213 | Bool_t tsNotFound = kTRUE ; | |
214 | ||
215 | for(ibranch = 0;(ibranch <branches->GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){ | |
216 | if(tsMakerNotFound){ | |
217 | tsMakerBranch=(TBranch *) branches->At(ibranch) ; | |
218 | if( fTSTitle.CompareTo(tsMakerBranch->GetTitle())==0 ) | |
219 | if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0) | |
220 | tsMakerNotFound = kFALSE ; | |
221 | } | |
222 | if(tsNotFound){ | |
223 | tsBranch=(TBranch *) branches->At(ibranch) ; | |
224 | if( fTSTitle.CompareTo(tsBranch->GetTitle())==0 ) | |
225 | if( strcmp(tsBranch->GetName(),"PHOSTS") == 0) | |
226 | tsNotFound = kFALSE ; | |
227 | } | |
228 | } | |
229 | ||
230 | if(tsMakerNotFound ||tsNotFound ){ | |
231 | cout << "Can't find Branch with TrackSegmentMaker and TrackSegments " ; | |
232 | cout << "Do nothing" <<endl ; | |
233 | return kFALSE ; | |
234 | } | |
235 | ||
236 | tsMakerBranch->SetAddress(&fTSMaker) ; | |
237 | tsBranch->SetAddress(&fTrackSegments) ; | |
238 | ||
761e34c0 | 239 | tsMakerBranch->GetEntry(0) ; |
240 | tsBranch->GetEntry(0) ; | |
7acf6008 | 241 | |
242 | fRecPointsTitle = fTSMaker->GetRecPointsBranch() ; | |
1cb7c1ee | 243 | |
7acf6008 | 244 | //reading now recponts branches |
245 | TBranch * emcBranch = 0; | |
246 | TBranch * cpvBranch = 0; | |
247 | TBranch * cluBranch = 0; | |
248 | ||
249 | Bool_t emcNotFound = kTRUE ; | |
250 | Bool_t cpvNotFound = kTRUE ; | |
251 | Bool_t cluNotFound = kTRUE ; | |
252 | ||
253 | for(ibranch = 0;(ibranch <branches->GetEntries())&&(emcNotFound||cpvNotFound||cluNotFound);ibranch++){ | |
254 | if(emcNotFound){ | |
255 | emcBranch=(TBranch *) branches->At(ibranch) ; | |
256 | if( fRecPointsTitle.CompareTo(emcBranch->GetTitle())==0 ) | |
257 | if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0) | |
258 | emcNotFound = kFALSE ; | |
259 | } | |
260 | if(cpvNotFound){ | |
261 | cpvBranch=(TBranch *) branches->At(ibranch) ; | |
262 | if( fRecPointsTitle.CompareTo(cpvBranch->GetTitle())==0 ) | |
263 | if( strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) | |
264 | cpvNotFound = kFALSE ; | |
265 | } | |
266 | if(cluNotFound){ | |
267 | cluBranch=(TBranch *) branches->At(ibranch) ; | |
268 | if( fRecPointsTitle.CompareTo(cluBranch->GetTitle())==0 ) | |
269 | if( strcmp(cluBranch->GetName(),"AliPHOSClusterizer") == 0) | |
270 | cluNotFound = kFALSE ; | |
271 | } | |
272 | } | |
273 | ||
274 | if(emcNotFound ||cpvNotFound ||cluNotFound ){ | |
275 | cout << "Can't find Branch with RecPoints or AliPHOSClusterizer " ; | |
276 | cout << "Do nothing" <<endl ; | |
277 | return kFALSE ; | |
278 | } | |
279 | ||
280 | emcBranch->SetAddress(&fEmcRecPoints) ; | |
281 | cpvBranch->SetAddress(&fCpvRecPoints) ; | |
282 | cluBranch->SetAddress(&fClusterizer) ; | |
283 | ||
761e34c0 | 284 | emcBranch->GetEntry(0) ; |
285 | cpvBranch->GetEntry(0) ; | |
286 | cluBranch->GetEntry(0) ; | |
287 | ||
7acf6008 | 288 | return kTRUE ; |
289 | ||
290 | ||
291 | ||
292 | } | |
69183710 | 293 | //____________________________________________________________________________ |
7acf6008 | 294 | Float_t AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSRecPoint * cpv, Option_t * Axis)const |
69183710 | 295 | { |
296 | // Calculates the distance between the EMC RecPoint and the PPSD RecPoint | |
297 | ||
69183710 | 298 | TVector3 vecEmc ; |
7acf6008 | 299 | TVector3 vecCpv ; |
300 | ||
301 | emc->GetLocalPosition(vecEmc) ; | |
302 | cpv->GetLocalPosition(vecCpv) ; | |
303 | if(emc->GetPHOSMod() == cpv->GetPHOSMod()){ | |
304 | ||
305 | // Correct to difference in CPV and EMC position due to different distance to center. | |
306 | // we assume, that particle moves from center | |
307 | Float_t dCPV = fGeom->GetIPtoOuterCoverDistance(); | |
308 | Float_t dEMC = fGeom->GetIPtoCrystalSurface() ; | |
309 | dEMC = dEMC / dCPV ; | |
310 | vecCpv = dEMC * vecCpv - vecEmc ; | |
311 | if (Axis == "X") return vecCpv.X(); | |
312 | if (Axis == "Y") return vecCpv.Y(); | |
313 | if (Axis == "Z") return vecCpv.Z(); | |
314 | if (Axis == "R") return vecCpv.Mag(); | |
315 | } | |
316 | ||
317 | return 100000000 ; | |
69183710 | 318 | } |
319 | ||
6ad0bfa0 | 320 | //____________________________________________________________________________ |
7acf6008 | 321 | void AliPHOSPIDv1::Exec(Option_t * option) |
6ad0bfa0 | 322 | { |
f035f6ce | 323 | //Steering method |
324 | ||
7acf6008 | 325 | if(!fIsInitialized) |
326 | Init() ; | |
327 | ||
328 | if(strstr(option,"tim")) | |
329 | gBenchmark->Start("PHOSPID"); | |
330 | ||
331 | ||
332 | Int_t nEvents = (Int_t) gAlice->TreeE()->GetEntries() ; | |
333 | ||
334 | for(fNEvent = 0 ;fNEvent <nEvents; fNEvent++){ | |
335 | if(!ReadTrackSegments()) | |
336 | return ; | |
337 | MakeRecParticles() ; | |
338 | WriteRecParticles(); | |
339 | if(strstr(option,"deb")) | |
340 | PrintRecParticles(option) ; | |
341 | } | |
342 | ||
343 | if(strstr(option,"tim")){ | |
344 | gBenchmark->Stop("PHOSPID"); | |
345 | cout << "AliPHOSPID:" << endl ; | |
346 | cout << " took " << gBenchmark->GetCpuTime("PHOSPID") << " seconds for PID " | |
347 | << gBenchmark->GetCpuTime("PHOSPID")/nEvents << " seconds per event " << endl ; | |
348 | cout << endl ; | |
349 | } | |
350 | ||
351 | } | |
352 | //____________________________________________________________________________ | |
353 | void AliPHOSPIDv1::MakeRecParticles(){ | |
354 | ||
b2a60966 | 355 | // Makes a RecParticle out of a TrackSegment |
6ad0bfa0 | 356 | |
7acf6008 | 357 | TIter next(fTrackSegments) ; |
358 | AliPHOSTrackSegment * ts ; | |
6ad0bfa0 | 359 | Int_t index = 0 ; |
09fc14a0 | 360 | AliPHOSRecParticle * rp ; |
7acf6008 | 361 | |
362 | Bool_t ellips = fIDOptions.Contains("ell",TString::kIgnoreCase ) ; | |
363 | Bool_t disp = fIDOptions.Contains("dis",TString::kIgnoreCase ) ; | |
364 | ||
365 | while ( (ts = (AliPHOSTrackSegment *)next()) ) { | |
fad3e5b9 | 366 | |
7acf6008 | 367 | new( (*fRecParticles)[index] ) AliPHOSRecParticle() ; |
368 | rp = (AliPHOSRecParticle *)fRecParticles->At(index) ; | |
369 | rp->SetTraskSegment(index) ; | |
f035f6ce | 370 | |
7acf6008 | 371 | AliPHOSEmcRecPoint * emc = 0 ; |
372 | if(ts->GetEmcIndex()>=0) | |
373 | emc = (AliPHOSEmcRecPoint *) fEmcRecPoints->At(ts->GetEmcIndex()) ; | |
fad3e5b9 | 374 | |
7acf6008 | 375 | AliPHOSRecPoint * cpv = 0 ; |
376 | if(ts->GetCpvIndex()>=0) | |
377 | cpv = (AliPHOSRecPoint *) fCpvRecPoints->At(ts->GetCpvIndex()) ; | |
fad3e5b9 | 378 | |
7acf6008 | 379 | AliPHOSRecPoint * ppsd = 0 ; |
380 | if(ts->GetPpsdIndex()>=0) | |
381 | ppsd= (AliPHOSRecPoint *) fCpvRecPoints->At(ts->GetPpsdIndex()) ; | |
382 | ||
383 | //set momentum and energy first | |
384 | Float_t e = emc->GetEnergy() ; | |
385 | TVector3 dir = GetMomentumDirection(emc,cpv,ppsd) ; | |
386 | dir.SetMag(e) ; | |
387 | ||
388 | rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),e) ; | |
389 | rp->SetCalcMass(0); | |
390 | ||
391 | //now set type (reconstructed) of the particle | |
392 | Int_t showerprofile = 0; // 0 narrow and 1 wide | |
fad3e5b9 | 393 | |
7acf6008 | 394 | if(ellips){ |
395 | Float_t lambda[2] ; | |
396 | emc->GetElipsAxis(lambda) ; | |
397 | if(fFormula->Eval(lambda[0],lambda[1]) <= 0 ) | |
398 | showerprofile = 1 ; // not narrow | |
1cb7c1ee | 399 | } |
fad3e5b9 | 400 | |
7acf6008 | 401 | if(disp) |
402 | if(emc->GetDispersion() > fDispersion ) | |
403 | showerprofile = 1 ; // not narrow | |
404 | ||
405 | ||
2aad621e | 406 | // Looking at the photon conversion detector |
7acf6008 | 407 | Int_t pcdetector= 0 ; //1 hit and 0 no hit |
408 | if(ppsd) | |
409 | if(GetDistance(emc, ppsd, "R") < fCpvEmcDistance) | |
410 | pcdetector = 1 ; | |
411 | ||
412 | // Looking at the CPV detector | |
413 | Int_t cpvdetector= 0 ; //1 hit and 0 no hit | |
414 | if(cpv) | |
415 | if(GetDistance(emc, cpv, "R") < fCpvEmcDistance) | |
416 | cpvdetector = 1 ; | |
417 | ||
418 | Int_t type = showerprofile + 2 * pcdetector + 4 * cpvdetector ; | |
09fc14a0 | 419 | rp->SetType(type) ; |
6ad0bfa0 | 420 | index++ ; |
421 | } | |
7acf6008 | 422 | |
6ad0bfa0 | 423 | } |
424 | ||
09fc14a0 | 425 | //____________________________________________________________________________ |
7acf6008 | 426 | void AliPHOSPIDv1:: Print(Option_t * option) const |
09fc14a0 | 427 | { |
b2a60966 | 428 | // Print the parameters used for the particle type identification |
f035f6ce | 429 | cout << "=============== AliPHOSPID1 ================" << endl ; |
430 | cout << "Making PID "<< endl ; | |
431 | cout << " Headers file: " << fHeaderFileName.Data() << endl ; | |
432 | cout << " RecPoints branch title: " << fRecPointsTitle.Data() << endl ; | |
433 | cout << " TrackSegments Branch title: " << fTSTitle.Data() << endl ; | |
434 | cout << " RecParticles Branch title " << fRecparticlesTitle.Data() << endl; | |
435 | cout << "with parameters: " << endl ; | |
436 | cout << " Maximal EMC - CPV (PPSD) distance (cm) " << fCpvEmcDistance << endl ; | |
437 | if(fIDOptions.Contains("dis",TString::kIgnoreCase )) | |
438 | cout << " dispersion cut " << fDispersion << endl ; | |
439 | if(fIDOptions.Contains("ell",TString::kIgnoreCase )){ | |
440 | cout << "Eliptic cuts function: " << endl ; | |
441 | cout << fFormula->GetTitle() << endl ; | |
442 | } | |
443 | cout << "============================================" << endl ; | |
09fc14a0 | 444 | } |
445 | ||
446 | //____________________________________________________________________________ | |
a4e98857 | 447 | void AliPHOSPIDv1::SetShowerProfileCut(char * formula) |
448 | { | |
7acf6008 | 449 | //set shape of the cut on the axis of ellipce, drown around shouer |
450 | //shower considered "narrow" if Formula(lambda[0],lambda[1]) > 0. | |
451 | if(fFormula) | |
452 | delete fFormula; | |
f035f6ce | 453 | fFormula = new TFormula("Lambda Cut",formula) ; |
7acf6008 | 454 | } |
455 | //____________________________________________________________________________ | |
456 | void AliPHOSPIDv1::WriteRecParticles() | |
09fc14a0 | 457 | { |
7acf6008 | 458 | //check, if these branches already exist |
459 | TBranch * pidBranch = 0; | |
460 | TBranch * rpBranch = 0; | |
461 | ||
462 | TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ; | |
463 | Int_t ibranch; | |
464 | Bool_t pidNotFound = kTRUE ; | |
465 | Bool_t rpNotFound = kTRUE ; | |
466 | ||
467 | for(ibranch = 0;(ibranch <branches->GetEntries())&& pidNotFound && rpNotFound;ibranch++){ | |
468 | if(pidNotFound){ | |
469 | pidBranch=(TBranch *) branches->At(ibranch) ; | |
470 | if( (strcmp(pidBranch->GetName(),"PHOSPID") == 0) && | |
471 | (fRecparticlesTitle.CompareTo(pidBranch->GetTitle()) == 0) ) | |
472 | pidNotFound = kFALSE ; | |
473 | } | |
474 | if(rpNotFound){ | |
475 | rpBranch=(TBranch *) branches->At(ibranch) ; | |
476 | if( (strcmp(rpBranch->GetName(),"PHOSRP") == 0) && | |
477 | (fRecparticlesTitle.CompareTo(rpBranch->GetTitle())==0 )) | |
478 | rpNotFound = kFALSE ; | |
479 | } | |
480 | } | |
481 | ||
482 | if(!pidNotFound || !rpNotFound) { | |
483 | cout << "AliPHOSPIDv1 error: " << endl ; | |
484 | cout << " Branch PHOSRP and PHOSPID with title '"<<fRecparticlesTitle.Data()<<"' already exist "<< endl ; | |
485 | cout << " can not overwrite " << endl ; | |
486 | return ; | |
487 | } | |
69183710 | 488 | |
7acf6008 | 489 | //Make branch in TreeR for TrackSegments |
490 | char * filename = 0; | |
491 | if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name | |
492 | filename = new char[strlen(gAlice->GetBaseFile())+20] ; | |
493 | sprintf(filename,"%s/PHOS.Reco.root",gAlice->GetBaseFile()) ; | |
494 | } | |
495 | ||
496 | TDirectory *cwd = gDirectory; | |
497 | ||
498 | //First rp | |
499 | Int_t bufferSize = 32000 ; | |
500 | rpBranch = gAlice->TreeR()->Branch("PHOSRP",&fRecParticles,bufferSize); | |
501 | rpBranch->SetTitle(fRecparticlesTitle.Data()); | |
502 | if (filename) { | |
503 | rpBranch->SetFile(filename); | |
504 | TIter next( rpBranch->GetListOfBranches()); | |
761e34c0 | 505 | TBranch * sb ; |
506 | while ((sb=(TBranch*)next())) { | |
507 | sb->SetFile(filename); | |
7acf6008 | 508 | } |
509 | cwd->cd(); | |
510 | } | |
511 | ||
512 | //second, pid | |
513 | Int_t splitlevel = 0 ; | |
514 | AliPHOSPIDv1 * pid = this ; | |
515 | pidBranch = gAlice->TreeR()->Branch("AliPHOSPID","AliPHOSPIDv1",&pid,bufferSize,splitlevel); | |
516 | pidBranch->SetTitle(fRecparticlesTitle.Data()); | |
517 | if (filename) { | |
518 | pidBranch->SetFile(filename); | |
519 | TIter next( pidBranch->GetListOfBranches()); | |
761e34c0 | 520 | TBranch * sb ; |
521 | while ((sb=(TBranch*)next())) { | |
522 | sb->SetFile(filename); | |
7acf6008 | 523 | } |
524 | cwd->cd(); | |
525 | } | |
526 | ||
761e34c0 | 527 | rpBranch->Fill() ; |
528 | pidBranch->Fill() ; | |
eec3ac52 | 529 | |
7acf6008 | 530 | gAlice->TreeR()->Write(0,kOverwrite) ; |
531 | ||
532 | } | |
69183710 | 533 | //____________________________________________________________________________ |
7acf6008 | 534 | void AliPHOSPIDv1::PlotDispersionCuts()const |
69183710 | 535 | { |
a4e98857 | 536 | // produces a plot of the dispersion cut |
537 | TCanvas* lambdas = new TCanvas("lambdas","Cuts on the ellipse axis",200,10,700,500); | |
dd5c4038 | 538 | |
7acf6008 | 539 | if(fIDOptions.Contains("ell",TString::kIgnoreCase ) ){ |
540 | TF2 * ell = new TF2("Elliptic Cuts",fFormula->GetName(),0,3,0,3) ; | |
541 | ell->SetMinimum(0.0000001) ; | |
542 | ell->SetMaximum(0.001) ; | |
543 | ell->SetLineStyle(1) ; | |
544 | ell->SetLineWidth(2) ; | |
545 | ell->Draw() ; | |
546 | } | |
547 | ||
548 | if( fIDOptions.Contains("dis",TString::kIgnoreCase ) ){ | |
549 | TF2 * dsp = new TF2("dispersion","(y<x)*(x*x+y*y < [0]*[0])",0,3,0,3) ; | |
550 | dsp->SetParameter(0,fDispersion) ; | |
551 | dsp->SetMinimum(0.0000001) ; | |
552 | dsp->SetMaximum(0.001) ; | |
553 | dsp->SetLineStyle(1) ; | |
554 | dsp->SetLineColor(2) ; | |
555 | dsp->SetLineWidth(2) ; | |
556 | dsp->SetNpx(200) ; | |
557 | dsp->SetNpy(200) ; | |
558 | if(fIDOptions.Contains("ell",TString::kIgnoreCase ) ) | |
559 | dsp->Draw("same") ; | |
560 | else | |
561 | dsp->Draw() ; | |
562 | } | |
563 | lambdas->Update(); | |
564 | } | |
69183710 | 565 | |
7acf6008 | 566 | //____________________________________________________________________________ |
567 | TVector3 AliPHOSPIDv1::GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSRecPoint * cpv,AliPHOSRecPoint * ppsd)const | |
568 | { | |
569 | // Calculates the momentum direction: | |
570 | // 1. if only a EMC RecPoint, direction is given by IP and this RecPoint | |
571 | // 2. if a EMC RecPoint and one PPSD RecPoint, direction is given by the line through the 2 recpoints | |
572 | // 3. if a EMC RecPoint and two PPSD RecPoints, dirrection is given by the average line through | |
573 | // the 2 pairs of recpoints | |
574 | // However because of the poor position resolution of PPSD the direction is always taken as if we were | |
575 | // in case 1. | |
576 | ||
577 | TVector3 dir(0,0,0) ; | |
578 | ||
579 | TVector3 emcglobalpos ; | |
580 | TMatrix dummy ; | |
581 | ||
582 | emc->GetGlobalPosition(emcglobalpos, dummy) ; | |
583 | ||
69183710 | 584 | |
a4e98857 | 585 | // The following commented code becomes valid once the PPSD provides |
7acf6008 | 586 | // a reasonable position resolution, at least as good as EMC ! |
587 | // TVector3 ppsdlglobalpos ; | |
588 | // TVector3 ppsduglobalpos ; | |
589 | // if( fPpsdLowRecPoint ){ // certainly a photon that has concerted | |
590 | // fPpsdLowRecPoint->GetGlobalPosition(ppsdlglobalpos, mdummy) ; | |
591 | // dir = emcglobalpos - ppsdlglobalpos ; | |
592 | // if( fPpsdUpRecPoint ){ // not looks like a charged | |
593 | // fPpsdUpRecPoint->GetGlobalPosition(ppsduglobalpos, mdummy) ; | |
594 | // dir = ( dir + emcglobalpos - ppsduglobalpos ) * 0.5 ; | |
595 | // } | |
596 | // } | |
597 | // else { // looks like a neutral | |
598 | // dir = emcglobalpos ; | |
599 | // } | |
600 | ||
601 | dir = emcglobalpos ; | |
602 | dir.SetZ( -dir.Z() ) ; // why ? | |
603 | dir.SetMag(1.) ; | |
604 | ||
605 | //account correction to the position of IP | |
606 | Float_t xo,yo,zo ; //Coordinates of the origin | |
607 | gAlice->Generator()->GetOrigin(xo,yo,zo) ; | |
608 | TVector3 origin(xo,yo,zo); | |
609 | dir = dir - origin ; | |
610 | ||
611 | return dir ; | |
612 | } | |
613 | //____________________________________________________________________________ | |
a4e98857 | 614 | void AliPHOSPIDv1::PrintRecParticles(Option_t * option) |
615 | { | |
dd5c4038 | 616 | // Print table of reconstructed particles |
617 | ||
7acf6008 | 618 | cout << "AliPHOSPIDv1: " << endl ; |
619 | cout << " found " << fRecParticles->GetEntriesFast() << " RecParticles " << endl ; | |
620 | ||
621 | if(strstr(option,"all")) { // printing found TS | |
622 | ||
623 | cout << " PARTICLE " | |
624 | << " Index " << endl ; | |
625 | // << " X " | |
626 | // << " Y " | |
627 | // << " Z " | |
628 | // << " # of primaries " | |
629 | // << " Primaries list " << endl; | |
630 | ||
631 | Int_t index ; | |
632 | for (index = 0 ; index < fRecParticles->GetEntries() ; index++) { | |
633 | AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) fRecParticles->At(index) ; | |
634 | ||
635 | Text_t particle[11]; | |
636 | switch(rp->GetType()) { | |
637 | case AliPHOSFastRecParticle::kNEUTRALEM: | |
638 | strcpy( particle, "NEUTRAL_EM"); | |
639 | break; | |
640 | case AliPHOSFastRecParticle::kNEUTRALHA: | |
641 | strcpy(particle, "NEUTRAL_HA"); | |
642 | break; | |
643 | case AliPHOSFastRecParticle::kGAMMA: | |
644 | strcpy(particle, "GAMMA"); | |
645 | break ; | |
646 | case AliPHOSFastRecParticle::kGAMMAHA: | |
647 | strcpy(particle, "GAMMA_H"); | |
648 | break ; | |
649 | case AliPHOSFastRecParticle::kABSURDEM: | |
650 | strcpy(particle, "ABSURD_EM") ; | |
651 | break ; | |
652 | case AliPHOSFastRecParticle::kABSURDHA: | |
653 | strcpy(particle, "ABSURD_HA") ; | |
654 | break ; | |
655 | case AliPHOSFastRecParticle::kELECTRON: | |
656 | strcpy(particle, "ELECTRON") ; | |
657 | break ; | |
658 | case AliPHOSFastRecParticle::kCHARGEDHA: | |
659 | strcpy(particle, "CHARGED_HA") ; | |
660 | break ; | |
661 | } | |
662 | ||
663 | // Int_t * primaries; | |
664 | // Int_t nprimaries; | |
665 | // primaries = rp->GetPrimaries(nprimaries); | |
666 | ||
667 | cout << setw(15) << particle << " " | |
668 | << setw(3) << rp->GetIndexInList() << " " ; | |
669 | // << setw(4) << nprimaries << " "; | |
670 | // for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) | |
671 | // cout << setw(4) << primaries[iprimary] << " "; | |
672 | cout << endl; | |
673 | } | |
674 | cout << "-------------------------------------------" << endl ; | |
675 | } | |
676 | ||
69183710 | 677 | } |
678 | ||
7acf6008 | 679 | |
680 |