Heavy flavor generation with Pythia tuned to reproduce Mangano-Nason-Ridolfi calculat...
[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 ---
32
33#include "AliPHOSFastRecParticle.h"
34#include "TPad.h"
35#include "TPaveText.h"
36
9ec91567 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)
48{
b2a60966 49 // copy ctor
50
6a40c29e 51 fType = rp.fType ;
cafda784 52 fPdgCode = rp.fPdgCode;
53 fStatusCode = rp.fStatusCode;
54 fMother[0] = rp.fMother[0];
55 fMother[1] = rp.fMother[1];
56 fDaughter[0] = rp.fDaughter[0];
57 fDaughter[1] = rp.fDaughter[1];
58 fWeight = rp.fWeight;
59 fCalcMass = rp.fCalcMass;
60 fPx = rp.fPx;
61 fPy = rp.fPy;
62 fPz = rp.fPz;
63 fE = rp.fE;
64 fVx = rp.fVx;
65 fVy = rp.fVy;
66 fVz = rp.fVz;
67 fVt = rp.fVt;
68 fPolarTheta = rp.fPolarTheta;
69 fPolarPhi = rp.fPolarPhi;
70 fParticlePDG = rp.fParticlePDG;
a73f33f0 71}
72
73//____________________________________________________________________________
74 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
75{
b2a60966 76 // ctor from a TParticle (crummy?!)
77
31aa6d6c 78 TParticle & pnoconst = (TParticle &)(pp) ;
79 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
03c03c49 80 fType = 0 ;
a73f33f0 81 fPdgCode = p.fPdgCode;
82 fStatusCode = p.fStatusCode;
83 fMother[0] = p.fMother[0];
84 fMother[1] = p.fMother[1];
85 fDaughter[0] = p.fDaughter[0];
86 fDaughter[1] = p.fDaughter[1];
87 fWeight = p.fWeight;
88 fCalcMass = p.fCalcMass;
89 fPx = p.fPx;
90 fPy = p.fPy;
91 fPz = p.fPz;
92 fE = p.fE;
93 fVx = p.fVx;
94 fVy = p.fVy;
95 fVz = p.fVz;
96 fVt = p.fVt;
97 fPolarTheta = p.fPolarTheta;
98 fPolarPhi = p.fPolarPhi;
99 fParticlePDG = p.fParticlePDG;
78022019 100
a73f33f0 101}
102
103//____________________________________________________________________________
a73f33f0 104Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
105{
106 // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
107 // Compute the closest distance of approach from point px,py to this marker.
108 // The distance is computed in pixels units.
109
110 Double_t kRADDEG = 180. / TMath::Pi() ;
111 Coord_t x = Phi() * kRADDEG ;
112 Coord_t y = Theta() * kRADDEG ;
113 const Int_t kMaxDiff = 10;
114 Int_t pxm = gPad->XtoAbsPixel(x);
115 Int_t pym = gPad->YtoAbsPixel(y);
116 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
117
118 if (dist > kMaxDiff) return 9999;
119 return dist;
120}
121
122//___________________________________________________________________________
123 void AliPHOSFastRecParticle::Draw(Option_t *option)
124 {
125 // Draw this AliPHOSFastRecParticle with its current attributes
126
127 AppendPad(option);
128 }
129
130//______________________________________________________________________________
131void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py)
132{
133 // Execute action corresponding to one event
134 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
794c2bc3 135
a73f33f0 136 if (!gPad->IsEditable())
137 return ;
794c2bc3 138
a73f33f0 139 static TPaveText * clustertext = 0 ;
794c2bc3 140
a73f33f0 141 switch (event) {
142
143 case kButton1Down: {
144 Double_t kRADDEG = 180. / TMath::Pi() ;
145 Coord_t x = Phi() * kRADDEG ;
146 Coord_t y = Theta() * kRADDEG ;
147 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
148 Text_t line1[40] ;
149 Text_t line2[40] ;
150 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
151 sprintf( line2, "ENERGY: %f ", Energy() ) ;
152 clustertext ->AddText(line1) ;
153 clustertext ->AddText(line2) ;
154 clustertext ->Draw("");
155 gPad->Update() ;
156 break ;
157 }
158
159 case kButton1Up: {
160 delete clustertext ;
161 clustertext = 0 ;
162 gPad->Update() ;
a4e98857 163 break ;
a73f33f0 164 }
a73f33f0 165 }
794c2bc3 166
a73f33f0 167}
794c2bc3 168
b2a60966 169//____________________________________________________________________________
3f6cb8ae 170Bool_t AliPHOSFastRecParticle::IsPhoton(const char* purity) const
171{
172 // Rec.Particle is a photon if it has a photon-like shape, fast and neutral
173 // photon-like shape is defined with a purity "low", "medium" or "high"
174
175 Bool_t photonLike = kFALSE;
084903f1 176 if (strcmp(purity,"low") ==0) photonLike = TestPIDBit(6);
177 else if (strcmp(purity,"medium")==0) photonLike = TestPIDBit(7);
178 else if (strcmp(purity,"high") ==0) photonLike = TestPIDBit(8);
179 else Error("IsPhoton","Wrong purity type: \'%s\'",purity);
3f6cb8ae 180 if (photonLike && // photon by PCA
181 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
182 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))) // neutral by CPV
183 return kTRUE ;
184 else
185 return kFALSE;
186}
187
188//____________________________________________________________________________
189Bool_t AliPHOSFastRecParticle::IsPi0(const char* purity) const
190{
191 // Rec.Particle is a pi0 if it has a pi0-like shape, fast and neutral
192 // pi0-like shape is defined with a purity "low", "medium" or "high"
193
194 Bool_t pi0Like = kFALSE;
084903f1 195 if (strcmp(purity,"low") ==0) pi0Like = TestPIDBit(9);
196 else if (strcmp(purity,"medium")==0) pi0Like = TestPIDBit(10);
197 else if (strcmp(purity,"high") ==0) pi0Like = TestPIDBit(11);
3f6cb8ae 198 else Error("IsPi0","Wrong purity type: %s",purity);
199 if (pi0Like && // pi0 by PCA
200 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
201 (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))) // neutral by CPV
202 return kTRUE ;
203 else
204 return kFALSE;
205}
206
207//____________________________________________________________________________
208Bool_t AliPHOSFastRecParticle::IsElectron(const char* purity) const
209{
210 // Rec.Particle is an electron if it has a photon-like shape, fast and charged
211 // photon-like shape is defined with a purity "low", "medium" or "high"
212
213 Bool_t photonLike = kFALSE;
084903f1 214 if (strcmp(purity,"low") ==0) photonLike = TestPIDBit(6);
215 else if (strcmp(purity,"medium")==0) photonLike = TestPIDBit(7);
216 else if (strcmp(purity,"high") ==0) photonLike = TestPIDBit(8);
3f6cb8ae 217 else Error("IsElectron","Wrong purity type: %s",purity);
218 if (photonLike && // photon by PCA
219 (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& // fast by TOF
220 !(TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0))) // charged by CPV
221 return kTRUE ;
222 else
223 return kFALSE;
224}
225
226//____________________________________________________________________________
227Bool_t AliPHOSFastRecParticle::IsHadron() const
228{
229 // Rec.Particle is an hadron if it does not look like
230 // a low-purity photon nor low-purity pi0
231
232 if ( !TestPIDBit(6) && !TestPIDBit(9) ) // not photon nor pi0
233 return kTRUE ;
234 else
235 return kFALSE;
236}
237
238//____________________________________________________________________________
239Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
240{
241 // Rec.Particle is a charged hadron if it does not look like
242 // a low-purity photon nor low-purity pi0 and is low-purity charged
243
244 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
245 !TestPIDBit(2)) // charged by CPV
246 return kTRUE ;
247 else
248 return kFALSE;
249}
250
251//____________________________________________________________________________
252Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
253{
254 // Rec.Particle is a neutral hadron if it does not look like
255 // a low-purity photon nor low-purity pi0 and is high-purity neutral
256
257 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
258 TestPIDBit(2)) // neutral by CPV
259 return kTRUE ;
260 else
261 return kFALSE;
262}
263
264//____________________________________________________________________________
265Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
266{
267 // Rec.Particle is a fast charged hadron if it does not look like
268 // a low-purity photon nor low-purity pi0, is low-purity charged
269 // and is high-purity fast
270
271 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
272 !TestPIDBit(2) && // charged by CPV
273 TestPIDBit(5)) // fast by TOF
274 return kTRUE ;
275 else
276 return kFALSE;
277}
278
279//____________________________________________________________________________
280Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
281{
282 // Rec.Particle is a slow neutral hadron if it does not look like
283 // a low-purity photon nor low-purity pi0, is high-purity neutral
284 // and is not high-purity fast
285
286 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
287 !TestPIDBit(2) && // charged by CPV
288 !TestPIDBit(5)) // slow by TOF
289 return kTRUE ;
290 else
291 return kFALSE;
292
293}
294
295//____________________________________________________________________________
296Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
297{
298 // Rec.Particle is a fast neutral hadron if it does not look like
299 // a low-purity photon nor low-purity pi0, is high-purity neutral
300 // and is high-purity fast
301
302 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
303 TestPIDBit(2) && // neutral by CPV
304 TestPIDBit(5)) // fast by TOF
305 return kTRUE ;
306 else
307 return kFALSE;
308}
309
310//____________________________________________________________________________
311Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
312{
313 // Rec.Particle is a slow neutral hadron if it does not look like
314 // a low-purity photon nor low-purity pi0, is high-purity neutral
315 // and is not high-purity fast
316
317 if ( !TestPIDBit(6) && !TestPIDBit(9) && // not photon nor pi0
318 TestPIDBit(2) && // neutral by CPV
319 !TestPIDBit(5)) // slow by TOF
320 return kTRUE ;
321 else
322 return kFALSE;
323}
324
325//____________________________________________________________________________
326TString AliPHOSFastRecParticle::Name() const
a73f33f0 327{
794c2bc3 328 // Returns the name of the particle type (only valid if PIDv1 is employed)
a73f33f0 329
794c2bc3 330 TString name ;
3f6cb8ae 331
332 name = "Undefined particle" ;
794c2bc3 333
3f6cb8ae 334 if (IsPhoton("low"))
335 name = "Photon low purity ";
336 else if (IsPhoton("medium"))
337 name = "Photon medium purity";
338 else if (IsPhoton("high"))
339 name = "Photon high purity ";
340
341 if (IsPi0("low"))
342 name += "Pi0 low purity ";
343 else if (IsPi0("medium"))
344 name += "Pi0 medium purity ";
345 else if (IsPi0("high"))
346 name += "Pi0 high purity ";
347
348 if (IsElectron("low"))
349 name += "Electron low purity ";
350 else if (IsElectron("medium"))
351 name += "Electron medium purity ";
352 else if (IsElectron("high"))
353 name += "Electron high purity ";
354
355 if (IsHadron()) {
356 name = "hadron";
357 if (IsChargedHadron()) {
358 name.Prepend("charged ");
359 if (IsFastChargedHadron())
360 name.Prepend("fast ");
361 else if (IsSlowChargedHadron())
362 name.Prepend("slow ");
363 }
364 else if (IsNeutralHadron()) {
365 name.Prepend("neutral ");
366 if (IsFastNeutralHadron())
367 name.Prepend("fast ");
368 else if (IsSlowNeutralHadron())
369 name.Prepend("slow ");
370 }
371 }
372
a73f33f0 373 return name ;
374}
375
14f6a871 376
377//______________________________________________________________________________
378void AliPHOSFastRecParticle::SetType(Int_t type) {
379 // sets the particle type
3f6cb8ae 380 // bit-mask of the particle type means the following:
381 // bits 0,1,2 - neutral particle with low, medium and high purity
382 // bits 3.4,5 - fast particle with low, medium and high purity
383 // bits 6.7,8 - photon shower with low, medium and high purity
384 // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
385
14f6a871 386 fType = type ;
387
388 if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
389 fPdgCode = 22 ;
390 return ;
391 }
392
393 if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
394 fPdgCode = 2112 ;
395 return ;
396 }
397 if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
398 fPdgCode = 11 ;
399 return ;
400 }
401 if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
402 fPdgCode = 13 ;
403 return ;
404 }
405 if((fType == 56)||(fType == 57)){
406 fPdgCode = 211 ;
407 return ;
408 }
409 if (fType == 0){
410 fPdgCode = 2212 ;
411 return ;
412 }
413
414}
415
a73f33f0 416//______________________________________________________________________________
417void AliPHOSFastRecParticle::Paint(Option_t *)
418{
b2a60966 419 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
a73f33f0 420
421 Double_t kRADDEG = 180. / TMath::Pi() ;
b2a60966 422 Coord_t x = Phi() * kRADDEG ;
423 Coord_t y = Theta() * kRADDEG ;
424 Color_t markercolor = 1 ;
425 Size_t markersize = 1. ;
426 Style_t markerstyle = 5 ;
427
428 if (!gPad->IsBatch()) {
429 gVirtualX->SetMarkerColor(markercolor) ;
430 gVirtualX->SetMarkerSize (markersize) ;
431 gVirtualX->SetMarkerStyle(markerstyle) ;
432 }
433 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
434 gPad->PaintPolyMarker(1,&x,&y,"") ;
a73f33f0 435}
436
437//____________________________________________________________________________
14f6a871 438void AliPHOSFastRecParticle::Print(Option_t * opt)const
a73f33f0 439{
a4e98857 440 // Print the type, energy and momentum of the reconstructed particle
3f6cb8ae 441
21cd0c07 442 TString message ;
3f6cb8ae 443 message = "\n PID bits are %d%d%d %d%d%d %d%d%d %d%d%d" ;
444 message += ", type is \"%s\"\n" ;
445 message += " (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n" ;
21cd0c07 446 Info("Print", message.Data(),
3f6cb8ae 447 TestPIDBit(0),TestPIDBit(1),
448 TestPIDBit(2),TestPIDBit(3),
449 TestPIDBit(4),TestPIDBit(5),
450 TestPIDBit(6),TestPIDBit(7),
451 TestPIDBit(8),TestPIDBit(9),
452 TestPIDBit(10),TestPIDBit(11),
21cd0c07 453 Name().Data(),
53ad38d8 454 Energy(),
455 Px(),
456 Py(),
457 Pz() );
a73f33f0 458}