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