1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //___________________________________________________
19 ////////////////////////////////////////////////////////////////////////////////
21 // class AliHBTPositionRandomizer
23 // These class randomizes particle vertex positions
24 // Piotr.Skowronski@cern.ch
26 ////////////////////////////////////////////////////////////////////////////////
32 #include "AliHBTPositionRandomizer.h"
34 #include "AliVAODParticle.h"
37 ClassImp(AliHBTPositionRandomizer)
39 const Int_t AliHBTPositionRandomizer::fgkNumberOfPids = 10;
41 /*********************************************************************/
43 AliHBTPositionRandomizer::AliHBTPositionRandomizer():
45 fDefaultRandomizer(0x0),
49 fAddToExistingPos(kFALSE),
50 fOnlyParticlesFromVertex(kFALSE),
51 fRandomizeTracks(kFALSE),
58 /*********************************************************************/
60 AliHBTPositionRandomizer::AliHBTPositionRandomizer(AliReader* reader):
62 fRandomizers(new TObjArray(fgkNumberOfPids)),
64 fPids(new Int_t[fgkNumberOfPids]),
65 fAddToExistingPos(kFALSE),
66 fOnlyParticlesFromVertex(kFALSE),
67 fRandomizeTracks(kFALSE),
73 fRandomizers->AddAt(new AliHBTRndmGaussBall(8.0,0.0,0.0),0);
75 /*********************************************************************/
77 AliHBTPositionRandomizer::AliHBTPositionRandomizer(const AliHBTPositionRandomizer& in):
83 fAddToExistingPos(kFALSE),
84 fOnlyParticlesFromVertex(kFALSE),
85 fRandomizeTracks(kFALSE),
93 /*********************************************************************/
94 AliHBTPositionRandomizer::~AliHBTPositionRandomizer()
101 /*********************************************************************/
102 AliHBTPositionRandomizer& AliHBTPositionRandomizer::operator=(const AliHBTPositionRandomizer& in)
108 /*********************************************************************/
110 AliAOD* AliHBTPositionRandomizer::GetEventSim() const
112 // gets from fReader and randomizes current particle event
115 Error("GetEventSim","Reader is null");
118 AliAOD *e = fReader->GetEventSim();
120 if (e->IsRandomized() == kFALSE)
124 /*********************************************************************/
126 AliAOD* AliHBTPositionRandomizer::GetEventRec() const
128 // gets from fReader and randomizes current track event
131 Error("GetEventRec","Reader is null");
134 AliAOD *e = fReader->GetEventRec();
135 if (fRandomizeTracks && e) if (e->IsRandomized() == kFALSE) Randomize(e);
138 /*********************************************************************/
140 AliAOD* AliHBTPositionRandomizer::GetEventSim(Int_t n)
143 if (fReader == 0x0) return 0x0;
144 AliAOD *e = fReader->GetEventSim(n);
145 if (e->IsRandomized() == kFALSE) Randomize(e);
149 /*********************************************************************/
150 void AliHBTPositionRandomizer::Randomize(AliAOD* event) const
152 // randomizes postions of all particles in the event
153 static const Double_t kfmtocm = 1.e-13;
155 if (event == 0x0) return;
157 for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
159 AliVAODParticle* p = event->GetParticle(i);
160 Double_t x,y,z,t=0.0;
161 AliHBTRndm* r = GetRandomizer(p->GetPdgCode());
162 r->Randomize(x,y,z,t,p);
164 Double_t nx = x*kfmtocm;
165 Double_t ny = y*kfmtocm;
166 Double_t nz = z*kfmtocm;
167 Double_t nt = t*kfmtocm;
169 if (fAddToExistingPos)
176 p->SetProductionVertex(nx,ny,nz,nt);
178 event->SetRandomized();
180 /*********************************************************************/
182 AliHBTRndm* AliHBTPositionRandomizer::GetRandomizer(Int_t pdg) const
184 //returns randomizer for a given pdg
185 Int_t idx = GetRandomizerIndex(pdg);//in most of cases
186 if (idx < 0) idx = 0;//if not found return a default one
187 return (AliHBTRndm*)fRandomizers->At(idx);
189 /*********************************************************************/
190 Int_t AliHBTPositionRandomizer::GetRandomizerIndex(Int_t pdg) const
192 //returns randomizer index for a given pdg
194 if (pdg == 0) return 0;
196 for (Int_t i=1; i < fNPid; i++)
204 /*********************************************************************/
206 void AliHBTPositionRandomizer::SetRandomizer(Int_t pid, AliHBTRndm* rndm)
208 //sets the randomizer for a given particle type
211 Error("SetRandomizer","Randomizer is null");
215 Int_t idx = GetRandomizerIndex(pid);
218 delete fRandomizers->At(idx);
219 fRandomizers->AddAt(rndm,idx);
222 if (fNPid == fgkNumberOfPids)
224 Error("SetRandomizer","There is no more space in the array");
229 fRandomizers->AddAt(rndm,fNPid);
232 /*********************************************************************/
234 void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t r, Double_t meantime, Double_t sigmatime)
236 //Sets Gaussian Ball Model
237 SetGaussianBall(pid,r,r,r,meantime,sigmatime);
239 /*********************************************************************/
241 void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t rx, Double_t ry, Double_t rz, Double_t meantime, Double_t sigmatime)
243 //Sets Gaussian Ball Model
244 AliHBTRndm* rndm = new AliHBTRndmGaussBall(rx,ry,rz,meantime,sigmatime);
245 SetRandomizer(pid,rndm);
247 /*********************************************************************/
249 void AliHBTPositionRandomizer::SetCyllinderSurface(Int_t pid, Double_t r, Double_t l)
251 //Sets Cylinder Surface Model
252 AliHBTRndm* rndm = new AliHBTRndmCyllSurf(r,l);
253 SetRandomizer(pid,rndm);
255 /*********************************************************************/
257 void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
259 //sets event vertex position
266 void AliHBTPositionRandomizer::SetEllipse(Int_t pid, Double_t rx, Double_t ryz)
268 //sets the ellipse randomization for the given pid
269 AliHBTRndm* rndm = new AliHBTRndmEllipse(rx,ryz);
270 SetRandomizer(pid,rndm);
273 /*********************************************************************/
274 //_____________________________________________________________________
275 ///////////////////////////////////////////////////////////////////////
277 // class AliHBTRndmGaussBall //
279 ///////////////////////////////////////////////////////////////////////
281 AliHBTRndmGaussBall::AliHBTRndmGaussBall():
290 /*********************************************************************/
292 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r, Double_t meantime, Double_t sigmatime):
301 /*********************************************************************/
303 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz, Double_t meantime, Double_t sigmatime):
312 /*********************************************************************/
315 AliHBTRndmEllipse::AliHBTRndmEllipse(Float_t rmin, Float_t rmax):
322 /*********************************************************************/
324 void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&t, AliVAODParticle*/*particle*/) const
326 //randomizez gauss for each coordinate separately
327 x = gRandom->Gaus(0.0,fRx);
328 y = gRandom->Gaus(0.0,fRy);
329 z = gRandom->Gaus(0.0,fRz);
337 t = gRandom->Gaus(fTmean,fTsigma);
340 /*********************************************************************/
341 //_____________________________________________________________________
342 ///////////////////////////////////////////////////////////////////////
344 // class AliHBTRndmGaussBall //
346 ///////////////////////////////////////////////////////////////////////
348 void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&/*t*/, AliVAODParticle* particle) const
351 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
352 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
353 //we move direction of string momentum but legth defined by r
354 x = sf*particle->Px();
355 y = sf*particle->Py();
356 z = gRandom->Uniform(-fL,fL);
359 /*********************************************************************/
360 /*********************************************************************/
362 void AliHBTRndmEllipse::Randomize(Double_t& x, Double_t& y, Double_t& z,Double_t&/*t*/, AliVAODParticle*p) const
364 // p=0; //workaround - fix this damn little thingy
368 R=fRmin+(fRmax-fRmin)*TMath::Sin(phi);