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