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 ////////////////////////////////////////////////////////////////////////////////
31 #include "AliHBTPositionRandomizer.h"
33 #include "AliVAODParticle.h"
36 ClassImp(AliHBTPositionRandomizer)
38 const Int_t AliHBTPositionRandomizer::fgkNumberOfPids = 10;
40 /*********************************************************************/
42 AliHBTPositionRandomizer::AliHBTPositionRandomizer():
44 fDefaultRandomizer(0x0),
48 fAddToExistingPos(kFALSE),
49 fOnlyParticlesFromVertex(kFALSE),
50 fRandomizeTracks(kFALSE),
57 /*********************************************************************/
59 AliHBTPositionRandomizer::AliHBTPositionRandomizer(AliReader* reader):
61 fRandomizers(new TObjArray(fgkNumberOfPids)),
63 fPids(new Int_t[fgkNumberOfPids]),
64 fAddToExistingPos(kFALSE),
65 fOnlyParticlesFromVertex(kFALSE),
66 fRandomizeTracks(kFALSE),
72 fRandomizers->AddAt(new AliHBTRndmGaussBall(8.0,0.0,0.0),0);
74 /*********************************************************************/
76 AliHBTPositionRandomizer::AliHBTPositionRandomizer(const AliHBTPositionRandomizer& in):
82 fAddToExistingPos(kFALSE),
83 fOnlyParticlesFromVertex(kFALSE),
84 fRandomizeTracks(kFALSE),
92 /*********************************************************************/
93 AliHBTPositionRandomizer::~AliHBTPositionRandomizer()
100 /*********************************************************************/
101 AliHBTPositionRandomizer& AliHBTPositionRandomizer::operator=(const AliHBTPositionRandomizer& in)
107 /*********************************************************************/
109 AliAOD* AliHBTPositionRandomizer::GetEventSim() const
111 // gets from fReader and randomizes current particle event
114 Error("GetEventSim","Reader is null");
117 AliAOD *e = fReader->GetEventSim();
119 if (e->IsRandomized() == kFALSE)
123 /*********************************************************************/
125 AliAOD* AliHBTPositionRandomizer::GetEventRec() const
127 // gets from fReader and randomizes current track event
130 Error("GetEventRec","Reader is null");
133 AliAOD *e = fReader->GetEventRec();
134 if (fRandomizeTracks && e) if (e->IsRandomized() == kFALSE) Randomize(e);
137 /*********************************************************************/
139 AliAOD* AliHBTPositionRandomizer::GetEventSim(Int_t n)
142 if (fReader == 0x0) return 0x0;
143 AliAOD *e = fReader->GetEventSim(n);
144 if (e->IsRandomized() == kFALSE) Randomize(e);
148 /*********************************************************************/
149 void AliHBTPositionRandomizer::Randomize(AliAOD* event) const
151 // randomizes postions of all particles in the event
152 static const Double_t kfmtocm = 1.e-13;
154 if (event == 0x0) return;
156 for (Int_t i = 0; i < event->GetNumberOfParticles(); i++)
158 AliVAODParticle* p = event->GetParticle(i);
159 Double_t x,y,z,t=0.0;
160 AliHBTRndm* r = GetRandomizer(p->GetPdgCode());
161 r->Randomize(x,y,z,t,p);
163 Double_t nx = x*kfmtocm;
164 Double_t ny = y*kfmtocm;
165 Double_t nz = z*kfmtocm;
166 Double_t nt = t*kfmtocm;
168 if (fAddToExistingPos)
175 p->SetProductionVertex(nx,ny,nz,nt);
177 event->SetRandomized();
179 /*********************************************************************/
181 AliHBTRndm* AliHBTPositionRandomizer::GetRandomizer(Int_t pdg) const
183 //returns randomizer for a given pdg
184 Int_t idx = GetRandomizerIndex(pdg);//in most of cases
185 if (idx < 0) idx = 0;//if not found return a default one
186 return (AliHBTRndm*)fRandomizers->At(idx);
188 /*********************************************************************/
189 Int_t AliHBTPositionRandomizer::GetRandomizerIndex(Int_t pdg) const
191 //returns randomizer index for a given pdg
193 if (pdg == 0) return 0;
195 for (Int_t i=1; i < fNPid; i++)
203 /*********************************************************************/
205 void AliHBTPositionRandomizer::SetRandomizer(Int_t pid, AliHBTRndm* rndm)
207 //sets the randomizer for a given particle type
210 Error("SetRandomizer","Randomizer is null");
214 Int_t idx = GetRandomizerIndex(pid);
217 delete fRandomizers->At(idx);
218 fRandomizers->AddAt(rndm,idx);
221 if (fNPid == fgkNumberOfPids)
223 Error("SetRandomizer","There is no more space in the array");
228 fRandomizers->AddAt(rndm,fNPid);
231 /*********************************************************************/
233 void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t r, Double_t meantime, Double_t sigmatime)
235 //Sets Gaussian Ball Model
236 SetGaussianBall(pid,r,r,r,meantime,sigmatime);
238 /*********************************************************************/
240 void AliHBTPositionRandomizer::SetGaussianBall(Int_t pid, Double_t rx, Double_t ry, Double_t rz, Double_t meantime, Double_t sigmatime)
242 //Sets Gaussian Ball Model
243 AliHBTRndm* rndm = new AliHBTRndmGaussBall(rx,ry,rz,meantime,sigmatime);
244 SetRandomizer(pid,rndm);
246 /*********************************************************************/
248 void AliHBTPositionRandomizer::SetCyllinderSurface(Int_t pid, Double_t r, Double_t l)
250 //Sets Cylinder Surface Model
251 AliHBTRndm* rndm = new AliHBTRndmCyllSurf(r,l);
252 SetRandomizer(pid,rndm);
254 /*********************************************************************/
256 void AliHBTPositionRandomizer::SetEventVertex(Double_t x, Double_t y,Double_t z)
258 //sets event vertex position
265 void AliHBTPositionRandomizer::SetEllipse(Int_t pid, Double_t rx, Double_t ryz)
267 //sets the ellipse randomization for the given pid
268 AliHBTRndm* rndm = new AliHBTRndmEllipse(rx,ryz);
269 SetRandomizer(pid,rndm);
272 /*********************************************************************/
273 //_____________________________________________________________________
274 ///////////////////////////////////////////////////////////////////////
276 // class AliHBTRndmGaussBall //
278 ///////////////////////////////////////////////////////////////////////
280 AliHBTRndmGaussBall::AliHBTRndmGaussBall():
289 /*********************************************************************/
291 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t r, Double_t meantime, Double_t sigmatime):
300 /*********************************************************************/
302 AliHBTRndmGaussBall::AliHBTRndmGaussBall(Float_t rx, Float_t ry, Float_t rz, Double_t meantime, Double_t sigmatime):
311 /*********************************************************************/
314 AliHBTRndmEllipse::AliHBTRndmEllipse(Float_t rmin, Float_t rmax):
321 /*********************************************************************/
323 void AliHBTRndmGaussBall::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&t, AliVAODParticle*/*particle*/) const
325 //randomizez gauss for each coordinate separately
326 x = gRandom->Gaus(0.0,fRx);
327 y = gRandom->Gaus(0.0,fRy);
328 z = gRandom->Gaus(0.0,fRz);
336 t = gRandom->Gaus(fTmean,fTsigma);
339 /*********************************************************************/
340 //_____________________________________________________________________
341 ///////////////////////////////////////////////////////////////////////
343 // class AliHBTRndmGaussBall //
345 ///////////////////////////////////////////////////////////////////////
347 void AliHBTRndmCyllSurf::Randomize(Double_t& x,Double_t& y,Double_t&z,Double_t&/*t*/, AliVAODParticle* particle) const
350 Double_t r = fR + gRandom->Gaus(0.0, 1.0);
351 Double_t sf = r/particle->Pt();//scaling factor for position transformation ->
352 //we move direction of string momentum but legth defined by r
353 x = sf*particle->Px();
354 y = sf*particle->Py();
355 z = gRandom->Uniform(-fL,fL);
358 /*********************************************************************/
359 /*********************************************************************/
361 void AliHBTRndmEllipse::Randomize(Double_t& x, Double_t& y, Double_t& z,Double_t&/*t*/, AliVAODParticle*p) const
363 // p=0; //workaround - fix this damn little thingy
367 R=fRmin+(fRmax-fRmin)*TMath::Sin(phi);