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 Revision 1.14 2001/07/27 17:13:12 morsch
19 - SetTrack, KeepTrack and SetHighWaterMark methods added to delegate to local
20 stack or stack owned by AliRun. (Piotr Skowronski, A.M.)
21 - Changes needed for afterburners (Piotr Skowronski)
23 Revision 1.13 2001/05/16 14:57:22 alibrary
24 New files for folders and Stack
26 Revision 1.12 2001/02/02 11:12:50 morsch
27 Add Vertex() method that allows to get vertex from merging manager, if needed.
29 Revision 1.11 2001/01/26 19:58:48 hristov
30 Major upgrade of AliRoot code
32 Revision 1.10 2000/12/21 15:30:18 fca
33 Correcting coding convention violations
35 Revision 1.9 2000/10/04 10:08:01 fca
36 Correction of minor typing mistakes
38 Revision 1.8 2000/10/02 21:28:14 fca
39 Removal of useless dependecies via forward declarations
41 Revision 1.7 2000/07/12 08:56:25 fca
42 Coding convention correction and warning removal
44 Revision 1.6 2000/07/11 18:24:59 fca
45 Coding convention corrections + few minor bug fixes
47 Revision 1.5 2000/06/08 13:34:50 fca
48 Better control of momentum range in GenBox
50 Revision 1.4 1999/09/29 09:24:29 fca
51 Introduction of the Copyright and cvs Log
55 ///////////////////////////////////////////////////////////////////
57 // Generate the final state of the interaction as the input //
58 // to the MonteCarlo //
62 <img src="picts/AliGeneratorClass.gif">
65 <font size=+2 color=red>
66 <p>The responsible person for this module is
67 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
73 ///////////////////////////////////////////////////////////////////
75 #include "AliGenerator.h"
76 #include "TGenerator.h"
78 #include "AliConfig.h"
82 ClassImp(AliGenerator)
84 TGenerator* AliGenerator::fgMCEvGen=0;
86 //____________________________________________________________
87 AliGenerator::AliGenerator()
90 // Default constructor
92 if (gAlice->GetDebug()>0)
93 printf("\n AliGenerator Default Constructor\n\n");
95 gAlice->SetGenerator(this);
96 SetThetaRange(); ResetBit(kThetaRange);
97 SetPhiRange(); ResetBit(kPhiRange);
98 SetMomentumRange(); ResetBit(kMomentumRange);
99 SetPtRange(); ResetBit(kPtRange);
100 SetYRange(); ResetBit(kYRange);
101 SetNumberParticles();
108 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
109 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
110 fVertex[0]=fVertex[1]=fVertex[2]=0;
113 fVMin[0]=fVMin[1]=fVMin[2]=0;
115 fVMax[0]=fVMax[1]=fVMax[2]=10000;
119 //____________________________________________________________
120 AliGenerator::AliGenerator(Int_t npart)
124 // Standard constructor
126 if (gAlice->GetDebug()>0)
127 printf("\n AliGenerator Constructor initializing number of particles \n\n");
128 gAlice->SetGenerator(this);
129 SetThetaRange(); ResetBit(kThetaRange);
130 SetPhiRange(); ResetBit(kPhiRange);
131 SetMomentumRange(); ResetBit(kMomentumRange);
132 SetPtRange(); ResetBit(kPtRange);
133 SetYRange(); ResetBit(kYRange);
140 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
141 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
142 fVertex[0]=fVertex[1]=fVertex[2]=0;
145 fVMin[0]=fVMin[1]=fVMin[2]=0;
147 fVMax[0]=fVMax[1]=fVMax[2]=10000;
149 SetNumberParticles(npart);
151 AliConfig::Instance()->Add(this);
155 //____________________________________________________________
156 AliGenerator::AliGenerator(const AliGenerator &gen) : TNamed(" "," ")
164 //____________________________________________________________
165 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
168 // Assignment operator
174 //____________________________________________________________
175 void AliGenerator::Copy(AliGenerator &/* gen */) const
178 // Copy *this onto gen
180 Fatal("Copy","Not implemented!\n");
183 //____________________________________________________________
184 AliGenerator::~AliGenerator()
194 void AliGenerator::Init()
197 // Dummy initialisation
201 //_______________________________________________________________________
202 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
205 // Set the vertex for the generated tracks
212 //_______________________________________________________________________
213 void AliGenerator::SetOrigin(const TLorentzVector &o)
216 // Set the vertex for the generated tracks
223 //_______________________________________________________________________
224 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
227 // Set the spread of the vertex
234 //_______________________________________________________________________
235 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
238 // Set the momentum range for the generated particles
242 SetBit(kMomentumRange);
245 //_______________________________________________________________________
246 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
249 // Set the Pt range for the generated particles
256 //_______________________________________________________________________
257 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
260 // Set the Phi range for the generated particles
262 fPhiMin = TMath::Pi()*phimin/180;
263 fPhiMax = TMath::Pi()*phimax/180; SetBit(kPhiRange);
266 //_______________________________________________________________________
267 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
270 // Set the Rapidity range for the generated particles
277 //_______________________________________________________________________
278 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
279 Float_t vymin, Float_t vymax,
280 Float_t vzmin, Float_t vzmax)
283 // Set the vertex range for the generated particles
285 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
286 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
287 SetBit(kVertexRange);
290 //_______________________________________________________________________
291 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
294 // Set the theta range for the generated particles
296 fThetaMin = TMath::Pi()*thetamin/180;
297 fThetaMax = TMath::Pi()*thetamax/180; SetBit(kThetaRange);
300 void AliGenerator::Vertex()
303 // Obtain vertex for current event from external source or calculated (internal)
305 if (fVertexSource == kInternal) {
313 void AliGenerator::VertexExternal()
316 // Obtain vertex from external source
318 // Should be something like fVertex = gAlice->GetVertex()
320 fVertex[0]=fVertex[1]=fVertex[2]=0;
323 void AliGenerator::VertexInternal()
326 // Obtain calculated vertex
327 // Default is gaussian smearing
330 for (Int_t j = 0; j<3 ; j++) {
332 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
333 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
337 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
338 Float_t *pmom, Float_t *vpos, Float_t *polar,
339 Float_t tof, AliMCProcess mech, Int_t &ntr,
344 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
347 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
350 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
351 Double_t px, Double_t py, Double_t pz, Double_t e,
352 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
353 Double_t polx, Double_t poly, Double_t polz,
354 AliMCProcess mech, Int_t &ntr, Float_t weight)
358 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
359 polx, poly, polz, mech, ntr, weight);
361 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
362 polx, poly, polz, mech, ntr, weight);
366 void AliGenerator:: KeepTrack(Int_t itrack)
369 fStack->KeepTrack(itrack);
371 gAlice->KeepTrack(itrack);
375 void AliGenerator:: SetHighWaterMark(Int_t nt)
378 fStack->SetHighWaterMark(nt);
380 gAlice->SetHighWaterMark(nt);