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>
39 #include "AliCollisionGeometry.h"
40 #include "AliConfig.h"
41 #include "AliGenerator.h"
45 #include "AliVertexGenerator.h"
47 ClassImp(AliGenerator)
50 //_______________________________________________________________________
51 AliGenerator::AliGenerator():
69 fVertexSmear(kNoSmear),
70 fVertexSource(kInternal),
80 // Default constructor
83 if (gAlice->GetDebug()>0)
84 printf("\n AliGenerator Default Constructor\n\n");
85 AliMC * mc = gAlice->GetMCApp();
86 if (mc) mc->SetGenerator(this);
89 SetThetaRange(); ResetBit(kThetaRange);
90 SetPhiRange(); ResetBit(kPhiRange);
91 SetMomentumRange(); ResetBit(kMomentumRange);
92 SetPtRange(); ResetBit(kPtRange);
93 SetYRange(); ResetBit(kYRange);
99 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
100 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
101 fVertex[0]=fVertex[1]=fVertex[2]=0;
103 fVMin[0]=fVMin[1]=fVMin[2]=0;
104 fVMax[0]=fVMax[1]=fVMax[2]=10000;
107 //_______________________________________________________________________
108 AliGenerator::AliGenerator(Int_t npart):
126 fVertexSmear(kNoSmear),
127 fVertexSource(kInternal),
134 fCollisionGeometry(0)
137 // Standard constructor
140 if (gAlice->GetDebug()>0)
141 printf("\n AliGenerator Constructor initializing number of particles \n\n");
142 AliMC * mc = gAlice->GetMCApp();
143 if (mc) mc->SetGenerator(this);
146 SetThetaRange(); ResetBit(kThetaRange);
147 SetPhiRange(); ResetBit(kPhiRange);
148 SetMomentumRange(); ResetBit(kMomentumRange);
149 SetPtRange(); ResetBit(kPtRange);
150 SetYRange(); ResetBit(kYRange);
154 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
155 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
156 fVertex[0]=fVertex[1]=fVertex[2]=0;
158 fVMin[0]=fVMin[1]=fVMin[2]=0;
159 fVMax[0]=fVMax[1]=fVMax[2]=10000;
161 SetNumberParticles(npart);
163 AliConfig::Instance()->Add(this);
166 //_______________________________________________________________________
167 AliGenerator::AliGenerator(const AliGenerator &gen):
187 fVertexSmear(kNoSmear),
188 fVertexSource(kInternal),
202 //_______________________________________________________________________
203 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
206 // Assignment operator
212 //_______________________________________________________________________
213 void AliGenerator::Copy(TObject &/* gen */) const
216 // Copy *this onto gen
218 Fatal("Copy","Not implemented!\n");
221 //_______________________________________________________________________
222 AliGenerator::~AliGenerator()
235 //_______________________________________________________________________
236 void AliGenerator::Init()
239 // Dummy initialisation
243 //_______________________________________________________________________
244 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
247 // Set the vertex for the generated tracks
254 //_______________________________________________________________________
255 void AliGenerator::SetOrigin(const TLorentzVector &o)
258 // Set the vertex for the generated tracks
265 //_______________________________________________________________________
266 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
269 // Set the spread of the vertex
276 //_______________________________________________________________________
277 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
280 // Set the momentum range for the generated particles
284 SetBit(kMomentumRange);
287 //_______________________________________________________________________
288 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
291 // Set the Pt range for the generated particles
298 //_______________________________________________________________________
299 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
302 // Set the Phi range for the generated particles
304 fPhiMin = TMath::Pi()*phimin/180;
305 fPhiMax = TMath::Pi()*phimax/180;
309 //_______________________________________________________________________
310 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
313 // Set the Rapidity range for the generated particles
320 //_______________________________________________________________________
321 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
322 Float_t vymin, Float_t vymax,
323 Float_t vzmin, Float_t vzmax)
326 // Set the vertex range for the generated particles
328 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
329 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
330 SetBit(kVertexRange);
333 //_______________________________________________________________________
334 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
337 // Set the theta range for the generated particles
339 fThetaMin = TMath::Pi()*thetamin/180;
340 fThetaMax = TMath::Pi()*thetamax/180;
344 void AliGenerator::Vertex()
347 // Obtain vertex for current event from external source or calculated (internal)
349 if (fVertexSource == kInternal) {
351 } else if (fVertexSource == kContainer) {
353 } else if (fVertexSource == kExternal) {
358 //_______________________________________________________________________
359 void AliGenerator::VertexExternal()
362 // Obtain vertex from external source (vertex generator)
364 TVector3 vertex = fVertexGenerator->GetVertex();
365 fVertex[0] = vertex.X();
366 fVertex[1] = vertex.Y();
367 fVertex[2] = vertex.Z();
370 //_______________________________________________________________________
371 void AliGenerator::VertexInternal()
374 // Obtain calculated vertex
375 // Default is gaussian smearing
380 if (!TestBit(kVertexRange)) {
381 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
383 for (j=0; j < 3; j++) {
384 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
385 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
388 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
391 for (j=0; j < 3; j++)
392 fVertex[j] = fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
396 //_______________________________________________________________________
397 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
398 Float_t *pmom, Float_t *vpos, Float_t *polar,
399 Float_t tof, TMCProcess mech, Int_t &ntr,
400 Float_t weight, Int_t is)
403 // Loads one track on the stack
407 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
408 mech, ntr, weight, is);
410 gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
411 mech, ntr, weight, is);
414 //_______________________________________________________________________
415 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
416 Double_t px, Double_t py, Double_t pz, Double_t e,
417 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
418 Double_t polx, Double_t poly, Double_t polz,
419 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
422 // Loads one track on the stack
426 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
427 polx, poly, polz, mech, ntr, weight, is);
429 gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
430 polx, poly, polz, mech, ntr, weight, is);
434 //_______________________________________________________________________
435 void AliGenerator:: KeepTrack(Int_t itrack)
438 // Declare a track permanent on the stack
441 fStack->KeepTrack(itrack);
443 gAlice->GetMCApp()->KeepTrack(itrack);
447 //_______________________________________________________________________
448 void AliGenerator:: SetHighWaterMark(Int_t nt)
451 // Internal function to set the maximum index used in the stack
454 fStack->SetHighWaterMark(nt);
456 gAlice->GetMCApp()->SetHighWaterMark(nt);
459 void AliGenerator::FinishRun()