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():
71 fVertexSmear(kNoSmear),
72 fVertexSource(kInternal),
83 // Default constructor
86 AliDebug(1, "AliGenerator Default Constructor");
87 AliMC * mc = gAlice->GetMCApp();
88 if (mc) mc->SetGenerator(this);
91 SetThetaRange(); ResetBit(kThetaRange);
92 SetPhiRange(); ResetBit(kPhiRange);
93 SetMomentumRange(); ResetBit(kMomentumRange);
94 SetPtRange(); ResetBit(kPtRange);
95 SetYRange(); ResetBit(kYRange);
101 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
102 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
103 fVertex[0]=fVertex[1]=fVertex[2]=0;
105 fVMin[0]=fVMin[1]=fVMin[2]=0;
106 fVMax[0]=fVMax[1]=fVMax[2]=10000;
109 //_______________________________________________________________________
110 AliGenerator::AliGenerator(Int_t npart):
128 fVertexSmear(kNoSmear),
129 fVertexSource(kInternal),
137 fCollisionGeometry(0)
140 // Standard constructor
143 AliDebug(1, "AliGenerator Constructor initializing number of particles");
144 AliMC * mc = gAlice->GetMCApp();
145 if (mc) mc->SetGenerator(this);
148 SetThetaRange(); ResetBit(kThetaRange);
149 SetPhiRange(); ResetBit(kPhiRange);
150 SetMomentumRange(); ResetBit(kMomentumRange);
151 SetPtRange(); ResetBit(kPtRange);
152 SetYRange(); ResetBit(kYRange);
156 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
157 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
158 fVertex[0]=fVertex[1]=fVertex[2]=0;
160 fVMin[0]=fVMin[1]=fVMin[2]=0;
161 fVMax[0]=fVMax[1]=fVMax[2]=10000;
163 SetNumberParticles(npart);
165 AliConfig::Instance()->Add(this);
168 //_______________________________________________________________________
169 AliGenerator::AliGenerator(const AliGenerator &gen):
189 fVertexSmear(kNoSmear),
190 fVertexSource(kInternal),
205 //_______________________________________________________________________
206 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
209 // Assignment operator
215 //_______________________________________________________________________
216 void AliGenerator::Copy(TObject &/* gen */) const
219 // Copy *this onto gen
221 AliFatal("Not implemented!");
224 //_______________________________________________________________________
225 AliGenerator::~AliGenerator()
238 //_______________________________________________________________________
239 void AliGenerator::Init()
242 // Dummy initialisation
246 //_______________________________________________________________________
247 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
250 // Set the vertex for the generated tracks
257 //_______________________________________________________________________
258 void AliGenerator::SetOrigin(const TLorentzVector &o)
261 // Set the vertex for the generated tracks
268 //_______________________________________________________________________
269 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
272 // Set the spread of the vertex
279 //_______________________________________________________________________
280 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
283 // Set the momentum range for the generated particles
287 SetBit(kMomentumRange);
290 //_______________________________________________________________________
291 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
294 // Set the Pt range for the generated particles
301 //_______________________________________________________________________
302 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
305 // Set the Phi range for the generated particles
307 fPhiMin = TMath::Pi()*phimin/180;
308 fPhiMax = TMath::Pi()*phimax/180;
312 //_______________________________________________________________________
313 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
316 // Set the Rapidity range for the generated particles
323 //_______________________________________________________________________
324 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
325 Float_t vymin, Float_t vymax,
326 Float_t vzmin, Float_t vzmax)
329 // Set the vertex range for the generated particles
331 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
332 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
333 SetBit(kVertexRange);
336 //_______________________________________________________________________
337 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
340 // Set the theta range for the generated particles
342 fThetaMin = TMath::Pi()*thetamin/180;
343 fThetaMax = TMath::Pi()*thetamax/180;
347 void AliGenerator::Vertex()
350 // Obtain vertex for current event from external source or calculated (internal)
352 if (fVertexSource == kInternal) {
354 } else if (fVertexSource == kContainer) {
356 } else if (fVertexSource == kExternal) {
361 //_______________________________________________________________________
362 void AliGenerator::VertexExternal()
365 // Obtain vertex from external source (vertex generator)
367 TVector3 vertex = fVertexGenerator->GetVertex();
368 fVertex[0] = vertex.X();
369 fVertex[1] = vertex.Y();
370 fVertex[2] = vertex.Z();
373 //_______________________________________________________________________
374 void AliGenerator::VertexInternal()
377 // Obtain calculated vertex
378 // Default is gaussian smearing
383 if (!TestBit(kVertexRange)) {
384 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
386 for (j=0; j < 3; j++) {
387 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
388 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
391 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
394 for (j=0; j < 3; j++)
395 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
399 //_______________________________________________________________________
400 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
401 Float_t *pmom, Float_t *vpos, Float_t *polar,
402 Float_t tof, TMCProcess mech, Int_t &ntr,
403 Float_t weight, Int_t is)
406 // Loads one track on the stack
410 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
411 mech, ntr, weight, is);
413 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
414 mech, ntr, weight, is);
417 //_______________________________________________________________________
418 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
419 Double_t px, Double_t py, Double_t pz, Double_t e,
420 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
421 Double_t polx, Double_t poly, Double_t polz,
422 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
425 // Loads one track on the stack
429 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
430 polx, poly, polz, mech, ntr, weight, is);
432 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
433 polx, poly, polz, mech, ntr, weight, is);
437 //_______________________________________________________________________
438 void AliGenerator:: KeepTrack(Int_t itrack)
441 // Declare a track permanent on the stack
444 fStack->KeepTrack(itrack);
446 gAlice->GetMCApp()->KeepTrack(itrack);
450 //_______________________________________________________________________
451 void AliGenerator:: SetHighWaterMark(Int_t nt)
454 // Internal function to set the maximum index used in the stack
457 fStack->SetHighWaterMark(nt);
459 gAlice->GetMCApp()->SetHighWaterMark(nt);
462 void AliGenerator::FinishRun()