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>
39 #include "AliCollisionGeometry.h"
40 #include "AliConfig.h"
41 #include "AliGenerator.h"
45 ClassImp(AliGenerator)
47 TGenerator* AliGenerator::fgMCEvGen=0;
49 //_______________________________________________________________________
50 AliGenerator::AliGenerator():
67 fVertexSmear(kNoSmear),
68 fVertexSource(kInternal),
78 // Default constructor
81 if (gAlice->GetDebug()>0)
82 printf("\n AliGenerator Default Constructor\n\n");
83 gAlice->SetGenerator(this);
86 SetThetaRange(); ResetBit(kThetaRange);
87 SetPhiRange(); ResetBit(kPhiRange);
88 SetMomentumRange(); ResetBit(kMomentumRange);
89 SetPtRange(); ResetBit(kPtRange);
90 SetYRange(); ResetBit(kYRange);
96 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
97 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
98 fVertex[0]=fVertex[1]=fVertex[2]=0;
100 fVMin[0]=fVMin[1]=fVMin[2]=0;
101 fVMax[0]=fVMax[1]=fVMax[2]=10000;
104 //_______________________________________________________________________
105 AliGenerator::AliGenerator(Int_t npart):
122 fVertexSmear(kNoSmear),
123 fVertexSource(kInternal),
130 fCollisionGeometry(0)
133 // Standard constructor
136 if (gAlice->GetDebug()>0)
137 printf("\n AliGenerator Constructor initializing number of particles \n\n");
138 gAlice->SetGenerator(this);
141 SetThetaRange(); ResetBit(kThetaRange);
142 SetPhiRange(); ResetBit(kPhiRange);
143 SetMomentumRange(); ResetBit(kMomentumRange);
144 SetPtRange(); ResetBit(kPtRange);
145 SetYRange(); ResetBit(kYRange);
149 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
150 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
151 fVertex[0]=fVertex[1]=fVertex[2]=0;
153 fVMin[0]=fVMin[1]=fVMin[2]=0;
154 fVMax[0]=fVMax[1]=fVMax[2]=10000;
156 SetNumberParticles(npart);
158 AliConfig::Instance()->Add(this);
161 //_______________________________________________________________________
162 AliGenerator::AliGenerator(const AliGenerator &gen):
181 fVertexSmear(kNoSmear),
182 fVertexSource(kInternal),
196 //_______________________________________________________________________
197 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
200 // Assignment operator
206 //_______________________________________________________________________
207 void AliGenerator::Copy(AliGenerator &/* gen */) const
210 // Copy *this onto gen
212 Fatal("Copy","Not implemented!\n");
215 //_______________________________________________________________________
216 AliGenerator::~AliGenerator()
229 //_______________________________________________________________________
230 void AliGenerator::Init()
233 // Dummy initialisation
237 //_______________________________________________________________________
238 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
241 // Set the vertex for the generated tracks
248 //_______________________________________________________________________
249 void AliGenerator::SetOrigin(const TLorentzVector &o)
252 // Set the vertex for the generated tracks
259 //_______________________________________________________________________
260 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
263 // Set the spread of the vertex
270 //_______________________________________________________________________
271 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
274 // Set the momentum range for the generated particles
278 SetBit(kMomentumRange);
281 //_______________________________________________________________________
282 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
285 // Set the Pt range for the generated particles
292 //_______________________________________________________________________
293 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
296 // Set the Phi range for the generated particles
298 fPhiMin = TMath::Pi()*phimin/180;
299 fPhiMax = TMath::Pi()*phimax/180;
303 //_______________________________________________________________________
304 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
307 // Set the Rapidity range for the generated particles
314 //_______________________________________________________________________
315 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
316 Float_t vymin, Float_t vymax,
317 Float_t vzmin, Float_t vzmax)
320 // Set the vertex range for the generated particles
322 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
323 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
324 SetBit(kVertexRange);
327 //_______________________________________________________________________
328 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
331 // Set the theta range for the generated particles
333 fThetaMin = TMath::Pi()*thetamin/180;
334 fThetaMax = TMath::Pi()*thetamax/180;
338 void AliGenerator::Vertex()
341 // Obtain vertex for current event from external source or calculated (internal)
343 if (fVertexSource == kInternal) {
345 } else if (fVertexSource == kContainer) {
347 } else if (fVertexSource == kExternal) {
352 //_______________________________________________________________________
353 void AliGenerator::VertexExternal()
356 // Obtain vertex from external source
358 // Should be something like fVertex = gAlice->GetVertex()
360 fVertex[0]=fVertex[1]=fVertex[2]=0;
363 //_______________________________________________________________________
364 void AliGenerator::VertexInternal()
367 // Obtain calculated vertex
368 // Default is gaussian smearing
374 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
376 for (j=0; j < 3; j++) {
377 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
378 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
381 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
385 //_______________________________________________________________________
386 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
387 Float_t *pmom, Float_t *vpos, Float_t *polar,
388 Float_t tof, TMCProcess mech, Int_t &ntr,
389 Float_t weight, Int_t is)
392 // Loads one track on the stack
396 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
397 mech, ntr, weight, is);
399 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
400 mech, ntr, weight, is);
403 //_______________________________________________________________________
404 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
405 Double_t px, Double_t py, Double_t pz, Double_t e,
406 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
407 Double_t polx, Double_t poly, Double_t polz,
408 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
411 // Loads one track on the stack
415 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
416 polx, poly, polz, mech, ntr, weight, is);
418 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
419 polx, poly, polz, mech, ntr, weight, is);
423 //_______________________________________________________________________
424 void AliGenerator:: KeepTrack(Int_t itrack)
427 // Declare a track permanent on the stack
430 fStack->KeepTrack(itrack);
432 gAlice->KeepTrack(itrack);
436 //_______________________________________________________________________
437 void AliGenerator:: SetHighWaterMark(Int_t nt)
440 // Internal function to set the maximum index used in the stack
443 fStack->SetHighWaterMark(nt);
445 gAlice->SetHighWaterMark(nt);
448 void AliGenerator::FinishRun()