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