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