]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTPositionRandomizer.cxx
Info guarded by debug flag
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPositionRandomizer.cxx
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
18 ClassImp(AliHBTPositionRandomizer)
19
20 /*********************************************************************/
21
22 AliHBTPositionRandomizer::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
36 AliHBTPositionRandomizer::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
50 AliHBTPositionRandomizer::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 /*********************************************************************/
65 AliHBTPositionRandomizer::~AliHBTPositionRandomizer()
66 {
67   //dtor
68   delete fReader;
69   delete fRandomizer;
70 }
71 /*********************************************************************/
72 AliHBTPositionRandomizer& AliHBTPositionRandomizer::operator=(const AliHBTPositionRandomizer& in)
73 {
74   //assigment operator
75   in.Copy(*this);
76   return *this;
77 }
78 /*********************************************************************/
79
80 AliHBTEvent* 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
90 AliHBTEvent* 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
100 Int_t AliHBTPositionRandomizer::Read(AliHBTRun* particles, AliHBTRun *tracks)
101 {
102   //Reads all available events and randomizes them
103   if (fReader == 0x0) return 1;
104   if (AliHBTParticle::GetDebug() > 5) 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
112 AliHBTEvent* 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
123 void AliHBTPositionRandomizer::Randomize(AliHBTRun* run) const
124 {
125 // randomizes postions of all particles in the run
126   if (run == 0x0) return;
127   if (AliHBTParticle::GetDebug() > 5) Info("Randomize(AliHBTRun*)","");
128   for (Int_t i = 0; i < run->GetNumberOfEvents(); i++)
129    {
130      Randomize(run->GetEvent(i));
131    }
132 }
133 /*********************************************************************/
134 void AliHBTPositionRandomizer::Randomize(AliHBTEvent* event) const
135 {
136 // randomizes postions of all particles in the event
137   static const Double_t kfmtocm = 1.e-13;
138   if (AliHBTParticle::GetDebug() > 5) 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);
146      p->SetProductionVertex(x*kfmtocm,y*kfmtocm,z*kfmtocm,t*kfmtocm);
147    }
148   event->SetRandomized();
149 }
150 /*********************************************************************/
151
152 void AliHBTPositionRandomizer::SetGaussianBall(Double_t r)
153 {
154  //Sets Gaussian Ball Model
155   SetGaussianBall(r,r,r);
156 }
157 /*********************************************************************/
158
159 void AliHBTPositionRandomizer::SetGaussianBall(Double_t rx, Double_t ry, Double_t rz)
160 {
161  //Sets Gaussian Ball Model
162   delete fRandomizer;
163   fRandomizer = new AliHBTRndmGaussBall(rx,ry,rz);
164 }
165 /*********************************************************************/
166
167 void AliHBTPositionRandomizer::SetCyllinderSurface(Double_t r, Double_t l)
168 {
169  //Sets Cylinder Surface Model
170   delete fRandomizer;
171   fRandomizer = new  AliHBTRndmCyllSurf(r,l);
172 }
173 /*********************************************************************/
174
175 void 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
190 AliHBTRndmGaussBall::AliHBTRndmGaussBall():
191  fRx(0.0),
192  fRy(0.0),
193  fRz(0.0)
194 {
195   //constructor
196 }
197 /*********************************************************************/
198
199 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r):
200  fRx(r),
201  fRy(r),
202  fRz(r)
203 {
204   //constructor
205 }
206 /*********************************************************************/
207
208 AliHBTRndmGaussBall::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
217 void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle*/*particle*/) const
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
232 void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle* particle) const
233 {
234 //Randomizes x,y,z
235    Double_t r = fR + gRandom->Gaus(0.0, 1.0);
236    Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
237                              //we move direction of string momentum but legth defined by r
238    x = sf*particle->Px();
239    y = sf*particle->Py();
240    z = gRandom->Uniform(-fL,fL);
241 }