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 //_________________________________________________________________________
19 // A Particle modified by PHOS response and produced by AliPHOSvFast
20 // To become a general class of AliRoot ?
22 // This is also a base class for AliPHOSRecParticle produced by AliPHOSPIDv1
23 // The rec.particle type is to be defined by AliPHOSvFast or AliPHOSPIDv1
25 //*-- Author: Yves Schutz (SUBATECH)
27 // --- ROOT system ---
29 // --- Standard library ---
31 // --- AliRoot header files ---
33 #include "AliPHOSFastRecParticle.h"
35 #include "TPaveText.h"
37 ClassImp(AliPHOSFastRecParticle)
39 //____________________________________________________________________________
40 AliPHOSFastRecParticle::AliPHOSFastRecParticle() : TParticle()
46 //____________________________________________________________________________
47 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
53 fPdgCode = rp.fPdgCode;
54 fStatusCode = rp.fStatusCode;
55 fMother[0] = rp.fMother[0];
56 fMother[1] = rp.fMother[1];
57 fDaughter[0] = rp.fDaughter[0];
58 fDaughter[1] = rp.fDaughter[1];
60 fCalcMass = rp.fCalcMass;
69 fPolarTheta = rp.fPolarTheta;
70 fPolarPhi = rp.fPolarPhi;
71 fParticlePDG = rp.fParticlePDG;
74 //____________________________________________________________________________
75 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
77 // ctor from a TParticle (crummy?!)
79 TParticle & pnoconst = (TParticle &)(pp) ;
80 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
82 fPdgCode = p.fPdgCode;
83 fStatusCode = p.fStatusCode;
84 fMother[0] = p.fMother[0];
85 fMother[1] = p.fMother[1];
86 fDaughter[0] = p.fDaughter[0];
87 fDaughter[1] = p.fDaughter[1];
89 fCalcMass = p.fCalcMass;
98 fPolarTheta = p.fPolarTheta;
99 fPolarPhi = p.fPolarPhi;
100 fParticlePDG = p.fParticlePDG;
104 //____________________________________________________________________________
105 Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
107 // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
108 // Compute the closest distance of approach from point px,py to this marker.
109 // The distance is computed in pixels units.
111 Double_t kRADDEG = 180. / TMath::Pi() ;
112 Coord_t x = Phi() * kRADDEG ;
113 Coord_t y = Theta() * kRADDEG ;
114 const Int_t kMaxDiff = 10;
115 Int_t pxm = gPad->XtoAbsPixel(x);
116 Int_t pym = gPad->YtoAbsPixel(y);
117 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
119 if (dist > kMaxDiff) return 9999;
123 //___________________________________________________________________________
124 void AliPHOSFastRecParticle::Draw(Option_t *option)
126 // Draw this AliPHOSFastRecParticle with its current attributes
131 //______________________________________________________________________________
132 void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
134 // Execute action corresponding to one event
135 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
137 if (!gPad->IsEditable())
140 static TPaveText * clustertext = 0 ;
145 Double_t kRADDEG = 180. / TMath::Pi() ;
146 Coord_t x = Phi() * kRADDEG ;
147 Coord_t y = Theta() * kRADDEG ;
148 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
151 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
152 sprintf( line2, "ENERGY: %f ", Energy() ) ;
153 clustertext ->AddText(line1) ;
154 clustertext ->AddText(line2) ;
155 clustertext ->Draw("");
170 //____________________________________________________________________________
171 Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
173 // Rec.Particle is a photon if it has a photon-like shape, fast and neutral
174 // photon-like shape is defined with a purity "low", "medium" or "high"
177 Bool_t photonLike = kFALSE;
178 if (purity == "low" ) photonLike = TestPIDBit(6);
179 else if (purity == "medium") photonLike = TestPIDBit(7);
180 else if (purity == "high" ) photonLike = TestPIDBit(8);
181 if (photonLike && // photon by PCA
182 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
183 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
184 !TestPIDBit(14)) // no charged track
190 //____________________________________________________________________________
191 Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
193 // Rec.Particle is a pi0 if it has a pi0-like shape, fast and neutral
194 // pi0-like shape is defined with a purity "low", "medium" or "high"
197 Bool_t pi0Like = kFALSE;
198 if (purity == "low" ) pi0Like = TestPIDBit(9);
199 else if (purity == "medium") pi0Like = TestPIDBit(10);
200 else if (purity == "high" ) pi0Like = TestPIDBit(11);
202 AliError(Form("Wrong purity type: %s",purity.Data()));
203 if (pi0Like && // pi0 by PCA
204 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
205 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
206 !TestPIDBit(14)) // no charged track
212 //____________________________________________________________________________
213 Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
215 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
216 // photon-like shape is defined with a purity "low", "medium" or "high"
219 Bool_t photonLike = kFALSE;
220 if (purity == "low" ) photonLike = TestPIDBit(6);
221 else if (purity == "medium") photonLike = TestPIDBit(7);
222 else if (purity == "high" ) photonLike = TestPIDBit(8);
224 AliError(Form("Wrong purity type: %s",purity.Data()));
226 if (photonLike && // photon by PCA
227 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
228 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
229 TestPIDBit(14)) // no charged track
235 //____________________________________________________________________________
236 Bool_t AliPHOSFastRecParticle::IsEleCon(TString purity) const
238 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
239 // photon-like shape is defined with a purity "low", "medium" or "high"
242 Bool_t photonLike = kFALSE;
243 if (purity == "low" ) photonLike = TestPIDBit(6);
244 else if (purity == "medium") photonLike = TestPIDBit(7);
245 else if (purity == "high" ) photonLike = TestPIDBit(8);
247 AliError(Form("Wrong purity type: %s",purity.Data()));
249 if (photonLike && // photon by PCA
250 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
251 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
252 !TestPIDBit(14)) // no charged track
258 //____________________________________________________________________________
259 Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
261 // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
262 // corresponds to photons
263 if (TestPIDBit(12) && !TestPIDBit(14))
269 //____________________________________________________________________________
270 Bool_t AliPHOSFastRecParticle::IsHardPi0() const
272 // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
273 // corresponds to pi0
274 if (TestPIDBit(13)&& !TestPIDBit(14))
280 //____________________________________________________________________________
281 Bool_t AliPHOSFastRecParticle::IsHadron() const
283 // Rec.Particle is an hadron if it does not look like
284 // a low-purity photon nor low-purity pi0
286 if ( !TestPIDBit(6) && !TestPIDBit(9) ) // not photon nor pi0
292 //____________________________________________________________________________
293 Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
295 // Rec.Particle is a charged hadron if it does not look like
296 // a low-purity photon nor low-purity pi0 and is low-purity charged
298 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
299 !TestPIDBit(2)) // charged by CPV
305 //____________________________________________________________________________
306 Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
308 // Rec.Particle is a neutral hadron if it does not look like
309 // a low-purity photon nor low-purity pi0 and is high-purity neutral
311 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
312 TestPIDBit(2)) // neutral by CPV
318 //____________________________________________________________________________
319 Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
321 // Rec.Particle is a fast charged hadron if it does not look like
322 // a low-purity photon nor low-purity pi0, is low-purity charged
323 // and is high-purity fast
325 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
326 !TestPIDBit(2) && // charged by CPV
327 TestPIDBit(5)) // fast by TOF
333 //____________________________________________________________________________
334 Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
336 // Rec.Particle is a slow neutral hadron if it does not look like
337 // a low-purity photon nor low-purity pi0, is high-purity neutral
338 // and is not high-purity fast
340 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
341 !TestPIDBit(2) && // charged by CPV
342 !TestPIDBit(5)) // slow by TOF
349 //____________________________________________________________________________
350 Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
352 // Rec.Particle is a fast neutral hadron if it does not look like
353 // a low-purity photon nor low-purity pi0, is high-purity neutral
354 // and is high-purity fast
356 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
357 TestPIDBit(2) && // neutral by CPV
358 TestPIDBit(5)) // fast by TOF
364 //____________________________________________________________________________
365 Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
367 // Rec.Particle is a slow neutral hadron if it does not look like
368 // a low-purity photon nor low-purity pi0, is high-purity neutral
369 // and is not high-purity fast
371 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
372 TestPIDBit(2) && // neutral by CPV
373 !TestPIDBit(5)) // slow by TOF
379 //____________________________________________________________________________
380 TString AliPHOSFastRecParticle::Name() const
382 // Returns the name of the particle type (only valid if PIDv1 is employed)
386 name = "Undefined particle" ;
389 name = "Photon low purity, ";
390 else if (IsPhoton("medium"))
391 name = "Photon medium purity, ";
392 else if (IsPhoton("high"))
393 name = "Photon high purity, ";
396 name = "Pi0 low purity, ";
397 else if (IsPi0("medium"))
398 name = "Pi0 medium purity, ";
399 else if (IsPi0("high"))
400 name = "Pi0 high purity, ";
402 if (IsElectron("low"))
403 name = "Electron low purity, ";
404 else if (IsElectron("medium"))
405 name = "Electron medium purity, ";
406 else if (IsElectron("high"))
407 name = "Electron high purity, ";
411 if (IsChargedHadron()) {
412 name.Prepend("charged, ");
413 if (IsFastChargedHadron())
414 name.Prepend("fast, ");
415 else if (IsSlowChargedHadron())
416 name.Prepend("slow, ");
418 else if (IsNeutralHadron()) {
419 name.Prepend("neutral, ");
420 if (IsFastNeutralHadron())
421 name.Prepend("fast, ");
422 else if (IsSlowNeutralHadron())
423 name.Prepend("slow, ");
431 //______________________________________________________________________________
432 void AliPHOSFastRecParticle::SetType(Int_t type) {
433 // sets the particle type
434 // bit-mask of the particle type means the following:
435 // bits 0,1,2 - neutral particle with low, medium and high purity
436 // bits 3.4,5 - fast particle with low, medium and high purity
437 // bits 6.7,8 - photon shower with low, medium and high purity
438 // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
442 if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
447 if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
451 if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
455 if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
459 if((fType == 56)||(fType == 57)){
470 //______________________________________________________________________________
471 void AliPHOSFastRecParticle::Paint(Option_t *)
473 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
475 Double_t kRADDEG = 180. / TMath::Pi() ;
476 Coord_t x = Phi() * kRADDEG ;
477 Coord_t y = Theta() * kRADDEG ;
478 Color_t markercolor = 1 ;
479 Size_t markersize = 1. ;
480 Style_t markerstyle = 5 ;
482 if (!gPad->IsBatch()) {
483 gVirtualX->SetMarkerColor(markercolor) ;
484 gVirtualX->SetMarkerSize (markersize) ;
485 gVirtualX->SetMarkerStyle(markerstyle) ;
487 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
488 gPad->PaintPolyMarker(1,&x,&y,"") ;
491 //____________________________________________________________________________
492 void AliPHOSFastRecParticle::Print()const
494 // Print the type, energy and momentum of the reconstructed particle
496 AliInfo(Form("Print", "-----------------------------")) ;
497 printf("PID bits are %d%d%d %d%d%d %d%d%d %d%d%d",
498 TestPIDBit(0),TestPIDBit(1),
499 TestPIDBit(2),TestPIDBit(3),
500 TestPIDBit(4),TestPIDBit(5),
501 TestPIDBit(6),TestPIDBit(7),
502 TestPIDBit(8),TestPIDBit(9),
503 TestPIDBit(10),TestPIDBit(11)) ;
504 printf(", type is \"%s\"\n", Name().Data()) ;
505 printf(" (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n",
510 printf(" TOF = %.3e ns\n", ToF() ) ;
511 printf(" PID weight: \n" ) ;
512 printf(" photon -> %f\n", fPID[AliPID::kPhoton] ) ;
513 printf(" electron -> %f\n", fPID[AliPID::kElectron] ) ;
514 printf(" Conversion electron -> %f\n", fPID[AliPID::kEleCon] ) ;
515 printf(" muon -> %f\n", fPID[AliPID::kMuon] ) ;
516 printf(" neutral pion -> %f\n", fPID[AliPID::kPi0] ) ;
517 printf(" charged pion -> %f\n", fPID[AliPID::kPion] ) ;
518 printf(" charged kaon -> %f\n", fPID[AliPID::kKaon] ) ;
519 printf(" neutral kaon -> %f\n", fPID[AliPID::kKaon0] ) ;
520 printf(" proton -> %f\n", fPID[AliPID::kProton] ) ;
521 printf(" neutron -> %f\n", fPID[AliPID::kNeutron] ) ;