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),
86 // Default constructor
89 AliDebug(1, "AliGenerator Default Constructor");
90 AliMC * mc = gAlice->GetMCApp();
91 if (mc) mc->SetGenerator(this);
94 SetThetaRange(); ResetBit(kThetaRange);
95 SetPhiRange(); ResetBit(kPhiRange);
96 SetMomentumRange(); ResetBit(kMomentumRange);
97 SetPtRange(); ResetBit(kPtRange);
98 SetYRange(); ResetBit(kYRange);
104 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
105 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
106 fVertex[0]=fVertex[1]=fVertex[2]=0;
108 fVMin[0]=fVMin[1]=fVMin[2]=0;
109 fVMax[0]=fVMax[1]=fVMax[2]=10000;
112 //_______________________________________________________________________
113 AliGenerator::AliGenerator(Int_t npart):
133 fVertexSmear(kNoSmear),
134 fVertexSource(kInternal),
143 fCollisionGeometry(0)
146 // Standard constructor
149 AliDebug(1, "AliGenerator Constructor initializing number of particles");
150 AliMC * mc = gAlice->GetMCApp();
151 if (mc) mc->SetGenerator(this);
154 SetThetaRange(); ResetBit(kThetaRange);
155 SetPhiRange(); ResetBit(kPhiRange);
156 SetMomentumRange(); ResetBit(kMomentumRange);
157 SetPtRange(); ResetBit(kPtRange);
158 SetYRange(); ResetBit(kYRange);
162 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
163 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
164 fVertex[0]=fVertex[1]=fVertex[2]=0;
166 fVMin[0]=fVMin[1]=fVMin[2]=0;
167 fVMax[0]=fVMax[1]=fVMax[2]=10000;
169 SetNumberParticles(npart);
171 AliConfig::Instance()->Add(this);
174 //_______________________________________________________________________
175 AliGenerator::AliGenerator(const AliGenerator &gen):
195 fVertexSmear(kNoSmear),
196 fVertexSource(kInternal),
205 fCollisionGeometry(0)
213 //_______________________________________________________________________
214 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
217 // Assignment operator
223 //_______________________________________________________________________
224 void AliGenerator::Copy(TObject &/* gen */) const
227 // Copy *this onto gen
229 AliFatal("Not implemented!");
232 //_______________________________________________________________________
233 AliGenerator::~AliGenerator()
246 //_______________________________________________________________________
247 void AliGenerator::Init()
250 // Dummy initialisation
254 //_______________________________________________________________________
255 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
258 // Set the vertex for the generated tracks
265 //_______________________________________________________________________
266 void AliGenerator::SetOrigin(const TLorentzVector &o)
269 // Set the vertex for the generated tracks
276 //_______________________________________________________________________
277 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
280 // Set the spread of the vertex
287 //_______________________________________________________________________
288 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
291 // Set the momentum range for the generated particles
295 SetBit(kMomentumRange);
298 //_______________________________________________________________________
299 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
302 // Set the Pt range for the generated particles
309 //_______________________________________________________________________
310 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
313 // Set the Phi range for the generated particles
315 fPhiMin = TMath::Pi()*phimin/180;
316 fPhiMax = TMath::Pi()*phimax/180;
320 //_______________________________________________________________________
321 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
324 // Set the Rapidity range for the generated particles
331 //_______________________________________________________________________
332 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
333 Float_t vymin, Float_t vymax,
334 Float_t vzmin, Float_t vzmax)
337 // Set the vertex range for the generated particles
339 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
340 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
341 SetBit(kVertexRange);
344 //_______________________________________________________________________
345 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
348 // Set the theta range for the generated particles
350 fThetaMin = TMath::Pi()*thetamin/180;
351 fThetaMax = TMath::Pi()*thetamax/180;
355 void AliGenerator::Vertex()
358 // Obtain vertex for current event from external source or calculated (internal)
360 if (fVertexSource == kInternal) {
362 } else if (fVertexSource == kContainer) {
364 } else if (fVertexSource == kExternal) {
369 //_______________________________________________________________________
370 void AliGenerator::VertexExternal()
373 // Obtain vertex from external source (vertex generator)
375 TVector3 vertex = fVertexGenerator->GetVertex();
376 fVertex[0] = vertex.X();
377 fVertex[1] = vertex.Y();
378 fVertex[2] = vertex.Z();
381 //_______________________________________________________________________
382 void AliGenerator::VertexInternal()
385 // Obtain calculated vertex
386 // Default is gaussian smearing
391 if (!TestBit(kVertexRange)) {
392 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
394 for (j=0; j < 3; j++) {
395 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
396 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
399 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
402 for (j=0; j < 3; j++)
403 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
407 //_______________________________________________________________________
408 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
409 Float_t *pmom, Float_t *vpos, Float_t *polar,
410 Float_t tof, TMCProcess mech, Int_t &ntr,
411 Float_t weight, Int_t is)
414 // Loads one track on the stack
418 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
419 mech, ntr, weight, is);
421 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
422 mech, ntr, weight, is);
425 //_______________________________________________________________________
426 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
427 Double_t px, Double_t py, Double_t pz, Double_t e,
428 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
429 Double_t polx, Double_t poly, Double_t polz,
430 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
433 // Loads one track on the stack
437 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
438 polx, poly, polz, mech, ntr, weight, is);
440 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
441 polx, poly, polz, mech, ntr, weight, is);
445 //_______________________________________________________________________
446 void AliGenerator:: KeepTrack(Int_t itrack)
449 // Declare a track permanent on the stack
452 fStack->KeepTrack(itrack);
454 gAlice->GetMCApp()->KeepTrack(itrack);
458 //_______________________________________________________________________
459 void AliGenerator:: SetHighWaterMark(Int_t nt)
462 // Internal function to set the maximum index used in the stack
465 fStack->SetHighWaterMark(nt);
467 gAlice->GetMCApp()->SetHighWaterMark(nt);
470 void AliGenerator::FinishRun()