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 // Generate the final state of the interaction as the input
22 //-----------------------------------------------------------------
25 <img src="picts/AliGeneratorClass.gif">
28 <font size=+2 color=red>
29 <p>The responsible person for this module is
30 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
36 ///////////////////////////////////////////////////////////////////
37 #include <TGenerator.h>
38 #include <TMCProcess.h>
41 #include "AliCollisionGeometry.h"
42 #include "AliConfig.h"
43 #include "AliGenerator.h"
47 #include "AliVertexGenerator.h"
49 ClassImp(AliGenerator)
52 //_______________________________________________________________________
53 AliGenerator::AliGenerator():
73 fVertexSmear(kNoSmear),
74 fVertexSource(kInternal),
76 fPileUpTimeWindow(-1.),
86 fCollisionGeometry(0),
96 // Default constructor
99 AliDebug(1, "AliGenerator Default Constructor");
100 AliMC * mc = gAlice->GetMCApp();
101 if (mc) mc->SetGenerator(this);
104 SetThetaRange(); ResetBit(kThetaRange);
105 SetPhiRange(); ResetBit(kPhiRange);
106 SetMomentumRange(); ResetBit(kMomentumRange);
107 SetPtRange(); ResetBit(kPtRange);
108 SetYRange(); ResetBit(kYRange);
109 SetNumberParticles();
114 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
115 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
116 fVertex[0]=fVertex[1]=fVertex[2]=0;
118 fVMin[0]=fVMin[1]=fVMin[2]=0;
119 fVMax[0]=fVMax[1]=fVMax[2]=10000;
122 //_______________________________________________________________________
123 AliGenerator::AliGenerator(Int_t npart):
143 fVertexSmear(kNoSmear),
144 fVertexSource(kInternal),
146 fPileUpTimeWindow(-1.),
156 fCollisionGeometry(0),
166 // Standard constructor
169 AliDebug(1, "AliGenerator Constructor initializing number of particles");
170 AliMC * mc = gAlice->GetMCApp();
171 if (mc) mc->SetGenerator(this);
174 SetThetaRange(); ResetBit(kThetaRange);
175 SetPhiRange(); ResetBit(kPhiRange);
176 SetMomentumRange(); ResetBit(kMomentumRange);
177 SetPtRange(); ResetBit(kPtRange);
178 SetYRange(); ResetBit(kYRange);
182 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
183 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
184 fVertex[0]=fVertex[1]=fVertex[2]=0;
186 fVMin[0]=fVMin[1]=fVMin[2]=0;
187 fVMax[0]=fVMax[1]=fVMax[2]=10000;
189 SetNumberParticles(npart);
191 AliConfig::Instance()->Add(this);
194 //_______________________________________________________________________
195 AliGenerator::~AliGenerator()
208 //_______________________________________________________________________
209 void AliGenerator::Init()
212 // Dummy initialisation
216 //_______________________________________________________________________
217 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
220 // Set the vertex for the generated tracks
227 //_______________________________________________________________________
228 void AliGenerator::SetOrigin(const TLorentzVector &o)
231 // Set the vertex for the generated tracks
238 //_______________________________________________________________________
239 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
242 // Set the spread of the vertex
249 //_______________________________________________________________________
250 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
253 // Set the momentum range for the generated particles
257 SetBit(kMomentumRange);
260 //_______________________________________________________________________
261 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
264 // Set the Pt range for the generated particles
271 //_______________________________________________________________________
272 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
275 // Set the Phi range for the generated particles
277 fPhiMin = TMath::Pi()*phimin/180;
278 fPhiMax = TMath::Pi()*phimax/180;
282 //_______________________________________________________________________
283 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
286 // Set the Rapidity range for the generated particles
293 //_______________________________________________________________________
294 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
295 Float_t vymin, Float_t vymax,
296 Float_t vzmin, Float_t vzmax)
299 // Set the vertex range for the generated particles
301 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
302 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
303 SetBit(kVertexRange);
306 //_______________________________________________________________________
307 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
310 // Set the theta range for the generated particles
312 fThetaMin = TMath::Pi()*thetamin/180;
313 fThetaMax = TMath::Pi()*thetamax/180;
317 void AliGenerator::Vertex()
320 // Obtain vertex for current event from external source or calculated (internal)
322 if (fVertexSource == kInternal) {
324 } else if (fVertexSource == kContainer) {
326 } else if (fVertexSource == kExternal) {
331 //_______________________________________________________________________
332 void AliGenerator::VertexExternal()
335 // Obtain vertex from external source (vertex generator)
337 TVector3 vertex = fVertexGenerator->GetVertex();
338 fVertex[0] = vertex.X();
339 fVertex[1] = vertex.Y();
340 fVertex[2] = vertex.Z();
344 //_______________________________________________________________________
345 void AliGenerator::VertexInternal()
348 // Obtain calculated vertex
349 // Default is gaussian smearing
354 if (!TestBit(kVertexRange)) {
355 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
357 for (j=0; j < 3; j++) {
358 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
359 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
362 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
364 // In case of gaussian smearing we smear also the event/collision time
366 fTime = fTimeOrigin + fOsigma[2]/TMath::Ccgs()*
367 TMath::Cos(2*random[0]*TMath::Pi())*
368 TMath::Sqrt(-2*TMath::Log(random[1]));
372 for (j=0; j < 3; j++)
373 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
378 //_______________________________________________________________________
379 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
380 Float_t *pmom, Float_t *vpos, Float_t *polar,
381 Float_t tof, TMCProcess mech, Int_t &ntr,
382 Float_t weight, Int_t is)
385 // Loads one track on the stack
389 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
390 mech, ntr, weight, is);
392 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
393 mech, ntr, weight, is);
396 //_______________________________________________________________________
397 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
398 Double_t px, Double_t py, Double_t pz, Double_t e,
399 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
400 Double_t polx, Double_t poly, Double_t polz,
401 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
404 // Loads one track on the stack
408 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
409 polx, poly, polz, mech, ntr, weight, is);
411 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
412 polx, poly, polz, mech, ntr, weight, is);
416 //_______________________________________________________________________
417 void AliGenerator:: KeepTrack(Int_t itrack)
420 // Declare a track permanent on the stack
423 fStack->KeepTrack(itrack);
425 gAlice->GetMCApp()->KeepTrack(itrack);
429 //_______________________________________________________________________
430 void AliGenerator:: SetHighWaterMark(Int_t nt)
433 // Internal function to set the maximum index used in the stack
436 fStack->SetHighWaterMark(nt);
438 gAlice->GetMCApp()->SetHighWaterMark(nt);
441 void AliGenerator::FinishRun()