Addtional check
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPositionRandomizer.cxx
CommitLineData
88cb7938 1#include "AliHBTPositionRandomizer.h"
abe00f6f 2//___________________________________________________
3////////////////////////////////////////////////////////////////////////////////
4//
5// class AliHBTPositionRandomizer
6//
7// These class randomizes particle vertex positions
8// Piotr.Skowronski@cern.ch
9//
10////////////////////////////////////////////////////////////////////////////////
11
88cb7938 12#include <TRandom.h>
415b66b5 13#include "AliAOD.h"
14#include "AliVAODParticle.h"
88cb7938 15
16
17ClassImp(AliHBTPositionRandomizer)
18
19/*********************************************************************/
20
21AliHBTPositionRandomizer::AliHBTPositionRandomizer():
22 fReader(0x0),
23 fRandomizer(0x0),
24 fModel(0),
25 fAddToExistingPos(kFALSE),
26 fOnlyParticlesFromVertex(kFALSE),
3a3bc78a 27 fRandomizeTracks(kFALSE),
88cb7938 28 fVX(0.0),
29 fVY(0.0),
30 fVZ(0.0)
31{
32//constructor
33}
34/*********************************************************************/
35
415b66b5 36AliHBTPositionRandomizer::AliHBTPositionRandomizer(AliReader* reader):
88cb7938 37 fReader(reader),
38 fRandomizer(new AliHBTRndmGaussBall(8.0)),
39 fModel(0),
40 fAddToExistingPos(kFALSE),
41 fOnlyParticlesFromVertex(kFALSE),
3a3bc78a 42 fRandomizeTracks(kFALSE),
88cb7938 43 fVX(0.0),
44 fVY(0.0),
45 fVZ(0.0)
46{
47//constructor
48}
49/*********************************************************************/
50
abe00f6f 51AliHBTPositionRandomizer::AliHBTPositionRandomizer(const AliHBTPositionRandomizer& in):
415b66b5 52 AliReader(in),
abe00f6f 53 fReader(),
54 fRandomizer(0x0),
55 fModel(0),
56 fAddToExistingPos(kFALSE),
57 fOnlyParticlesFromVertex(kFALSE),
3a3bc78a 58 fRandomizeTracks(kFALSE),
abe00f6f 59 fVX(0.0),
60 fVY(0.0),
61 fVZ(0.0)
62{
63 //cpy constructor
64 in.Copy(*this);
65}
66/*********************************************************************/
67AliHBTPositionRandomizer::~AliHBTPositionRandomizer()
68{
69 //dtor
70 delete fReader;
71 delete fRandomizer;
72}
73/*********************************************************************/
34914285 74AliHBTPositionRandomizer& AliHBTPositionRandomizer::operator=(const AliHBTPositionRandomizer& in)
abe00f6f 75{
76 //assigment operator
77 in.Copy(*this);
78 return *this;
79}
80/*********************************************************************/
81
1c654289 82AliAOD* AliHBTPositionRandomizer::GetEventSim() const
efaf00f8 83{
84 // gets from fReader and randomizes current particle event
1c654289 85 if (fReader == 0x0)
86 {
87 Error("GetEventSim","Reader is null");
88 return 0x0;
89 }
415b66b5 90 AliAOD *e = fReader->GetEventSim();
6c15cd50 91 if (e)
92 if (e->IsRandomized() == kFALSE)
93 Randomize(e);
efaf00f8 94 return e;
95}
96/*********************************************************************/
97
1c654289 98AliAOD* AliHBTPositionRandomizer::GetEventRec() const
efaf00f8 99{
100 // gets from fReader and randomizes current track event
1c654289 101 if (fReader == 0x0)
102 {
103 Error("GetEventRec","Reader is null");
104 return 0x0;
105 }
415b66b5 106 AliAOD *e = fReader->GetEventRec();
6c15cd50 107 if (fRandomizeTracks && e) if (e->IsRandomized() == kFALSE) Randomize(e);
efaf00f8 108 return e;
109}
110/*********************************************************************/
111
415b66b5 112AliAOD* AliHBTPositionRandomizer::GetEventSim(Int_t n)
88cb7938 113{
114//returns event n
115 if (fReader == 0x0) return 0x0;
415b66b5 116 AliAOD *e = fReader->GetEventSim(n);
88cb7938 117 if (e->IsRandomized() == kFALSE) Randomize(e);
118 return e;
119}
120
121/*********************************************************************/
415b66b5 122void AliHBTPositionRandomizer::Randomize(AliAOD* event) const
88cb7938 123{
124// randomizes postions of all particles in the event
abe00f6f 125 static const Double_t kfmtocm = 1.e-13;
415b66b5 126 if (AliVAODParticle::GetDebug() > 5) Info("Randomize(AliAOD*)","");
88cb7938 127 if (event == 0x0) return;
128
129 for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
130 {
415b66b5 131 AliVAODParticle* p = event->GetParticle(i);
88cb7938 132 Double_t x,y,z,t=0.0;
133 fRandomizer->Randomize(x,y,z,p);
3a3bc78a 134
135 Double_t nx = x*kfmtocm;
136 Double_t ny = y*kfmtocm;
137 Double_t nz = z*kfmtocm;
138 Double_t nt = t*kfmtocm;
139
140 if (fAddToExistingPos)
141 {
142 nx += p->Vx();
143 ny += p->Vy();
144 nz += p->Vz();
145 nt += p->T();
146 }
147 p->SetProductionVertex(nx,ny,nz,nt);
88cb7938 148 }
149 event->SetRandomized();
150}
151/*********************************************************************/
152
153void AliHBTPositionRandomizer::SetGaussianBall(Double_t r)
154{
abe00f6f 155 //Sets Gaussian Ball Model
88cb7938 156 SetGaussianBall(r,r,r);
157}
158/*********************************************************************/
159
160void AliHBTPositionRandomizer::SetGaussianBall(Double_t rx, Double_t ry, Double_t rz)
161{
abe00f6f 162 //Sets Gaussian Ball Model
88cb7938 163 delete fRandomizer;
164 fRandomizer = new AliHBTRndmGaussBall(rx,ry,rz);
165}
166/*********************************************************************/
167
168void AliHBTPositionRandomizer::SetCyllinderSurface(Double_t r, Double_t l)
169{
abe00f6f 170 //Sets Cylinder Surface Model
88cb7938 171 delete fRandomizer;
172 fRandomizer = new AliHBTRndmCyllSurf(r,l);
173}
174/*********************************************************************/
175
176void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
177{
178//sets event vertex position
179 fVX = x;
180 fVY = y;
181 fVZ = z;
182}
183/*********************************************************************/
184//_____________________________________________________________________
185///////////////////////////////////////////////////////////////////////
186// //
187// class AliHBTRndmGaussBall //
188// //
189///////////////////////////////////////////////////////////////////////
190
191AliHBTRndmGaussBall::AliHBTRndmGaussBall():
192 fRx(0.0),
193 fRy(0.0),
194 fRz(0.0)
195{
196 //constructor
197}
198/*********************************************************************/
199
200AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r):
201 fRx(r),
202 fRy(r),
203 fRz(r)
204{
205 //constructor
206}
207/*********************************************************************/
208
209AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz):
210 fRx(rx),
211 fRy(ry),
212 fRz(rz)
213{
214 //constructor
215}
216/*********************************************************************/
217
415b66b5 218void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z, AliVAODParticle*/*particle*/) const
88cb7938 219{
220//randomizez gauss for each coordinate separately
221 x = gRandom->Gaus(0.0,fRx);
222 y = gRandom->Gaus(0.0,fRy);
223 z = gRandom->Gaus(0.0,fRz);
224}
225/*********************************************************************/
226//_____________________________________________________________________
227///////////////////////////////////////////////////////////////////////
228// //
229// class AliHBTRndmGaussBall //
230// //
231///////////////////////////////////////////////////////////////////////
232
415b66b5 233void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z, AliVAODParticle* particle) const
88cb7938 234{
abe00f6f 235//Randomizes x,y,z
568f8a1a 236 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
bed069a4 237 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
88cb7938 238 //we move direction of string momentum but legth defined by r
bed069a4 239 x = sf*particle->Px();
240 y = sf*particle->Py();
88cb7938 241 z = gRandom->Uniform(-fL,fL);
88cb7938 242}