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>
40 #include "AliCollisionGeometry.h"
41 #include "AliConfig.h"
42 #include "AliGenerator.h"
46 #include "AliVertexGenerator.h"
48 ClassImp(AliGenerator)
51 //_______________________________________________________________________
52 AliGenerator::AliGenerator():
70 fVertexSmear(kNoSmear),
71 fVertexSource(kInternal),
81 // Default constructor
84 if (gAlice->GetDebug()>0)
85 printf("\n AliGenerator Default Constructor\n\n");
86 AliMC * mc = gAlice->GetMCApp();
87 if (mc) mc->SetGenerator(this);
90 SetThetaRange(); ResetBit(kThetaRange);
91 SetPhiRange(); ResetBit(kPhiRange);
92 SetMomentumRange(); ResetBit(kMomentumRange);
93 SetPtRange(); ResetBit(kPtRange);
94 SetYRange(); ResetBit(kYRange);
100 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
101 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
102 fVertex[0]=fVertex[1]=fVertex[2]=0;
104 fVMin[0]=fVMin[1]=fVMin[2]=0;
105 fVMax[0]=fVMax[1]=fVMax[2]=10000;
108 //_______________________________________________________________________
109 AliGenerator::AliGenerator(Int_t npart):
127 fVertexSmear(kNoSmear),
128 fVertexSource(kInternal),
135 fCollisionGeometry(0)
138 // Standard constructor
141 if (gAlice->GetDebug()>0)
142 printf("\n AliGenerator Constructor initializing number of particles \n\n");
143 AliMC * mc = gAlice->GetMCApp();
144 if (mc) mc->SetGenerator(this);
147 SetThetaRange(); ResetBit(kThetaRange);
148 SetPhiRange(); ResetBit(kPhiRange);
149 SetMomentumRange(); ResetBit(kMomentumRange);
150 SetPtRange(); ResetBit(kPtRange);
151 SetYRange(); ResetBit(kYRange);
155 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
156 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
157 fVertex[0]=fVertex[1]=fVertex[2]=0;
159 fVMin[0]=fVMin[1]=fVMin[2]=0;
160 fVMax[0]=fVMax[1]=fVMax[2]=10000;
162 SetNumberParticles(npart);
164 AliConfig::Instance()->Add(this);
167 //_______________________________________________________________________
168 AliGenerator::AliGenerator(const AliGenerator &gen):
188 fVertexSmear(kNoSmear),
189 fVertexSource(kInternal),
203 //_______________________________________________________________________
204 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
207 // Assignment operator
213 //_______________________________________________________________________
214 void AliGenerator::Copy(TObject &/* gen */) const
217 // Copy *this onto gen
219 Fatal("Copy","Not implemented!\n");
222 //_______________________________________________________________________
223 AliGenerator::~AliGenerator()
236 //_______________________________________________________________________
237 void AliGenerator::Init()
240 // Dummy initialisation
244 //_______________________________________________________________________
245 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
248 // Set the vertex for the generated tracks
255 //_______________________________________________________________________
256 void AliGenerator::SetOrigin(const TLorentzVector &o)
259 // Set the vertex for the generated tracks
266 //_______________________________________________________________________
267 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
270 // Set the spread of the vertex
277 //_______________________________________________________________________
278 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
281 // Set the momentum range for the generated particles
285 SetBit(kMomentumRange);
288 //_______________________________________________________________________
289 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
292 // Set the Pt range for the generated particles
299 //_______________________________________________________________________
300 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
303 // Set the Phi range for the generated particles
305 fPhiMin = TMath::Pi()*phimin/180;
306 fPhiMax = TMath::Pi()*phimax/180;
310 //_______________________________________________________________________
311 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
314 // Set the Rapidity range for the generated particles
321 //_______________________________________________________________________
322 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
323 Float_t vymin, Float_t vymax,
324 Float_t vzmin, Float_t vzmax)
327 // Set the vertex range for the generated particles
329 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
330 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
331 SetBit(kVertexRange);
334 //_______________________________________________________________________
335 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
338 // Set the theta range for the generated particles
340 fThetaMin = TMath::Pi()*thetamin/180;
341 fThetaMax = TMath::Pi()*thetamax/180;
345 void AliGenerator::Vertex()
348 // Obtain vertex for current event from external source or calculated (internal)
350 if (fVertexSource == kInternal) {
352 } else if (fVertexSource == kContainer) {
354 } else if (fVertexSource == kExternal) {
359 //_______________________________________________________________________
360 void AliGenerator::VertexExternal()
363 // Obtain vertex from external source (vertex generator)
365 TVector3 vertex = fVertexGenerator->GetVertex();
366 fVertex[0] = vertex.X();
367 fVertex[1] = vertex.Y();
368 fVertex[2] = vertex.Z();
371 //_______________________________________________________________________
372 void AliGenerator::VertexInternal()
375 // Obtain calculated vertex
376 // Default is gaussian smearing
381 if (!TestBit(kVertexRange)) {
382 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
384 for (j=0; j < 3; j++) {
385 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
386 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
389 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
392 for (j=0; j < 3; j++)
393 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
397 //_______________________________________________________________________
398 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
399 Float_t *pmom, Float_t *vpos, Float_t *polar,
400 Float_t tof, TMCProcess mech, Int_t &ntr,
401 Float_t weight, Int_t is)
404 // Loads one track on the stack
408 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
409 mech, ntr, weight, is);
411 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
412 mech, ntr, weight, is);
415 //_______________________________________________________________________
416 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
417 Double_t px, Double_t py, Double_t pz, Double_t e,
418 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
419 Double_t polx, Double_t poly, Double_t polz,
420 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
423 // Loads one track on the stack
427 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
428 polx, poly, polz, mech, ntr, weight, is);
430 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
431 polx, poly, polz, mech, ntr, weight, is);
435 //_______________________________________________________________________
436 void AliGenerator:: KeepTrack(Int_t itrack)
439 // Declare a track permanent on the stack
442 fStack->KeepTrack(itrack);
444 gAlice->GetMCApp()->KeepTrack(itrack);
448 //_______________________________________________________________________
449 void AliGenerator:: SetHighWaterMark(Int_t nt)
452 // Internal function to set the maximum index used in the stack
455 fStack->SetHighWaterMark(nt);
457 gAlice->GetMCApp()->SetHighWaterMark(nt);
460 void AliGenerator::FinishRun()