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