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:
21 * Revision 1.39 2005/05/28 14:19:04 schutz
22 * Compilation warnings fixed by T.P.
26 //_________________________________________________________________________
27 // A Particle modified by PHOS response and produced by AliPHOSvFast
28 // To become a general class of AliRoot ?
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
33 //*-- Author: Yves Schutz (SUBATECH)
35 // --- ROOT system ---
37 // --- Standard library ---
39 // --- AliRoot header files ---
41 #include "AliPHOSFastRecParticle.h"
43 #include "TPaveText.h"
45 ClassImp(AliPHOSFastRecParticle)
47 //____________________________________________________________________________
48 AliPHOSFastRecParticle::AliPHOSFastRecParticle() :
56 //____________________________________________________________________________
57 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
59 fIndexInList(rp.fIndexInList),//?
64 fPdgCode = rp.fPdgCode;
65 fStatusCode = rp.fStatusCode;
66 fMother[0] = rp.fMother[0];
67 fMother[1] = rp.fMother[1];
68 fDaughter[0] = rp.fDaughter[0];
69 fDaughter[1] = rp.fDaughter[1];
71 fCalcMass = rp.fCalcMass;
80 fPolarTheta = rp.fPolarTheta;
81 fPolarPhi = rp.fPolarPhi;
82 fParticlePDG = rp.fParticlePDG;
85 //____________________________________________________________________________
86 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp) :
91 // ctor from a TParticle (crummy?!)
92 TParticle & pnoconst = (TParticle &)(pp) ;
93 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
94 fPdgCode = p.fPdgCode;
95 fStatusCode = p.fStatusCode;
96 fMother[0] = p.fMother[0];
97 fMother[1] = p.fMother[1];
98 fDaughter[0] = p.fDaughter[0];
99 fDaughter[1] = p.fDaughter[1];
101 fCalcMass = p.fCalcMass;
110 fPolarTheta = p.fPolarTheta;
111 fPolarPhi = p.fPolarPhi;
112 fParticlePDG = p.fParticlePDG;
116 //____________________________________________________________________________
117 Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
119 // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
120 // Compute the closest distance of approach from point px,py to this marker.
121 // The distance is computed in pixels units.
123 Double_t kRADDEG = 180. / TMath::Pi() ;
124 Coord_t x = Phi() * kRADDEG ;
125 Coord_t y = Theta() * kRADDEG ;
126 const Int_t kMaxDiff = 10;
127 Int_t pxm = gPad->XtoAbsPixel(x);
128 Int_t pym = gPad->YtoAbsPixel(y);
129 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
131 if (dist > kMaxDiff) return 9999;
135 //___________________________________________________________________________
136 void AliPHOSFastRecParticle::Draw(Option_t *option)
138 // Draw this AliPHOSFastRecParticle with its current attributes
143 //______________________________________________________________________________
144 void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
146 // Execute action corresponding to one event
147 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
149 if (!gPad->IsEditable())
152 static TPaveText * clustertext = 0 ;
157 Double_t kRADDEG = 180. / TMath::Pi() ;
158 Coord_t x = Phi() * kRADDEG ;
159 Coord_t y = Theta() * kRADDEG ;
160 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
163 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
164 sprintf( line2, "ENERGY: %f ", Energy() ) ;
165 clustertext ->AddText(line1) ;
166 clustertext ->AddText(line2) ;
167 clustertext ->Draw("");
182 //____________________________________________________________________________
183 Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
185 // Rec.Particle is a photon if it has a photon-like shape, fast and neutral
186 // photon-like shape is defined with a purity "low", "medium" or "high"
189 Bool_t photonLike = kFALSE;
190 if (purity == "low" ) photonLike = TestPIDBit(6);
191 else if (purity == "medium") photonLike = TestPIDBit(7);
192 else if (purity == "high" ) photonLike = TestPIDBit(8);
193 if (photonLike && // photon by PCA
194 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
195 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
196 !TestPIDBit(14)) // no charged track
202 //____________________________________________________________________________
203 Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
205 // Rec.Particle is a pi0 if it has a pi0-like shape, fast and neutral
206 // pi0-like shape is defined with a purity "low", "medium" or "high"
209 Bool_t pi0Like = kFALSE;
210 if (purity == "low" ) pi0Like = TestPIDBit(9);
211 else if (purity == "medium") pi0Like = TestPIDBit(10);
212 else if (purity == "high" ) pi0Like = TestPIDBit(11);
214 AliError(Form("Wrong purity type: %s",purity.Data()));
215 if (pi0Like && // pi0 by PCA
216 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
217 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
218 !TestPIDBit(14)) // no charged track
224 //____________________________________________________________________________
225 Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
227 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
228 // photon-like shape is defined with a purity "low", "medium" or "high"
231 Bool_t photonLike = kFALSE;
232 if (purity == "low" ) photonLike = TestPIDBit(6);
233 else if (purity == "medium") photonLike = TestPIDBit(7);
234 else if (purity == "high" ) photonLike = TestPIDBit(8);
236 AliError(Form("Wrong purity type: %s",purity.Data()));
238 if (photonLike && // photon by PCA
239 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
240 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
241 TestPIDBit(14)) // no charged track
247 //____________________________________________________________________________
248 Bool_t AliPHOSFastRecParticle::IsEleCon(TString purity) const
250 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
251 // photon-like shape is defined with a purity "low", "medium" or "high"
254 Bool_t photonLike = kFALSE;
255 if (purity == "low" ) photonLike = TestPIDBit(6);
256 else if (purity == "medium") photonLike = TestPIDBit(7);
257 else if (purity == "high" ) photonLike = TestPIDBit(8);
259 AliError(Form("Wrong purity type: %s",purity.Data()));
261 if (photonLike && // photon by PCA
262 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
263 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
264 !TestPIDBit(14)) // no charged track
270 //____________________________________________________________________________
271 Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
273 // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
274 // corresponds to photons
275 if (TestPIDBit(12) && !TestPIDBit(14))
281 //____________________________________________________________________________
282 Bool_t AliPHOSFastRecParticle::IsHardPi0() const
284 // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
285 // corresponds to pi0
286 if (TestPIDBit(13)&& !TestPIDBit(14))
292 //____________________________________________________________________________
293 Bool_t AliPHOSFastRecParticle::IsHadron() const
295 // Rec.Particle is an hadron if it does not look like
296 // a low-purity photon nor low-purity pi0
298 if ( !TestPIDBit(6) && !TestPIDBit(9) ) // not photon nor pi0
304 //____________________________________________________________________________
305 Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
307 // Rec.Particle is a charged hadron if it does not look like
308 // a low-purity photon nor low-purity pi0 and is low-purity charged
310 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
311 !TestPIDBit(2)) // charged by CPV
317 //____________________________________________________________________________
318 Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
320 // Rec.Particle is a neutral hadron if it does not look like
321 // a low-purity photon nor low-purity pi0 and is high-purity neutral
323 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
324 TestPIDBit(2)) // neutral by CPV
330 //____________________________________________________________________________
331 Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
333 // Rec.Particle is a fast charged hadron if it does not look like
334 // a low-purity photon nor low-purity pi0, is low-purity charged
335 // and is high-purity fast
337 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
338 !TestPIDBit(2) && // charged by CPV
339 TestPIDBit(5)) // fast by TOF
345 //____________________________________________________________________________
346 Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
348 // Rec.Particle is a slow neutral hadron if it does not look like
349 // a low-purity photon nor low-purity pi0, is high-purity neutral
350 // and is not high-purity fast
352 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
353 !TestPIDBit(2) && // charged by CPV
354 !TestPIDBit(5)) // slow by TOF
361 //____________________________________________________________________________
362 Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
364 // Rec.Particle is a fast neutral hadron if it does not look like
365 // a low-purity photon nor low-purity pi0, is high-purity neutral
366 // and is high-purity fast
368 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
369 TestPIDBit(2) && // neutral by CPV
370 TestPIDBit(5)) // fast by TOF
376 //____________________________________________________________________________
377 Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
379 // Rec.Particle is a slow neutral hadron if it does not look like
380 // a low-purity photon nor low-purity pi0, is high-purity neutral
381 // and is not high-purity fast
383 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
384 TestPIDBit(2) && // neutral by CPV
385 !TestPIDBit(5)) // slow by TOF
391 //____________________________________________________________________________
392 TString AliPHOSFastRecParticle::Name() const
394 // Returns the name of the particle type (only valid if PIDv1 is employed)
398 name = "Undefined particle" ;
401 name = "Photon low purity, ";
402 else if (IsPhoton("medium"))
403 name = "Photon medium purity, ";
404 else if (IsPhoton("high"))
405 name = "Photon high purity, ";
408 name = "Pi0 low purity, ";
409 else if (IsPi0("medium"))
410 name = "Pi0 medium purity, ";
411 else if (IsPi0("high"))
412 name = "Pi0 high purity, ";
414 if (IsElectron("low"))
415 name = "Electron low purity, ";
416 else if (IsElectron("medium"))
417 name = "Electron medium purity, ";
418 else if (IsElectron("high"))
419 name = "Electron high purity, ";
423 if (IsChargedHadron()) {
424 name.Prepend("charged, ");
425 if (IsFastChargedHadron())
426 name.Prepend("fast, ");
427 else if (IsSlowChargedHadron())
428 name.Prepend("slow, ");
430 else if (IsNeutralHadron()) {
431 name.Prepend("neutral, ");
432 if (IsFastNeutralHadron())
433 name.Prepend("fast, ");
434 else if (IsSlowNeutralHadron())
435 name.Prepend("slow, ");
443 //______________________________________________________________________________
444 void AliPHOSFastRecParticle::SetType(Int_t type) {
445 // sets the particle type
446 // bit-mask of the particle type means the following:
447 // bits 0,1,2 - neutral particle with low, medium and high purity
448 // bits 3.4,5 - fast particle with low, medium and high purity
449 // bits 6.7,8 - photon shower with low, medium and high purity
450 // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
454 if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
459 if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
463 if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
467 if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
471 if((fType == 56)||(fType == 57)){
482 //______________________________________________________________________________
483 void AliPHOSFastRecParticle::Paint(Option_t *)
485 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
487 Double_t kRADDEG = 180. / TMath::Pi() ;
488 Coord_t x = Phi() * kRADDEG ;
489 Coord_t y = Theta() * kRADDEG ;
490 Color_t markercolor = 1 ;
491 Size_t markersize = 1. ;
492 Style_t markerstyle = 5 ;
494 if (!gPad->IsBatch()) {
495 gVirtualX->SetMarkerColor(markercolor) ;
496 gVirtualX->SetMarkerSize (markersize) ;
497 gVirtualX->SetMarkerStyle(markerstyle) ;
499 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
500 gPad->PaintPolyMarker(1,&x,&y,"") ;
503 //____________________________________________________________________________
504 void AliPHOSFastRecParticle::Print(const Option_t *)const
506 // Print the type, energy and momentum of the reconstructed particle
508 AliInfo(Form("Print", "-----------------------------")) ;
509 printf("PID bits are %d%d%d %d%d%d %d%d%d %d%d%d",
510 TestPIDBit(0),TestPIDBit(1),
511 TestPIDBit(2),TestPIDBit(3),
512 TestPIDBit(4),TestPIDBit(5),
513 TestPIDBit(6),TestPIDBit(7),
514 TestPIDBit(8),TestPIDBit(9),
515 TestPIDBit(10),TestPIDBit(11)) ;
516 printf(", type is \"%s\"\n", Name().Data()) ;
517 printf(" (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n",
522 printf(" TOF = %.3e ns\n", ToF() ) ;
523 printf(" PID weight: \n" ) ;
524 printf(" photon -> %f\n", fPID[AliPID::kPhoton] ) ;
525 printf(" electron -> %f\n", fPID[AliPID::kElectron] ) ;
526 printf(" Conversion electron -> %f\n", fPID[AliPID::kEleCon] ) ;
527 printf(" muon -> %f\n", fPID[AliPID::kMuon] ) ;
528 printf(" neutral pion -> %f\n", fPID[AliPID::kPi0] ) ;
529 printf(" charged pion -> %f\n", fPID[AliPID::kPion] ) ;
530 printf(" charged kaon -> %f\n", fPID[AliPID::kKaon] ) ;
531 printf(" neutral kaon -> %f\n", fPID[AliPID::kKaon0] ) ;
532 printf(" proton -> %f\n", fPID[AliPID::kProton] ) ;
533 printf(" neutron -> %f\n", fPID[AliPID::kNeutron] ) ;