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()
190 //_______________________________________________________________________
191 void AliGenerator::Init()
194 // Dummy initialisation
198 //_______________________________________________________________________
199 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
202 // Set the vertex for the generated tracks
209 //_______________________________________________________________________
210 void AliGenerator::SetOrigin(const TLorentzVector &o)
213 // Set the vertex for the generated tracks
220 //_______________________________________________________________________
221 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
224 // Set the spread of the vertex
231 //_______________________________________________________________________
232 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
235 // Set the momentum range for the generated particles
239 SetBit(kMomentumRange);
242 //_______________________________________________________________________
243 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
246 // Set the Pt range for the generated particles
253 //_______________________________________________________________________
254 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
257 // Set the Phi range for the generated particles
259 fPhiMin = TMath::Pi()*phimin/180;
260 fPhiMax = TMath::Pi()*phimax/180;
264 //_______________________________________________________________________
265 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
268 // Set the Rapidity range for the generated particles
275 //_______________________________________________________________________
276 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
277 Float_t vymin, Float_t vymax,
278 Float_t vzmin, Float_t vzmax)
281 // Set the vertex range for the generated particles
283 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
284 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
285 SetBit(kVertexRange);
288 //_______________________________________________________________________
289 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
292 // Set the theta range for the generated particles
294 fThetaMin = TMath::Pi()*thetamin/180;
295 fThetaMax = TMath::Pi()*thetamax/180;
299 void AliGenerator::Vertex()
302 // Obtain vertex for current event from external source or calculated (internal)
304 if (fVertexSource == kInternal) {
306 } else if (fVertexSource == kContainer) {
308 } else if (fVertexSource == kExternal) {
313 //_______________________________________________________________________
314 void AliGenerator::VertexExternal()
317 // Obtain vertex from external source (vertex generator)
319 TVector3 vertex = fVertexGenerator->GetVertex();
320 fVertex[0] = vertex.X();
321 fVertex[1] = vertex.Y();
322 fVertex[2] = vertex.Z();
325 //_______________________________________________________________________
326 void AliGenerator::VertexInternal()
329 // Obtain calculated vertex
330 // Default is gaussian smearing
335 if (!TestBit(kVertexRange)) {
336 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
338 for (j=0; j < 3; j++) {
339 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
340 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
343 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
346 for (j=0; j < 3; j++)
347 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
351 //_______________________________________________________________________
352 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
353 Float_t *pmom, Float_t *vpos, Float_t *polar,
354 Float_t tof, TMCProcess mech, Int_t &ntr,
355 Float_t weight, Int_t is)
358 // Loads one track on the stack
362 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
363 mech, ntr, weight, is);
365 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
366 mech, ntr, weight, is);
369 //_______________________________________________________________________
370 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
371 Double_t px, Double_t py, Double_t pz, Double_t e,
372 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
373 Double_t polx, Double_t poly, Double_t polz,
374 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
377 // Loads one track on the stack
381 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
382 polx, poly, polz, mech, ntr, weight, is);
384 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
385 polx, poly, polz, mech, ntr, weight, is);
389 //_______________________________________________________________________
390 void AliGenerator:: KeepTrack(Int_t itrack)
393 // Declare a track permanent on the stack
396 fStack->KeepTrack(itrack);
398 gAlice->GetMCApp()->KeepTrack(itrack);
402 //_______________________________________________________________________
403 void AliGenerator:: SetHighWaterMark(Int_t nt)
406 // Internal function to set the maximum index used in the stack
409 fStack->SetHighWaterMark(nt);
411 gAlice->GetMCApp()->SetHighWaterMark(nt);
414 void AliGenerator::FinishRun()