Removing extra semicolons (FedoraCore3, gcc 3.4.2)
[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 ---
351dd634 32#include "AliLog.h"
a73f33f0 33#include "AliPHOSFastRecParticle.h"
34#include "TPad.h"
35#include "TPaveText.h"
36
925e6570 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)
a8c47ab6 48 : TParticle(rp)
a73f33f0 49{
b2a60966 50 // copy ctor
51
6a40c29e 52 fType = rp.fType ;
cafda784 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;
a73f33f0 72}
73
74//____________________________________________________________________________
75 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
76{
b2a60966 77 // ctor from a TParticle (crummy?!)
78
31aa6d6c 79 TParticle & pnoconst = (TParticle &)(pp) ;
80 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
03c03c49 81 fType = 0 ;
a73f33f0 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;
78022019 101
a73f33f0 102}
103
104//____________________________________________________________________________
a73f33f0 105Int_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//______________________________________________________________________________
8f2a3661 132void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t , Int_t )
a73f33f0 133{
134 // Execute action corresponding to one event
135 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
794c2bc3 136
a73f33f0 137 if (!gPad->IsEditable())
138 return ;
794c2bc3 139
a73f33f0 140 static TPaveText * clustertext = 0 ;
794c2bc3 141
a73f33f0 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() ;
a4e98857 164 break ;
a73f33f0 165 }
a73f33f0 166 }
794c2bc3 167
a73f33f0 168}
794c2bc3 169
b2a60966 170//____________________________________________________________________________
80457dd3 171Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
3f6cb8ae 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
80457dd3 176 purity.ToLower();
3f6cb8ae 177 Bool_t photonLike = kFALSE;
80457dd3 178 if (purity == "low" ) photonLike = TestPIDBit(6);
179 else if (purity == "medium") photonLike = TestPIDBit(7);
180 else if (purity == "high" ) photonLike = TestPIDBit(8);
3f6cb8ae 181 if (photonLike && // photon by PCA
182 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
d61a215f 183 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
184 !TestPIDBit(14)) // no charged track
3f6cb8ae 185 return kTRUE ;
186 else
187 return kFALSE;
188}
189
190//____________________________________________________________________________
80457dd3 191Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
3f6cb8ae 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
80457dd3 196 purity.ToLower();
3f6cb8ae 197 Bool_t pi0Like = kFALSE;
80457dd3 198 if (purity == "low" ) pi0Like = TestPIDBit(9);
199 else if (purity == "medium") pi0Like = TestPIDBit(10);
200 else if (purity == "high" ) pi0Like = TestPIDBit(11);
351dd634 201 else
202 AliError(Form("Wrong purity type: %s",purity.Data()));
3f6cb8ae 203 if (pi0Like && // pi0 by PCA
204 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
d61a215f 205 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))&& // neutral by CPV
206 !TestPIDBit(14)) // no charged track
3f6cb8ae 207 return kTRUE ;
208 else
209 return kFALSE;
210}
211
212//____________________________________________________________________________
80457dd3 213Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
3f6cb8ae 214{
215 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
216 // photon-like shape is defined with a purity "low", "medium" or "high"
217
80457dd3 218 purity.ToLower();
3f6cb8ae 219 Bool_t photonLike = kFALSE;
80457dd3 220 if (purity == "low" ) photonLike = TestPIDBit(6);
221 else if (purity == "medium") photonLike = TestPIDBit(7);
222 else if (purity == "high" ) photonLike = TestPIDBit(8);
351dd634 223 else
224 AliError(Form("Wrong purity type: %s",purity.Data()));
eea10c57 225
3f6cb8ae 226 if (photonLike && // photon by PCA
7629b49c 227 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
d61a215f 228 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
229 TestPIDBit(14)) // no charged track
d9c7f006 230 return kTRUE ;
231 else
232 return kFALSE;
233}
234
235//____________________________________________________________________________
948a4b24 236Bool_t AliPHOSFastRecParticle::IsEleCon(TString purity) const
d9c7f006 237{
238 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
239 // photon-like shape is defined with a purity "low", "medium" or "high"
240
241 purity.ToLower();
242 Bool_t photonLike = kFALSE;
243 if (purity == "low" ) photonLike = TestPIDBit(6);
244 else if (purity == "medium") photonLike = TestPIDBit(7);
245 else if (purity == "high" ) photonLike = TestPIDBit(8);
351dd634 246 else
247 AliError(Form("Wrong purity type: %s",purity.Data()));
d9c7f006 248
249 if (photonLike && // photon by PCA
250 (TestPIDBit(5)|| TestPIDBit(4)|| TestPIDBit(3))&& // fast by TOF
251 (!TestPIDBit(2)||!TestPIDBit(1)||!TestPIDBit(0))&& // charged by CPV
252 !TestPIDBit(14)) // no charged track
3f6cb8ae 253 return kTRUE ;
254 else
255 return kFALSE;
256}
257
258//____________________________________________________________________________
e3817e5f 259Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
260{
261 // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
262 // corresponds to photons
d61a215f 263 if (TestPIDBit(12) && !TestPIDBit(14))
e3817e5f 264 return kTRUE;
265 else
266 return kFALSE;
267}
268
269//____________________________________________________________________________
270Bool_t AliPHOSFastRecParticle::IsHardPi0() const
271{
272 // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
273 // corresponds to pi0
d61a215f 274 if (TestPIDBit(13)&& !TestPIDBit(14))
e3817e5f 275 return kTRUE;
276 else
277 return kFALSE;
278}
279
280//____________________________________________________________________________
3f6cb8ae 281Bool_t AliPHOSFastRecParticle::IsHadron() const
282{
283 // Rec.Particle is an hadron if it does not look like
284 // a low-purity photon nor low-purity pi0
285
286 if ( !TestPIDBit(6) && !TestPIDBit(9) ) // not photon nor pi0
287 return kTRUE ;
288 else
289 return kFALSE;
290}
291
292//____________________________________________________________________________
293Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
294{
295 // Rec.Particle is a charged hadron if it does not look like
296 // a low-purity photon nor low-purity pi0 and is low-purity charged
297
298 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
299 !TestPIDBit(2)) // charged by CPV
300 return kTRUE ;
301 else
302 return kFALSE;
303}
304
305//____________________________________________________________________________
306Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
307{
308 // Rec.Particle is a neutral hadron if it does not look like
309 // a low-purity photon nor low-purity pi0 and is high-purity neutral
310
311 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
312 TestPIDBit(2)) // neutral by CPV
313 return kTRUE ;
314 else
315 return kFALSE;
316}
317
318//____________________________________________________________________________
319Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
320{
321 // Rec.Particle is a fast charged hadron if it does not look like
322 // a low-purity photon nor low-purity pi0, is low-purity charged
323 // and is high-purity fast
324
325 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
326 !TestPIDBit(2) && // charged by CPV
327 TestPIDBit(5)) // fast by TOF
328 return kTRUE ;
329 else
330 return kFALSE;
331}
332
333//____________________________________________________________________________
334Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
335{
336 // Rec.Particle is a slow neutral hadron if it does not look like
337 // a low-purity photon nor low-purity pi0, is high-purity neutral
338 // and is not high-purity fast
339
340 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
341 !TestPIDBit(2) && // charged by CPV
342 !TestPIDBit(5)) // slow by TOF
343 return kTRUE ;
344 else
345 return kFALSE;
346
347}
348
349//____________________________________________________________________________
350Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
351{
352 // Rec.Particle is a fast neutral hadron if it does not look like
353 // a low-purity photon nor low-purity pi0, is high-purity neutral
354 // and is high-purity fast
355
356 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
357 TestPIDBit(2) && // neutral by CPV
358 TestPIDBit(5)) // fast by TOF
359 return kTRUE ;
360 else
361 return kFALSE;
362}
363
364//____________________________________________________________________________
365Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
366{
367 // Rec.Particle is a slow neutral hadron if it does not look like
368 // a low-purity photon nor low-purity pi0, is high-purity neutral
369 // and is not high-purity fast
370
371 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
372 TestPIDBit(2) && // neutral by CPV
373 !TestPIDBit(5)) // slow by TOF
374 return kTRUE ;
375 else
376 return kFALSE;
377}
378
379//____________________________________________________________________________
380TString AliPHOSFastRecParticle::Name() const
a73f33f0 381{
794c2bc3 382 // Returns the name of the particle type (only valid if PIDv1 is employed)
a73f33f0 383
794c2bc3 384 TString name ;
3f6cb8ae 385
386 name = "Undefined particle" ;
794c2bc3 387
3f6cb8ae 388 if (IsPhoton("low"))
7629b49c 389 name = "Photon low purity, ";
3f6cb8ae 390 else if (IsPhoton("medium"))
7629b49c 391 name = "Photon medium purity, ";
3f6cb8ae 392 else if (IsPhoton("high"))
7629b49c 393 name = "Photon high purity, ";
3f6cb8ae 394
395 if (IsPi0("low"))
43dc5270 396 name = "Pi0 low purity, ";
3f6cb8ae 397 else if (IsPi0("medium"))
43dc5270 398 name = "Pi0 medium purity, ";
3f6cb8ae 399 else if (IsPi0("high"))
43dc5270 400 name = "Pi0 high purity, ";
3f6cb8ae 401
402 if (IsElectron("low"))
43dc5270 403 name = "Electron low purity, ";
3f6cb8ae 404 else if (IsElectron("medium"))
43dc5270 405 name = "Electron medium purity, ";
3f6cb8ae 406 else if (IsElectron("high"))
43dc5270 407 name = "Electron high purity, ";
3f6cb8ae 408
409 if (IsHadron()) {
410 name = "hadron";
411 if (IsChargedHadron()) {
7629b49c 412 name.Prepend("charged, ");
3f6cb8ae 413 if (IsFastChargedHadron())
7629b49c 414 name.Prepend("fast, ");
3f6cb8ae 415 else if (IsSlowChargedHadron())
7629b49c 416 name.Prepend("slow, ");
3f6cb8ae 417 }
418 else if (IsNeutralHadron()) {
7629b49c 419 name.Prepend("neutral, ");
3f6cb8ae 420 if (IsFastNeutralHadron())
7629b49c 421 name.Prepend("fast, ");
3f6cb8ae 422 else if (IsSlowNeutralHadron())
7629b49c 423 name.Prepend("slow, ");
3f6cb8ae 424 }
425 }
426
a73f33f0 427 return name ;
428}
429
14f6a871 430
431//______________________________________________________________________________
432void AliPHOSFastRecParticle::SetType(Int_t type) {
433 // sets the particle type
3f6cb8ae 434 // bit-mask of the particle type means the following:
435 // bits 0,1,2 - neutral particle with low, medium and high purity
436 // bits 3.4,5 - fast particle with low, medium and high purity
437 // bits 6.7,8 - photon shower with low, medium and high purity
438 // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
439
14f6a871 440 fType = type ;
441
442 if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
443 fPdgCode = 22 ;
444 return ;
445 }
446
447 if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
448 fPdgCode = 2112 ;
449 return ;
450 }
451 if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
452 fPdgCode = 11 ;
453 return ;
454 }
455 if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
456 fPdgCode = 13 ;
457 return ;
458 }
459 if((fType == 56)||(fType == 57)){
460 fPdgCode = 211 ;
461 return ;
462 }
463 if (fType == 0){
464 fPdgCode = 2212 ;
465 return ;
466 }
467
468}
469
a73f33f0 470//______________________________________________________________________________
471void AliPHOSFastRecParticle::Paint(Option_t *)
472{
b2a60966 473 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
a73f33f0 474
475 Double_t kRADDEG = 180. / TMath::Pi() ;
b2a60966 476 Coord_t x = Phi() * kRADDEG ;
477 Coord_t y = Theta() * kRADDEG ;
478 Color_t markercolor = 1 ;
479 Size_t markersize = 1. ;
480 Style_t markerstyle = 5 ;
481
482 if (!gPad->IsBatch()) {
483 gVirtualX->SetMarkerColor(markercolor) ;
484 gVirtualX->SetMarkerSize (markersize) ;
485 gVirtualX->SetMarkerStyle(markerstyle) ;
486 }
487 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
488 gPad->PaintPolyMarker(1,&x,&y,"") ;
a73f33f0 489}
490
491//____________________________________________________________________________
e957fea8 492void AliPHOSFastRecParticle::Print()const
a73f33f0 493{
a4e98857 494 // Print the type, energy and momentum of the reconstructed particle
3f6cb8ae 495
351dd634 496 AliInfo(Form("Print", "-----------------------------")) ;
cc1fe362 497 printf("PID bits are %d%d%d %d%d%d %d%d%d %d%d%d",
498 TestPIDBit(0),TestPIDBit(1),
499 TestPIDBit(2),TestPIDBit(3),
500 TestPIDBit(4),TestPIDBit(5),
501 TestPIDBit(6),TestPIDBit(7),
502 TestPIDBit(8),TestPIDBit(9),
503 TestPIDBit(10),TestPIDBit(11)) ;
504 printf(", type is \"%s\"\n", Name().Data()) ;
505 printf(" (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n",
506 Energy(),
507 Px(),
508 Py(),
509 Pz() ) ;
510 printf(" TOF = %.3e ns\n", ToF() ) ;
511 printf(" PID weight: \n" ) ;
304864ab 512 printf(" photon -> %f\n", fPID[AliPID::kPhoton] ) ;
513 printf(" electron -> %f\n", fPID[AliPID::kElectron] ) ;
514 printf(" Conversion electron -> %f\n", fPID[AliPID::kEleCon] ) ;
515 printf(" muon -> %f\n", fPID[AliPID::kMuon] ) ;
516 printf(" neutral pion -> %f\n", fPID[AliPID::kPi0] ) ;
517 printf(" charged pion -> %f\n", fPID[AliPID::kPion] ) ;
518 printf(" charged kaon -> %f\n", fPID[AliPID::kKaon] ) ;
519 printf(" neutral kaon -> %f\n", fPID[AliPID::kKaon0] ) ;
520 printf(" proton -> %f\n", fPID[AliPID::kProton] ) ;
521 printf(" neutron -> %f\n", fPID[AliPID::kNeutron] ) ;
cc1fe362 522
a73f33f0 523}