]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTPositionRandomizer.cxx
f05815aa8f51f739369bd989c892fe3e68ad8644
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPositionRandomizer.cxx
1 #include "AliHBTPositionRandomizer.h"
2 #include <TRandom.h>
3 #include "AliHBTRun.h"
4 #include "AliHBTEvent.h"
5 #include "AliHBTParticle.h"
6
7
8 ClassImp(AliHBTPositionRandomizer)
9
10 /*********************************************************************/
11
12 AliHBTPositionRandomizer::AliHBTPositionRandomizer():
13  fReader(0x0),
14  fRandomizer(0x0),
15  fModel(0),
16  fAddToExistingPos(kFALSE),
17  fOnlyParticlesFromVertex(kFALSE),
18  fVX(0.0),
19  fVY(0.0),
20  fVZ(0.0)
21 {
22 //constructor
23 }
24 /*********************************************************************/
25
26 AliHBTPositionRandomizer::AliHBTPositionRandomizer(AliHBTReader* reader):
27  fReader(reader),
28  fRandomizer(new AliHBTRndmGaussBall(8.0)),
29  fModel(0),
30  fAddToExistingPos(kFALSE),
31  fOnlyParticlesFromVertex(kFALSE),
32  fVX(0.0),
33  fVY(0.0),
34  fVZ(0.0)
35 {
36 //constructor
37
38 /*********************************************************************/
39
40 Int_t AliHBTPositionRandomizer::Read(AliHBTRun* particles, AliHBTRun *tracks)
41 {
42   if (fReader == 0x0) return 1;
43   Info("Randomize(AliHBTRun*)","");
44   Int_t err = fReader->Read(particles,tracks);
45   if (err) return err;
46   Randomize(particles);
47   return 0;
48 }
49 /*********************************************************************/
50
51 AliHBTEvent* AliHBTPositionRandomizer::GetParticleEvent(Int_t n)
52 {
53 //returns event n
54  if (fReader == 0x0) return 0x0;
55  AliHBTEvent *e =  fReader->GetParticleEvent(n);
56  if (e->IsRandomized() == kFALSE) Randomize(e);
57  return e;
58 }
59
60 /*********************************************************************/
61
62 void AliHBTPositionRandomizer::Randomize(AliHBTRun* run)
63 {
64 // randomizes postions of all particles in the run
65   if (run == 0x0) return;
66   Info("Randomize(AliHBTRun*)","");
67   for (Int_t i = 0; i < run->GetNumberOfEvents(); i++)
68    {
69      Randomize(run->GetEvent(i));
70    }
71 }
72 /*********************************************************************/
73 void AliHBTPositionRandomizer::Randomize(AliHBTEvent* event)
74 {
75 // randomizes postions of all particles in the event
76   static const Double_t fmtocm = 1.e-13;
77   Info("Randomize(AliHBTEvent*)","");
78   if (event == 0x0) return;
79
80   for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
81    {
82      AliHBTParticle* p = event->GetParticle(i);
83      Double_t x,y,z,t=0.0;
84      fRandomizer->Randomize(x,y,z,p);
85      p->SetProductionVertex(x*fmtocm,y*fmtocm,z*fmtocm,t*fmtocm);
86    }
87   event->SetRandomized();
88 }
89 /*********************************************************************/
90
91 void AliHBTPositionRandomizer::SetGaussianBall(Double_t r)
92 {
93   SetGaussianBall(r,r,r);
94 }
95 /*********************************************************************/
96
97 void AliHBTPositionRandomizer::SetGaussianBall(Double_t rx, Double_t ry, Double_t rz)
98 {
99   delete fRandomizer;
100   fRandomizer = new AliHBTRndmGaussBall(rx,ry,rz);
101 }
102 /*********************************************************************/
103
104 void AliHBTPositionRandomizer::SetCyllinderSurface(Double_t r, Double_t l)
105 {
106   delete fRandomizer;
107   fRandomizer = new  AliHBTRndmCyllSurf(r,l);
108 }
109 /*********************************************************************/
110
111 void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
112 {
113 //sets event vertex position
114   fVX = x;
115   fVY = y;
116   fVZ = z;
117 }
118 /*********************************************************************/
119 //_____________________________________________________________________
120 ///////////////////////////////////////////////////////////////////////
121 //                                                                   //
122 //  class AliHBTRndmGaussBall                                        //
123 //                                                                   //
124 ///////////////////////////////////////////////////////////////////////
125
126 AliHBTRndmGaussBall::AliHBTRndmGaussBall():
127  fRx(0.0),
128  fRy(0.0),
129  fRz(0.0)
130 {
131   //constructor
132 }
133 /*********************************************************************/
134
135 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r):
136  fRx(r),
137  fRy(r),
138  fRz(r)
139 {
140   //constructor
141 }
142 /*********************************************************************/
143
144 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz):
145  fRx(rx),
146  fRy(ry),
147  fRz(rz)
148 {
149   //constructor
150 }
151 /*********************************************************************/
152
153 void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle*p)
154 {
155 //randomizez gauss for each coordinate separately
156   x = gRandom->Gaus(0.0,fRx);
157   y = gRandom->Gaus(0.0,fRy);
158   z = gRandom->Gaus(0.0,fRz);
159 }
160 /*********************************************************************/
161 //_____________________________________________________________________
162 ///////////////////////////////////////////////////////////////////////
163 //                                                                   //
164 //  class AliHBTRndmGaussBall                                        //
165 //                                                                   //
166 ///////////////////////////////////////////////////////////////////////
167
168 void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle*p)
169 {
170    Double_t sf = fR/p->Pt();//scaling factor for position transformation ->
171                              //we move direction of string momentum but legth defined by r
172    x = sf*p->Px();
173    y = sf*p->Py();
174    z = gRandom->Uniform(-fL,fL);
175   
176 }