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