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 fCollisionGeometry(0),
97 // Default constructor
100 AliDebug(1, "AliGenerator Default Constructor");
101 AliMC * mc = gAlice->GetMCApp();
102 if (mc) mc->SetGenerator(this);
105 SetThetaRange(); ResetBit(kThetaRange);
106 SetPhiRange(); ResetBit(kPhiRange);
107 SetMomentumRange(); ResetBit(kMomentumRange);
108 SetPtRange(); ResetBit(kPtRange);
109 SetYRange(); ResetBit(kYRange);
110 SetNumberParticles();
115 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
116 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
117 fVertex[0]=fVertex[1]=fVertex[2]=0;
119 fVMin[0]=fVMin[1]=fVMin[2]=0;
120 fVMax[0]=fVMax[1]=fVMax[2]=10000;
123 //_______________________________________________________________________
124 AliGenerator::AliGenerator(Int_t npart):
144 fVertexSmear(kNoSmear),
145 fVertexSource(kInternal),
147 fPileUpTimeWindow(-1.),
158 fCollisionGeometry(0),
168 // Standard constructor
171 AliDebug(1, "AliGenerator Constructor initializing number of particles");
172 AliMC * mc = gAlice->GetMCApp();
173 if (mc) mc->SetGenerator(this);
176 SetThetaRange(); ResetBit(kThetaRange);
177 SetPhiRange(); ResetBit(kPhiRange);
178 SetMomentumRange(); ResetBit(kMomentumRange);
179 SetPtRange(); ResetBit(kPtRange);
180 SetYRange(); ResetBit(kYRange);
184 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
185 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
186 fVertex[0]=fVertex[1]=fVertex[2]=0;
188 fVMin[0]=fVMin[1]=fVMin[2]=0;
189 fVMax[0]=fVMax[1]=fVMax[2]=10000;
191 SetNumberParticles(npart);
193 AliConfig::Instance()->Add(this);
196 //_______________________________________________________________________
197 AliGenerator::~AliGenerator()
210 //_______________________________________________________________________
211 void AliGenerator::Init()
214 // Dummy initialisation
218 //_______________________________________________________________________
219 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
222 // Set the vertex for the generated tracks
229 //_______________________________________________________________________
230 void AliGenerator::SetOrigin(const TLorentzVector &o)
233 // Set the vertex for the generated tracks
240 //_______________________________________________________________________
241 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
244 // Set the spread of the vertex
251 //_______________________________________________________________________
252 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
255 // Set the momentum range for the generated particles
259 SetBit(kMomentumRange);
262 //_______________________________________________________________________
263 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
266 // Set the Pt range for the generated particles
273 //_______________________________________________________________________
274 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
277 // Set the Phi range for the generated particles
279 fPhiMin = TMath::Pi()*phimin/180;
280 fPhiMax = TMath::Pi()*phimax/180;
284 //_______________________________________________________________________
285 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
288 // Set the Rapidity range for the generated particles
295 //_______________________________________________________________________
296 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
297 Float_t vymin, Float_t vymax,
298 Float_t vzmin, Float_t vzmax)
301 // Set the vertex range for the generated particles
303 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
304 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
305 SetBit(kVertexRange);
308 //_______________________________________________________________________
309 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
312 // Set the theta range for the generated particles
314 fThetaMin = TMath::Pi()*thetamin/180;
315 fThetaMax = TMath::Pi()*thetamax/180;
319 void AliGenerator::Vertex()
322 // Obtain vertex for current event from external source or calculated (internal)
324 if (fVertexSource == kInternal) {
326 } else if (fVertexSource == kContainer) {
328 } else if (fVertexSource == kExternal) {
333 //_______________________________________________________________________
334 void AliGenerator::VertexExternal()
337 // Obtain vertex from external source (vertex generator)
339 TVector3 vertex = fVertexGenerator->GetVertex();
340 fVertex[0] = vertex.X();
341 fVertex[1] = vertex.Y();
342 fVertex[2] = vertex.Z();
346 //_______________________________________________________________________
347 void AliGenerator::VertexInternal()
350 // Obtain calculated vertex
351 // Default is gaussian smearing
356 if (!TestBit(kVertexRange)) {
357 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
359 for (j=0; j < 3; j++) {
360 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
361 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
364 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
366 // In case of gaussian smearing we smear also the event/collision time
368 fTime = fTimeOrigin + fOsigma[2]/TMath::Ccgs()*
369 TMath::Cos(2*random[0]*TMath::Pi())*
370 TMath::Sqrt(-2*TMath::Log(random[1]));
374 for (j=0; j < 3; j++)
375 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
380 //_______________________________________________________________________
381 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
382 Float_t *pmom, Float_t *vpos, Float_t *polar,
383 Float_t tof, TMCProcess mech, Int_t &ntr,
384 Float_t weight, Int_t is)
387 // Loads one track on the stack
391 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
392 mech, ntr, weight, is);
394 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
395 mech, ntr, weight, is);
398 //_______________________________________________________________________
399 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
400 Double_t px, Double_t py, Double_t pz, Double_t e,
401 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
402 Double_t polx, Double_t poly, Double_t polz,
403 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
406 // Loads one track on the stack
410 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
411 polx, poly, polz, mech, ntr, weight, is);
413 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
414 polx, poly, polz, mech, ntr, weight, is);
418 //_______________________________________________________________________
419 void AliGenerator:: KeepTrack(Int_t itrack)
422 // Declare a track permanent on the stack
425 fStack->KeepTrack(itrack);
427 gAlice->GetMCApp()->KeepTrack(itrack);
431 //_______________________________________________________________________
432 void AliGenerator:: SetHighWaterMark(Int_t nt)
435 // Internal function to set the maximum index used in the stack
438 fStack->SetHighWaterMark(nt);
440 gAlice->GetMCApp()->SetHighWaterMark(nt);
443 void AliGenerator::FinishRun()