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 /* History of cvs commits:
23 //_________________________________________________________________________
24 // A Particle modified by PHOS response and produced by AliPHOSvFast
25 // To become a general class of AliRoot ?
27 // This is also a base class for AliPHOSRecParticle produced by AliPHOSPIDv1
28 // The rec.particle type is to be defined by AliPHOSvFast or AliPHOSPIDv1
30 //*-- Author: Yves Schutz (SUBATECH)
32 // --- ROOT system ---
34 // --- Standard library ---
36 // --- AliRoot header files ---
38 #include "AliPHOSFastRecParticle.h"
40 #include "TPaveText.h"
42 ClassImp(AliPHOSFastRecParticle)
44 //____________________________________________________________________________
45 AliPHOSFastRecParticle::AliPHOSFastRecParticle() : TParticle()
51 //____________________________________________________________________________
52 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
58 fPdgCode = rp.fPdgCode;
59 fStatusCode = rp.fStatusCode;
60 fMother[0] = rp.fMother[0];
61 fMother[1] = rp.fMother[1];
62 fDaughter[0] = rp.fDaughter[0];
63 fDaughter[1] = rp.fDaughter[1];
65 fCalcMass = rp.fCalcMass;
74 fPolarTheta = rp.fPolarTheta;
75 fPolarPhi = rp.fPolarPhi;
76 fParticlePDG = rp.fParticlePDG;
79 //____________________________________________________________________________
80 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
82 // ctor from a TParticle (crummy?!)
84 TParticle & pnoconst = (TParticle &)(pp) ;
85 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
87 fPdgCode = p.fPdgCode;
88 fStatusCode = p.fStatusCode;
89 fMother[0] = p.fMother[0];
90 fMother[1] = p.fMother[1];
91 fDaughter[0] = p.fDaughter[0];
92 fDaughter[1] = p.fDaughter[1];
94 fCalcMass = p.fCalcMass;
103 fPolarTheta = p.fPolarTheta;
104 fPolarPhi = p.fPolarPhi;
105 fParticlePDG = p.fParticlePDG;
109 //____________________________________________________________________________
110 Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
112 // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
113 // Compute the closest distance of approach from point px,py to this marker.
114 // The distance is computed in pixels units.
116 Double_t kRADDEG = 180. / TMath::Pi() ;
117 Coord_t x = Phi() * kRADDEG ;
118 Coord_t y = Theta() * kRADDEG ;
119 const Int_t kMaxDiff = 10;
120 Int_t pxm = gPad->XtoAbsPixel(x);
121 Int_t pym = gPad->YtoAbsPixel(y);
122 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
124 if (dist > kMaxDiff) return 9999;
128 //___________________________________________________________________________
129 void AliPHOSFastRecParticle::Draw(Option_t *option)
131 // Draw this AliPHOSFastRecParticle with its current attributes
136 //______________________________________________________________________________
137 void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
139 // Execute action corresponding to one event
140 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
142 if (!gPad->IsEditable())
145 static TPaveText * clustertext = 0 ;
150 Double_t kRADDEG = 180. / TMath::Pi() ;
151 Coord_t x = Phi() * kRADDEG ;
152 Coord_t y = Theta() * kRADDEG ;
153 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
156 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
157 sprintf( line2, "ENERGY: %f ", Energy() ) ;
158 clustertext ->AddText(line1) ;
159 clustertext ->AddText(line2) ;
160 clustertext ->Draw("");
175 //____________________________________________________________________________
176 Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
178 // Rec.Particle is a photon if it has a photon-like shape, fast and neutral
179 // photon-like shape is defined with a purity "low", "medium" or "high"
182 Bool_t photonLike = kFALSE;
183 if (purity == "low" ) photonLike = TestPIDBit(6);
184 else if (purity == "medium") photonLike = TestPIDBit(7);
185 else if (purity == "high" ) photonLike = TestPIDBit(8);
186 if (photonLike && // photon by PCA
187 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
188 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
189 !TestPIDBit(14)) // no charged track
195 //____________________________________________________________________________
196 Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
198 // Rec.Particle is a pi0 if it has a pi0-like shape, fast and neutral
199 // pi0-like shape is defined with a purity "low", "medium" or "high"
202 Bool_t pi0Like = kFALSE;
203 if (purity == "low" ) pi0Like = TestPIDBit(9);
204 else if (purity == "medium") pi0Like = TestPIDBit(10);
205 else if (purity == "high" ) pi0Like = TestPIDBit(11);
207 AliError(Form("Wrong purity type: %s",purity.Data()));
208 if (pi0Like && // pi0 by PCA
209 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
210 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
211 !TestPIDBit(14)) // no charged track
217 //____________________________________________________________________________
218 Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
220 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
221 // photon-like shape is defined with a purity "low", "medium" or "high"
224 Bool_t photonLike = kFALSE;
225 if (purity == "low" ) photonLike = TestPIDBit(6);
226 else if (purity == "medium") photonLike = TestPIDBit(7);
227 else if (purity == "high" ) photonLike = TestPIDBit(8);
229 AliError(Form("Wrong purity type: %s",purity.Data()));
231 if (photonLike && // photon by PCA
232 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
233 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
234 TestPIDBit(14)) // no charged track
240 //____________________________________________________________________________
241 Bool_t AliPHOSFastRecParticle::IsEleCon(TString purity) const
243 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
244 // photon-like shape is defined with a purity "low", "medium" or "high"
247 Bool_t photonLike = kFALSE;
248 if (purity == "low" ) photonLike = TestPIDBit(6);
249 else if (purity == "medium") photonLike = TestPIDBit(7);
250 else if (purity == "high" ) photonLike = TestPIDBit(8);
252 AliError(Form("Wrong purity type: %s",purity.Data()));
254 if (photonLike && // photon by PCA
255 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
256 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
257 !TestPIDBit(14)) // no charged track
263 //____________________________________________________________________________
264 Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
266 // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
267 // corresponds to photons
268 if (TestPIDBit(12) && !TestPIDBit(14))
274 //____________________________________________________________________________
275 Bool_t AliPHOSFastRecParticle::IsHardPi0() const
277 // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
278 // corresponds to pi0
279 if (TestPIDBit(13)&& !TestPIDBit(14))
285 //____________________________________________________________________________
286 Bool_t AliPHOSFastRecParticle::IsHadron() const
288 // Rec.Particle is an hadron if it does not look like
289 // a low-purity photon nor low-purity pi0
291 if ( !TestPIDBit(6) && !TestPIDBit(9) ) // not photon nor pi0
297 //____________________________________________________________________________
298 Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
300 // Rec.Particle is a charged hadron if it does not look like
301 // a low-purity photon nor low-purity pi0 and is low-purity charged
303 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
304 !TestPIDBit(2)) // charged by CPV
310 //____________________________________________________________________________
311 Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
313 // Rec.Particle is a neutral hadron if it does not look like
314 // a low-purity photon nor low-purity pi0 and is high-purity neutral
316 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
317 TestPIDBit(2)) // neutral by CPV
323 //____________________________________________________________________________
324 Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
326 // Rec.Particle is a fast charged hadron if it does not look like
327 // a low-purity photon nor low-purity pi0, is low-purity charged
328 // and is high-purity fast
330 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
331 !TestPIDBit(2) && // charged by CPV
332 TestPIDBit(5)) // fast by TOF
338 //____________________________________________________________________________
339 Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
341 // Rec.Particle is a slow neutral hadron if it does not look like
342 // a low-purity photon nor low-purity pi0, is high-purity neutral
343 // and is not high-purity fast
345 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
346 !TestPIDBit(2) && // charged by CPV
347 !TestPIDBit(5)) // slow by TOF
354 //____________________________________________________________________________
355 Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
357 // Rec.Particle is a fast neutral hadron if it does not look like
358 // a low-purity photon nor low-purity pi0, is high-purity neutral
359 // and is high-purity fast
361 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
362 TestPIDBit(2) && // neutral by CPV
363 TestPIDBit(5)) // fast by TOF
369 //____________________________________________________________________________
370 Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
372 // Rec.Particle is a slow neutral hadron if it does not look like
373 // a low-purity photon nor low-purity pi0, is high-purity neutral
374 // and is not high-purity fast
376 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
377 TestPIDBit(2) && // neutral by CPV
378 !TestPIDBit(5)) // slow by TOF
384 //____________________________________________________________________________
385 TString AliPHOSFastRecParticle::Name() const
387 // Returns the name of the particle type (only valid if PIDv1 is employed)
391 name = "Undefined particle" ;
394 name = "Photon low purity, ";
395 else if (IsPhoton("medium"))
396 name = "Photon medium purity, ";
397 else if (IsPhoton("high"))
398 name = "Photon high purity, ";
401 name = "Pi0 low purity, ";
402 else if (IsPi0("medium"))
403 name = "Pi0 medium purity, ";
404 else if (IsPi0("high"))
405 name = "Pi0 high purity, ";
407 if (IsElectron("low"))
408 name = "Electron low purity, ";
409 else if (IsElectron("medium"))
410 name = "Electron medium purity, ";
411 else if (IsElectron("high"))
412 name = "Electron high purity, ";
416 if (IsChargedHadron()) {
417 name.Prepend("charged, ");
418 if (IsFastChargedHadron())
419 name.Prepend("fast, ");
420 else if (IsSlowChargedHadron())
421 name.Prepend("slow, ");
423 else if (IsNeutralHadron()) {
424 name.Prepend("neutral, ");
425 if (IsFastNeutralHadron())
426 name.Prepend("fast, ");
427 else if (IsSlowNeutralHadron())
428 name.Prepend("slow, ");
436 //______________________________________________________________________________
437 void AliPHOSFastRecParticle::SetType(Int_t type) {
438 // sets the particle type
439 // bit-mask of the particle type means the following:
440 // bits 0,1,2 - neutral particle with low, medium and high purity
441 // bits 3.4,5 - fast particle with low, medium and high purity
442 // bits 6.7,8 - photon shower with low, medium and high purity
443 // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
447 if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
452 if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
456 if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
460 if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
464 if((fType == 56)||(fType == 57)){
475 //______________________________________________________________________________
476 void AliPHOSFastRecParticle::Paint(Option_t *)
478 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
480 Double_t kRADDEG = 180. / TMath::Pi() ;
481 Coord_t x = Phi() * kRADDEG ;
482 Coord_t y = Theta() * kRADDEG ;
483 Color_t markercolor = 1 ;
484 Size_t markersize = 1. ;
485 Style_t markerstyle = 5 ;
487 if (!gPad->IsBatch()) {
488 gVirtualX->SetMarkerColor(markercolor) ;
489 gVirtualX->SetMarkerSize (markersize) ;
490 gVirtualX->SetMarkerStyle(markerstyle) ;
492 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
493 gPad->PaintPolyMarker(1,&x,&y,"") ;
496 //____________________________________________________________________________
497 void AliPHOSFastRecParticle::Print(const Option_t *)const
499 // Print the type, energy and momentum of the reconstructed particle
501 AliInfo(Form("Print", "-----------------------------")) ;
502 printf("PID bits are %d%d%d %d%d%d %d%d%d %d%d%d",
503 TestPIDBit(0),TestPIDBit(1),
504 TestPIDBit(2),TestPIDBit(3),
505 TestPIDBit(4),TestPIDBit(5),
506 TestPIDBit(6),TestPIDBit(7),
507 TestPIDBit(8),TestPIDBit(9),
508 TestPIDBit(10),TestPIDBit(11)) ;
509 printf(", type is \"%s\"\n", Name().Data()) ;
510 printf(" (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n",
515 printf(" TOF = %.3e ns\n", ToF() ) ;
516 printf(" PID weight: \n" ) ;
517 printf(" photon -> %f\n", fPID[AliPID::kPhoton] ) ;
518 printf(" electron -> %f\n", fPID[AliPID::kElectron] ) ;
519 printf(" Conversion electron -> %f\n", fPID[AliPID::kEleCon] ) ;
520 printf(" muon -> %f\n", fPID[AliPID::kMuon] ) ;
521 printf(" neutral pion -> %f\n", fPID[AliPID::kPi0] ) ;
522 printf(" charged pion -> %f\n", fPID[AliPID::kPion] ) ;
523 printf(" charged kaon -> %f\n", fPID[AliPID::kKaon] ) ;
524 printf(" neutral kaon -> %f\n", fPID[AliPID::kKaon0] ) ;
525 printf(" proton -> %f\n", fPID[AliPID::kProton] ) ;
526 printf(" neutron -> %f\n", fPID[AliPID::kNeutron] ) ;