]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSFastRecParticle.cxx
PHOS altro mappings stored in the CDB
[u/mrichter/AliRoot.git] / PHOS / AliPHOSFastRecParticle.cxx
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 ClassImp(AliPHOSFastRecParticle) 
46
47 //____________________________________________________________________________
48 AliPHOSFastRecParticle::AliPHOSFastRecParticle() :
49   fIndexInList(0),
50   fTof(0.f),
51   fType(0)
52 {
53   // ctor
54 }
55
56 //____________________________________________________________________________
57  AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
58    : TParticle(rp),
59      fIndexInList(rp.fIndexInList),//?
60      fTof(rp.fTof),//?
61      fType(rp.fType)
62 {
63   // copy ctor
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];
70   fWeight      = rp.fWeight;
71   fCalcMass    = rp.fCalcMass;
72   fPx          = rp.fPx;
73   fPy          = rp.fPy;
74   fPz          = rp.fPz;
75   fE           = rp.fE;
76   fVx          = rp.fVx;
77   fVy          = rp.fVy;
78   fVz          = rp.fVz;
79   fVt          = rp.fVt;
80   fPolarTheta  = rp.fPolarTheta;
81   fPolarPhi    = rp.fPolarPhi;
82   fParticlePDG = rp.fParticlePDG; 
83 }
84
85 //____________________________________________________________________________
86  AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp) :
87    fIndexInList(0),
88    fTof(0.f),
89    fType(0)
90 {
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];
100   fWeight      = p.fWeight;
101   fCalcMass    = p.fCalcMass;
102   fPx          = p.fPx;
103   fPy          = p.fPy;
104   fPz          = p.fPz;
105   fE           = p.fE;
106   fVx          = p.fVx;
107   fVy          = p.fVy;
108   fVz          = p.fVz;
109   fVt          = p.fVt;
110   fPolarTheta  = p.fPolarTheta;
111   fPolarPhi    = p.fPolarPhi;
112   fParticlePDG = p.fParticlePDG; 
113
114 }
115
116 //____________________________________________________________________________
117 Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
118 {
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.
122
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);
130   
131   if (dist > kMaxDiff) return 9999;
132   return dist;
133 }
134
135 //___________________________________________________________________________
136  void AliPHOSFastRecParticle::Draw(Option_t *option)
137  {
138    // Draw this AliPHOSFastRecParticle with its current attributes
139     
140    AppendPad(option);
141  }
142
143 //______________________________________________________________________________
144 void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
145 {
146   //  Execute action corresponding to one event
147   //  This member function is called when a AliPHOSFastRecParticle is clicked with the locator
148   
149   if (!gPad->IsEditable()) 
150     return ;
151   
152   static TPaveText * clustertext = 0 ; 
153   
154   switch (event) {
155     
156   case kButton1Down: {
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, "") ;
161     Text_t  line1[40] ;
162     Text_t  line2[40] ;
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("");   
168     gPad->Update() ; 
169     break ;
170   }
171   
172   case kButton1Up: {
173     delete clustertext ; 
174     clustertext = 0 ; 
175     gPad->Update() ; 
176     break ;
177   }
178   }
179   
180 }
181
182 //____________________________________________________________________________
183 Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
184 {
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"
187
188   purity.ToLower();
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
197     return kTRUE ;
198   else
199     return kFALSE;
200 }
201
202 //____________________________________________________________________________
203 Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
204 {
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"
207
208   purity.ToLower();
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);
213   else 
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
219     return kTRUE ;
220   else
221     return kFALSE;
222 }
223
224 //____________________________________________________________________________
225 Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
226 {
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"
229
230   purity.ToLower();
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);
235   else 
236     AliError(Form("Wrong purity type: %s",purity.Data()));
237   
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
242     return kTRUE ;
243   else
244     return kFALSE;
245 }
246
247 //____________________________________________________________________________
248 Bool_t AliPHOSFastRecParticle::IsEleCon(TString purity) const
249 {
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"
252
253   purity.ToLower();
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);
258   else 
259     AliError(Form("Wrong purity type: %s",purity.Data()));
260   
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
265     return kTRUE ;
266   else
267     return kFALSE;
268 }
269
270 //____________________________________________________________________________
271 Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
272 {
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))
276     return kTRUE;
277   else
278     return kFALSE;
279 }
280
281 //____________________________________________________________________________
282 Bool_t AliPHOSFastRecParticle::IsHardPi0() const
283 {
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))
287     return kTRUE;
288   else
289     return kFALSE;
290 }
291
292 //____________________________________________________________________________
293 Bool_t AliPHOSFastRecParticle::IsHadron() const
294 {
295   // Rec.Particle is an hadron if it does not look like
296   // a low-purity photon nor low-purity pi0
297
298   if ( !TestPIDBit(6) && !TestPIDBit(9) )             // not photon nor pi0
299     return kTRUE ;
300   else
301     return kFALSE;
302 }
303
304 //____________________________________________________________________________
305 Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
306 {
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
309
310   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
311        !TestPIDBit(2))                                // charged by CPV
312     return kTRUE ;
313   else
314     return kFALSE;
315 }
316
317 //____________________________________________________________________________
318 Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
319 {
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
322
323   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
324         TestPIDBit(2))                                // neutral by CPV
325     return kTRUE ;
326   else
327     return kFALSE;
328 }
329
330 //____________________________________________________________________________
331 Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
332 {
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
336
337   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
338        !TestPIDBit(2) &&                              // charged by CPV
339         TestPIDBit(5))                                // fast by TOF
340     return kTRUE ;
341   else
342     return kFALSE;
343 }
344
345 //____________________________________________________________________________
346 Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
347 {
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
351
352   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
353        !TestPIDBit(2) &&                              // charged by CPV
354        !TestPIDBit(5))                                // slow by TOF
355     return kTRUE ;
356   else
357     return kFALSE;
358
359 }
360
361 //____________________________________________________________________________
362 Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
363 {
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
367
368   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
369         TestPIDBit(2) &&                              // neutral by CPV
370         TestPIDBit(5))                                // fast by TOF
371     return kTRUE ;
372   else
373     return kFALSE;
374 }
375
376 //____________________________________________________________________________
377 Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
378 {
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
382
383   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
384         TestPIDBit(2) &&                              // neutral by CPV
385        !TestPIDBit(5))                                // slow by TOF
386     return kTRUE ;
387   else
388     return kFALSE;
389 }
390
391 //____________________________________________________________________________
392 TString AliPHOSFastRecParticle::Name() const
393 {
394   // Returns the name of the particle type (only valid if PIDv1 is employed)
395
396   TString  name ; 
397
398   name = "Undefined particle" ;
399   
400   if      (IsPhoton("low"))
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, ";
406
407   if      (IsPi0("low"))
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, ";
413
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, ";
420
421   if     (IsHadron()) {
422     name = "hadron";
423     if      (IsChargedHadron()) {
424       name.Prepend("charged, ");
425       if      (IsFastChargedHadron())
426         name.Prepend("fast, ");
427       else if (IsSlowChargedHadron())
428         name.Prepend("slow, ");
429     }
430     else if (IsNeutralHadron()) {
431       name.Prepend("neutral, ");
432       if      (IsFastNeutralHadron())
433         name.Prepend("fast, ");
434       else if (IsSlowNeutralHadron())
435         name.Prepend("slow, ");
436     }
437   }
438
439   return name ; 
440 }
441
442
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
451
452   fType = type ; 
453   
454   if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
455     fPdgCode = 22 ; 
456     return ;
457   }
458   
459   if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
460     fPdgCode = 2112 ; 
461     return ;
462   }
463   if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
464     fPdgCode = 11 ; 
465     return ;
466   }
467   if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
468     fPdgCode = 13 ; 
469     return ;
470   }
471   if((fType == 56)||(fType == 57)){
472     fPdgCode = 211 ; 
473     return ;
474   }
475   if (fType == 0){
476     fPdgCode = 2212 ; 
477     return ;
478   }
479
480 }           
481
482 //______________________________________________________________________________
483 void AliPHOSFastRecParticle::Paint(Option_t *)
484 {
485   // Paint this ALiRecParticle in theta,phi coordinate as a TMarker  with its current attributes
486
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 ;
493   
494   if (!gPad->IsBatch()) {
495     gVirtualX->SetMarkerColor(markercolor) ;
496     gVirtualX->SetMarkerSize (markersize)  ;
497     gVirtualX->SetMarkerStyle(markerstyle) ;
498   }
499   gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
500   gPad->PaintPolyMarker(1,&x,&y,"") ;
501 }
502
503 //____________________________________________________________________________
504 void AliPHOSFastRecParticle::Print(const Option_t *)const
505 {
506   // Print the type, energy and momentum of the reconstructed particle
507
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",     
518          Energy(), 
519          Px(), 
520          Py(),
521          Pz() ) ; 
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] ) ; 
534
535 }