Line data Source code
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 : /* History of cvs commits:
19 : *
20 : * $Log$
21 : * Revision 1.39 2005/05/28 14:19:04 schutz
22 : * Compilation warnings fixed by T.P.
23 : *
24 : */
25 :
26 : //_________________________________________________________________________
27 : // A Particle modified by PHOS response and produced by AliPHOSvFast
28 : // To become a general class of AliRoot ?
29 : //--
30 : // This is also a base class for AliPHOSRecParticle produced by AliPHOSPIDv1
31 : // The rec.particle type is to be defined by AliPHOSvFast or AliPHOSPIDv1
32 : //--
33 : //*-- Author: Yves Schutz (SUBATECH)
34 :
35 : // --- ROOT system ---
36 :
37 : // --- Standard library ---
38 :
39 : // --- AliRoot header files ---
40 : #include "AliLog.h"
41 : #include "AliPHOSFastRecParticle.h"
42 : #include "TPad.h"
43 : #include "TPaveText.h"
44 :
45 22 : ClassImp(AliPHOSFastRecParticle)
46 :
47 : //____________________________________________________________________________
48 10 : AliPHOSFastRecParticle::AliPHOSFastRecParticle() :
49 10 : fIndexInList(0),
50 10 : fTof(0.f),
51 10 : fType(0)
52 30 : {
53 : // ctor
54 :
55 300 : for(Int_t i=0; i<AliPID::kSPECIESCN; i++) {
56 140 : fPID[i] = -111.;
57 : }
58 :
59 10 : }
60 :
61 : //____________________________________________________________________________
62 : AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
63 0 : : TParticle(rp),
64 0 : fIndexInList(rp.fIndexInList),//?
65 0 : fTof(rp.fTof),//?
66 0 : fType(rp.fType)
67 0 : {
68 : // copy ctor
69 0 : fPdgCode = rp.fPdgCode;
70 0 : fStatusCode = rp.fStatusCode;
71 0 : fMother[0] = rp.fMother[0];
72 0 : fMother[1] = rp.fMother[1];
73 0 : fDaughter[0] = rp.fDaughter[0];
74 0 : fDaughter[1] = rp.fDaughter[1];
75 0 : fWeight = rp.fWeight;
76 0 : fCalcMass = rp.fCalcMass;
77 0 : fPx = rp.fPx;
78 0 : fPy = rp.fPy;
79 0 : fPz = rp.fPz;
80 0 : fE = rp.fE;
81 0 : fVx = rp.fVx;
82 0 : fVy = rp.fVy;
83 0 : fVz = rp.fVz;
84 0 : fVt = rp.fVt;
85 0 : fPolarTheta = rp.fPolarTheta;
86 0 : fPolarPhi = rp.fPolarPhi;
87 0 : fParticlePDG = rp.fParticlePDG;
88 :
89 0 : for(Int_t i=0; i<AliPID::kSPECIESCN; i++) {
90 0 : fPID[i] = rp.fPID[i];
91 : }
92 :
93 0 : }
94 :
95 : //____________________________________________________________________________
96 0 : AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp) :
97 0 : fIndexInList(0),
98 0 : fTof(0.f),
99 0 : fType(0)
100 0 : {
101 : // ctor from a TParticle (crummy?!)
102 : TParticle & pnoconst = (TParticle &)(pp) ;
103 0 : AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
104 0 : fPdgCode = p.fPdgCode;
105 0 : fStatusCode = p.fStatusCode;
106 0 : fMother[0] = p.fMother[0];
107 0 : fMother[1] = p.fMother[1];
108 0 : fDaughter[0] = p.fDaughter[0];
109 0 : fDaughter[1] = p.fDaughter[1];
110 0 : fWeight = p.fWeight;
111 0 : fCalcMass = p.fCalcMass;
112 0 : fPx = p.fPx;
113 0 : fPy = p.fPy;
114 0 : fPz = p.fPz;
115 0 : fE = p.fE;
116 0 : fVx = p.fVx;
117 0 : fVy = p.fVy;
118 0 : fVz = p.fVz;
119 0 : fVt = p.fVt;
120 0 : fPolarTheta = p.fPolarTheta;
121 0 : fPolarPhi = p.fPolarPhi;
122 0 : fParticlePDG = p.fParticlePDG;
123 :
124 0 : for(Int_t i=0; i<AliPID::kSPECIESCN; i++) {
125 0 : fPID[i] = p.fPID[i];
126 : }
127 :
128 0 : }
129 :
130 : //____________________________________________________________________________
131 : AliPHOSFastRecParticle & AliPHOSFastRecParticle::operator = (const AliPHOSFastRecParticle &)
132 : {
133 0 : Fatal("operator =", "not implemented");
134 0 : return *this;
135 :
136 : }
137 : //____________________________________________________________________________
138 : Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
139 : {
140 : // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
141 : // Compute the closest distance of approach from point px,py to this marker.
142 : // The distance is computed in pixels units.
143 :
144 0 : Double_t kRADDEG = 180. / TMath::Pi() ;
145 0 : Coord_t x = Phi() * kRADDEG ;
146 0 : Coord_t y = Theta() * kRADDEG ;
147 : const Int_t kMaxDiff = 10;
148 0 : Int_t pxm = gPad->XtoAbsPixel(x);
149 0 : Int_t pym = gPad->YtoAbsPixel(y);
150 0 : Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
151 :
152 0 : if (dist > kMaxDiff) return 9999;
153 0 : return dist;
154 0 : }
155 :
156 : //___________________________________________________________________________
157 : void AliPHOSFastRecParticle::Draw(Option_t *option)
158 : {
159 : // Draw this AliPHOSFastRecParticle with its current attributes
160 :
161 0 : AppendPad(option);
162 0 : }
163 :
164 : //______________________________________________________________________________
165 : void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
166 : {
167 : // Execute action corresponding to one event
168 : // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
169 :
170 0 : if (!gPad->IsEditable())
171 : return ;
172 :
173 : static TPaveText * clustertext = 0 ;
174 :
175 0 : switch (event) {
176 :
177 : case kButton1Down: {
178 0 : Double_t kRADDEG = 180. / TMath::Pi() ;
179 0 : Coord_t x = Phi() * kRADDEG ;
180 0 : Coord_t y = Theta() * kRADDEG ;
181 0 : clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
182 0 : Text_t line1[40] ;
183 0 : Text_t line2[40] ;
184 0 : snprintf( line1,40, "PID: %s ", (const char*)Name() ) ;
185 0 : snprintf( line2,40, "ENERGY: %f ", Energy() ) ;
186 0 : clustertext ->AddText(line1) ;
187 0 : clustertext ->AddText(line2) ;
188 0 : clustertext ->Draw("");
189 0 : gPad->Update() ;
190 : break ;
191 0 : }
192 :
193 : case kButton1Up: {
194 0 : delete clustertext ;
195 0 : clustertext = 0 ;
196 0 : gPad->Update() ;
197 0 : break ;
198 : }
199 : }
200 :
201 0 : }
202 :
203 : //____________________________________________________________________________
204 : Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
205 : {
206 : // Rec.Particle is a photon if it has a photon-like shape, fast and neutral
207 : // photon-like shape is defined with a purity "low", "medium" or "high"
208 :
209 36 : purity.ToLower();
210 : Bool_t photonLike = kFALSE;
211 28 : if (purity == "low" ) photonLike = TestPIDBit(6);
212 12 : else if (purity == "medium") photonLike = TestPIDBit(7);
213 8 : else if (purity == "high" ) photonLike = TestPIDBit(8);
214 24 : if (photonLike && // photon by PCA
215 18 : (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
216 42 : (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
217 6 : !TestPIDBit(14)) // no charged track
218 6 : return kTRUE ;
219 : else
220 12 : return kFALSE;
221 18 : }
222 :
223 : //____________________________________________________________________________
224 : Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
225 : {
226 : // Rec.Particle is a pi0 if it has a pi0-like shape, fast and neutral
227 : // pi0-like shape is defined with a purity "low", "medium" or "high"
228 :
229 60 : purity.ToLower();
230 : Bool_t pi0Like = kFALSE;
231 40 : if (purity == "low" ) pi0Like = TestPIDBit(9);
232 30 : else if (purity == "medium") pi0Like = TestPIDBit(10);
233 20 : else if (purity == "high" ) pi0Like = TestPIDBit(11);
234 : else
235 0 : AliError(Form("Wrong purity type: %s",purity.Data()));
236 30 : if (pi0Like && // pi0 by PCA
237 0 : (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
238 0 : (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
239 0 : !TestPIDBit(14)) // no charged track
240 0 : return kTRUE ;
241 : else
242 30 : return kFALSE;
243 30 : }
244 :
245 : //____________________________________________________________________________
246 : Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
247 : {
248 : // Rec.Particle is an electron if it has a photon-like shape, fast and charged
249 : // photon-like shape is defined with a purity "low", "medium" or "high"
250 :
251 44 : purity.ToLower();
252 : Bool_t photonLike = kFALSE;
253 32 : if (purity == "low" ) photonLike = TestPIDBit(6);
254 18 : else if (purity == "medium") photonLike = TestPIDBit(7);
255 12 : else if (purity == "high" ) photonLike = TestPIDBit(8);
256 : else
257 0 : AliError(Form("Wrong purity type: %s",purity.Data()));
258 :
259 26 : if (photonLike && // photon by PCA
260 20 : (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
261 52 : (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
262 4 : TestPIDBit(14)) // no charged track
263 4 : return kTRUE ;
264 : else
265 18 : return kFALSE;
266 22 : }
267 :
268 : //____________________________________________________________________________
269 : Bool_t AliPHOSFastRecParticle::IsEleCon(TString purity) const
270 : {
271 : // Rec.Particle is an electron if it has a photon-like shape, fast and charged
272 : // photon-like shape is defined with a purity "low", "medium" or "high"
273 :
274 20 : purity.ToLower();
275 : Bool_t photonLike = kFALSE;
276 20 : if (purity == "low" ) photonLike = TestPIDBit(6);
277 0 : else if (purity == "medium") photonLike = TestPIDBit(7);
278 0 : else if (purity == "high" ) photonLike = TestPIDBit(8);
279 : else
280 0 : AliError(Form("Wrong purity type: %s",purity.Data()));
281 :
282 14 : if (photonLike && // photon by PCA
283 10 : (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
284 22 : (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
285 4 : !TestPIDBit(14)) // no charged track
286 0 : return kTRUE ;
287 : else
288 10 : return kFALSE;
289 10 : }
290 :
291 : //____________________________________________________________________________
292 : Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
293 : {
294 : // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
295 : // corresponds to photons
296 0 : if (TestPIDBit(12) && !TestPIDBit(14))
297 0 : return kTRUE;
298 : else
299 0 : return kFALSE;
300 0 : }
301 :
302 : //____________________________________________________________________________
303 : Bool_t AliPHOSFastRecParticle::IsHardPi0() const
304 : {
305 : // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
306 : // corresponds to pi0
307 0 : if (TestPIDBit(13)&& !TestPIDBit(14))
308 0 : return kTRUE;
309 : else
310 0 : return kFALSE;
311 0 : }
312 :
313 : //____________________________________________________________________________
314 : Bool_t AliPHOSFastRecParticle::IsHadron() const
315 : {
316 : // Rec.Particle is an hadron if it does not look like
317 : // a low-purity photon nor low-purity pi0
318 :
319 20 : if ( !TestPIDBit(6) && !TestPIDBit(9) ) // not photon nor pi0
320 0 : return kTRUE ;
321 : else
322 10 : return kFALSE;
323 10 : }
324 :
325 : //____________________________________________________________________________
326 : Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
327 : {
328 : // Rec.Particle is a charged hadron if it does not look like
329 : // a low-purity photon nor low-purity pi0 and is low-purity charged
330 :
331 0 : if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
332 0 : !TestPIDBit(2)) // charged by CPV
333 0 : return kTRUE ;
334 : else
335 0 : return kFALSE;
336 0 : }
337 :
338 : //____________________________________________________________________________
339 : Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
340 : {
341 : // Rec.Particle is a neutral hadron if it does not look like
342 : // a low-purity photon nor low-purity pi0 and is high-purity neutral
343 :
344 0 : if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
345 0 : TestPIDBit(2)) // neutral by CPV
346 0 : return kTRUE ;
347 : else
348 0 : return kFALSE;
349 0 : }
350 :
351 : //____________________________________________________________________________
352 : Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
353 : {
354 : // Rec.Particle is a fast charged hadron if it does not look like
355 : // a low-purity photon nor low-purity pi0, is low-purity charged
356 : // and is high-purity fast
357 :
358 0 : if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
359 0 : !TestPIDBit(2) && // charged by CPV
360 0 : TestPIDBit(5)) // fast by TOF
361 0 : return kTRUE ;
362 : else
363 0 : return kFALSE;
364 0 : }
365 :
366 : //____________________________________________________________________________
367 : Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
368 : {
369 : // Rec.Particle is a slow neutral hadron if it does not look like
370 : // a low-purity photon nor low-purity pi0, is high-purity neutral
371 : // and is not high-purity fast
372 :
373 0 : if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
374 0 : !TestPIDBit(2) && // charged by CPV
375 0 : !TestPIDBit(5)) // slow by TOF
376 0 : return kTRUE ;
377 : else
378 0 : return kFALSE;
379 :
380 0 : }
381 :
382 : //____________________________________________________________________________
383 : Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
384 : {
385 : // Rec.Particle is a fast neutral hadron if it does not look like
386 : // a low-purity photon nor low-purity pi0, is high-purity neutral
387 : // and is high-purity fast
388 :
389 0 : if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
390 0 : TestPIDBit(2) && // neutral by CPV
391 0 : TestPIDBit(5)) // fast by TOF
392 0 : return kTRUE ;
393 : else
394 0 : return kFALSE;
395 0 : }
396 :
397 : //____________________________________________________________________________
398 : Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
399 : {
400 : // Rec.Particle is a slow neutral hadron if it does not look like
401 : // a low-purity photon nor low-purity pi0, is high-purity neutral
402 : // and is not high-purity fast
403 :
404 0 : if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
405 0 : TestPIDBit(2) && // neutral by CPV
406 0 : !TestPIDBit(5)) // slow by TOF
407 0 : return kTRUE ;
408 : else
409 0 : return kFALSE;
410 0 : }
411 :
412 : //____________________________________________________________________________
413 : TString AliPHOSFastRecParticle::Name() const
414 : {
415 : // Returns the name of the particle type (only valid if PIDv1 is employed)
416 :
417 20 : TString name ;
418 :
419 10 : name = "Undefined particle" ;
420 :
421 30 : if (IsPhoton("low"))
422 6 : name = "Photon low purity, ";
423 12 : else if (IsPhoton("medium"))
424 0 : name = "Photon medium purity, ";
425 12 : else if (IsPhoton("high"))
426 0 : name = "Photon high purity, ";
427 :
428 30 : if (IsPi0("low"))
429 0 : name = "Pi0 low purity, ";
430 30 : else if (IsPi0("medium"))
431 0 : name = "Pi0 medium purity, ";
432 30 : else if (IsPi0("high"))
433 0 : name = "Pi0 high purity, ";
434 :
435 30 : if (IsElectron("low"))
436 4 : name = "Electron low purity, ";
437 18 : else if (IsElectron("medium"))
438 0 : name = "Electron medium purity, ";
439 18 : else if (IsElectron("high"))
440 0 : name = "Electron high purity, ";
441 :
442 20 : if (IsHadron()) {
443 0 : name = "hadron";
444 0 : if (IsChargedHadron()) {
445 0 : name.Prepend("charged, ");
446 0 : if (IsFastChargedHadron())
447 0 : name.Prepend("fast, ");
448 0 : else if (IsSlowChargedHadron())
449 0 : name.Prepend("slow, ");
450 : }
451 0 : else if (IsNeutralHadron()) {
452 0 : name.Prepend("neutral, ");
453 0 : if (IsFastNeutralHadron())
454 0 : name.Prepend("fast, ");
455 0 : else if (IsSlowNeutralHadron())
456 0 : name.Prepend("slow, ");
457 : }
458 : }
459 :
460 : return name ;
461 20 : }
462 :
463 :
464 : //______________________________________________________________________________
465 : void AliPHOSFastRecParticle::SetType(Int_t type) {
466 : // sets the particle type
467 : // bit-mask of the particle type means the following:
468 : // bits 0,1,2 - neutral particle with low, medium and high purity
469 : // bits 3.4,5 - fast particle with low, medium and high purity
470 : // bits 6.7,8 - photon shower with low, medium and high purity
471 : // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
472 :
473 0 : fType = type ;
474 :
475 0 : if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
476 0 : fPdgCode = 22 ;
477 0 : return ;
478 : }
479 :
480 0 : if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
481 0 : fPdgCode = 2112 ;
482 0 : return ;
483 : }
484 0 : if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
485 0 : fPdgCode = 11 ;
486 0 : return ;
487 : }
488 0 : if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
489 0 : fPdgCode = 13 ;
490 0 : return ;
491 : }
492 0 : if((fType == 56)||(fType == 57)){
493 0 : fPdgCode = 211 ;
494 0 : return ;
495 : }
496 0 : if (fType == 0){
497 0 : fPdgCode = 2212 ;
498 0 : return ;
499 : }
500 :
501 0 : }
502 :
503 : //______________________________________________________________________________
504 : void AliPHOSFastRecParticle::Paint(Option_t *)
505 : {
506 : // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
507 :
508 0 : Double_t kRADDEG = 180. / TMath::Pi() ;
509 0 : Coord_t x = Phi() * kRADDEG ;
510 0 : Coord_t y = Theta() * kRADDEG ;
511 : Color_t markercolor = 1 ;
512 : Size_t markersize = 1. ;
513 : Style_t markerstyle = 5 ;
514 :
515 0 : if (!gPad->IsBatch()) {
516 0 : gVirtualX->SetMarkerColor(markercolor) ;
517 0 : gVirtualX->SetMarkerSize (markersize) ;
518 0 : gVirtualX->SetMarkerStyle(markerstyle) ;
519 0 : }
520 0 : gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
521 0 : gPad->PaintPolyMarker(1,&x,&y,"") ;
522 0 : }
523 :
524 : //____________________________________________________________________________
525 : void AliPHOSFastRecParticle::Print(const Option_t *)const
526 : {
527 : // Print the type, energy and momentum of the reconstructed particle
528 :
529 0 : AliInfo(Form("Print -----------------------------")) ;
530 0 : printf("PID bits are %d%d%d %d%d%d %d%d%d %d%d%d",
531 0 : TestPIDBit(0),TestPIDBit(1),
532 0 : TestPIDBit(2),TestPIDBit(3),
533 0 : TestPIDBit(4),TestPIDBit(5),
534 0 : TestPIDBit(6),TestPIDBit(7),
535 0 : TestPIDBit(8),TestPIDBit(9),
536 0 : TestPIDBit(10),TestPIDBit(11)) ;
537 0 : printf(", type is \"%s\"\n", Name().Data()) ;
538 0 : printf(" (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n",
539 0 : Energy(),
540 0 : Px(),
541 0 : Py(),
542 0 : Pz() ) ;
543 0 : printf(" TOF = %.3e ns\n", ToF() ) ;
544 0 : printf(" PID weight: \n" ) ;
545 0 : printf(" photon -> %f\n", fPID[AliPID::kPhoton] ) ;
546 0 : printf(" electron -> %f\n", fPID[AliPID::kElectron] ) ;
547 0 : printf(" Conversion electron -> %f\n", fPID[AliPID::kEleCon] ) ;
548 0 : printf(" muon -> %f\n", fPID[AliPID::kMuon] ) ;
549 0 : printf(" neutral pion -> %f\n", fPID[AliPID::kPi0] ) ;
550 0 : printf(" charged pion -> %f\n", fPID[AliPID::kPion] ) ;
551 0 : printf(" charged kaon -> %f\n", fPID[AliPID::kKaon] ) ;
552 0 : printf(" neutral kaon -> %f\n", fPID[AliPID::kKaon0] ) ;
553 0 : printf(" proton -> %f\n", fPID[AliPID::kProton] ) ;
554 0 : printf(" neutron -> %f\n", fPID[AliPID::kNeutron] ) ;
555 :
556 0 : }
|