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