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.18 2002/02/18 19:23:00 hristov
19 Put protection in the destructor
21 Revision 1.17 2001/11/26 15:46:35 morsch
22 Set default value for vertex truncation in constructor.
24 Revision 1.16 2001/10/16 08:45:37 morsch
25 All vertex truncation and event vertex moved here.
27 Revision 1.15 2001/07/28 10:43:41 hristov
28 Default argument initialised once
30 Revision 1.14 2001/07/27 17:13:12 morsch
31 - SetTrack, KeepTrack and SetHighWaterMark methods added to delegate to local
32 stack or stack owned by AliRun. (Piotr Skowronski, A.M.)
33 - Changes needed for afterburners (Piotr Skowronski)
35 Revision 1.13 2001/05/16 14:57:22 alibrary
36 New files for folders and Stack
38 Revision 1.12 2001/02/02 11:12:50 morsch
39 Add Vertex() method that allows to get vertex from merging manager, if needed.
41 Revision 1.11 2001/01/26 19:58:48 hristov
42 Major upgrade of AliRoot code
44 Revision 1.10 2000/12/21 15:30:18 fca
45 Correcting coding convention violations
47 Revision 1.9 2000/10/04 10:08:01 fca
48 Correction of minor typing mistakes
50 Revision 1.8 2000/10/02 21:28:14 fca
51 Removal of useless dependecies via forward declarations
53 Revision 1.7 2000/07/12 08:56:25 fca
54 Coding convention correction and warning removal
56 Revision 1.6 2000/07/11 18:24:59 fca
57 Coding convention corrections + few minor bug fixes
59 Revision 1.5 2000/06/08 13:34:50 fca
60 Better control of momentum range in GenBox
62 Revision 1.4 1999/09/29 09:24:29 fca
63 Introduction of the Copyright and cvs Log
67 ///////////////////////////////////////////////////////////////////
69 // Generate the final state of the interaction as the input //
70 // to the MonteCarlo //
74 <img src="picts/AliGeneratorClass.gif">
77 <font size=+2 color=red>
78 <p>The responsible person for this module is
79 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
85 ///////////////////////////////////////////////////////////////////
87 #include "AliGenerator.h"
88 #include "TGenerator.h"
90 #include "AliConfig.h"
94 ClassImp(AliGenerator)
96 TGenerator* AliGenerator::fgMCEvGen=0;
98 //____________________________________________________________
99 AliGenerator::AliGenerator()
102 // Default constructor
105 if (gAlice->GetDebug()>0)
106 printf("\n AliGenerator Default Constructor\n\n");
107 gAlice->SetGenerator(this);
110 SetThetaRange(); ResetBit(kThetaRange);
111 SetPhiRange(); ResetBit(kPhiRange);
112 SetMomentumRange(); ResetBit(kMomentumRange);
113 SetPtRange(); ResetBit(kPtRange);
114 SetYRange(); ResetBit(kYRange);
115 SetNumberParticles();
124 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
125 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
126 fVertex[0]=fVertex[1]=fVertex[2]=0;
129 fVMin[0]=fVMin[1]=fVMin[2]=0;
131 fVMax[0]=fVMax[1]=fVMax[2]=10000;
135 //____________________________________________________________
136 AliGenerator::AliGenerator(Int_t npart)
140 // Standard constructor
143 if (gAlice->GetDebug()>0)
144 printf("\n AliGenerator Constructor initializing number of particles \n\n");
145 gAlice->SetGenerator(this);
148 SetThetaRange(); ResetBit(kThetaRange);
149 SetPhiRange(); ResetBit(kPhiRange);
150 SetMomentumRange(); ResetBit(kMomentumRange);
151 SetPtRange(); ResetBit(kPtRange);
152 SetYRange(); ResetBit(kYRange);
160 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
161 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
162 fVertex[0]=fVertex[1]=fVertex[2]=0;
165 fVMin[0]=fVMin[1]=fVMin[2]=0;
167 fVMax[0]=fVMax[1]=fVMax[2]=10000;
169 SetNumberParticles(npart);
171 AliConfig::Instance()->Add(this);
175 //____________________________________________________________
176 AliGenerator::AliGenerator(const AliGenerator &gen) : TNamed(" "," ")
184 //____________________________________________________________
185 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
188 // Assignment operator
194 //____________________________________________________________
195 void AliGenerator::Copy(AliGenerator &/* gen */) const
198 // Copy *this onto gen
200 Fatal("Copy","Not implemented!\n");
203 //____________________________________________________________
204 AliGenerator::~AliGenerator()
217 void AliGenerator::Init()
220 // Dummy initialisation
224 //_______________________________________________________________________
225 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
228 // Set the vertex for the generated tracks
235 //_______________________________________________________________________
236 void AliGenerator::SetOrigin(const TLorentzVector &o)
239 // Set the vertex for the generated tracks
246 //_______________________________________________________________________
247 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
250 // Set the spread of the vertex
257 //_______________________________________________________________________
258 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
261 // Set the momentum range for the generated particles
265 SetBit(kMomentumRange);
268 //_______________________________________________________________________
269 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
272 // Set the Pt range for the generated particles
279 //_______________________________________________________________________
280 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
283 // Set the Phi range for the generated particles
285 fPhiMin = TMath::Pi()*phimin/180;
286 fPhiMax = TMath::Pi()*phimax/180;
290 //_______________________________________________________________________
291 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
294 // Set the Rapidity range for the generated particles
301 //_______________________________________________________________________
302 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
303 Float_t vymin, Float_t vymax,
304 Float_t vzmin, Float_t vzmax)
307 // Set the vertex range for the generated particles
309 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
310 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
311 SetBit(kVertexRange);
314 //_______________________________________________________________________
315 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
318 // Set the theta range for the generated particles
320 fThetaMin = TMath::Pi()*thetamin/180;
321 fThetaMax = TMath::Pi()*thetamax/180;
325 void AliGenerator::Vertex()
328 // Obtain vertex for current event from external source or calculated (internal)
330 if (fVertexSource == kInternal) {
338 void AliGenerator::VertexExternal()
341 // Obtain vertex from external source
343 // Should be something like fVertex = gAlice->GetVertex()
345 fVertex[0]=fVertex[1]=fVertex[2]=0;
348 void AliGenerator::VertexInternal()
351 // Obtain calculated vertex
352 // Default is gaussian smearing
355 for (Int_t j = 0; j<3 ; j++) {
357 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
358 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
362 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
363 Float_t *pmom, Float_t *vpos, Float_t *polar,
364 Float_t tof, AliMCProcess mech, Int_t &ntr,
365 Float_t weight, Int_t is)
369 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
370 mech, ntr, weight, is);
372 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
373 mech, ntr, weight, is);
375 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
376 Double_t px, Double_t py, Double_t pz, Double_t e,
377 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
378 Double_t polx, Double_t poly, Double_t polz,
379 AliMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
383 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
384 polx, poly, polz, mech, ntr, weight, is);
386 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
387 polx, poly, polz, mech, ntr, weight, is);
391 void AliGenerator:: KeepTrack(Int_t itrack)
394 fStack->KeepTrack(itrack);
396 gAlice->KeepTrack(itrack);
400 void AliGenerator:: SetHighWaterMark(Int_t nt)
403 fStack->SetHighWaterMark(nt);
405 gAlice->SetHighWaterMark(nt);