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.20 2002/10/29 14:26:49 hristov
19 Code clean-up (F.Carminati)
21 Revision 1.19 2002/03/12 11:06:03 morsch
22 Add particle status code to argument list of SetTrack(..).
24 Revision 1.18 2002/02/18 19:23:00 hristov
25 Put protection in the destructor
27 Revision 1.17 2001/11/26 15:46:35 morsch
28 Set default value for vertex truncation in constructor.
30 Revision 1.16 2001/10/16 08:45:37 morsch
31 All vertex truncation and event vertex moved here.
33 Revision 1.15 2001/07/28 10:43:41 hristov
34 Default argument initialised once
36 Revision 1.14 2001/07/27 17:13:12 morsch
37 - SetTrack, KeepTrack and SetHighWaterMark methods added to delegate to local
38 stack or stack owned by AliRun. (Piotr Skowronski, A.M.)
39 - Changes needed for afterburners (Piotr Skowronski)
41 Revision 1.13 2001/05/16 14:57:22 alibrary
42 New files for folders and Stack
44 Revision 1.12 2001/02/02 11:12:50 morsch
45 Add Vertex() method that allows to get vertex from merging manager, if needed.
47 Revision 1.11 2001/01/26 19:58:48 hristov
48 Major upgrade of AliRoot code
50 Revision 1.10 2000/12/21 15:30:18 fca
51 Correcting coding convention violations
53 Revision 1.9 2000/10/04 10:08:01 fca
54 Correction of minor typing mistakes
56 Revision 1.8 2000/10/02 21:28:14 fca
57 Removal of useless dependecies via forward declarations
59 Revision 1.7 2000/07/12 08:56:25 fca
60 Coding convention correction and warning removal
62 Revision 1.6 2000/07/11 18:24:59 fca
63 Coding convention corrections + few minor bug fixes
65 Revision 1.5 2000/06/08 13:34:50 fca
66 Better control of momentum range in GenBox
68 Revision 1.4 1999/09/29 09:24:29 fca
69 Introduction of the Copyright and cvs Log
73 ///////////////////////////////////////////////////////////////////
75 // Generate the final state of the interaction as the input //
76 // to the MonteCarlo //
80 <img src="picts/AliGeneratorClass.gif">
83 <font size=+2 color=red>
84 <p>The responsible person for this module is
85 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
91 ///////////////////////////////////////////////////////////////////
92 #include "TGenerator.h"
94 #include "AliConfig.h"
95 #include "AliGenerator.h"
99 ClassImp(AliGenerator)
101 TGenerator* AliGenerator::fgMCEvGen=0;
103 //_______________________________________________________________________
104 AliGenerator::AliGenerator():
121 fVertexSmear(kNoSmear),
122 fVertexSource(kExternal),
132 // Default constructor
135 if (gAlice->GetDebug()>0)
136 printf("\n AliGenerator Default Constructor\n\n");
137 gAlice->SetGenerator(this);
140 SetThetaRange(); ResetBit(kThetaRange);
141 SetPhiRange(); ResetBit(kPhiRange);
142 SetMomentumRange(); ResetBit(kMomentumRange);
143 SetPtRange(); ResetBit(kPtRange);
144 SetYRange(); ResetBit(kYRange);
145 SetNumberParticles();
150 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
151 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
152 fVertex[0]=fVertex[1]=fVertex[2]=0;
154 fVMin[0]=fVMin[1]=fVMin[2]=0;
155 fVMax[0]=fVMax[1]=fVMax[2]=10000;
158 //_______________________________________________________________________
159 AliGenerator::AliGenerator(Int_t npart):
176 fVertexSmear(kNoSmear),
177 fVertexSource(kExternal),
187 // Standard constructor
190 if (gAlice->GetDebug()>0)
191 printf("\n AliGenerator Constructor initializing number of particles \n\n");
192 gAlice->SetGenerator(this);
195 SetThetaRange(); ResetBit(kThetaRange);
196 SetPhiRange(); ResetBit(kPhiRange);
197 SetMomentumRange(); ResetBit(kMomentumRange);
198 SetPtRange(); ResetBit(kPtRange);
199 SetYRange(); ResetBit(kYRange);
203 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
204 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
205 fVertex[0]=fVertex[1]=fVertex[2]=0;
207 fVMin[0]=fVMin[1]=fVMin[2]=0;
208 fVMax[0]=fVMax[1]=fVMax[2]=10000;
210 SetNumberParticles(npart);
212 AliConfig::Instance()->Add(this);
215 //_______________________________________________________________________
216 AliGenerator::AliGenerator(const AliGenerator &gen):
235 fVertexSmear(kNoSmear),
236 fVertexSource(kExternal),
251 //_______________________________________________________________________
252 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
255 // Assignment operator
261 //_______________________________________________________________________
262 void AliGenerator::Copy(AliGenerator &/* gen */) const
265 // Copy *this onto gen
267 Fatal("Copy","Not implemented!\n");
270 //_______________________________________________________________________
271 AliGenerator::~AliGenerator()
284 //_______________________________________________________________________
285 void AliGenerator::Init()
288 // Dummy initialisation
292 //_______________________________________________________________________
293 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
296 // Set the vertex for the generated tracks
303 //_______________________________________________________________________
304 void AliGenerator::SetOrigin(const TLorentzVector &o)
307 // Set the vertex for the generated tracks
314 //_______________________________________________________________________
315 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
318 // Set the spread of the vertex
325 //_______________________________________________________________________
326 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
329 // Set the momentum range for the generated particles
333 SetBit(kMomentumRange);
336 //_______________________________________________________________________
337 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
340 // Set the Pt range for the generated particles
347 //_______________________________________________________________________
348 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
351 // Set the Phi range for the generated particles
353 fPhiMin = TMath::Pi()*phimin/180;
354 fPhiMax = TMath::Pi()*phimax/180;
358 //_______________________________________________________________________
359 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
362 // Set the Rapidity range for the generated particles
369 //_______________________________________________________________________
370 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
371 Float_t vymin, Float_t vymax,
372 Float_t vzmin, Float_t vzmax)
375 // Set the vertex range for the generated particles
377 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
378 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
379 SetBit(kVertexRange);
382 //_______________________________________________________________________
383 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
386 // Set the theta range for the generated particles
388 fThetaMin = TMath::Pi()*thetamin/180;
389 fThetaMax = TMath::Pi()*thetamax/180;
393 void AliGenerator::Vertex()
396 // Obtain vertex for current event from external source or calculated (internal)
398 if (fVertexSource == kInternal) {
405 //_______________________________________________________________________
406 void AliGenerator::VertexExternal()
409 // Obtain vertex from external source
411 // Should be something like fVertex = gAlice->GetVertex()
413 fVertex[0]=fVertex[1]=fVertex[2]=0;
416 //_______________________________________________________________________
417 void AliGenerator::VertexInternal()
420 // Obtain calculated vertex
421 // Default is gaussian smearing
424 for (Int_t j = 0; j<3 ; j++) {
426 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
427 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
431 //_______________________________________________________________________
432 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
433 Float_t *pmom, Float_t *vpos, Float_t *polar,
434 Float_t tof, TMCProcess mech, Int_t &ntr,
435 Float_t weight, Int_t is)
439 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
440 mech, ntr, weight, is);
442 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
443 mech, ntr, weight, is);
446 //_______________________________________________________________________
447 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
448 Double_t px, Double_t py, Double_t pz, Double_t e,
449 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
450 Double_t polx, Double_t poly, Double_t polz,
451 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
455 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
456 polx, poly, polz, mech, ntr, weight, is);
458 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
459 polx, poly, polz, mech, ntr, weight, is);
463 //_______________________________________________________________________
464 void AliGenerator:: KeepTrack(Int_t itrack)
467 fStack->KeepTrack(itrack);
469 gAlice->KeepTrack(itrack);
473 //_______________________________________________________________________
474 void AliGenerator:: SetHighWaterMark(Int_t nt)
477 fStack->SetHighWaterMark(nt);
479 gAlice->SetHighWaterMark(nt);