]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTPositionRandomizer.cxx
Tic preliminary support in config and menu
[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
a296aa84 19const Int_t AliHBTPositionRandomizer::fgkNumberOfPids = 10;
20
88cb7938 21/*********************************************************************/
22
23AliHBTPositionRandomizer::AliHBTPositionRandomizer():
24 fReader(0x0),
a296aa84 25 fDefaultRandomizer(0x0),
26 fRandomizers(0x0),
27 fNPid(0),
28 fPids(0x0),
88cb7938 29 fAddToExistingPos(kFALSE),
30 fOnlyParticlesFromVertex(kFALSE),
3a3bc78a 31 fRandomizeTracks(kFALSE),
88cb7938 32 fVX(0.0),
33 fVY(0.0),
34 fVZ(0.0)
35{
36//constructor
37}
38/*********************************************************************/
39
415b66b5 40AliHBTPositionRandomizer::AliHBTPositionRandomizer(AliReader* reader):
88cb7938 41 fReader(reader),
a296aa84 42 fRandomizers(new TObjArray(fgkNumberOfPids)),
43 fNPid(1),
44 fPids(new Int_t[fgkNumberOfPids]),
88cb7938 45 fAddToExistingPos(kFALSE),
46 fOnlyParticlesFromVertex(kFALSE),
3a3bc78a 47 fRandomizeTracks(kFALSE),
88cb7938 48 fVX(0.0),
49 fVY(0.0),
50 fVZ(0.0)
51{
52//constructor
a296aa84 53 fRandomizers->AddAt(new AliHBTRndmGaussBall(8.0,0.0,0.0),0);
88cb7938 54}
55/*********************************************************************/
56
abe00f6f 57AliHBTPositionRandomizer::AliHBTPositionRandomizer(const AliHBTPositionRandomizer& in):
415b66b5 58 AliReader(in),
abe00f6f 59 fReader(),
a296aa84 60 fRandomizers(0x0),
61 fNPid(0),
62 fPids(0x0),
abe00f6f 63 fAddToExistingPos(kFALSE),
64 fOnlyParticlesFromVertex(kFALSE),
3a3bc78a 65 fRandomizeTracks(kFALSE),
abe00f6f 66 fVX(0.0),
67 fVY(0.0),
68 fVZ(0.0)
69{
70 //cpy constructor
71 in.Copy(*this);
72}
73/*********************************************************************/
74AliHBTPositionRandomizer::~AliHBTPositionRandomizer()
75{
76 //dtor
77 delete fReader;
a296aa84 78 delete fRandomizers;
79 delete [] fPids;
abe00f6f 80}
81/*********************************************************************/
34914285 82AliHBTPositionRandomizer& AliHBTPositionRandomizer::operator=(const AliHBTPositionRandomizer& in)
abe00f6f 83{
84 //assigment operator
85 in.Copy(*this);
86 return *this;
87}
88/*********************************************************************/
89
1c654289 90AliAOD* AliHBTPositionRandomizer::GetEventSim() const
efaf00f8 91{
92 // gets from fReader and randomizes current particle event
1c654289 93 if (fReader == 0x0)
94 {
95 Error("GetEventSim","Reader is null");
96 return 0x0;
97 }
415b66b5 98 AliAOD *e = fReader->GetEventSim();
6c15cd50 99 if (e)
100 if (e->IsRandomized() == kFALSE)
101 Randomize(e);
efaf00f8 102 return e;
103}
104/*********************************************************************/
105
1c654289 106AliAOD* AliHBTPositionRandomizer::GetEventRec() const
efaf00f8 107{
108 // gets from fReader and randomizes current track event
1c654289 109 if (fReader == 0x0)
110 {
111 Error("GetEventRec","Reader is null");
112 return 0x0;
113 }
415b66b5 114 AliAOD *e = fReader->GetEventRec();
6c15cd50 115 if (fRandomizeTracks && e) if (e->IsRandomized() == kFALSE) Randomize(e);
efaf00f8 116 return e;
117}
118/*********************************************************************/
119
415b66b5 120AliAOD* AliHBTPositionRandomizer::GetEventSim(Int_t n)
88cb7938 121{
122//returns event n
123 if (fReader == 0x0) return 0x0;
415b66b5 124 AliAOD *e = fReader->GetEventSim(n);
88cb7938 125 if (e->IsRandomized() == kFALSE) Randomize(e);
126 return e;
127}
128
129/*********************************************************************/
415b66b5 130void AliHBTPositionRandomizer::Randomize(AliAOD* event) const
88cb7938 131{
132// randomizes postions of all particles in the event
abe00f6f 133 static const Double_t kfmtocm = 1.e-13;
415b66b5 134 if (AliVAODParticle::GetDebug() > 5) Info("Randomize(AliAOD*)","");
88cb7938 135 if (event == 0x0) return;
136
137 for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
138 {
415b66b5 139 AliVAODParticle* p = event->GetParticle(i);
88cb7938 140 Double_t x,y,z,t=0.0;
a296aa84 141 AliHBTRndm* r = GetRandomizer(p->GetPdgCode());
142 r->Randomize(x,y,z,t,p);
3a3bc78a 143
144 Double_t nx = x*kfmtocm;
145 Double_t ny = y*kfmtocm;
146 Double_t nz = z*kfmtocm;
147 Double_t nt = t*kfmtocm;
148
149 if (fAddToExistingPos)
150 {
151 nx += p->Vx();
152 ny += p->Vy();
153 nz += p->Vz();
154 nt += p->T();
155 }
156 p->SetProductionVertex(nx,ny,nz,nt);
88cb7938 157 }
158 event->SetRandomized();
159}
160/*********************************************************************/
161
a296aa84 162AliHBTRndm* AliHBTPositionRandomizer::GetRandomizer(Int_t pdg) const
163{
164 //returns randomizer for a given pdg
165 Int_t idx = GetRandomizerIndex(pdg);//in most of cases
166 if (idx < 0) idx = 0;//if not found return a default one
167 return (AliHBTRndm*)fRandomizers->At(idx);
168}
169/*********************************************************************/
170Int_t AliHBTPositionRandomizer::GetRandomizerIndex(Int_t pdg) const
171{
172 //returns randomizer index for a given pdg
173
174 if (pdg == 0) return 0;
175
176 for (Int_t i=1; i < fNPid; i++)
177 {
178 if (fPids[i] == pdg)
179 return i;
180 }
181
182 return -1;
183}
184/*********************************************************************/
185
186void AliHBTPositionRandomizer::SetRandomizer(Int_t pid, AliHBTRndm* rndm)
187{
188 //sets the randomizer for a given particle type
189 if (rndm == 0x0)
190 {
191 Error("SetRandomizer","Randomizer is null");
192 return;
193 }
194
195 Int_t idx = GetRandomizerIndex(pid);
196 if (idx >= 0)
197 {
198 delete fRandomizers->At(idx);
199 fRandomizers->AddAt(rndm,idx);
200 }
201
202 if (fNPid == fgkNumberOfPids)
203 {
204 Error("SetRandomizer","There is no more space in the array");
205 return;
206 }
207
208 fPids[fNPid] = pid;
209 fRandomizers->AddAt(rndm,fNPid);
210 fNPid++;
211}
212/*********************************************************************/
213
214void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t r, Double_t meantime, Double_t sigmatime)
88cb7938 215{
abe00f6f 216 //Sets Gaussian Ball Model
a296aa84 217 SetGaussianBall(pid,r,r,r,meantime,sigmatime);
88cb7938 218}
219/*********************************************************************/
220
a296aa84 221void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t rx, Double_t ry, Double_t rz, Double_t meantime, Double_t sigmatime)
88cb7938 222{
abe00f6f 223 //Sets Gaussian Ball Model
a296aa84 224 AliHBTRndm* rndm = new AliHBTRndmGaussBall(rx,ry,rz,meantime,sigmatime);
225 SetRandomizer(pid,rndm);
88cb7938 226}
227/*********************************************************************/
228
a296aa84 229void AliHBTPositionRandomizer::SetCyllinderSurface(Int_t pid, Double_t r, Double_t l)
88cb7938 230{
abe00f6f 231 //Sets Cylinder Surface Model
a296aa84 232 AliHBTRndm* rndm = new AliHBTRndmCyllSurf(r,l);
233 SetRandomizer(pid,rndm);
88cb7938 234}
235/*********************************************************************/
236
237void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
238{
239//sets event vertex position
240 fVX = x;
241 fVY = y;
242 fVZ = z;
243}
94a709e1 244
245
a296aa84 246void AliHBTPositionRandomizer::SetEllipse(Int_t pid, Double_t rx, Double_t ryz)
94a709e1 247{
a296aa84 248//sets the ellipse randomization for the given pid
249 AliHBTRndm* rndm = new AliHBTRndmEllipse(rx,ryz);
250 SetRandomizer(pid,rndm);
94a709e1 251}
252
88cb7938 253/*********************************************************************/
254//_____________________________________________________________________
255///////////////////////////////////////////////////////////////////////
256// //
257// class AliHBTRndmGaussBall //
258// //
259///////////////////////////////////////////////////////////////////////
260
261AliHBTRndmGaussBall::AliHBTRndmGaussBall():
262 fRx(0.0),
263 fRy(0.0),
a296aa84 264 fRz(0.0),
265 fTmean(0.0),
266 fTsigma(0.0)
88cb7938 267{
268 //constructor
269}
270/*********************************************************************/
271
a296aa84 272AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r, Double_t meantime, Double_t sigmatime):
88cb7938 273 fRx(r),
274 fRy(r),
a296aa84 275 fRz(r),
276 fTmean(meantime),
277 fTsigma(sigmatime)
88cb7938 278{
279 //constructor
280}
281/*********************************************************************/
282
a296aa84 283AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz, Double_t meantime, Double_t sigmatime):
88cb7938 284 fRx(rx),
285 fRy(ry),
a296aa84 286 fRz(rz),
287 fTmean(meantime),
288 fTsigma(sigmatime)
88cb7938 289{
290 //constructor
291}
292/*********************************************************************/
293
94a709e1 294
295AliHBTRndmEllipse::AliHBTRndmEllipse(Float_t rmin, Float_t rmax):
296 fRmin(rmin),
297 fRmax(rmax)
298{
299 //constructor
300}
301
302/*********************************************************************/
303
a296aa84 304void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&t, AliVAODParticle*/*particle*/) const
88cb7938 305{
306//randomizez gauss for each coordinate separately
307 x = gRandom->Gaus(0.0,fRx);
308 y = gRandom->Gaus(0.0,fRy);
309 z = gRandom->Gaus(0.0,fRz);
a296aa84 310
311 if (fTsigma == 0.0)
312 {
1a1e58ac 313 t = fTmean;
a296aa84 314 return;
315 }
316
317 t = gRandom->Gaus(fTmean,fTsigma);
318
88cb7938 319}
320/*********************************************************************/
321//_____________________________________________________________________
322///////////////////////////////////////////////////////////////////////
323// //
324// class AliHBTRndmGaussBall //
325// //
326///////////////////////////////////////////////////////////////////////
327
a296aa84 328void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&/*t*/, AliVAODParticle* particle) const
88cb7938 329{
abe00f6f 330//Randomizes x,y,z
568f8a1a 331 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
bed069a4 332 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
88cb7938 333 //we move direction of string momentum but legth defined by r
bed069a4 334 x = sf*particle->Px();
335 y = sf*particle->Py();
88cb7938 336 z = gRandom->Uniform(-fL,fL);
88cb7938 337}
94a709e1 338
339/*********************************************************************/
340/*********************************************************************/
341
a296aa84 342void AliHBTRndmEllipse::Randomize(Double_t& x, Double_t& y, Double_t& z,Double_t&/*t*/, AliVAODParticle*p) const
94a709e1 343{
344 // p=0; //workaround - fix this damn little thingy
345 double R;
346 double phi=p->Phi();
347
348 R=fRmin+(fRmax-fRmin)*TMath::Sin(phi);
349 x=R*TMath::Sin(phi);
350 y=R*TMath::Cos(phi);
351 z=z;
352}