]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODMCParticle.cxx
Bug fix. Removed delete statement
[u/mrichter/AliRoot.git] / STEER / 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 {
51   // Default Constructor
52   fDaughter[0] =   fDaughter[1] = 0;
53 }
54
55     
56 AliAODMCParticle::AliAODMCParticle(TParticle* part, Int_t label,Int_t flag):
57     AliVParticle(),
58     fPdgCode(part->GetPdgCode()),
59     fFlag(flag),
60     fLabel(label),
61     fMother(part->GetMother(0)),
62     fPx(part->Px()),
63     fPy(part->Py()),
64     fPz(part->Pz()),
65     fE(part->Energy()),
66     fVx(part->Vx()),
67     fVy(part->Vy()),
68     fVz(part->Vz())
69 {
70   fDaughter[0] =  part->GetDaughter(0); 
71   fDaughter[1] =  part->GetDaughter(1);
72   // Set unique id
73   TObject::SetUniqueID(part->GetUniqueID());
74 }
75     
76     
77 AliAODMCParticle::AliAODMCParticle(const AliAODMCParticle& mcPart) :
78     AliVParticle(mcPart),
79     fPdgCode(mcPart.fPdgCode),
80     fFlag(mcPart.fFlag),
81     fLabel(mcPart.fLabel),
82     fMother(mcPart.fMother),
83     fPx(mcPart.fPx),
84     fPy(mcPart.fPy),
85     fPz(mcPart.fPz),
86     fE(mcPart.fE),
87     fVx(mcPart.fVx),
88     fVy(mcPart.fVy),
89     fVz(mcPart.fVz)
90 {
91   // Copy constructor
92   fDaughter[0] = mcPart.fDaughter[0]; 
93   fDaughter[1] = mcPart.fDaughter[1]; 
94
95 }
96
97 AliAODMCParticle& AliAODMCParticle::operator=(const AliAODMCParticle& mcPart)
98
99
100   if (this!=&mcPart) { 
101     AliVParticle::operator=(mcPart);
102     fPdgCode    = mcPart.fPdgCode;
103     fFlag       = mcPart.fFlag;
104     fLabel      = mcPart.fLabel;
105     fMother     = mcPart.fMother;
106     fPx         = mcPart.fPx;
107     fPy         = mcPart.fPy;
108     fPz         = mcPart.fPz;
109     fE          = mcPart.fE;
110     fVx         = mcPart.fVx;
111     fVy         = mcPart.fVy;
112     fVz         = mcPart.fVz;
113     fDaughter[0] = mcPart.fDaughter[0]; 
114     fDaughter[1] = mcPart.fDaughter[1]; 
115   }  
116   
117   return *this;
118
119 }
120
121 Double_t AliAODMCParticle::M()         const
122 {
123     TParticlePDG* pdg =  TDatabasePDG::Instance()->GetParticle(fPdgCode);
124     if (pdg) {
125         return (pdg->Mass());
126     } else {
127         return GetCalcMass();
128     }
129 }
130
131
132 Short_t AliAODMCParticle::Charge()     const
133 {
134     TParticlePDG* pdg =  TDatabasePDG::Instance()->GetParticle(fPdgCode);
135     if (pdg) {
136         return (Short_t (pdg->Charge()));
137     } else {
138         return -99;
139     }
140 }
141
142 void AliAODMCParticle::Print(const Option_t */*opt*/) const {
143   if(TDatabasePDG::Instance()->GetParticle(fPdgCode)){
144     Printf(">>> PDG (%d) : %s",fPdgCode,TDatabasePDG::Instance()->GetParticle(fPdgCode)->GetName());
145   }
146   else{
147     Printf(">>> PDG (%d) : %s",fPdgCode,"Unknown");
148   }
149   Printf(">>  P(%3.3f,%3.3f,%3.3f) V((%3.3f,%3.3f,%3.3f)",fPx,fPy,fPz,fVx,fVy,fVz);  
150   Printf(">   Mother %d, First Daughter %d Last Daughter %d Process %d",fMother,fDaughter[0],fDaughter[1],TObject::GetUniqueID());
151 }