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