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>
38 #include <TMCProcess.h>
41 #include "AliCollisionGeometry.h"
42 #include "AliConfig.h"
43 #include "AliGenerator.h"
47 #include "AliVertexGenerator.h"
49 ClassImp(AliGenerator)
52 //_______________________________________________________________________
53 AliGenerator::AliGenerator():
73 fVertexSmear(kNoSmear),
74 fVertexSource(kInternal),
76 fPileUpTimeWindow(-1.),
87 // Default constructor
90 AliDebug(1, "AliGenerator Default Constructor");
91 AliMC * mc = gAlice->GetMCApp();
92 if (mc) mc->SetGenerator(this);
95 SetThetaRange(); ResetBit(kThetaRange);
96 SetPhiRange(); ResetBit(kPhiRange);
97 SetMomentumRange(); ResetBit(kMomentumRange);
98 SetPtRange(); ResetBit(kPtRange);
99 SetYRange(); ResetBit(kYRange);
100 SetNumberParticles();
105 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
106 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
107 fVertex[0]=fVertex[1]=fVertex[2]=0;
109 fVMin[0]=fVMin[1]=fVMin[2]=0;
110 fVMax[0]=fVMax[1]=fVMax[2]=10000;
113 //_______________________________________________________________________
114 AliGenerator::AliGenerator(Int_t npart):
134 fVertexSmear(kNoSmear),
135 fVertexSource(kInternal),
137 fPileUpTimeWindow(-1.),
145 fCollisionGeometry(0)
148 // Standard constructor
151 AliDebug(1, "AliGenerator Constructor initializing number of particles");
152 AliMC * mc = gAlice->GetMCApp();
153 if (mc) mc->SetGenerator(this);
156 SetThetaRange(); ResetBit(kThetaRange);
157 SetPhiRange(); ResetBit(kPhiRange);
158 SetMomentumRange(); ResetBit(kMomentumRange);
159 SetPtRange(); ResetBit(kPtRange);
160 SetYRange(); ResetBit(kYRange);
164 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
165 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
166 fVertex[0]=fVertex[1]=fVertex[2]=0;
168 fVMin[0]=fVMin[1]=fVMin[2]=0;
169 fVMax[0]=fVMax[1]=fVMax[2]=10000;
171 SetNumberParticles(npart);
173 AliConfig::Instance()->Add(this);
176 //_______________________________________________________________________
177 AliGenerator::AliGenerator(const AliGenerator &gen):
197 fVertexSmear(kNoSmear),
198 fVertexSource(kInternal),
200 fPileUpTimeWindow(-1.),
208 fCollisionGeometry(0)
216 //_______________________________________________________________________
217 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
220 // Assignment operator
226 //_______________________________________________________________________
227 void AliGenerator::Copy(TObject &/* gen */) const
230 // Copy *this onto gen
232 AliFatal("Not implemented!");
235 //_______________________________________________________________________
236 AliGenerator::~AliGenerator()
249 //_______________________________________________________________________
250 void AliGenerator::Init()
253 // Dummy initialisation
257 //_______________________________________________________________________
258 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
261 // Set the vertex for the generated tracks
268 //_______________________________________________________________________
269 void AliGenerator::SetOrigin(const TLorentzVector &o)
272 // Set the vertex for the generated tracks
279 //_______________________________________________________________________
280 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
283 // Set the spread of the vertex
290 //_______________________________________________________________________
291 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
294 // Set the momentum range for the generated particles
298 SetBit(kMomentumRange);
301 //_______________________________________________________________________
302 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
305 // Set the Pt range for the generated particles
312 //_______________________________________________________________________
313 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
316 // Set the Phi range for the generated particles
318 fPhiMin = TMath::Pi()*phimin/180;
319 fPhiMax = TMath::Pi()*phimax/180;
323 //_______________________________________________________________________
324 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
327 // Set the Rapidity range for the generated particles
334 //_______________________________________________________________________
335 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
336 Float_t vymin, Float_t vymax,
337 Float_t vzmin, Float_t vzmax)
340 // Set the vertex range for the generated particles
342 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
343 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
344 SetBit(kVertexRange);
347 //_______________________________________________________________________
348 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
351 // Set the theta range for the generated particles
353 fThetaMin = TMath::Pi()*thetamin/180;
354 fThetaMax = TMath::Pi()*thetamax/180;
358 void AliGenerator::Vertex()
361 // Obtain vertex for current event from external source or calculated (internal)
363 if (fVertexSource == kInternal) {
365 } else if (fVertexSource == kContainer) {
367 } else if (fVertexSource == kExternal) {
372 //_______________________________________________________________________
373 void AliGenerator::VertexExternal()
376 // Obtain vertex from external source (vertex generator)
378 TVector3 vertex = fVertexGenerator->GetVertex();
379 fVertex[0] = vertex.X();
380 fVertex[1] = vertex.Y();
381 fVertex[2] = vertex.Z();
384 //_______________________________________________________________________
385 void AliGenerator::VertexInternal()
388 // Obtain calculated vertex
389 // Default is gaussian smearing
394 if (!TestBit(kVertexRange)) {
395 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
397 for (j=0; j < 3; j++) {
398 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
399 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
402 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
405 for (j=0; j < 3; j++)
406 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
410 //_______________________________________________________________________
411 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
412 Float_t *pmom, Float_t *vpos, Float_t *polar,
413 Float_t tof, TMCProcess mech, Int_t &ntr,
414 Float_t weight, Int_t is)
417 // Loads one track on the stack
421 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
422 mech, ntr, weight, is);
424 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
425 mech, ntr, weight, is);
428 //_______________________________________________________________________
429 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
430 Double_t px, Double_t py, Double_t pz, Double_t e,
431 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
432 Double_t polx, Double_t poly, Double_t polz,
433 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
436 // Loads one track on the stack
440 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
441 polx, poly, polz, mech, ntr, weight, is);
443 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
444 polx, poly, polz, mech, ntr, weight, is);
448 //_______________________________________________________________________
449 void AliGenerator:: KeepTrack(Int_t itrack)
452 // Declare a track permanent on the stack
455 fStack->KeepTrack(itrack);
457 gAlice->GetMCApp()->KeepTrack(itrack);
461 //_______________________________________________________________________
462 void AliGenerator:: SetHighWaterMark(Int_t nt)
465 // Internal function to set the maximum index used in the stack
468 fStack->SetHighWaterMark(nt);
470 gAlice->GetMCApp()->SetHighWaterMark(nt);
473 void AliGenerator::FinishRun()