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"
46 ClassImp(AliGenerator)
49 //_______________________________________________________________________
50 AliGenerator::AliGenerator():
68 fVertexSmear(kNoSmear),
69 fVertexSource(kInternal),
79 // Default constructor
82 if (gAlice->GetDebug()>0)
83 printf("\n AliGenerator Default Constructor\n\n");
84 AliMC * mc = gAlice->GetMCApp();
85 if (mc) mc->SetGenerator(this);
88 SetThetaRange(); ResetBit(kThetaRange);
89 SetPhiRange(); ResetBit(kPhiRange);
90 SetMomentumRange(); ResetBit(kMomentumRange);
91 SetPtRange(); ResetBit(kPtRange);
92 SetYRange(); ResetBit(kYRange);
98 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
99 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
100 fVertex[0]=fVertex[1]=fVertex[2]=0;
102 fVMin[0]=fVMin[1]=fVMin[2]=0;
103 fVMax[0]=fVMax[1]=fVMax[2]=10000;
106 //_______________________________________________________________________
107 AliGenerator::AliGenerator(Int_t npart):
125 fVertexSmear(kNoSmear),
126 fVertexSource(kInternal),
133 fCollisionGeometry(0)
136 // Standard constructor
139 if (gAlice->GetDebug()>0)
140 printf("\n AliGenerator Constructor initializing number of particles \n\n");
141 AliMC * mc = gAlice->GetMCApp();
142 if (mc) mc->SetGenerator(this);
145 SetThetaRange(); ResetBit(kThetaRange);
146 SetPhiRange(); ResetBit(kPhiRange);
147 SetMomentumRange(); ResetBit(kMomentumRange);
148 SetPtRange(); ResetBit(kPtRange);
149 SetYRange(); ResetBit(kYRange);
153 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
154 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
155 fVertex[0]=fVertex[1]=fVertex[2]=0;
157 fVMin[0]=fVMin[1]=fVMin[2]=0;
158 fVMax[0]=fVMax[1]=fVMax[2]=10000;
160 SetNumberParticles(npart);
162 AliConfig::Instance()->Add(this);
165 //_______________________________________________________________________
166 AliGenerator::AliGenerator(const AliGenerator &gen):
186 fVertexSmear(kNoSmear),
187 fVertexSource(kInternal),
201 //_______________________________________________________________________
202 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
205 // Assignment operator
211 //_______________________________________________________________________
212 void AliGenerator::Copy(AliGenerator &/* gen */) const
215 // Copy *this onto gen
217 Fatal("Copy","Not implemented!\n");
220 //_______________________________________________________________________
221 AliGenerator::~AliGenerator()
234 //_______________________________________________________________________
235 void AliGenerator::Init()
238 // Dummy initialisation
242 //_______________________________________________________________________
243 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
246 // Set the vertex for the generated tracks
253 //_______________________________________________________________________
254 void AliGenerator::SetOrigin(const TLorentzVector &o)
257 // Set the vertex for the generated tracks
264 //_______________________________________________________________________
265 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
268 // Set the spread of the vertex
275 //_______________________________________________________________________
276 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
279 // Set the momentum range for the generated particles
283 SetBit(kMomentumRange);
286 //_______________________________________________________________________
287 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
290 // Set the Pt range for the generated particles
297 //_______________________________________________________________________
298 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
301 // Set the Phi range for the generated particles
303 fPhiMin = TMath::Pi()*phimin/180;
304 fPhiMax = TMath::Pi()*phimax/180;
308 //_______________________________________________________________________
309 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
312 // Set the Rapidity range for the generated particles
319 //_______________________________________________________________________
320 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
321 Float_t vymin, Float_t vymax,
322 Float_t vzmin, Float_t vzmax)
325 // Set the vertex range for the generated particles
327 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
328 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
329 SetBit(kVertexRange);
332 //_______________________________________________________________________
333 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
336 // Set the theta range for the generated particles
338 fThetaMin = TMath::Pi()*thetamin/180;
339 fThetaMax = TMath::Pi()*thetamax/180;
343 void AliGenerator::Vertex()
346 // Obtain vertex for current event from external source or calculated (internal)
348 if (fVertexSource == kInternal) {
350 } else if (fVertexSource == kContainer) {
352 } else if (fVertexSource == kExternal) {
357 //_______________________________________________________________________
358 void AliGenerator::VertexExternal()
361 // Obtain vertex from external source
363 // Should be something like fVertex = gAlice->GetVertex()
365 fVertex[0]=fVertex[1]=fVertex[2]=0;
368 //_______________________________________________________________________
369 void AliGenerator::VertexInternal()
372 // Obtain calculated vertex
373 // Default is gaussian smearing
378 if (!TestBit(kVertexRange)) {
379 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
381 for (j=0; j < 3; j++) {
382 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
383 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
386 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
389 for (j=0; j < 3; j++)
390 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
394 //_______________________________________________________________________
395 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
396 Float_t *pmom, Float_t *vpos, Float_t *polar,
397 Float_t tof, TMCProcess mech, Int_t &ntr,
398 Float_t weight, Int_t is)
401 // Loads one track on the stack
405 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
406 mech, ntr, weight, is);
408 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
409 mech, ntr, weight, is);
412 //_______________________________________________________________________
413 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
414 Double_t px, Double_t py, Double_t pz, Double_t e,
415 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
416 Double_t polx, Double_t poly, Double_t polz,
417 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
420 // Loads one track on the stack
424 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
425 polx, poly, polz, mech, ntr, weight, is);
427 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
428 polx, poly, polz, mech, ntr, weight, is);
432 //_______________________________________________________________________
433 void AliGenerator:: KeepTrack(Int_t itrack)
436 // Declare a track permanent on the stack
439 fStack->KeepTrack(itrack);
441 gAlice->GetMCApp()->KeepTrack(itrack);
445 //_______________________________________________________________________
446 void AliGenerator:: SetHighWaterMark(Int_t nt)
449 // Internal function to set the maximum index used in the stack
452 fStack->SetHighWaterMark(nt);
454 gAlice->GetMCApp()->SetHighWaterMark(nt);
457 void AliGenerator::FinishRun()