2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 /////////////////////////////////////////////////////////////
21 // base class for AOD containers
23 /////////////////////////////////////////////////////////////
25 #include <TParticle.h>
28 #include "AliAODParticle.h"
29 #include "AliTrackPoints.h"
35 fIsRandomized(kFALSE),
42 // Info("AliAOD()","Entered");
44 // Info("AliAOD()","Exited");
46 /**************************************************************************/
51 //fParticleClass does not belong to AliAOD -> Do not delete it
55 /**************************************************************************/
57 void AliAOD::SetParticleClassName(const char* classname)
59 //Sets type of particle that is going to be stored
60 if (gROOT == 0x0) Fatal("SetParticleClassName","ROOT System not initialized");
61 TClass* pclass = gROOT->GetClass(classname);
64 Error("SetParticleClass","Can not get TClass for class named %s",classname);
67 SetParticleClass(pclass);
69 /**************************************************************************/
71 void AliAOD::SetParticleClass(TClass* pclass)
73 //Sets type of particle that is going to be stored
77 Error("SetParticleClass","Parameter is NULL.");
81 if ( pclass->InheritsFrom("AliVAODParticle") == kFALSE )
83 Error("SetParticleClass","Class named %s does not inherit from AliVAODParticle",pclass->GetName());
86 if (pclass != fParticleClass)
88 fParticleClass = pclass;
89 if (fParticleClass) delete fParticles;
90 fParticles = new TClonesArray(fParticleClass);
94 /**************************************************************************/
96 void AliAOD::AddParticle(TParticle* part, Int_t idx)
98 //Adds TParticle to event
101 Error("AddParticle(TParticle*,Int_t)","pointer to particle is NULL");
105 if (fParticles == 0x0) SetParticleClassName("AliAODParticle");
106 AddParticle( new AliAODParticle(*part,idx) );
108 /**************************************************************************/
110 void AliAOD::AddParticle(AliVAODParticle* particle)
112 //add particle to AOD
113 //MAKES ITS OWN COPY OF THE PARTICLE!!! (AOD is not going to keep and delete input pointer)
115 if (fParticles == 0x0) SetParticleClassName("AliAODParticle");
117 Int_t idx = fParticles->GetLast() + 1;
118 TClonesArray& arr = *fParticles;
120 AliVAODParticle* pp = (AliVAODParticle*)fParticleClass->New(arr[idx]);
121 pp->operator=(*particle);
124 /**************************************************************************/
126 void AliAOD::AddParticle(Int_t pdg, Int_t idx,
127 Double_t px, Double_t py, Double_t pz, Double_t etot,
128 Double_t vx, Double_t vy, Double_t vz, Double_t time)
130 //adds particle to event (standard AOD class)
132 if (fParticles == 0x0) SetParticleClassName("AliAODParticle");
134 Int_t newpartidx = fParticles->GetLast() + 1;
135 TClonesArray& arr = *fParticles;
137 AliVAODParticle* p = (AliVAODParticle*)fParticleClass->New(arr[newpartidx]);
141 p->SetMomentum(px,py,pz,etot);
142 p->SetProductionVertex(vx,vy,vz,time);
145 /**************************************************************************/
147 void AliAOD::SwapParticles(Int_t i, Int_t j)
149 //swaps particles positions; used by AliHBTEvent::Blend
150 if ( (i<0) || (i>=GetNumberOfParticles()) ) return;
151 if ( (j<0) || (j>=GetNumberOfParticles()) ) return;
153 AliVAODParticle* tmpobj = (AliVAODParticle*)fParticleClass->New();
154 AliVAODParticle& tmp = *tmpobj;
155 AliVAODParticle& first = *(GetParticle(i));
156 AliVAODParticle& second = *(GetParticle(j));
163 /**************************************************************************/
167 //deletes all particles from the event
168 if (fParticles) fParticles->Clear("C");
170 fIsRandomized = kFALSE;
172 /**************************************************************************/
174 void AliAOD::GetPrimaryVertex(Double_t&x, Double_t&y, Double_t&z)
176 //returns positions of the primary vertex
181 /**************************************************************************/
183 void AliAOD::SetPrimaryVertex(Double_t x, Double_t y, Double_t z)
185 //Sets positions of the primary vertex
190 /**************************************************************************/
192 Int_t AliAOD::GetNumberOfCharged(Double_t etamin, Double_t etamax) const
194 //reurns number of charged particles within given pseudorapidity range
196 Int_t npart = GetNumberOfParticles();
197 for (Int_t i = 0; i < npart; i++)
199 AliVAODParticle* p = GetParticle(i);
200 Double_t eta = p->Eta();
201 if ( (eta < etamin) || (eta > etamax) ) continue;
202 if (p->Charge() != 0.0) n++;
206 /**************************************************************************/
208 void AliAOD::Move(Double_t x, Double_t y, Double_t z)
210 //moves all spacial coordinates about this vector
213 // and whatever will be added to AOD and AOD particles that is a space coordinate
215 fPrimaryVertexX += x;
216 fPrimaryVertexY += y;
217 fPrimaryVertexZ += z;
219 Int_t npart = GetNumberOfParticles();
220 for (Int_t i = 0; i < npart; i++)
222 AliVAODParticle* p = GetParticle(i);
223 AliTrackPoints* tp = p->GetTPCTrackPoints();
224 if (tp) tp->Move(x,y,z);
225 tp = p->GetITSTrackPoints();
226 if (tp) tp->Move(x,y,z);
230 void AliAOD::Print(Option_t* /*option*/)
235 msg+="Particle Class: ";
238 msg+=fParticleClass->GetName();
242 msg+="Not specified yet";
245 msg += "Vertex position X: ";
246 msg += fPrimaryVertexX;
248 msg += fPrimaryVertexY;
250 msg += fPrimaryVertexZ;
253 msg += "Randomized: ";
254 msg += fIsRandomized;
257 Info("Print","%s",msg.Data());
259 Int_t npart = GetNumberOfParticles();
260 Info("Print","Npart: %d",npart);
261 for (Int_t i = 0; i < npart; i++)
263 Info("Print","Getting particle %d",i);
264 AliVAODParticle* p = GetParticle(i);
265 Info("Print","Printing particle %d, address %#x",i,p);
268 Info("Print","particle %d printed",i);
272 void AliAOD::SetOwner(Bool_t /*owner*/)
274 //Sets the ownership of particles: if particles should be also deleted if AOD is deleted/reseted
275 //Since fParticles is Clones and not Object Array, it is always the owner and this method does not have sense
277 MayNotUse("SetOwner");
278 //if fParticles->SetOwner(owner);