]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODMCParticle.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[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 {
52   // Default Constructor
53   fDaughter[0] =   fDaughter[1] = 0;
54 }
55
56     
57 AliAODMCParticle::AliAODMCParticle(const AliMCParticle* mcpart, Int_t label,Int_t flag):
58     AliVParticle(*mcpart),
59     fPdgCode(mcpart->Particle()->GetPdgCode()),
60     fFlag(flag),
61     fLabel(label),
62     fMother(mcpart->GetMother()),
63     fPx(mcpart->Particle()->Px()),
64     fPy(mcpart->Particle()->Py()),
65     fPz(mcpart->Particle()->Pz()),
66     fE(mcpart->Particle()->Energy()),
67     fVx(mcpart->Particle()->Vx()),
68     fVy(mcpart->Particle()->Vy()),
69     fVz(mcpart->Particle()->Vz()),
70     fVt(mcpart->Particle()->T())
71 {
72     // Constructor
73   fDaughter[0] =  mcpart->GetFirstDaughter(); 
74   fDaughter[1] =  mcpart->GetLastDaughter();
75 }
76     
77     
78 AliAODMCParticle::AliAODMCParticle(const AliAODMCParticle& mcPart) :
79     AliVParticle(mcPart),
80     fPdgCode(mcPart.fPdgCode),
81     fFlag(mcPart.fFlag),
82     fLabel(mcPart.fLabel),
83     fMother(mcPart.fMother),
84     fPx(mcPart.fPx),
85     fPy(mcPart.fPy),
86     fPz(mcPart.fPz),
87     fE(mcPart.fE),
88     fVx(mcPart.fVx),
89     fVy(mcPart.fVy),
90     fVz(mcPart.fVz),
91     fVt(mcPart.fVt)
92 {
93   // Copy constructor
94   fDaughter[0] = mcPart.fDaughter[0]; 
95   fDaughter[1] = mcPart.fDaughter[1]; 
96 }
97
98 AliAODMCParticle& AliAODMCParticle::operator=(const AliAODMCParticle& mcPart)
99
100   //
101   // assignment operator
102   //
103   if (this!=&mcPart) { 
104     AliVParticle::operator=(mcPart);
105     fPdgCode    = mcPart.fPdgCode;
106     fFlag       = mcPart.fFlag;
107     fLabel      = mcPart.fLabel;
108     fMother     = mcPart.fMother;
109     fPx         = mcPart.fPx;
110     fPy         = mcPart.fPy;
111     fPz         = mcPart.fPz;
112     fE          = mcPart.fE;
113     fVx         = mcPart.fVx;
114     fVy         = mcPart.fVy;
115     fVz         = mcPart.fVz;
116     fVt         = mcPart.fVt;
117     fDaughter[0] = mcPart.fDaughter[0]; 
118     fDaughter[1] = mcPart.fDaughter[1]; 
119   }  
120   
121   return *this;
122
123 }
124
125 Double_t AliAODMCParticle::M()         const
126 {
127   //
128   // return the mass 
129   //
130     TParticlePDG* pdg =  TDatabasePDG::Instance()->GetParticle(fPdgCode);
131     if (pdg) {
132         return (pdg->Mass());
133     } else {
134         return GetCalcMass();
135     }
136 }
137
138
139 Short_t AliAODMCParticle::Charge()     const
140 {
141   //
142   // return tha charge
143   //
144     TParticlePDG* pdg =  TDatabasePDG::Instance()->GetParticle(fPdgCode);
145     if (pdg) {
146         return (Short_t (pdg->Charge()));
147     } else {
148         return -99;
149     }
150 }
151
152 void AliAODMCParticle::Print(const Option_t */*opt*/) const {
153 // Print particle information
154   if(TDatabasePDG::Instance()->GetParticle(fPdgCode)){
155     Printf(">>> PDG (%d) : %s",fPdgCode,TDatabasePDG::Instance()->GetParticle(fPdgCode)->GetName());
156   }
157   else{
158     Printf(">>> PDG (%d) : %s",fPdgCode,"Unknown");
159   }
160   Printf(">>  P(%3.3f,%3.3f,%3.3f) V((%3.3f,%3.3f,%3.3f,%3.3f)",fPx,fPy,fPz,fVx,fVy,fVz,fVt);  
161   Printf(">   Mother %d, First Daughter %d Last Daughter %d , Status %d, PhysicalPrimary %d",
162          fMother,fDaughter[0],fDaughter[1],GetStatus(),
163          IsPhysicalPrimary());
164 }