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 //-----------------------------------------------------------------
19 // Generate the final state of the interaction as the input
22 //-----------------------------------------------------------------
25 <img src="picts/AliGeneratorClass.gif">
28 <font size=+2 color=red>
29 <p>The responsible person for this module is
30 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
36 ///////////////////////////////////////////////////////////////////
37 #include <TGenerator.h>
39 #include "AliCollisionGeometry.h"
40 #include "AliConfig.h"
41 #include "AliGenerator.h"
45 ClassImp(AliGenerator)
47 TGenerator* AliGenerator::fgMCEvGen=0;
49 //_______________________________________________________________________
50 AliGenerator::AliGenerator():
67 fVertexSmear(kNoSmear),
68 fVertexSource(kExternal),
79 // Default constructor
82 if (gAlice->GetDebug()>0)
83 printf("\n AliGenerator Default Constructor\n\n");
84 gAlice->SetGenerator(this);
87 SetThetaRange(); ResetBit(kThetaRange);
88 SetPhiRange(); ResetBit(kPhiRange);
89 SetMomentumRange(); ResetBit(kMomentumRange);
90 SetPtRange(); ResetBit(kPtRange);
91 SetYRange(); ResetBit(kYRange);
97 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
98 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
99 fVertex[0]=fVertex[1]=fVertex[2]=0;
101 fVMin[0]=fVMin[1]=fVMin[2]=0;
102 fVMax[0]=fVMax[1]=fVMax[2]=10000;
105 //_______________________________________________________________________
106 AliGenerator::AliGenerator(Int_t npart):
123 fVertexSmear(kNoSmear),
124 fVertexSource(kExternal),
132 fCollisionGeometry(0)
135 // Standard constructor
138 if (gAlice->GetDebug()>0)
139 printf("\n AliGenerator Constructor initializing number of particles \n\n");
140 gAlice->SetGenerator(this);
143 SetThetaRange(); ResetBit(kThetaRange);
144 SetPhiRange(); ResetBit(kPhiRange);
145 SetMomentumRange(); ResetBit(kMomentumRange);
146 SetPtRange(); ResetBit(kPtRange);
147 SetYRange(); ResetBit(kYRange);
151 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
152 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
153 fVertex[0]=fVertex[1]=fVertex[2]=0;
155 fVMin[0]=fVMin[1]=fVMin[2]=0;
156 fVMax[0]=fVMax[1]=fVMax[2]=10000;
158 SetNumberParticles(npart);
160 AliConfig::Instance()->Add(this);
163 //_______________________________________________________________________
164 AliGenerator::AliGenerator(const AliGenerator &gen):
183 fVertexSmear(kNoSmear),
184 fVertexSource(kExternal),
199 //_______________________________________________________________________
200 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
203 // Assignment operator
209 //_______________________________________________________________________
210 void AliGenerator::Copy(AliGenerator &/* gen */) const
213 // Copy *this onto gen
215 Fatal("Copy","Not implemented!\n");
218 //_______________________________________________________________________
219 AliGenerator::~AliGenerator()
232 //_______________________________________________________________________
233 void AliGenerator::Init()
236 // Dummy initialisation
240 //_______________________________________________________________________
241 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
244 // Set the vertex for the generated tracks
251 //_______________________________________________________________________
252 void AliGenerator::SetOrigin(const TLorentzVector &o)
255 // Set the vertex for the generated tracks
262 //_______________________________________________________________________
263 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
266 // Set the spread of the vertex
273 //_______________________________________________________________________
274 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
277 // Set the momentum range for the generated particles
281 SetBit(kMomentumRange);
284 //_______________________________________________________________________
285 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
288 // Set the Pt range for the generated particles
295 //_______________________________________________________________________
296 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
299 // Set the Phi range for the generated particles
301 fPhiMin = TMath::Pi()*phimin/180;
302 fPhiMax = TMath::Pi()*phimax/180;
306 //_______________________________________________________________________
307 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
310 // Set the Rapidity range for the generated particles
317 //_______________________________________________________________________
318 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
319 Float_t vymin, Float_t vymax,
320 Float_t vzmin, Float_t vzmax)
323 // Set the vertex range for the generated particles
325 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
326 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
327 SetBit(kVertexRange);
330 //_______________________________________________________________________
331 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
334 // Set the theta range for the generated particles
336 fThetaMin = TMath::Pi()*thetamin/180;
337 fThetaMax = TMath::Pi()*thetamax/180;
341 void AliGenerator::Vertex()
344 // Obtain vertex for current event from external source or calculated (internal)
346 if (fVertexSource == kInternal) {
353 //_______________________________________________________________________
354 void AliGenerator::VertexExternal()
357 // Obtain vertex from external source
359 // Should be something like fVertex = gAlice->GetVertex()
361 fVertex[0]=fVertex[1]=fVertex[2]=0;
364 //_______________________________________________________________________
365 void AliGenerator::VertexInternal()
368 // Obtain calculated vertex
369 // Default is gaussian smearing
372 for (Int_t j = 0; j<3 ; j++) {
374 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
375 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
379 //_______________________________________________________________________
380 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
381 Float_t *pmom, Float_t *vpos, Float_t *polar,
382 Float_t tof, TMCProcess mech, Int_t &ntr,
383 Float_t weight, Int_t is)
386 // Loads one track on the stack
390 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
391 mech, ntr, weight, is);
393 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
394 mech, ntr, weight, is);
397 //_______________________________________________________________________
398 void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
399 Double_t px, Double_t py, Double_t pz, Double_t e,
400 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
401 Double_t polx, Double_t poly, Double_t polz,
402 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
405 // Loads one track on the stack
409 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
410 polx, poly, polz, mech, ntr, weight, is);
412 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
413 polx, poly, polz, mech, ntr, weight, is);
417 //_______________________________________________________________________
418 void AliGenerator:: KeepTrack(Int_t itrack)
421 // Declare a track permanent on the stack
424 fStack->KeepTrack(itrack);
426 gAlice->KeepTrack(itrack);
430 //_______________________________________________________________________
431 void AliGenerator:: SetHighWaterMark(Int_t nt)
434 // Internal function to set the maximum index used in the stack
437 fStack->SetHighWaterMark(nt);
439 gAlice->SetHighWaterMark(nt);