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.16 2001/10/16 08:45:37 morsch
19 All vertex truncation and event vertex moved here.
21 Revision 1.15 2001/07/28 10:43:41 hristov
22 Default argument initialised once
24 Revision 1.14 2001/07/27 17:13:12 morsch
25 - SetTrack, KeepTrack and SetHighWaterMark methods added to delegate to local
26 stack or stack owned by AliRun. (Piotr Skowronski, A.M.)
27 - Changes needed for afterburners (Piotr Skowronski)
29 Revision 1.13 2001/05/16 14:57:22 alibrary
30 New files for folders and Stack
32 Revision 1.12 2001/02/02 11:12:50 morsch
33 Add Vertex() method that allows to get vertex from merging manager, if needed.
35 Revision 1.11 2001/01/26 19:58:48 hristov
36 Major upgrade of AliRoot code
38 Revision 1.10 2000/12/21 15:30:18 fca
39 Correcting coding convention violations
41 Revision 1.9 2000/10/04 10:08:01 fca
42 Correction of minor typing mistakes
44 Revision 1.8 2000/10/02 21:28:14 fca
45 Removal of useless dependecies via forward declarations
47 Revision 1.7 2000/07/12 08:56:25 fca
48 Coding convention correction and warning removal
50 Revision 1.6 2000/07/11 18:24:59 fca
51 Coding convention corrections + few minor bug fixes
53 Revision 1.5 2000/06/08 13:34:50 fca
54 Better control of momentum range in GenBox
56 Revision 1.4 1999/09/29 09:24:29 fca
57 Introduction of the Copyright and cvs Log
61 ///////////////////////////////////////////////////////////////////
63 // Generate the final state of the interaction as the input //
64 // to the MonteCarlo //
68 <img src="picts/AliGeneratorClass.gif">
71 <font size=+2 color=red>
72 <p>The responsible person for this module is
73 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
79 ///////////////////////////////////////////////////////////////////
81 #include "AliGenerator.h"
82 #include "TGenerator.h"
84 #include "AliConfig.h"
88 ClassImp(AliGenerator)
90 TGenerator* AliGenerator::fgMCEvGen=0;
92 //____________________________________________________________
93 AliGenerator::AliGenerator()
96 // Default constructor
99 if (gAlice->GetDebug()>0)
100 printf("\n AliGenerator Default Constructor\n\n");
101 gAlice->SetGenerator(this);
104 SetThetaRange(); ResetBit(kThetaRange);
105 SetPhiRange(); ResetBit(kPhiRange);
106 SetMomentumRange(); ResetBit(kMomentumRange);
107 SetPtRange(); ResetBit(kPtRange);
108 SetYRange(); ResetBit(kYRange);
109 SetNumberParticles();
118 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
119 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
120 fVertex[0]=fVertex[1]=fVertex[2]=0;
123 fVMin[0]=fVMin[1]=fVMin[2]=0;
125 fVMax[0]=fVMax[1]=fVMax[2]=10000;
129 //____________________________________________________________
130 AliGenerator::AliGenerator(Int_t npart)
134 // Standard constructor
137 if (gAlice->GetDebug()>0)
138 printf("\n AliGenerator Constructor initializing number of particles \n\n");
139 gAlice->SetGenerator(this);
142 SetThetaRange(); ResetBit(kThetaRange);
143 SetPhiRange(); ResetBit(kPhiRange);
144 SetMomentumRange(); ResetBit(kMomentumRange);
145 SetPtRange(); ResetBit(kPtRange);
146 SetYRange(); ResetBit(kYRange);
154 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
155 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
156 fVertex[0]=fVertex[1]=fVertex[2]=0;
159 fVMin[0]=fVMin[1]=fVMin[2]=0;
161 fVMax[0]=fVMax[1]=fVMax[2]=10000;
163 SetNumberParticles(npart);
165 AliConfig::Instance()->Add(this);
169 //____________________________________________________________
170 AliGenerator::AliGenerator(const AliGenerator &gen) : TNamed(" "," ")
178 //____________________________________________________________
179 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
182 // Assignment operator
188 //____________________________________________________________
189 void AliGenerator::Copy(AliGenerator &/* gen */) const
192 // Copy *this onto gen
194 Fatal("Copy","Not implemented!\n");
197 //____________________________________________________________
198 AliGenerator::~AliGenerator()
208 void AliGenerator::Init()
211 // Dummy initialisation
215 //_______________________________________________________________________
216 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
219 // Set the vertex for the generated tracks
226 //_______________________________________________________________________
227 void AliGenerator::SetOrigin(const TLorentzVector &o)
230 // Set the vertex for the generated tracks
237 //_______________________________________________________________________
238 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
241 // Set the spread of the vertex
248 //_______________________________________________________________________
249 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
252 // Set the momentum range for the generated particles
256 SetBit(kMomentumRange);
259 //_______________________________________________________________________
260 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
263 // Set the Pt range for the generated particles
270 //_______________________________________________________________________
271 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
274 // Set the Phi range for the generated particles
276 fPhiMin = TMath::Pi()*phimin/180;
277 fPhiMax = TMath::Pi()*phimax/180;
281 //_______________________________________________________________________
282 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
285 // Set the Rapidity range for the generated particles
292 //_______________________________________________________________________
293 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
294 Float_t vymin, Float_t vymax,
295 Float_t vzmin, Float_t vzmax)
298 // Set the vertex range for the generated particles
300 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
301 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
302 SetBit(kVertexRange);
305 //_______________________________________________________________________
306 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
309 // Set the theta range for the generated particles
311 fThetaMin = TMath::Pi()*thetamin/180;
312 fThetaMax = TMath::Pi()*thetamax/180;
316 void AliGenerator::Vertex()
319 // Obtain vertex for current event from external source or calculated (internal)
321 if (fVertexSource == kInternal) {
329 void AliGenerator::VertexExternal()
332 // Obtain vertex from external source
334 // Should be something like fVertex = gAlice->GetVertex()
336 fVertex[0]=fVertex[1]=fVertex[2]=0;
339 void AliGenerator::VertexInternal()
342 // Obtain calculated vertex
343 // Default is gaussian smearing
346 for (Int_t j = 0; j<3 ; j++) {
348 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
349 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
353 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
354 Float_t *pmom, Float_t *vpos, Float_t *polar,
355 Float_t tof, AliMCProcess mech, Int_t &ntr,
360 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
363 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
366 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
367 Double_t px, Double_t py, Double_t pz, Double_t e,
368 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
369 Double_t polx, Double_t poly, Double_t polz,
370 AliMCProcess mech, Int_t &ntr, Float_t weight)
374 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
375 polx, poly, polz, mech, ntr, weight);
377 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
378 polx, poly, polz, mech, ntr, weight);
382 void AliGenerator:: KeepTrack(Int_t itrack)
385 fStack->KeepTrack(itrack);
387 gAlice->KeepTrack(itrack);
391 void AliGenerator:: SetHighWaterMark(Int_t nt)
394 fStack->SetHighWaterMark(nt);
396 gAlice->SetHighWaterMark(nt);