1 #include "AliHBTPositionRandomizer.h"
4 #include "AliHBTEvent.h"
5 #include "AliHBTParticle.h"
8 ClassImp(AliHBTPositionRandomizer)
10 /*********************************************************************/
12 AliHBTPositionRandomizer::AliHBTPositionRandomizer():
16 fAddToExistingPos(kFALSE),
17 fOnlyParticlesFromVertex(kFALSE),
24 /*********************************************************************/
26 AliHBTPositionRandomizer::AliHBTPositionRandomizer(AliHBTReader* reader):
28 fRandomizer(new AliHBTRndmGaussBall(8.0)),
30 fAddToExistingPos(kFALSE),
31 fOnlyParticlesFromVertex(kFALSE),
38 /*********************************************************************/
40 AliHBTEvent* AliHBTPositionRandomizer::GetParticleEvent()
42 // gets from fReader and randomizes current particle event
43 if (fReader == 0x0) return 0x0;
44 AliHBTEvent *e = fReader->GetParticleEvent();
45 if (e->IsRandomized() == kFALSE) Randomize(e);
48 /*********************************************************************/
50 AliHBTEvent* AliHBTPositionRandomizer::GetTrackEvent()
52 // gets from fReader and randomizes current track event
53 if (fReader == 0x0) return 0x0;
54 AliHBTEvent *e = fReader->GetTrackEvent();
55 if (e->IsRandomized() == kFALSE) Randomize(e);
58 /*********************************************************************/
60 Int_t AliHBTPositionRandomizer::Read(AliHBTRun* particles, AliHBTRun *tracks)
62 //Reads all available events and randomizes them
63 if (fReader == 0x0) return 1;
64 Info("Randomize(AliHBTRun*)","");
65 Int_t err = fReader->Read(particles,tracks);
70 /*********************************************************************/
72 AliHBTEvent* AliHBTPositionRandomizer::GetParticleEvent(Int_t n)
75 if (fReader == 0x0) return 0x0;
76 AliHBTEvent *e = fReader->GetParticleEvent(n);
77 if (e->IsRandomized() == kFALSE) Randomize(e);
81 /*********************************************************************/
83 void AliHBTPositionRandomizer::Randomize(AliHBTRun* run)
85 // randomizes postions of all particles in the run
86 if (run == 0x0) return;
87 Info("Randomize(AliHBTRun*)","");
88 for (Int_t i = 0; i < run->GetNumberOfEvents(); i++)
90 Randomize(run->GetEvent(i));
93 /*********************************************************************/
94 void AliHBTPositionRandomizer::Randomize(AliHBTEvent* event)
96 // randomizes postions of all particles in the event
97 static const Double_t fmtocm = 1.e-13;
98 Info("Randomize(AliHBTEvent*)","");
99 if (event == 0x0) return;
101 for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
103 AliHBTParticle* p = event->GetParticle(i);
104 Double_t x,y,z,t=0.0;
105 fRandomizer->Randomize(x,y,z,p);
106 p->SetProductionVertex(x*fmtocm,y*fmtocm,z*fmtocm,t*fmtocm);
108 event->SetRandomized();
110 /*********************************************************************/
112 void AliHBTPositionRandomizer::SetGaussianBall(Double_t r)
114 SetGaussianBall(r,r,r);
116 /*********************************************************************/
118 void AliHBTPositionRandomizer::SetGaussianBall(Double_t rx, Double_t ry, Double_t rz)
121 fRandomizer = new AliHBTRndmGaussBall(rx,ry,rz);
123 /*********************************************************************/
125 void AliHBTPositionRandomizer::SetCyllinderSurface(Double_t r, Double_t l)
128 fRandomizer = new AliHBTRndmCyllSurf(r,l);
130 /*********************************************************************/
132 void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
134 //sets event vertex position
139 /*********************************************************************/
140 //_____________________________________________________________________
141 ///////////////////////////////////////////////////////////////////////
143 // class AliHBTRndmGaussBall //
145 ///////////////////////////////////////////////////////////////////////
147 AliHBTRndmGaussBall::AliHBTRndmGaussBall():
154 /*********************************************************************/
156 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r):
163 /*********************************************************************/
165 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz):
172 /*********************************************************************/
174 void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle*/*particle*/)
176 //randomizez gauss for each coordinate separately
177 x = gRandom->Gaus(0.0,fRx);
178 y = gRandom->Gaus(0.0,fRy);
179 z = gRandom->Gaus(0.0,fRz);
181 /*********************************************************************/
182 //_____________________________________________________________________
183 ///////////////////////////////////////////////////////////////////////
185 // class AliHBTRndmGaussBall //
187 ///////////////////////////////////////////////////////////////////////
189 void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle* particle)
191 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
192 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
193 //we move direction of string momentum but legth defined by r
194 x = sf*particle->Px();
195 y = sf*particle->Py();
196 z = gRandom->Uniform(-fL,fL);