]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSFastRecParticle.cxx
Protection against uninitialized fQADM
[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
702ab87e 18/* History of cvs commits:
19 *
20 * $Log$
3f7dbdb7 21 * Revision 1.39 2005/05/28 14:19:04 schutz
22 * Compilation warnings fixed by T.P.
23 *
702ab87e 24 */
25
a73f33f0 26//_________________________________________________________________________
b2a60966 27// A Particle modified by PHOS response and produced by AliPHOSvFast
28// To become a general class of AliRoot ?
3f6cb8ae 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//--
b2a60966 33//*-- Author: Yves Schutz (SUBATECH)
a73f33f0 34
35// --- ROOT system ---
36
37// --- Standard library ---
38
a73f33f0 39// --- AliRoot header files ---
351dd634 40#include "AliLog.h"
a73f33f0 41#include "AliPHOSFastRecParticle.h"
42#include "TPad.h"
43#include "TPaveText.h"
44
925e6570 45ClassImp(AliPHOSFastRecParticle)
a73f33f0 46
03c03c49 47//____________________________________________________________________________
3f7dbdb7 48AliPHOSFastRecParticle::AliPHOSFastRecParticle() :
49 fIndexInList(0),
50 fTof(0.f),
51 fType(0)
03c03c49 52{
53 // ctor
03c03c49 54}
55
a73f33f0 56//____________________________________________________________________________
57 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
3f7dbdb7 58 : TParticle(rp),
59 fIndexInList(rp.fIndexInList),//?
60 fTof(rp.fTof),//?
61 fType(rp.fType)
a73f33f0 62{
b2a60966 63 // copy ctor
cafda784 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;
a73f33f0 83}
84
85//____________________________________________________________________________
3f7dbdb7 86 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp) :
87 fIndexInList(0),
88 fTof(0.f),
89 fType(0)
a73f33f0 90{
b2a60966 91 // ctor from a TParticle (crummy?!)
31aa6d6c 92 TParticle & pnoconst = (TParticle &)(pp) ;
93 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
a73f33f0 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;
78022019 113
a73f33f0 114}
115
a73f33f0 116//____________________________________________________________________________
117Int_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//______________________________________________________________________________
8f2a3661 144void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
a73f33f0 145{
146 // Execute action corresponding to one event
147 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
794c2bc3 148
a73f33f0 149 if (!gPad->IsEditable())
150 return ;
794c2bc3 151
a73f33f0 152 static TPaveText * clustertext = 0 ;
794c2bc3 153
a73f33f0 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() ;
a4e98857 176 break ;
a73f33f0 177 }
a73f33f0 178 }
794c2bc3 179
a73f33f0 180}
794c2bc3 181
a73f33f0 182//____________________________________________________________________________
80457dd3 183Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
3f6cb8ae 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
80457dd3 188 purity.ToLower();
3f6cb8ae 189 Bool_t photonLike = kFALSE;
80457dd3 190 if (purity == "low" ) photonLike = TestPIDBit(6);
191 else if (purity == "medium") photonLike = TestPIDBit(7);
192 else if (purity == "high" ) photonLike = TestPIDBit(8);
3f6cb8ae 193 if (photonLike && // photon by PCA
194 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
d61a215f 195 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
196 !TestPIDBit(14)) // no charged track
3f6cb8ae 197 return kTRUE ;
198 else
199 return kFALSE;
200}
201
202//____________________________________________________________________________
80457dd3 203Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
3f6cb8ae 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
80457dd3 208 purity.ToLower();
3f6cb8ae 209 Bool_t pi0Like = kFALSE;
80457dd3 210 if (purity == "low" ) pi0Like = TestPIDBit(9);
211 else if (purity == "medium") pi0Like = TestPIDBit(10);
212 else if (purity == "high" ) pi0Like = TestPIDBit(11);
351dd634 213 else
214 AliError(Form("Wrong purity type: %s",purity.Data()));
3f6cb8ae 215 if (pi0Like && // pi0 by PCA
216 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
d61a215f 217 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
218 !TestPIDBit(14)) // no charged track
3f6cb8ae 219 return kTRUE ;
220 else
221 return kFALSE;
222}
223
224//____________________________________________________________________________
80457dd3 225Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
3f6cb8ae 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
80457dd3 230 purity.ToLower();
3f6cb8ae 231 Bool_t photonLike = kFALSE;
80457dd3 232 if (purity == "low" ) photonLike = TestPIDBit(6);
233 else if (purity == "medium") photonLike = TestPIDBit(7);
234 else if (purity == "high" ) photonLike = TestPIDBit(8);
351dd634 235 else
236 AliError(Form("Wrong purity type: %s",purity.Data()));
eea10c57 237
3f6cb8ae 238 if (photonLike && // photon by PCA
7629b49c 239 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
d61a215f 240 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
241 TestPIDBit(14)) // no charged track
d9c7f006 242 return kTRUE ;
243 else
244 return kFALSE;
245}
246
247//____________________________________________________________________________
948a4b24 248Bool_t AliPHOSFastRecParticle::IsEleCon(TString purity) const
d9c7f006 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);
351dd634 258 else
259 AliError(Form("Wrong purity type: %s",purity.Data()));
d9c7f006 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
3f6cb8ae 265 return kTRUE ;
266 else
267 return kFALSE;
268}
269
e3817e5f 270//____________________________________________________________________________
271Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
272{
273 // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
274 // corresponds to photons
d61a215f 275 if (TestPIDBit(12) && !TestPIDBit(14))
e3817e5f 276 return kTRUE;
277 else
278 return kFALSE;
279}
280
281//____________________________________________________________________________
282Bool_t AliPHOSFastRecParticle::IsHardPi0() const
283{
284 // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
285 // corresponds to pi0
d61a215f 286 if (TestPIDBit(13)&& !TestPIDBit(14))
e3817e5f 287 return kTRUE;
288 else
289 return kFALSE;
290}
291
3f6cb8ae 292//____________________________________________________________________________
293Bool_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//____________________________________________________________________________
305Bool_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//____________________________________________________________________________
318Bool_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//____________________________________________________________________________
331Bool_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//____________________________________________________________________________
346Bool_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//____________________________________________________________________________
362Bool_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//____________________________________________________________________________
377Bool_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//____________________________________________________________________________
392TString AliPHOSFastRecParticle::Name() const
a73f33f0 393{
794c2bc3 394 // Returns the name of the particle type (only valid if PIDv1 is employed)
a73f33f0 395
794c2bc3 396 TString name ;
3f6cb8ae 397
398 name = "Undefined particle" ;
794c2bc3 399
3f6cb8ae 400 if (IsPhoton("low"))
7629b49c 401 name = "Photon low purity, ";
3f6cb8ae 402 else if (IsPhoton("medium"))
7629b49c 403 name = "Photon medium purity, ";
3f6cb8ae 404 else if (IsPhoton("high"))
7629b49c 405 name = "Photon high purity, ";
3f6cb8ae 406
407 if (IsPi0("low"))
43dc5270 408 name = "Pi0 low purity, ";
3f6cb8ae 409 else if (IsPi0("medium"))
43dc5270 410 name = "Pi0 medium purity, ";
3f6cb8ae 411 else if (IsPi0("high"))
43dc5270 412 name = "Pi0 high purity, ";
3f6cb8ae 413
414 if (IsElectron("low"))
43dc5270 415 name = "Electron low purity, ";
3f6cb8ae 416 else if (IsElectron("medium"))
43dc5270 417 name = "Electron medium purity, ";
3f6cb8ae 418 else if (IsElectron("high"))
43dc5270 419 name = "Electron high purity, ";
3f6cb8ae 420
421 if (IsHadron()) {
422 name = "hadron";
423 if (IsChargedHadron()) {
7629b49c 424 name.Prepend("charged, ");
3f6cb8ae 425 if (IsFastChargedHadron())
7629b49c 426 name.Prepend("fast, ");
3f6cb8ae 427 else if (IsSlowChargedHadron())
7629b49c 428 name.Prepend("slow, ");
3f6cb8ae 429 }
430 else if (IsNeutralHadron()) {
7629b49c 431 name.Prepend("neutral, ");
3f6cb8ae 432 if (IsFastNeutralHadron())
7629b49c 433 name.Prepend("fast, ");
3f6cb8ae 434 else if (IsSlowNeutralHadron())
7629b49c 435 name.Prepend("slow, ");
3f6cb8ae 436 }
437 }
438
a73f33f0 439 return name ;
440}
441
14f6a871 442
443//______________________________________________________________________________
444void AliPHOSFastRecParticle::SetType(Int_t type) {
445 // sets the particle type
3f6cb8ae 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
14f6a871 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
a73f33f0 482//______________________________________________________________________________
483void AliPHOSFastRecParticle::Paint(Option_t *)
484{
b2a60966 485 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
a73f33f0 486
487 Double_t kRADDEG = 180. / TMath::Pi() ;
b2a60966 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,"") ;
a73f33f0 501}
502
503//____________________________________________________________________________
702ab87e 504void AliPHOSFastRecParticle::Print(const Option_t *)const
a73f33f0 505{
a4e98857 506 // Print the type, energy and momentum of the reconstructed particle
3f6cb8ae 507
351dd634 508 AliInfo(Form("Print", "-----------------------------")) ;
cc1fe362 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" ) ;
304864ab 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] ) ;
cc1fe362 534
a73f33f0 535}