]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HBTAN/AliHBTPositionRandomizer.cxx
New version including TOF
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPositionRandomizer.cxx
... / ...
CommitLineData
1#include "AliHBTPositionRandomizer.h"
2//___________________________________________________
3////////////////////////////////////////////////////////////////////////////////
4//
5// class AliHBTPositionRandomizer
6//
7// These class randomizes particle vertex positions
8// Piotr.Skowronski@cern.ch
9//
10////////////////////////////////////////////////////////////////////////////////
11
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),
28 fRandomizeTracks(kFALSE),
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),
43 fRandomizeTracks(kFALSE),
44 fVX(0.0),
45 fVY(0.0),
46 fVZ(0.0)
47{
48//constructor
49}
50/*********************************************************************/
51
52AliHBTPositionRandomizer::AliHBTPositionRandomizer(const AliHBTPositionRandomizer& in):
53 AliHBTReader(in),
54 fReader(),
55 fRandomizer(0x0),
56 fModel(0),
57 fAddToExistingPos(kFALSE),
58 fOnlyParticlesFromVertex(kFALSE),
59 fRandomizeTracks(kFALSE),
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/*********************************************************************/
75AliHBTPositionRandomizer& AliHBTPositionRandomizer::operator=(const AliHBTPositionRandomizer& in)
76{
77 //assigment operator
78 in.Copy(*this);
79 return *this;
80}
81/*********************************************************************/
82
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();
98 if (fRandomizeTracks) if (e->IsRandomized() == kFALSE) Randomize(e);
99 return e;
100}
101/*********************************************************************/
102
103Int_t AliHBTPositionRandomizer::Read(AliHBTRun* particles, AliHBTRun *tracks)
104{
105 //Reads all available events and randomizes them
106 if (fReader == 0x0) return 1;
107 if (AliHBTParticle::GetDebug() > 5) Info("Randomize(AliHBTRun*)","");
108 Int_t err = fReader->Read(particles,tracks);
109 if (err) return err;
110 Randomize(particles);
111 if (fRandomizeTracks) Randomize(tracks);
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
127void AliHBTPositionRandomizer::Randomize(AliHBTRun* run) const
128{
129// randomizes postions of all particles in the run
130 if (run == 0x0) return;
131 if (AliHBTParticle::GetDebug() > 5) Info("Randomize(AliHBTRun*)","");
132 for (Int_t i = 0; i < run->GetNumberOfEvents(); i++)
133 {
134 Randomize(run->GetEvent(i));
135 }
136}
137/*********************************************************************/
138void AliHBTPositionRandomizer::Randomize(AliHBTEvent* event) const
139{
140// randomizes postions of all particles in the event
141 static const Double_t kfmtocm = 1.e-13;
142 if (AliHBTParticle::GetDebug() > 5) Info("Randomize(AliHBTEvent*)","");
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);
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);
164 }
165 event->SetRandomized();
166}
167/*********************************************************************/
168
169void AliHBTPositionRandomizer::SetGaussianBall(Double_t r)
170{
171 //Sets Gaussian Ball Model
172 SetGaussianBall(r,r,r);
173}
174/*********************************************************************/
175
176void AliHBTPositionRandomizer::SetGaussianBall(Double_t rx, Double_t ry, Double_t rz)
177{
178 //Sets Gaussian Ball Model
179 delete fRandomizer;
180 fRandomizer = new AliHBTRndmGaussBall(rx,ry,rz);
181}
182/*********************************************************************/
183
184void AliHBTPositionRandomizer::SetCyllinderSurface(Double_t r, Double_t l)
185{
186 //Sets Cylinder Surface Model
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
234void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle*/*particle*/) const
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
249void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle* particle) const
250{
251//Randomizes x,y,z
252 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
253 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
254 //we move direction of string momentum but legth defined by r
255 x = sf*particle->Px();
256 y = sf*particle->Py();
257 z = gRandom->Uniform(-fL,fL);
258}