AliRoot Core  ee782a0 (ee782a0)
AliAODMCParticle.h
Go to the documentation of this file.
1 #ifndef AliAODMCPARTICLE_H
2 #define AliAODMCPARTICLE_H
3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice */
5 
6 
13 
14 #include <Rtypes.h>
15 #include <TParticlePDG.h>
16 #include <TExMap.h>
17 #include <TString.h>
18 
19 
20 #include "AliTrackReference.h"
21 #include "AliVParticle.h"
22 #include "AliMCParticle.h"
23 
24 class AliAODEvent;
25 class TParticle;
26 class TClonesArray;
27 
29  public:
31  AliAODMCParticle(const AliMCParticle* part, Int_t label=0,Int_t flag = 0);
32  virtual ~AliAODMCParticle(){};
33  AliAODMCParticle(const AliAODMCParticle& mcPart);
35 
36  // Kinematics
37  virtual Double_t Px() const;
38  virtual Double_t Py() const;
39  virtual Double_t Pz() const;
40  virtual Double_t Pt() const;
41  virtual Double_t P() const;
42  virtual Bool_t PxPyPz(Double_t p[3]) const;
43 
44  virtual void Momentum(TLorentzVector & lv) { lv.SetPxPyPzE(Px(),Py(),Pz(),E()) ; }
45 
46  virtual Double_t OneOverPt() const;
47  virtual Double_t Phi() const;
48  virtual Double_t Theta() const;
49 
50  virtual Double_t Xv() const;
51  virtual Double_t Yv() const;
52  virtual Double_t Zv() const;
53  virtual Bool_t XvYvZv(Double_t x[3]) const;
54  virtual Double_t T() const;
55  virtual Double_t Tv() const;
56 
57  virtual Double_t E() const;
58  virtual Double_t M() const;
59 
60  virtual Double_t Eta() const;
61  virtual Double_t Y() const;
62 
63  virtual Short_t Charge() const;
64 
65  virtual Int_t Label() const;
66  virtual Int_t GetLabel() const {return Label();}
67 
68  // PID
69  virtual const Double_t *PID() const {return 0;} // return PID object (to be defined, still)
70 
71  //
72  virtual Double_t GetCalcMass() const;
73  virtual void SetDaughter(Int_t i,Int_t id){if(i<2)fDaughter[i] = id;}
74  virtual Int_t GetDaughter(Int_t i) const {if(i<2)return fDaughter[i];else return -1;}
75  virtual Int_t GetDaughterLabel(Int_t i) const { return GetDaughter(i); }
76  virtual Int_t GetNDaughters () const { return fDaughter[1]>0 ? fDaughter[1]-fDaughter[0]+1 : (fDaughter[0]>0 ? 1:0 ) ;}
77  virtual void SetMother(Int_t im){fMother = im;}
78  virtual Int_t GetMother() const {return fMother;}
79 
80  virtual Int_t GetFirstDaughter() const {return fDaughter[0];}
81  virtual Int_t GetLastDaughter() const {return fDaughter[1];}
82 
83  virtual void Print(const Option_t *opt = "") const;
84  virtual Int_t GetPdgCode() const { return fPdgCode;}
85  virtual Int_t PdgCode() const { return GetPdgCode();}
86  virtual void SetGeneratorIndex(Short_t i) {fGeneratorIndex = i;}
87  virtual Short_t GetGeneratorIndex() const {return fGeneratorIndex;}
88  enum { kPrimary = 1<<0, kPhysicalPrim = 1<<1, kSecondaryFromWeakDecay = 1<<2, kSecondaryFromMaterial = 1 <<3}; // use only the first 8bits!
89  virtual void SetFlag(UInt_t flag){fFlag = flag;} // carefull flag encodes three different types of information
90  virtual UInt_t GetFlag() const {return fFlag;}
91 
92 
93  // for the status we use the upper 16 bits/2 bytes of the flag word
94  void SetStatus(Int_t status){
95  if(status<0)return; // a TParticle can have a negative status, catch this here and do nothing
96  fFlag &= 0xffff; // reset the upper bins keep the lower bins
97  fFlag |= (((UInt_t)status)<<16); // bit shift by 16
98  }
99 
100  virtual ULong64_t GetStatus() const {
102 
103  return ULong64_t(fFlag>>16);
104  }
105 
106  void SetMCStatusCode(Int_t status) { SetStatus(status) ; }
107  virtual UInt_t MCStatusCode() const { return GetStatus() ; }
108 
109  // Bitwise operations
110  void SetPrimary(Bool_t b = kTRUE){
111  if(b)fFlag |= kPrimary;
112  else fFlag &= ~kPrimary;
113  }
114  virtual Bool_t IsPrimary() const {return ((fFlag&kPrimary)==kPrimary);}
115 
116  void SetPhysicalPrimary(Bool_t b = kTRUE){
117  if(b)fFlag |= kPhysicalPrim;
118  else fFlag &= ~kPhysicalPrim;
119  }
120  Bool_t IsPhysicalPrimary() const {return ((fFlag&kPhysicalPrim)==kPhysicalPrim);}
121 
122  void SetSecondaryFromWeakDecay(Bool_t b = kTRUE){
124  else fFlag &= ~kSecondaryFromWeakDecay;
125  }
126  Bool_t IsSecondaryFromWeakDecay() const {return ((fFlag&kSecondaryFromWeakDecay)==kSecondaryFromWeakDecay);}
127 
128  void SetSecondaryFromMaterial(Bool_t b = kTRUE){
130  else fFlag &= ~kSecondaryFromMaterial;
131  }
132  Bool_t IsSecondaryFromMaterial() const {return ((fFlag&kSecondaryFromMaterial)==kSecondaryFromMaterial);}
133 
134 
135  void SetMCProcessCode(UInt_t mcProcess){
136  if(mcProcess>1<<7)return; // should not be larger than 46 (see TMCProcess) allow up to 128
137  fFlag &= 0xffff00ff; // keep the upper bins and the lower bins just reset 9-16
138  fFlag |= (mcProcess<<8); // bit shift by 8
139  }
140 
142  return ((fFlag&0xff00)>>8); // just return bit shifted bits 9-16
143  }
144 
145 
146 
147 
148 
149  static const char* StdBranchName(){return fgkStdBranchName.Data();}
150 
151  private:
152 
153  static TString fgkStdBranchName;
154 
155 
156  Int_t fPdgCode;
157  UInt_t fFlag;
158  Int_t fLabel;
159  Int_t fMother;
160  Int_t fDaughter[2];
161  Double32_t fPx;
162  Double32_t fPy;
163  Double32_t fPz;
164  Double32_t fE;
165 
167  Double32_t fVx; //[0.,0.,12]
169  Double32_t fVy; //[0.,0.,12]
171  Double32_t fVz; //[0.,0.,12]
173  Double32_t fVt; //[0.,0.,12]
174  Short_t fGeneratorIndex;
175  // Copy the uniquID to another data member? unique ID is correctly handled
176  // via TOBject Copy construct but not by AliVParticle ctor (no passing of
177  // TParticles
178  // Need a flag for primaries?
179 
180  /*
181  const TMCProcess kMCprocesses[kMaxMCProcess] =
182  {
183  kPNoProcess, kPMultipleScattering, kPEnergyLoss, kPMagneticFieldL,
184  kPDecay, kPPair, kPCompton, kPPhotoelectric, kPBrem, kPDeltaRay,
185  kPAnnihilation, kPHadronic, kPNoProcess, kPEvaporation, kPNuclearFission,
186  kPNuclearAbsorption, kPPbarAnnihilation, kPNCapture, kPHElastic,
187  kPHInhelastic, kPMuonNuclear, kPTOFlimit,kPPhotoFission, kPNoProcess,
188  kPRayleigh, kPNoProcess, kPNoProcess, kPNoProcess, kPNull, kPStop
189  };
190  */
191 
192  ClassDef(AliAODMCParticle,9) // AliVParticle realisation for AODMCParticles
193 
194 };
195 
196 inline Double_t AliAODMCParticle::Px() const {return fPx;}
197 inline Double_t AliAODMCParticle::Py() const {return fPy;}
198 inline Double_t AliAODMCParticle::Pz() const {return fPz;}
199 inline Double_t AliAODMCParticle::Pt() const {return TMath::Sqrt(fPx*fPx+fPy*fPy);}
200 inline Double_t AliAODMCParticle::P() const {return TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz); }
201 inline Double_t AliAODMCParticle::OneOverPt() const {return 1. / Pt();}
202 inline Bool_t AliAODMCParticle::PxPyPz(Double_t p[3]) const { p[0] = fPx; p[1] = fPy; p[2] = fPz; return kTRUE; }
203 inline Double_t AliAODMCParticle::Phi() const {return TMath::Pi()+TMath::ATan2(-fPy,-fPx); } // note that Phi() returns an angle between 0 and 2pi
204 inline Double_t AliAODMCParticle::Theta() const {return (fPz==0)?TMath::PiOver2():TMath::ACos(fPz/P()); }
205 inline Double_t AliAODMCParticle::Xv() const {return fVx;}
206 inline Double_t AliAODMCParticle::Yv() const {return fVy;}
207 inline Double_t AliAODMCParticle::Zv() const {return fVz;}
208 inline Bool_t AliAODMCParticle::XvYvZv(Double_t x[3]) const { x[0] = fVx; x[1] = fVy; x[2] = fVz; return kTRUE; }
209 inline Double_t AliAODMCParticle::T() const {return fVt;}
210 inline Double_t AliAODMCParticle::Tv() const {return fVt;}
211 inline Double_t AliAODMCParticle::E() const {return fE;}
212 inline Double_t AliAODMCParticle::Eta() const {
213  Double_t pmom = P();
214  if (pmom != TMath::Abs(fPz)) return 0.5*TMath::Log((pmom+fPz)/(pmom-fPz));
215  else return 1.e30;
216 }
217 
218 
219 inline Double_t AliAODMCParticle::Y() const
220 {
221  Double_t e = E();
222  Double_t pz = Pz();
223 
224  if (e > TMath::Abs(pz)) {
225  return 0.5*TMath::Log((e+pz)/(e-pz));
226  } else {
227  return -999.;
228  }
229 }
230 
231 inline Int_t AliAODMCParticle::Label() const {return fLabel;}
232 
233 inline Double_t AliAODMCParticle::GetCalcMass() const {
234 
235  Double_t m2 = E()*E()-Px()*Px()-Py()*Py()-Pz()*Pz();
236  if(m2<0)return 0;
237  return TMath::Sqrt(m2);
238 }
239 
240 
241 #endif
TBrowser b
Definition: RunAnaESD.C:12
virtual Int_t GetMother() const
static TString fgkStdBranchName
Standard branch name.
virtual Double_t P() const
virtual Double_t M() const
Double32_t fPx
x component of momentum
Double32_t fE
Energy.
Int_t fPdgCode
PDG code of the particle.
virtual const Double_t * PID() const
virtual Double_t Yv() const
virtual Double_t E() const
Bool_t IsPhysicalPrimary() const
virtual void Print(const Option_t *opt="") const
Double32_t fPy
y component of momentum
virtual UInt_t MCStatusCode() const
virtual Double_t Zv() const
Double32_t fVz
z of production vertex
virtual Double_t Px() const
virtual Double_t Pz() const
virtual Int_t GetFirstDaughter() const
void SetMCProcessCode(UInt_t mcProcess)
Float_t p[]
Definition: kNNTest.C:133
virtual Int_t GetLabel() const
virtual Bool_t PxPyPz(Double_t p[3]) const
virtual Double_t T() const
static const char * StdBranchName()
Double32_t fPz
z component of momentum
virtual void SetFlag(UInt_t flag)
AliVParticle realisation for MC Particles in the AOD.
virtual Int_t GetDaughter(Int_t i) const
virtual Double_t Theta() const
virtual UInt_t GetFlag() const
Double32_t fVy
y of production vertex
Double32_t fVt
t of production vertex
virtual Int_t GetDaughterLabel(Int_t i) const
void SetMCStatusCode(Int_t status)
Int_t fDaughter[2]
Indices of the daughter particles.
void SetSecondaryFromMaterial(Bool_t b=kTRUE)
virtual Double_t Tv() const
virtual Double_t Eta() const
virtual Short_t GetGeneratorIndex() const
virtual void SetMother(Int_t im)
virtual Double_t Pt() const
virtual Int_t PdgCode() const
UInt_t fFlag
Flag for indication of primary etc, Status code in the upper 16 bits 17-32, MC process id (AKA Unique...
void SetPrimary(Bool_t b=kTRUE)
Int_t fMother
Index of the mother particles.
virtual Int_t GetLastDaughter() const
void SetStatus(Int_t status)
virtual ULong64_t GetStatus() const
Short_t fGeneratorIndex
! Index of generator in cocktail
AOD base class.
Definition: AliAODEvent.h:48
virtual Double_t OneOverPt() const
virtual void SetDaughter(Int_t i, Int_t id)
virtual Bool_t IsPrimary() const
virtual Bool_t XvYvZv(Double_t x[3]) const
AliAODMCParticle & operator=(const AliAODMCParticle &mcPart)
Double32_t fVx
x of production vertex
virtual Double_t Phi() const
virtual Int_t GetNDaughters() const
virtual Double_t Py() const
virtual Int_t GetPdgCode() const
Bool_t IsSecondaryFromWeakDecay() const
Int_t fLabel
Label of the original MCParticle.
virtual ~AliAODMCParticle()
virtual void Momentum(TLorentzVector &lv)
virtual void SetGeneratorIndex(Short_t i)
virtual Int_t Label() const
Bool_t IsSecondaryFromMaterial() const
virtual Short_t Charge() const
virtual Double_t Xv() const
virtual Double_t Y() const
void SetPhysicalPrimary(Bool_t b=kTRUE)
virtual Double_t GetCalcMass() const
void SetSecondaryFromWeakDecay(Bool_t b=kTRUE)