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)
48 //_______________________________________________________________________
49 AliGenerator::AliGenerator():
66 fVertexSmear(kNoSmear),
67 fVertexSource(kInternal),
77 // Default constructor
80 if (gAlice->GetDebug()>0)
81 printf("\n AliGenerator Default Constructor\n\n");
82 gAlice->SetGenerator(this);
85 SetThetaRange(); ResetBit(kThetaRange);
86 SetPhiRange(); ResetBit(kPhiRange);
87 SetMomentumRange(); ResetBit(kMomentumRange);
88 SetPtRange(); ResetBit(kPtRange);
89 SetYRange(); ResetBit(kYRange);
95 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
96 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
97 fVertex[0]=fVertex[1]=fVertex[2]=0;
99 fVMin[0]=fVMin[1]=fVMin[2]=0;
100 fVMax[0]=fVMax[1]=fVMax[2]=10000;
103 //_______________________________________________________________________
104 AliGenerator::AliGenerator(Int_t npart):
121 fVertexSmear(kNoSmear),
122 fVertexSource(kInternal),
129 fCollisionGeometry(0)
132 // Standard constructor
135 if (gAlice->GetDebug()>0)
136 printf("\n AliGenerator Constructor initializing number of particles \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);
148 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
149 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
150 fVertex[0]=fVertex[1]=fVertex[2]=0;
152 fVMin[0]=fVMin[1]=fVMin[2]=0;
153 fVMax[0]=fVMax[1]=fVMax[2]=10000;
155 SetNumberParticles(npart);
157 AliConfig::Instance()->Add(this);
160 //_______________________________________________________________________
161 AliGenerator::AliGenerator(const AliGenerator &gen):
180 fVertexSmear(kNoSmear),
181 fVertexSource(kInternal),
195 //_______________________________________________________________________
196 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
199 // Assignment operator
205 //_______________________________________________________________________
206 void AliGenerator::Copy(AliGenerator &/* gen */) const
209 // Copy *this onto gen
211 Fatal("Copy","Not implemented!\n");
214 //_______________________________________________________________________
215 AliGenerator::~AliGenerator()
228 //_______________________________________________________________________
229 void AliGenerator::Init()
232 // Dummy initialisation
236 //_______________________________________________________________________
237 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
240 // Set the vertex for the generated tracks
247 //_______________________________________________________________________
248 void AliGenerator::SetOrigin(const TLorentzVector &o)
251 // Set the vertex for the generated tracks
258 //_______________________________________________________________________
259 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
262 // Set the spread of the vertex
269 //_______________________________________________________________________
270 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
273 // Set the momentum range for the generated particles
277 SetBit(kMomentumRange);
280 //_______________________________________________________________________
281 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
284 // Set the Pt range for the generated particles
291 //_______________________________________________________________________
292 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
295 // Set the Phi range for the generated particles
297 fPhiMin = TMath::Pi()*phimin/180;
298 fPhiMax = TMath::Pi()*phimax/180;
302 //_______________________________________________________________________
303 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
306 // Set the Rapidity range for the generated particles
313 //_______________________________________________________________________
314 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
315 Float_t vymin, Float_t vymax,
316 Float_t vzmin, Float_t vzmax)
319 // Set the vertex range for the generated particles
321 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
322 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
323 SetBit(kVertexRange);
326 //_______________________________________________________________________
327 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
330 // Set the theta range for the generated particles
332 fThetaMin = TMath::Pi()*thetamin/180;
333 fThetaMax = TMath::Pi()*thetamax/180;
337 void AliGenerator::Vertex()
340 // Obtain vertex for current event from external source or calculated (internal)
342 if (fVertexSource == kInternal) {
344 } else if (fVertexSource == kContainer) {
346 } else if (fVertexSource == kExternal) {
351 //_______________________________________________________________________
352 void AliGenerator::VertexExternal()
355 // Obtain vertex from external source
357 // Should be something like fVertex = gAlice->GetVertex()
359 fVertex[0]=fVertex[1]=fVertex[2]=0;
362 //_______________________________________________________________________
363 void AliGenerator::VertexInternal()
366 // Obtain calculated vertex
367 // Default is gaussian smearing
373 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
375 for (j=0; j < 3; j++) {
376 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
377 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
380 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
384 //_______________________________________________________________________
385 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
386 Float_t *pmom, Float_t *vpos, Float_t *polar,
387 Float_t tof, TMCProcess mech, Int_t &ntr,
388 Float_t weight, Int_t is)
391 // Loads one track on the stack
395 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
396 mech, ntr, weight, is);
398 gAlice->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
399 mech, ntr, weight, is);
402 //_______________________________________________________________________
403 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
404 Double_t px, Double_t py, Double_t pz, Double_t e,
405 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
406 Double_t polx, Double_t poly, Double_t polz,
407 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
410 // Loads one track on the stack
414 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
415 polx, poly, polz, mech, ntr, weight, is);
417 gAlice->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
418 polx, poly, polz, mech, ntr, weight, is);
422 //_______________________________________________________________________
423 void AliGenerator:: KeepTrack(Int_t itrack)
426 // Declare a track permanent on the stack
429 fStack->KeepTrack(itrack);
431 gAlice->KeepTrack(itrack);
435 //_______________________________________________________________________
436 void AliGenerator:: SetHighWaterMark(Int_t nt)
439 // Internal function to set the maximum index used in the stack
442 fStack->SetHighWaterMark(nt);
444 gAlice->SetHighWaterMark(nt);
447 void AliGenerator::FinishRun()