]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTPositionRandomizer.cxx
Finalization of the convertion to the new ANALYSIS schema
[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() 
83 {
84  // gets from fReader and randomizes current particle event
85  if (fReader == 0x0) return 0x0;
86  AliAOD *e =  fReader->GetEventSim();
87  if (e->IsRandomized() == kFALSE) Randomize(e);
88  return e;
89 }
90 /*********************************************************************/
91
92 AliAOD* AliHBTPositionRandomizer::GetEventRec() 
93 {
94  // gets from fReader and randomizes current track event
95  if (fReader == 0x0) return 0x0;
96  AliAOD *e =  fReader->GetEventRec();
97  if (fRandomizeTracks) if (e->IsRandomized() == kFALSE) Randomize(e);
98  return e;
99 }
100 /*********************************************************************/
101
102 AliAOD* AliHBTPositionRandomizer::GetEventSim(Int_t n)
103 {
104 //returns event n
105  if (fReader == 0x0) return 0x0;
106  AliAOD *e =  fReader->GetEventSim(n);
107  if (e->IsRandomized() == kFALSE) Randomize(e);
108  return e;
109 }
110
111 /*********************************************************************/
112 void AliHBTPositionRandomizer::Randomize(AliAOD* event) const
113 {
114 // randomizes postions of all particles in the event
115   static const Double_t kfmtocm = 1.e-13;
116   if (AliVAODParticle::GetDebug() > 5) Info("Randomize(AliAOD*)","");
117   if (event == 0x0) return;
118
119   for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
120    {
121      AliVAODParticle* p = event->GetParticle(i);
122      Double_t x,y,z,t=0.0;
123      fRandomizer->Randomize(x,y,z,p);
124      
125      Double_t nx = x*kfmtocm;
126      Double_t ny = y*kfmtocm;
127      Double_t nz = z*kfmtocm;
128      Double_t nt = t*kfmtocm;
129      
130      if (fAddToExistingPos)
131       {
132        nx += p->Vx();
133        ny += p->Vy();
134        nz += p->Vz();
135        nt += p->T();
136       }
137      p->SetProductionVertex(nx,ny,nz,nt); 
138    }
139   event->SetRandomized();
140 }
141 /*********************************************************************/
142
143 void AliHBTPositionRandomizer::SetGaussianBall(Double_t r)
144 {
145  //Sets Gaussian Ball Model
146   SetGaussianBall(r,r,r);
147 }
148 /*********************************************************************/
149
150 void AliHBTPositionRandomizer::SetGaussianBall(Double_t rx, Double_t ry, Double_t rz)
151 {
152  //Sets Gaussian Ball Model
153   delete fRandomizer;
154   fRandomizer = new AliHBTRndmGaussBall(rx,ry,rz);
155 }
156 /*********************************************************************/
157
158 void AliHBTPositionRandomizer::SetCyllinderSurface(Double_t r, Double_t l)
159 {
160  //Sets Cylinder Surface Model
161   delete fRandomizer;
162   fRandomizer = new  AliHBTRndmCyllSurf(r,l);
163 }
164 /*********************************************************************/
165
166 void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
167 {
168 //sets event vertex position
169   fVX = x;
170   fVY = y;
171   fVZ = z;
172 }
173 /*********************************************************************/
174 //_____________________________________________________________________
175 ///////////////////////////////////////////////////////////////////////
176 //                                                                   //
177 //  class AliHBTRndmGaussBall                                        //
178 //                                                                   //
179 ///////////////////////////////////////////////////////////////////////
180
181 AliHBTRndmGaussBall::AliHBTRndmGaussBall():
182  fRx(0.0),
183  fRy(0.0),
184  fRz(0.0)
185 {
186   //constructor
187 }
188 /*********************************************************************/
189
190 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r):
191  fRx(r),
192  fRy(r),
193  fRz(r)
194 {
195   //constructor
196 }
197 /*********************************************************************/
198
199 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz):
200  fRx(rx),
201  fRy(ry),
202  fRz(rz)
203 {
204   //constructor
205 }
206 /*********************************************************************/
207
208 void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z, AliVAODParticle*/*particle*/) const
209 {
210 //randomizez gauss for each coordinate separately
211   x = gRandom->Gaus(0.0,fRx);
212   y = gRandom->Gaus(0.0,fRy);
213   z = gRandom->Gaus(0.0,fRz);
214 }
215 /*********************************************************************/
216 //_____________________________________________________________________
217 ///////////////////////////////////////////////////////////////////////
218 //                                                                   //
219 //  class AliHBTRndmGaussBall                                        //
220 //                                                                   //
221 ///////////////////////////////////////////////////////////////////////
222
223 void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z, AliVAODParticle* particle) const
224 {
225 //Randomizes x,y,z
226    Double_t r = fR + gRandom->Gaus(0.0, 1.0);
227    Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
228                              //we move direction of string momentum but legth defined by r
229    x = sf*particle->Px();
230    y = sf*particle->Py();
231    z = gRandom->Uniform(-fL,fL);
232 }