]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODMCParticle.cxx
ATO-98 - default streamer TFile::Open , const char * option="update"
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODMCParticle.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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
16
17 //-------------------------------------------------------------------------
18 //     Realisation of AliVParticle for MC Particles
19 //     Basically a stripped down AliMCParicle / TParticle
20 //     with minimum information on MC tracks
21 //     Author: Christian Klein-Bösing, CERN
22 //-------------------------------------------------------------------------
23
24
25 #include "AliAODMCParticle.h"
26 #include "AliAODEvent.h"
27
28 #include "TDatabasePDG.h"
29 #include "TParticle.h"
30 #include "TClonesArray.h"
31
32
33 ClassImp(AliAODMCParticle)
34
35 TString AliAODMCParticle::fgkStdBranchName("mcparticles");
36
37 AliAODMCParticle::AliAODMCParticle():
38 AliVParticle(),
39   fPdgCode(0),
40   fFlag(0),
41   fLabel(0),
42   fMother(0),
43   fPx(0),
44   fPy(0),
45   fPz(0),
46   fE(0),
47   fVx(0),
48   fVy(0),
49   fVz(0),
50   fVt(0),
51   fGeneratorIndex(-1)
52 {
53   // Default Constructor
54   fDaughter[0] =   fDaughter[1] = 0;
55 }
56
57     
58 AliAODMCParticle::AliAODMCParticle(const AliMCParticle* mcpart, Int_t label,Int_t flag):
59     AliVParticle(*mcpart),
60     fPdgCode(mcpart->Particle()->GetPdgCode()),
61     fFlag(flag),
62     fLabel(label),
63     fMother(mcpart->GetMother()),
64     fPx(mcpart->Particle()->Px()),
65     fPy(mcpart->Particle()->Py()),
66     fPz(mcpart->Particle()->Pz()),
67     fE(mcpart->Particle()->Energy()),
68     fVx(mcpart->Particle()->Vx()),
69     fVy(mcpart->Particle()->Vy()),
70     fVz(mcpart->Particle()->Vz()),
71     fVt(mcpart->Particle()->T()),
72     fGeneratorIndex(mcpart->GetGeneratorIndex())
73 {
74     // Constructor
75   fDaughter[0] =  mcpart->GetFirstDaughter(); 
76   fDaughter[1] =  mcpart->GetLastDaughter();
77 }
78     
79     
80 AliAODMCParticle::AliAODMCParticle(const AliAODMCParticle& mcPart) :
81     AliVParticle(mcPart),
82     fPdgCode(mcPart.fPdgCode),
83     fFlag(mcPart.fFlag),
84     fLabel(mcPart.fLabel),
85     fMother(mcPart.fMother),
86     fPx(mcPart.fPx),
87     fPy(mcPart.fPy),
88     fPz(mcPart.fPz),
89     fE(mcPart.fE),
90     fVx(mcPart.fVx),
91     fVy(mcPart.fVy),
92     fVz(mcPart.fVz),
93     fVt(mcPart.fVt),
94     fGeneratorIndex(-1)
95 {
96   // Copy constructor
97   fDaughter[0] = mcPart.fDaughter[0]; 
98   fDaughter[1] = mcPart.fDaughter[1]; 
99 }
100
101 AliAODMCParticle& AliAODMCParticle::operator=(const AliAODMCParticle& mcPart)
102
103   //
104   // assignment operator
105   //
106   if (this!=&mcPart) { 
107     AliVParticle::operator=(mcPart);
108     fPdgCode    = mcPart.fPdgCode;
109     fFlag       = mcPart.fFlag;
110     fLabel      = mcPart.fLabel;
111     fMother     = mcPart.fMother;
112     fPx         = mcPart.fPx;
113     fPy         = mcPart.fPy;
114     fPz         = mcPart.fPz;
115     fE          = mcPart.fE;
116     fVx         = mcPart.fVx;
117     fVy         = mcPart.fVy;
118     fVz         = mcPart.fVz;
119     fVt         = mcPart.fVt;
120     fGeneratorIndex = mcPart.fGeneratorIndex;
121     fDaughter[0] = mcPart.fDaughter[0]; 
122     fDaughter[1] = mcPart.fDaughter[1]; 
123   }  
124   
125   return *this;
126
127 }
128
129 Double_t AliAODMCParticle::M()         const
130 {
131   //
132   // return the mass 
133   //
134     TParticlePDG* pdg =  TDatabasePDG::Instance()->GetParticle(fPdgCode);
135     if (pdg) {
136         return (pdg->Mass());
137     } else {
138         return GetCalcMass();
139     }
140 }
141
142
143 Short_t AliAODMCParticle::Charge()     const
144 {
145   //
146   // return tha charge
147   //
148     TParticlePDG* pdg =  TDatabasePDG::Instance()->GetParticle(fPdgCode);
149     if (pdg) {
150         return (Short_t (pdg->Charge()));
151     } else {
152         return -99;
153     }
154 }
155
156 void AliAODMCParticle::Print(const Option_t */*opt*/) const {
157 // Print particle information
158   if(TDatabasePDG::Instance()->GetParticle(fPdgCode)){
159     Printf(">>> PDG (%d) : %s",fPdgCode,TDatabasePDG::Instance()->GetParticle(fPdgCode)->GetName());
160   }
161   else{
162     Printf(">>> PDG (%d) : %s",fPdgCode,"Unknown");
163   }
164   Printf(">>  P(%3.3f,%3.3f,%3.3f) V((%3.3f,%3.3f,%3.3f,%3.3f)",fPx,fPy,fPz,fVx,fVy,fVz,fVt);  
165   Printf(">   Mother %d, First Daughter %d Last Daughter %d , Status %d, PhysicalPrimary %d",
166          fMother,fDaughter[0],fDaughter[1],GetStatus(),
167          IsPhysicalPrimary());
168 }