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 fDefaultRandomizer(0x0),
63 fRandomizers(new TObjArray(fgkNumberOfPids)),
65 fPids(new Int_t[fgkNumberOfPids]),
66 fAddToExistingPos(kFALSE),
67 fOnlyParticlesFromVertex(kFALSE),
68 fRandomizeTracks(kFALSE),
74 fRandomizers->AddAt(new AliHBTRndmGaussBall(8.0,0.0,0.0),0);
76 /*********************************************************************/
78 AliHBTPositionRandomizer::AliHBTPositionRandomizer(const AliHBTPositionRandomizer& in):
81 fDefaultRandomizer(0x0),
85 fAddToExistingPos(kFALSE),
86 fOnlyParticlesFromVertex(kFALSE),
87 fRandomizeTracks(kFALSE),
95 /*********************************************************************/
96 AliHBTPositionRandomizer::~AliHBTPositionRandomizer()
103 /*********************************************************************/
104 AliHBTPositionRandomizer& AliHBTPositionRandomizer::operator=(const AliHBTPositionRandomizer& in)
110 /*********************************************************************/
112 AliAOD* AliHBTPositionRandomizer::GetEventSim() const
114 // gets from fReader and randomizes current particle event
117 Error("GetEventSim","Reader is null");
120 AliAOD *e = fReader->GetEventSim();
122 if (e->IsRandomized() == kFALSE)
126 /*********************************************************************/
128 AliAOD* AliHBTPositionRandomizer::GetEventRec() const
130 // gets from fReader and randomizes current track event
133 Error("GetEventRec","Reader is null");
136 AliAOD *e = fReader->GetEventRec();
137 if (fRandomizeTracks && e) if (e->IsRandomized() == kFALSE) Randomize(e);
140 /*********************************************************************/
142 AliAOD* AliHBTPositionRandomizer::GetEventSim(Int_t n)
145 if (fReader == 0x0) return 0x0;
146 AliAOD *e = fReader->GetEventSim(n);
147 if (e->IsRandomized() == kFALSE) Randomize(e);
151 /*********************************************************************/
152 void AliHBTPositionRandomizer::Randomize(AliAOD* event) const
154 // randomizes postions of all particles in the event
155 static const Double_t kfmtocm = 1.e-13;
157 if (event == 0x0) return;
159 for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
161 AliVAODParticle* p = event->GetParticle(i);
162 Double_t x,y,z,t=0.0;
163 AliHBTRndm* r = GetRandomizer(p->GetPdgCode());
164 r->Randomize(x,y,z,t,p);
166 Double_t nx = x*kfmtocm;
167 Double_t ny = y*kfmtocm;
168 Double_t nz = z*kfmtocm;
169 Double_t nt = t*kfmtocm;
171 if (fAddToExistingPos)
178 p->SetProductionVertex(nx,ny,nz,nt);
180 event->SetRandomized();
182 /*********************************************************************/
184 AliHBTRndm* AliHBTPositionRandomizer::GetRandomizer(Int_t pdg) const
186 //returns randomizer for a given pdg
187 Int_t idx = GetRandomizerIndex(pdg);//in most of cases
188 if (idx < 0) idx = 0;//if not found return a default one
189 return (AliHBTRndm*)fRandomizers->At(idx);
191 /*********************************************************************/
192 Int_t AliHBTPositionRandomizer::GetRandomizerIndex(Int_t pdg) const
194 //returns randomizer index for a given pdg
196 if (pdg == 0) return 0;
198 for (Int_t i=1; i < fNPid; i++)
206 /*********************************************************************/
208 void AliHBTPositionRandomizer::SetRandomizer(Int_t pid, AliHBTRndm* rndm)
210 //sets the randomizer for a given particle type
213 Error("SetRandomizer","Randomizer is null");
217 Int_t idx = GetRandomizerIndex(pid);
220 delete fRandomizers->At(idx);
221 fRandomizers->AddAt(rndm,idx);
224 if (fNPid == fgkNumberOfPids)
226 Error("SetRandomizer","There is no more space in the array");
231 fRandomizers->AddAt(rndm,fNPid);
234 /*********************************************************************/
236 void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t r, Double_t meantime, Double_t sigmatime)
238 //Sets Gaussian Ball Model
239 SetGaussianBall(pid,r,r,r,meantime,sigmatime);
241 /*********************************************************************/
243 void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t rx, Double_t ry, Double_t rz, Double_t meantime, Double_t sigmatime)
245 //Sets Gaussian Ball Model
246 AliHBTRndm* rndm = new AliHBTRndmGaussBall(rx,ry,rz,meantime,sigmatime);
247 SetRandomizer(pid,rndm);
249 /*********************************************************************/
251 void AliHBTPositionRandomizer::SetCyllinderSurface(Int_t pid, Double_t r, Double_t l)
253 //Sets Cylinder Surface Model
254 AliHBTRndm* rndm = new AliHBTRndmCyllSurf(r,l);
255 SetRandomizer(pid,rndm);
257 /*********************************************************************/
259 void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
261 //sets event vertex position
268 void AliHBTPositionRandomizer::SetEllipse(Int_t pid, Double_t rx, Double_t ryz)
270 //sets the ellipse randomization for the given pid
271 AliHBTRndm* rndm = new AliHBTRndmEllipse(rx,ryz);
272 SetRandomizer(pid,rndm);
275 /*********************************************************************/
276 //_____________________________________________________________________
277 ///////////////////////////////////////////////////////////////////////
279 // class AliHBTRndmGaussBall //
281 ///////////////////////////////////////////////////////////////////////
283 AliHBTRndmGaussBall::AliHBTRndmGaussBall():
292 /*********************************************************************/
294 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r, Double_t meantime, Double_t sigmatime):
303 /*********************************************************************/
305 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz, Double_t meantime, Double_t sigmatime):
314 /*********************************************************************/
317 AliHBTRndmEllipse::AliHBTRndmEllipse(Float_t rmin, Float_t rmax):
324 /*********************************************************************/
326 void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&t, AliVAODParticle*/*particle*/) const
328 //randomizez gauss for each coordinate separately
329 x = gRandom->Gaus(0.0,fRx);
330 y = gRandom->Gaus(0.0,fRy);
331 z = gRandom->Gaus(0.0,fRz);
339 t = gRandom->Gaus(fTmean,fTsigma);
342 /*********************************************************************/
343 //_____________________________________________________________________
344 ///////////////////////////////////////////////////////////////////////
346 // class AliHBTRndmGaussBall //
348 ///////////////////////////////////////////////////////////////////////
350 void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&/*t*/, AliVAODParticle* particle) const
353 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
354 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
355 //we move direction of string momentum but legth defined by r
356 x = sf*particle->Px();
357 y = sf*particle->Py();
358 z = gRandom->Uniform(-fL,fL);
361 /*********************************************************************/
362 /*********************************************************************/
364 void AliHBTRndmEllipse::Randomize(Double_t& x, Double_t& y, Double_t& z,Double_t&/*t*/, AliVAODParticle*p) const
366 // p=0; //workaround - fix this damn little thingy
370 R=fRmin+(fRmax-fRmin)*TMath::Sin(phi);