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.21 2002/11/21 16:13:03 alibrary
19 Removing AliMCProcess and AliMC
21 Revision 1.20 2002/10/29 14:26:49 hristov
22 Code clean-up (F.Carminati)
24 Revision 1.19 2002/03/12 11:06:03 morsch
25 Add particle status code to argument list of SetTrack(..).
27 Revision 1.18 2002/02/18 19:23:00 hristov
28 Put protection in the destructor
30 Revision 1.17 2001/11/26 15:46:35 morsch
31 Set default value for vertex truncation in constructor.
33 Revision 1.16 2001/10/16 08:45:37 morsch
34 All vertex truncation and event vertex moved here.
36 Revision 1.15 2001/07/28 10:43:41 hristov
37 Default argument initialised once
39 Revision 1.14 2001/07/27 17:13:12 morsch
40 - SetTrack, KeepTrack and SetHighWaterMark methods added to delegate to local
41 stack or stack owned by AliRun. (Piotr Skowronski, A.M.)
42 - Changes needed for afterburners (Piotr Skowronski)
44 Revision 1.13 2001/05/16 14:57:22 alibrary
45 New files for folders and Stack
47 Revision 1.12 2001/02/02 11:12:50 morsch
48 Add Vertex() method that allows to get vertex from merging manager, if needed.
50 Revision 1.11 2001/01/26 19:58:48 hristov
51 Major upgrade of AliRoot code
53 Revision 1.10 2000/12/21 15:30:18 fca
54 Correcting coding convention violations
56 Revision 1.9 2000/10/04 10:08:01 fca
57 Correction of minor typing mistakes
59 Revision 1.8 2000/10/02 21:28:14 fca
60 Removal of useless dependecies via forward declarations
62 Revision 1.7 2000/07/12 08:56:25 fca
63 Coding convention correction and warning removal
65 Revision 1.6 2000/07/11 18:24:59 fca
66 Coding convention corrections + few minor bug fixes
68 Revision 1.5 2000/06/08 13:34:50 fca
69 Better control of momentum range in GenBox
71 Revision 1.4 1999/09/29 09:24:29 fca
72 Introduction of the Copyright and cvs Log
76 ///////////////////////////////////////////////////////////////////
78 // Generate the final state of the interaction as the input //
79 // to the MonteCarlo //
83 <img src="picts/AliGeneratorClass.gif">
86 <font size=+2 color=red>
87 <p>The responsible person for this module is
88 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
94 ///////////////////////////////////////////////////////////////////
95 #include "TGenerator.h"
97 #include "AliConfig.h"
98 #include "AliGenerator.h"
99 #include "AliCollisionGeometry.h"
101 #include "AliStack.h"
103 ClassImp(AliGenerator)
105 TGenerator* AliGenerator::fgMCEvGen=0;
107 //_______________________________________________________________________
108 AliGenerator::AliGenerator():
125 fVertexSmear(kNoSmear),
126 fVertexSource(kExternal),
134 fCollisionGeometry(0)
137 // Default constructor
140 if (gAlice->GetDebug()>0)
141 printf("\n AliGenerator Default Constructor\n\n");
142 gAlice->SetGenerator(this);
145 SetThetaRange(); ResetBit(kThetaRange);
146 SetPhiRange(); ResetBit(kPhiRange);
147 SetMomentumRange(); ResetBit(kMomentumRange);
148 SetPtRange(); ResetBit(kPtRange);
149 SetYRange(); ResetBit(kYRange);
150 SetNumberParticles();
155 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
156 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
157 fVertex[0]=fVertex[1]=fVertex[2]=0;
159 fVMin[0]=fVMin[1]=fVMin[2]=0;
160 fVMax[0]=fVMax[1]=fVMax[2]=10000;
163 //_______________________________________________________________________
164 AliGenerator::AliGenerator(Int_t npart):
181 fVertexSmear(kNoSmear),
182 fVertexSource(kExternal),
190 fCollisionGeometry(0)
193 // Standard constructor
196 if (gAlice->GetDebug()>0)
197 printf("\n AliGenerator Constructor initializing number of particles \n\n");
198 gAlice->SetGenerator(this);
201 SetThetaRange(); ResetBit(kThetaRange);
202 SetPhiRange(); ResetBit(kPhiRange);
203 SetMomentumRange(); ResetBit(kMomentumRange);
204 SetPtRange(); ResetBit(kPtRange);
205 SetYRange(); ResetBit(kYRange);
209 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
210 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
211 fVertex[0]=fVertex[1]=fVertex[2]=0;
213 fVMin[0]=fVMin[1]=fVMin[2]=0;
214 fVMax[0]=fVMax[1]=fVMax[2]=10000;
216 SetNumberParticles(npart);
218 AliConfig::Instance()->Add(this);
221 //_______________________________________________________________________
222 AliGenerator::AliGenerator(const AliGenerator &gen):
241 fVertexSmear(kNoSmear),
242 fVertexSource(kExternal),
257 //_______________________________________________________________________
258 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
261 // Assignment operator
267 //_______________________________________________________________________
268 void AliGenerator::Copy(AliGenerator &/* gen */) const
271 // Copy *this onto gen
273 Fatal("Copy","Not implemented!\n");
276 //_______________________________________________________________________
277 AliGenerator::~AliGenerator()
290 //_______________________________________________________________________
291 void AliGenerator::Init()
294 // Dummy initialisation
298 //_______________________________________________________________________
299 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
302 // Set the vertex for the generated tracks
309 //_______________________________________________________________________
310 void AliGenerator::SetOrigin(const TLorentzVector &o)
313 // Set the vertex for the generated tracks
320 //_______________________________________________________________________
321 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
324 // Set the spread of the vertex
331 //_______________________________________________________________________
332 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
335 // Set the momentum range for the generated particles
339 SetBit(kMomentumRange);
342 //_______________________________________________________________________
343 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
346 // Set the Pt range for the generated particles
353 //_______________________________________________________________________
354 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
357 // Set the Phi range for the generated particles
359 fPhiMin = TMath::Pi()*phimin/180;
360 fPhiMax = TMath::Pi()*phimax/180;
364 //_______________________________________________________________________
365 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
368 // Set the Rapidity range for the generated particles
375 //_______________________________________________________________________
376 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
377 Float_t vymin, Float_t vymax,
378 Float_t vzmin, Float_t vzmax)
381 // Set the vertex range for the generated particles
383 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
384 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
385 SetBit(kVertexRange);
388 //_______________________________________________________________________
389 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
392 // Set the theta range for the generated particles
394 fThetaMin = TMath::Pi()*thetamin/180;
395 fThetaMax = TMath::Pi()*thetamax/180;
399 void AliGenerator::Vertex()
402 // Obtain vertex for current event from external source or calculated (internal)
404 if (fVertexSource == kInternal) {
411 //_______________________________________________________________________
412 void AliGenerator::VertexExternal()
415 // Obtain vertex from external source
417 // Should be something like fVertex = gAlice->GetVertex()
419 fVertex[0]=fVertex[1]=fVertex[2]=0;
422 //_______________________________________________________________________
423 void AliGenerator::VertexInternal()
426 // Obtain calculated vertex
427 // Default is gaussian smearing
430 for (Int_t j = 0; j<3 ; j++) {
432 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
433 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
437 //_______________________________________________________________________
438 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
439 Float_t *pmom, Float_t *vpos, Float_t *polar,
440 Float_t tof, TMCProcess mech, Int_t &ntr,
441 Float_t weight, Int_t is)
445 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
446 mech, ntr, weight, is);
448 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
449 mech, ntr, weight, is);
452 //_______________________________________________________________________
453 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
454 Double_t px, Double_t py, Double_t pz, Double_t e,
455 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
456 Double_t polx, Double_t poly, Double_t polz,
457 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
461 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
462 polx, poly, polz, mech, ntr, weight, is);
464 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
465 polx, poly, polz, mech, ntr, weight, is);
469 //_______________________________________________________________________
470 void AliGenerator:: KeepTrack(Int_t itrack)
473 fStack->KeepTrack(itrack);
475 gAlice->KeepTrack(itrack);
479 //_______________________________________________________________________
480 void AliGenerator:: SetHighWaterMark(Int_t nt)
483 fStack->SetHighWaterMark(nt);
485 gAlice->SetHighWaterMark(nt);