]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSFastRecParticle.cxx
Conversion 8 to 10 bits for the SDD digits (Yu.Belikov)
[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 //_________________________________________________________________________
19 //  A  Particle modified by PHOS response and produced by AliPHOSvFast
20 //  To become a general class of AliRoot ?    
21 //--
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
24 //--
25 //*-- Author: Yves Schutz (SUBATECH)
26
27 // --- ROOT system ---
28
29 // --- Standard library ---
30
31 // --- AliRoot header files ---
32
33 #include "AliPHOSFastRecParticle.h"
34 #include "TPad.h"
35 #include "TPaveText.h"
36
37 ClassImp(AliPHOSFastRecParticle) ; 
38
39 //____________________________________________________________________________
40 AliPHOSFastRecParticle::AliPHOSFastRecParticle() : TParticle()
41 {
42   // ctor
43   fType = 0 ; 
44 }
45
46 //____________________________________________________________________________
47  AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
48    : TParticle(rp)
49 {
50   // copy ctor
51
52   fType        = rp.fType ;
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];
59   fWeight      = rp.fWeight;
60   fCalcMass    = rp.fCalcMass;
61   fPx          = rp.fPx;
62   fPy          = rp.fPy;
63   fPz          = rp.fPz;
64   fE           = rp.fE;
65   fVx          = rp.fVx;
66   fVy          = rp.fVy;
67   fVz          = rp.fVz;
68   fVt          = rp.fVt;
69   fPolarTheta  = rp.fPolarTheta;
70   fPolarPhi    = rp.fPolarPhi;
71   fParticlePDG = rp.fParticlePDG; 
72 }
73
74 //____________________________________________________________________________
75  AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
76 {
77   // ctor from a TParticle (crummy?!)
78  
79   TParticle & pnoconst = (TParticle &)(pp) ;
80   AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
81   fType        = 0  ;
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];
88   fWeight      = p.fWeight;
89   fCalcMass    = p.fCalcMass;
90   fPx          = p.fPx;
91   fPy          = p.fPy;
92   fPz          = p.fPz;
93   fE           = p.fE;
94   fVx          = p.fVx;
95   fVy          = p.fVy;
96   fVz          = p.fVz;
97   fVt          = p.fVt;
98   fPolarTheta  = p.fPolarTheta;
99   fPolarPhi    = p.fPolarPhi;
100   fParticlePDG = p.fParticlePDG; 
101
102 }
103
104 //____________________________________________________________________________
105 Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
106 {
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.
110
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);
118   
119   if (dist > kMaxDiff) return 9999;
120   return dist;
121 }
122
123 //___________________________________________________________________________
124  void AliPHOSFastRecParticle::Draw(Option_t *option)
125  {
126    // Draw this AliPHOSFastRecParticle with its current attributes
127     
128    AppendPad(option);
129  }
130
131 //______________________________________________________________________________
132 void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
133 {
134   //  Execute action corresponding to one event
135   //  This member function is called when a AliPHOSFastRecParticle is clicked with the locator
136   
137   if (!gPad->IsEditable()) 
138     return ;
139   
140   static TPaveText * clustertext = 0 ; 
141   
142   switch (event) {
143     
144   case kButton1Down: {
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, "") ;
149     Text_t  line1[40] ;
150     Text_t  line2[40] ;
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("");   
156     gPad->Update() ; 
157     break ;
158   }
159   
160   case kButton1Up: {
161     delete clustertext ; 
162     clustertext = 0 ; 
163     gPad->Update() ; 
164     break ;
165   }
166   }
167   
168 }
169
170 //____________________________________________________________________________
171 Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
172 {
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"
175
176   purity.ToLower();
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   else Error("IsPhoton","Wrong purity type: \'%s\'",purity.Data());
182   if (photonLike                                   && //  photon by PCA
183       (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& //  fast by TOF
184       (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0)))  //  neutral by CPV
185     return kTRUE ;
186   else
187     return kFALSE;
188 }
189
190 //____________________________________________________________________________
191 Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
192 {
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"
195
196   purity.ToLower();
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);
201   else Error("IsPi0","Wrong purity type: %s",purity.Data());
202   if (pi0Like                                      && //  pi0 by PCA
203       (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& //  fast by TOF
204       (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0)))  //  neutral by CPV
205     return kTRUE ;
206   else
207     return kFALSE;
208 }
209
210 //____________________________________________________________________________
211 Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
212 {
213   // Rec.Particle is an electron if it has a photon-like shape, fast and charged
214   // photon-like shape is defined with a purity "low", "medium" or "high"
215
216   purity.ToLower();
217   Bool_t photonLike = kFALSE;
218   if      (purity == "low"   ) photonLike = TestPIDBit(6);
219   else if (purity == "medium") photonLike = TestPIDBit(7);
220   else if (purity == "high"  ) photonLike = TestPIDBit(8);
221   else Error("IsElectron","Wrong purity type: %s",purity.Data());
222   if (photonLike                                   && //  photon by PCA
223       (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& //  fast by TOF
224      !(TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0)))  //  charged by CPV
225     return kTRUE ;
226   else
227     return kFALSE;
228 }
229
230 //____________________________________________________________________________
231 Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
232 {
233   // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
234   // corresponds to photons
235   if (TestPIDBit(12))
236     return kTRUE;
237   else
238     return kFALSE;
239 }
240
241 //____________________________________________________________________________
242 Bool_t AliPHOSFastRecParticle::IsHardPi0() const
243 {
244   // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
245   // corresponds to pi0
246   if (TestPIDBit(13))
247     return kTRUE;
248   else
249     return kFALSE;
250 }
251
252 //____________________________________________________________________________
253 Bool_t AliPHOSFastRecParticle::IsHadron() const
254 {
255   // Rec.Particle is an hadron if it does not look like
256   // a low-purity photon nor low-purity pi0
257
258   if ( !TestPIDBit(6) && !TestPIDBit(9) )             // not photon nor pi0
259     return kTRUE ;
260   else
261     return kFALSE;
262 }
263
264 //____________________________________________________________________________
265 Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
266 {
267   // Rec.Particle is a charged hadron if it does not look like
268   // a low-purity photon nor low-purity pi0 and is low-purity charged
269
270   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
271        !TestPIDBit(2))                                // charged by CPV
272     return kTRUE ;
273   else
274     return kFALSE;
275 }
276
277 //____________________________________________________________________________
278 Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
279 {
280   // Rec.Particle is a neutral hadron if it does not look like
281   // a low-purity photon nor low-purity pi0 and is high-purity neutral
282
283   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
284         TestPIDBit(2))                                // neutral by CPV
285     return kTRUE ;
286   else
287     return kFALSE;
288 }
289
290 //____________________________________________________________________________
291 Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
292 {
293   // Rec.Particle is a fast charged hadron if it does not look like
294   // a low-purity photon nor low-purity pi0, is low-purity charged
295   // and is high-purity fast
296
297   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
298        !TestPIDBit(2) &&                              // charged by CPV
299         TestPIDBit(5))                                // fast by TOF
300     return kTRUE ;
301   else
302     return kFALSE;
303 }
304
305 //____________________________________________________________________________
306 Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
307 {
308   // Rec.Particle is a slow neutral hadron if it does not look like
309   // a low-purity photon nor low-purity pi0, is high-purity neutral
310   // and is not high-purity fast
311
312   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
313        !TestPIDBit(2) &&                              // charged by CPV
314        !TestPIDBit(5))                                // slow by TOF
315     return kTRUE ;
316   else
317     return kFALSE;
318
319 }
320
321 //____________________________________________________________________________
322 Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
323 {
324   // Rec.Particle is a fast neutral hadron if it does not look like
325   // a low-purity photon nor low-purity pi0, is high-purity neutral
326   // and is high-purity fast
327
328   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
329         TestPIDBit(2) &&                              // neutral by CPV
330         TestPIDBit(5))                                // fast by TOF
331     return kTRUE ;
332   else
333     return kFALSE;
334 }
335
336 //____________________________________________________________________________
337 Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
338 {
339   // Rec.Particle is a slow neutral hadron if it does not look like
340   // a low-purity photon nor low-purity pi0, is high-purity neutral
341   // and is not high-purity fast
342
343   if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
344         TestPIDBit(2) &&                              // neutral by CPV
345        !TestPIDBit(5))                                // slow by TOF
346     return kTRUE ;
347   else
348     return kFALSE;
349 }
350
351 //____________________________________________________________________________
352 TString AliPHOSFastRecParticle::Name() const
353 {
354   // Returns the name of the particle type (only valid if PIDv1 is employed)
355
356   TString  name ; 
357
358   name = "Undefined particle" ;
359   
360   if      (IsPhoton("low"))
361     name = "Photon low purity ";
362   else if (IsPhoton("medium"))
363     name = "Photon medium purity";
364   else if (IsPhoton("high"))
365     name = "Photon high purity ";
366
367   if      (IsPi0("low"))
368     name += "Pi0 low purity ";
369   else if (IsPi0("medium"))
370     name += "Pi0 medium purity ";
371   else if (IsPi0("high"))
372     name += "Pi0 high purity ";
373
374   if      (IsElectron("low"))
375     name += "Electron low purity ";
376   else if (IsElectron("medium"))
377     name += "Electron medium purity ";
378   else if (IsElectron("high"))
379     name += "Electron high purity ";
380
381   if     (IsHadron()) {
382     name = "hadron";
383     if      (IsChargedHadron()) {
384       name.Prepend("charged ");
385       if      (IsFastChargedHadron())
386         name.Prepend("fast ");
387       else if (IsSlowChargedHadron())
388         name.Prepend("slow ");
389     }
390     else if (IsNeutralHadron()) {
391       name.Prepend("neutral ");
392       if      (IsFastNeutralHadron())
393         name.Prepend("fast ");
394       else if (IsSlowNeutralHadron())
395         name.Prepend("slow ");
396     }
397   }
398
399   return name ; 
400 }
401
402
403 //______________________________________________________________________________
404 void AliPHOSFastRecParticle::SetType(Int_t type) { 
405   // sets the particle type 
406   // bit-mask of the particle type means the following:
407   // bits 0,1,2   - neutral particle with low, medium and high purity
408   // bits 3.4,5   - fast particle with low, medium and high purity
409   // bits 6.7,8   - photon shower with low, medium and high purity
410   // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
411
412   fType = type ; 
413   
414   if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
415     fPdgCode = 22 ; 
416     return ;
417   }
418   
419   if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
420     fPdgCode = 2112 ; 
421     return ;
422   }
423   if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
424     fPdgCode = 11 ; 
425     return ;
426   }
427   if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
428     fPdgCode = 13 ; 
429     return ;
430   }
431   if((fType == 56)||(fType == 57)){
432     fPdgCode = 211 ; 
433     return ;
434   }
435   if (fType == 0){
436     fPdgCode = 2212 ; 
437     return ;
438   }
439
440 }           
441
442 //______________________________________________________________________________
443 void AliPHOSFastRecParticle::Paint(Option_t *)
444 {
445   // Paint this ALiRecParticle in theta,phi coordinate as a TMarker  with its current attributes
446
447   Double_t kRADDEG = 180. / TMath::Pi() ; 
448   Coord_t x = Phi() * kRADDEG     ;
449   Coord_t y = Theta() * kRADDEG     ;
450   Color_t markercolor = 1 ;
451   Size_t  markersize  = 1. ;
452   Style_t markerstyle = 5 ;
453   
454   if (!gPad->IsBatch()) {
455     gVirtualX->SetMarkerColor(markercolor) ;
456     gVirtualX->SetMarkerSize (markersize)  ;
457     gVirtualX->SetMarkerStyle(markerstyle) ;
458   }
459   gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
460   gPad->PaintPolyMarker(1,&x,&y,"") ;
461 }
462
463 //____________________________________________________________________________
464 void AliPHOSFastRecParticle::Print()const
465 {
466   // Print the type, energy and momentum of the reconstructed particle
467
468   TString message ; 
469   message  = "\n   PID bits are %d%d%d %d%d%d %d%d%d %d%d%d" ; 
470   message += ", type is \"%s\"\n" ; 
471   message += "   (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n" ; 
472   Info("Print", message.Data(), 
473        TestPIDBit(0),TestPIDBit(1),
474        TestPIDBit(2),TestPIDBit(3),
475        TestPIDBit(4),TestPIDBit(5),
476        TestPIDBit(6),TestPIDBit(7),
477        TestPIDBit(8),TestPIDBit(9),
478        TestPIDBit(10),TestPIDBit(11),
479        Name().Data(), 
480        Energy(), 
481        Px(), 
482        Py(),
483        Pz() ); 
484 }