]>
Commit | Line | Data |
---|---|---|
dd2b6810 | 1 | #include "AliAOD.h" |
a5556ea5 | 2 | /************************************************************************** |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /* $Id$ */ | |
18 | ||
19 | ///////////////////////////////////////////////////////////// | |
20 | // | |
21 | // base class for AOD containers | |
22 | // | |
23 | ///////////////////////////////////////////////////////////// | |
24 | ||
7f03938c | 25 | #include <TROOT.h> |
a5556ea5 | 26 | #include <TParticle.h> |
dd2b6810 | 27 | #include <TClass.h> |
28 | #include <TString.h> | |
afa8b37b | 29 | #include "AliAODParticle.h" |
0d8a4589 | 30 | #include "AliTrackPoints.h" |
a5556ea5 | 31 | |
32 | ClassImp(AliAOD) | |
33 | ||
0d8a4589 | 34 | AliAOD::AliAOD(): |
dd2b6810 | 35 | fParticles(0x0), |
0d8a4589 | 36 | fIsRandomized(kFALSE), |
37 | fPrimaryVertexX(0.0), | |
38 | fPrimaryVertexY(0.0), | |
dd2b6810 | 39 | fPrimaryVertexZ(0.0), |
40 | fParticleClass(0x0) | |
0d8a4589 | 41 | { |
42 | //ctor | |
dd2b6810 | 43 | // Info("AliAOD()","Entered"); |
44 | // SetOwner(kTRUE); | |
45 | // Info("AliAOD()","Exited"); | |
46 | } | |
47 | /**************************************************************************/ | |
48 | ||
49 | AliAOD::~AliAOD() | |
50 | { | |
51 | //Destructor | |
52 | //fParticleClass does not belong to AliAOD -> Do not delete it | |
53 | delete fParticles; | |
54 | ||
55 | } | |
56 | /**************************************************************************/ | |
57 | ||
58 | void AliAOD::SetParticleClassName(const char* classname) | |
59 | { | |
60 | //Sets type of particle that is going to be stored | |
61 | if (gROOT == 0x0) Fatal("SetParticleClassName","ROOT System not initialized"); | |
62 | TClass* pclass = gROOT->GetClass(classname); | |
63 | if ( pclass == 0x0 ) | |
64 | { | |
65 | Error("SetParticleClass","Can not get TClass for class named %s",classname); | |
66 | return; | |
67 | } | |
68 | SetParticleClass(pclass); | |
69 | } | |
70 | /**************************************************************************/ | |
71 | ||
72 | void AliAOD::SetParticleClass(TClass* pclass) | |
73 | { | |
74 | //Sets type of particle that is going to be stored | |
75 | ||
76 | if ( pclass == 0x0 ) | |
77 | { | |
78 | Error("SetParticleClass","Parameter is NULL."); | |
79 | return; | |
80 | } | |
81 | ||
82 | if ( pclass->InheritsFrom("AliVAODParticle") == kFALSE ) | |
83 | { | |
84 | Error("SetParticleClass","Class named %s does not inherit from AliVAODParticle",pclass->GetName()); | |
85 | return; | |
86 | } | |
87 | if (pclass != fParticleClass) | |
88 | { | |
89 | fParticleClass = pclass; | |
90 | if (fParticleClass) delete fParticles; | |
91 | fParticles = new TClonesArray(fParticleClass); | |
92 | } | |
0d8a4589 | 93 | } |
94 | ||
a5556ea5 | 95 | /**************************************************************************/ |
96 | ||
97 | void AliAOD::AddParticle(TParticle* part, Int_t idx) | |
98 | { | |
99 | //Adds TParticle to event | |
100 | if (part == 0x0) | |
101 | { | |
102 | Error("AddParticle(TParticle*,Int_t)","pointer to particle is NULL"); | |
103 | return; | |
104 | } | |
dd2b6810 | 105 | |
106 | if (fParticles == 0x0) SetParticleClassName("AliAODParticle"); | |
afa8b37b | 107 | AddParticle( new AliAODParticle(*part,idx) ); |
a5556ea5 | 108 | } |
109 | /**************************************************************************/ | |
110 | ||
dd2b6810 | 111 | void AliAOD::AddParticle(AliVAODParticle* particle) |
112 | { | |
113 | //add particle to AOD | |
114 | //MAKES ITS OWN COPY OF THE PARTICLE!!! (AOD is not going to keep and delete input pointer) | |
115 | ||
116 | if (fParticles == 0x0) SetParticleClassName("AliAODParticle"); | |
117 | ||
118 | Int_t idx = fParticles->GetLast() + 1; | |
119 | TClonesArray& arr = *fParticles; | |
120 | ||
121 | AliVAODParticle* pp = (AliVAODParticle*)fParticleClass->New(arr[idx]); | |
122 | pp->operator=(*particle); | |
123 | ||
124 | } | |
125 | /**************************************************************************/ | |
126 | ||
a5556ea5 | 127 | void AliAOD::AddParticle(Int_t pdg, Int_t idx, |
128 | Double_t px, Double_t py, Double_t pz, Double_t etot, | |
129 | Double_t vx, Double_t vy, Double_t vz, Double_t time) | |
130 | { | |
dd2b6810 | 131 | //adds particle to event (standard AOD class) |
132 | ||
133 | if (fParticles == 0x0) SetParticleClassName("AliAODParticle"); | |
134 | ||
135 | Int_t newpartidx = fParticles->GetLast() + 1; | |
136 | TClonesArray& arr = *fParticles; | |
137 | ||
138 | AliVAODParticle* p = (AliVAODParticle*)fParticleClass->New(arr[newpartidx]); | |
139 | ||
140 | p->SetPdgCode(pdg); | |
141 | p->SetUID(idx); | |
142 | p->SetMomentum(px,py,pz,etot); | |
143 | p->SetProductionVertex(vx,vy,vz,time); | |
144 | ||
a5556ea5 | 145 | } |
146 | /**************************************************************************/ | |
147 | ||
148 | void AliAOD::SwapParticles(Int_t i, Int_t j) | |
149 | { | |
150 | //swaps particles positions; used by AliHBTEvent::Blend | |
151 | if ( (i<0) || (i>=GetNumberOfParticles()) ) return; | |
152 | if ( (j<0) || (j>=GetNumberOfParticles()) ) return; | |
dd2b6810 | 153 | |
154 | AliVAODParticle* tmpobj = (AliVAODParticle*)fParticleClass->New(); | |
155 | AliVAODParticle& tmp = *tmpobj; | |
156 | AliVAODParticle& first = *(GetParticle(i)); | |
157 | AliVAODParticle& second = *(GetParticle(j)); | |
158 | ||
159 | tmp = first; | |
160 | first = second; | |
161 | second = tmp; | |
162 | ||
a5556ea5 | 163 | } |
164 | /**************************************************************************/ | |
165 | ||
166 | void AliAOD::Reset() | |
167 | { | |
168 | //deletes all particles from the event | |
dd2b6810 | 169 | if (fParticles) fParticles->Clear("C"); |
170 | ||
171 | fIsRandomized = kFALSE; | |
a5556ea5 | 172 | } |
0d8a4589 | 173 | /**************************************************************************/ |
174 | ||
175 | void AliAOD::GetPrimaryVertex(Double_t&x, Double_t&y, Double_t&z) | |
176 | { | |
177 | //returns positions of the primary vertex | |
178 | x = fPrimaryVertexX; | |
179 | y = fPrimaryVertexY; | |
180 | z = fPrimaryVertexZ; | |
181 | } | |
182 | /**************************************************************************/ | |
183 | ||
184 | void AliAOD::SetPrimaryVertex(Double_t x, Double_t y, Double_t z) | |
185 | { | |
186 | //Sets positions of the primary vertex | |
187 | fPrimaryVertexX = x; | |
188 | fPrimaryVertexY = y; | |
189 | fPrimaryVertexZ = z; | |
190 | } | |
191 | /**************************************************************************/ | |
192 | ||
193 | Int_t AliAOD::GetNumberOfCharged(Double_t etamin, Double_t etamax) const | |
194 | { | |
195 | //reurns number of charged particles within given pseudorapidity range | |
29e00d75 | 196 | Int_t n = 0; |
dd2b6810 | 197 | Int_t npart = GetNumberOfParticles(); |
0d8a4589 | 198 | for (Int_t i = 0; i < npart; i++) |
199 | { | |
dd2b6810 | 200 | AliVAODParticle* p = GetParticle(i); |
0d8a4589 | 201 | Double_t eta = p->Eta(); |
202 | if ( (eta < etamin) || (eta > etamax) ) continue; | |
203 | if (p->Charge() != 0.0) n++; | |
204 | } | |
29e00d75 | 205 | return n; |
0d8a4589 | 206 | } |
207 | /**************************************************************************/ | |
208 | ||
209 | void AliAOD::Move(Double_t x, Double_t y, Double_t z) | |
210 | { | |
211 | //moves all spacial coordinates about this vector | |
212 | // vertex | |
213 | // track points | |
214 | // and whatever will be added to AOD and AOD particles that is a space coordinate | |
215 | ||
216 | fPrimaryVertexX += x; | |
217 | fPrimaryVertexY += y; | |
218 | fPrimaryVertexZ += z; | |
219 | ||
dd2b6810 | 220 | Int_t npart = GetNumberOfParticles(); |
0d8a4589 | 221 | for (Int_t i = 0; i < npart; i++) |
222 | { | |
dd2b6810 | 223 | AliVAODParticle* p = GetParticle(i); |
0d8a4589 | 224 | AliTrackPoints* tp = p->GetTPCTrackPoints(); |
225 | if (tp) tp->Move(x,y,z); | |
226 | tp = p->GetITSTrackPoints(); | |
227 | if (tp) tp->Move(x,y,z); | |
228 | } | |
229 | } | |
dd2b6810 | 230 | |
231 | void AliAOD::Print(Option_t* /*option*/) | |
232 | { | |
233 | //Prints AOD | |
234 | TString ts; | |
235 | TString msg("\n"); | |
236 | msg+="Particle Class: "; | |
237 | if (fParticleClass) | |
238 | { | |
239 | msg+=fParticleClass->GetName(); | |
240 | } | |
241 | else | |
242 | { | |
243 | msg+="Not specified yet"; | |
244 | } | |
245 | msg += "\n"; | |
246 | msg += "Vertex position X: "; | |
247 | msg += fPrimaryVertexX; | |
248 | msg += " Y:" ; | |
249 | msg += fPrimaryVertexY; | |
250 | msg += " Z:"; | |
251 | msg += fPrimaryVertexZ; | |
252 | msg += "\n"; | |
253 | ||
254 | msg += "Randomized: "; | |
255 | msg += fIsRandomized; | |
256 | msg += "\n"; | |
257 | ||
258 | Info("Print","%s",msg.Data()); | |
259 | ||
260 | Int_t npart = GetNumberOfParticles(); | |
261 | Info("Print","Npart: %d",npart); | |
262 | for (Int_t i = 0; i < npart; i++) | |
263 | { | |
264 | Info("Print","Getting particle %d",i); | |
265 | AliVAODParticle* p = GetParticle(i); | |
266 | Info("Print","Printing particle %d, address %#x",i,p); | |
267 | p->Dump(); | |
268 | p->Print(); | |
269 | Info("Print","particle %d printed",i); | |
270 | } | |
271 | } | |
272 | ||
273 | void AliAOD::SetOwner(Bool_t /*owner*/) | |
274 | { | |
275 | //Sets the ownership of particles: if particles should be also deleted if AOD is deleted/reseted | |
276 | //Since fParticles is Clones and not Object Array, it is always the owner and this method does not have sense | |
277 | ||
278 | MayNotUse("SetOwner"); | |
279 | //if fParticles->SetOwner(owner); | |
280 | ||
281 | } |