]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTPositionRandomizer.cxx
Bug corrections. New monitoring functions added (Q's VS QInv)
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPositionRandomizer.cxx
CommitLineData
88cb7938 1#include "AliHBTPositionRandomizer.h"
2#include <TRandom.h>
3#include "AliHBTRun.h"
4#include "AliHBTEvent.h"
5#include "AliHBTParticle.h"
6
7
8ClassImp(AliHBTPositionRandomizer)
9
10/*********************************************************************/
11
12AliHBTPositionRandomizer::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
26AliHBTPositionRandomizer::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
efaf00f8 40AliHBTEvent* AliHBTPositionRandomizer::GetParticleEvent()
41{
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);
46 return e;
47}
48/*********************************************************************/
49
50AliHBTEvent* AliHBTPositionRandomizer::GetTrackEvent()
51{
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);
56 return e;
57}
58/*********************************************************************/
59
88cb7938 60Int_t AliHBTPositionRandomizer::Read(AliHBTRun* particles, AliHBTRun *tracks)
61{
efaf00f8 62 //Reads all available events and randomizes them
88cb7938 63 if (fReader == 0x0) return 1;
64 Info("Randomize(AliHBTRun*)","");
65 Int_t err = fReader->Read(particles,tracks);
66 if (err) return err;
67 Randomize(particles);
68 return 0;
69}
70/*********************************************************************/
71
72AliHBTEvent* AliHBTPositionRandomizer::GetParticleEvent(Int_t n)
73{
74//returns event n
75 if (fReader == 0x0) return 0x0;
76 AliHBTEvent *e = fReader->GetParticleEvent(n);
77 if (e->IsRandomized() == kFALSE) Randomize(e);
78 return e;
79}
80
81/*********************************************************************/
82
83void AliHBTPositionRandomizer::Randomize(AliHBTRun* run)
84{
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++)
89 {
90 Randomize(run->GetEvent(i));
91 }
92}
93/*********************************************************************/
94void AliHBTPositionRandomizer::Randomize(AliHBTEvent* event)
95{
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;
100
101 for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
102 {
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);
107 }
108 event->SetRandomized();
109}
110/*********************************************************************/
111
112void AliHBTPositionRandomizer::SetGaussianBall(Double_t r)
113{
114 SetGaussianBall(r,r,r);
115}
116/*********************************************************************/
117
118void AliHBTPositionRandomizer::SetGaussianBall(Double_t rx, Double_t ry, Double_t rz)
119{
120 delete fRandomizer;
121 fRandomizer = new AliHBTRndmGaussBall(rx,ry,rz);
122}
123/*********************************************************************/
124
125void AliHBTPositionRandomizer::SetCyllinderSurface(Double_t r, Double_t l)
126{
127 delete fRandomizer;
128 fRandomizer = new AliHBTRndmCyllSurf(r,l);
129}
130/*********************************************************************/
131
132void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
133{
134//sets event vertex position
135 fVX = x;
136 fVY = y;
137 fVZ = z;
138}
139/*********************************************************************/
140//_____________________________________________________________________
141///////////////////////////////////////////////////////////////////////
142// //
143// class AliHBTRndmGaussBall //
144// //
145///////////////////////////////////////////////////////////////////////
146
147AliHBTRndmGaussBall::AliHBTRndmGaussBall():
148 fRx(0.0),
149 fRy(0.0),
150 fRz(0.0)
151{
152 //constructor
153}
154/*********************************************************************/
155
156AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r):
157 fRx(r),
158 fRy(r),
159 fRz(r)
160{
161 //constructor
162}
163/*********************************************************************/
164
165AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz):
166 fRx(rx),
167 fRy(ry),
168 fRz(rz)
169{
170 //constructor
171}
172/*********************************************************************/
173
bed069a4 174void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle*/*particle*/)
88cb7938 175{
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);
180}
181/*********************************************************************/
182//_____________________________________________________________________
183///////////////////////////////////////////////////////////////////////
184// //
185// class AliHBTRndmGaussBall //
186// //
187///////////////////////////////////////////////////////////////////////
188
bed069a4 189void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z, AliHBTParticle* particle)
88cb7938 190{
568f8a1a 191 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
bed069a4 192 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
88cb7938 193 //we move direction of string momentum but legth defined by r
bed069a4 194 x = sf*particle->Px();
195 y = sf*particle->Py();
88cb7938 196 z = gRandom->Uniform(-fL,fL);
197
198}