]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAOD.cxx
06-jul-2004 NvE AliCalorimeter hit I/O only via the linear array to decrease filesize...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAOD.cxx
CommitLineData
a5556ea5 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/* $Id$ */
17
18/////////////////////////////////////////////////////////////
19//
20// base class for AOD containers
21//
22/////////////////////////////////////////////////////////////
23
24#include <TParticle.h>
25#include "AliAOD.h"
afa8b37b 26#include "AliAODParticle.h"
0d8a4589 27#include "AliTrackPoints.h"
a5556ea5 28
29ClassImp(AliAOD)
30
0d8a4589 31AliAOD::AliAOD():
32 fParticles(10),
33 fIsRandomized(kFALSE),
34 fPrimaryVertexX(0.0),
35 fPrimaryVertexY(0.0),
36 fPrimaryVertexZ(0.0)
37{
38 //ctor
39 SetOwner(kTRUE);
40}
41
a5556ea5 42/**************************************************************************/
43
44void AliAOD::AddParticle(TParticle* part, Int_t idx)
45{
46 //Adds TParticle to event
47 if (part == 0x0)
48 {
49 Error("AddParticle(TParticle*,Int_t)","pointer to particle is NULL");
50 return;
51 }
afa8b37b 52 AddParticle( new AliAODParticle(*part,idx) );
a5556ea5 53}
54/**************************************************************************/
55
56void AliAOD::AddParticle(Int_t pdg, Int_t idx,
57 Double_t px, Double_t py, Double_t pz, Double_t etot,
58 Double_t vx, Double_t vy, Double_t vz, Double_t time)
59{
60 //adds particle to event
afa8b37b 61 AddParticle(new AliAODParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time));
a5556ea5 62}
63/**************************************************************************/
64
65void AliAOD::SwapParticles(Int_t i, Int_t j)
66{
67//swaps particles positions; used by AliHBTEvent::Blend
68 if ( (i<0) || (i>=GetNumberOfParticles()) ) return;
69 if ( (j<0) || (j>=GetNumberOfParticles()) ) return;
70
afa8b37b 71 AliVAODParticle* tmp = (AliVAODParticle*)fParticles.At(i);
a5556ea5 72 fParticles.AddAt(fParticles.At(j),i);
73 fParticles.AddAt(tmp,j);
74}
75/**************************************************************************/
76
77void AliAOD::Reset()
78{
79 //deletes all particles from the event
80 for(Int_t i =0; i<GetNumberOfParticles(); i++)
81 {
82 for (Int_t j = i+1; j<GetNumberOfParticles(); j++)
83 if ( fParticles.At(j) == fParticles.At(i) ) fParticles.RemoveAt(j);
84 delete fParticles.RemoveAt(i);
85 }
86// fRandomized = kFALSE;
87}
0d8a4589 88/**************************************************************************/
89
90void AliAOD::GetPrimaryVertex(Double_t&x, Double_t&y, Double_t&z)
91{
92//returns positions of the primary vertex
93 x = fPrimaryVertexX;
94 y = fPrimaryVertexY;
95 z = fPrimaryVertexZ;
96}
97/**************************************************************************/
98
99void AliAOD::SetPrimaryVertex(Double_t x, Double_t y, Double_t z)
100{
101//Sets positions of the primary vertex
102 fPrimaryVertexX = x;
103 fPrimaryVertexY = y;
104 fPrimaryVertexZ = z;
105}
106/**************************************************************************/
107
108Int_t AliAOD::GetNumberOfCharged(Double_t etamin, Double_t etamax) const
109{
110 //reurns number of charged particles within given pseudorapidity range
111 Int_t n;
112 Int_t npart = fParticles.GetEntries();
113 for (Int_t i = 0; i < npart; i++)
114 {
115 AliVAODParticle* p = (AliVAODParticle*)fParticles.At(i);
116 Double_t eta = p->Eta();
117 if ( (eta < etamin) || (eta > etamax) ) continue;
118 if (p->Charge() != 0.0) n++;
119 }
120 return 0;
121}
122/**************************************************************************/
123
124void AliAOD::Move(Double_t x, Double_t y, Double_t z)
125{
126 //moves all spacial coordinates about this vector
127 // vertex
128 // track points
129 // and whatever will be added to AOD and AOD particles that is a space coordinate
130
131 fPrimaryVertexX += x;
132 fPrimaryVertexY += y;
133 fPrimaryVertexZ += z;
134
135 Int_t npart = fParticles.GetEntries();
136 for (Int_t i = 0; i < npart; i++)
137 {
138 AliVAODParticle* p = (AliVAODParticle*)fParticles.At(i);
139 AliTrackPoints* tp = p->GetTPCTrackPoints();
140 if (tp) tp->Move(x,y,z);
141 tp = p->GetITSTrackPoints();
142 if (tp) tp->Move(x,y,z);
143 }
144}