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.),
84 fCollisionGeometry(0),
94 // Default constructor
97 AliDebug(1, "AliGenerator Default Constructor");
98 AliMC * mc = gAlice->GetMCApp();
99 if (mc) mc->SetGenerator(this);
102 SetThetaRange(); ResetBit(kThetaRange);
103 SetPhiRange(); ResetBit(kPhiRange);
104 SetMomentumRange(); ResetBit(kMomentumRange);
105 SetPtRange(); ResetBit(kPtRange);
106 SetYRange(); ResetBit(kYRange);
107 SetNumberParticles();
112 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
113 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
114 fVertex[0]=fVertex[1]=fVertex[2]=0;
116 fVMin[0]=fVMin[1]=fVMin[2]=0;
117 fVMax[0]=fVMax[1]=fVMax[2]=10000;
120 //_______________________________________________________________________
121 AliGenerator::AliGenerator(Int_t npart):
141 fVertexSmear(kNoSmear),
142 fVertexSource(kInternal),
144 fPileUpTimeWindow(-1.),
152 fCollisionGeometry(0),
162 // Standard constructor
165 AliDebug(1, "AliGenerator Constructor initializing number of particles");
166 AliMC * mc = gAlice->GetMCApp();
167 if (mc) mc->SetGenerator(this);
170 SetThetaRange(); ResetBit(kThetaRange);
171 SetPhiRange(); ResetBit(kPhiRange);
172 SetMomentumRange(); ResetBit(kMomentumRange);
173 SetPtRange(); ResetBit(kPtRange);
174 SetYRange(); ResetBit(kYRange);
178 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
179 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
180 fVertex[0]=fVertex[1]=fVertex[2]=0;
182 fVMin[0]=fVMin[1]=fVMin[2]=0;
183 fVMax[0]=fVMax[1]=fVMax[2]=10000;
185 SetNumberParticles(npart);
187 AliConfig::Instance()->Add(this);
190 //_______________________________________________________________________
191 AliGenerator::~AliGenerator()
204 //_______________________________________________________________________
205 void AliGenerator::Init()
208 // Dummy initialisation
212 //_______________________________________________________________________
213 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
216 // Set the vertex for the generated tracks
223 //_______________________________________________________________________
224 void AliGenerator::SetOrigin(const TLorentzVector &o)
227 // Set the vertex for the generated tracks
234 //_______________________________________________________________________
235 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
238 // Set the spread of the vertex
245 //_______________________________________________________________________
246 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
249 // Set the momentum range for the generated particles
253 SetBit(kMomentumRange);
256 //_______________________________________________________________________
257 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
260 // Set the Pt range for the generated particles
267 //_______________________________________________________________________
268 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
271 // Set the Phi range for the generated particles
273 fPhiMin = TMath::Pi()*phimin/180;
274 fPhiMax = TMath::Pi()*phimax/180;
278 //_______________________________________________________________________
279 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
282 // Set the Rapidity range for the generated particles
289 //_______________________________________________________________________
290 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
291 Float_t vymin, Float_t vymax,
292 Float_t vzmin, Float_t vzmax)
295 // Set the vertex range for the generated particles
297 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
298 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
299 SetBit(kVertexRange);
302 //_______________________________________________________________________
303 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
306 // Set the theta range for the generated particles
308 fThetaMin = TMath::Pi()*thetamin/180;
309 fThetaMax = TMath::Pi()*thetamax/180;
313 void AliGenerator::Vertex()
316 // Obtain vertex for current event from external source or calculated (internal)
318 if (fVertexSource == kInternal) {
320 } else if (fVertexSource == kContainer) {
322 } else if (fVertexSource == kExternal) {
327 //_______________________________________________________________________
328 void AliGenerator::VertexExternal()
331 // Obtain vertex from external source (vertex generator)
333 TVector3 vertex = fVertexGenerator->GetVertex();
334 fVertex[0] = vertex.X();
335 fVertex[1] = vertex.Y();
336 fVertex[2] = vertex.Z();
339 //_______________________________________________________________________
340 void AliGenerator::VertexInternal()
343 // Obtain calculated vertex
344 // Default is gaussian smearing
349 if (!TestBit(kVertexRange)) {
350 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
352 for (j=0; j < 3; j++) {
353 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
354 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
357 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
360 for (j=0; j < 3; j++)
361 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
365 //_______________________________________________________________________
366 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
367 Float_t *pmom, Float_t *vpos, Float_t *polar,
368 Float_t tof, TMCProcess mech, Int_t &ntr,
369 Float_t weight, Int_t is)
372 // Loads one track on the stack
376 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
377 mech, ntr, weight, is);
379 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
380 mech, ntr, weight, is);
383 //_______________________________________________________________________
384 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
385 Double_t px, Double_t py, Double_t pz, Double_t e,
386 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
387 Double_t polx, Double_t poly, Double_t polz,
388 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
391 // Loads one track on the stack
395 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
396 polx, poly, polz, mech, ntr, weight, is);
398 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
399 polx, poly, polz, mech, ntr, weight, is);
403 //_______________________________________________________________________
404 void AliGenerator:: KeepTrack(Int_t itrack)
407 // Declare a track permanent on the stack
410 fStack->KeepTrack(itrack);
412 gAlice->GetMCApp()->KeepTrack(itrack);
416 //_______________________________________________________________________
417 void AliGenerator:: SetHighWaterMark(Int_t nt)
420 // Internal function to set the maximum index used in the stack
423 fStack->SetHighWaterMark(nt);
425 gAlice->GetMCApp()->SetHighWaterMark(nt);
428 void AliGenerator::FinishRun()