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 ClassImp(AliGenerator)
48 //_______________________________________________________________________
49 AliGenerator::AliGenerator():
67 fVertexSmear(kNoSmear),
68 fVertexSource(kInternal),
78 // Default constructor
81 if (gAlice->GetDebug()>0)
82 printf("\n AliGenerator Default Constructor\n\n");
83 gAlice->SetGenerator(this);
86 SetThetaRange(); ResetBit(kThetaRange);
87 SetPhiRange(); ResetBit(kPhiRange);
88 SetMomentumRange(); ResetBit(kMomentumRange);
89 SetPtRange(); ResetBit(kPtRange);
90 SetYRange(); ResetBit(kYRange);
96 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
97 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
98 fVertex[0]=fVertex[1]=fVertex[2]=0;
100 fVMin[0]=fVMin[1]=fVMin[2]=0;
101 fVMax[0]=fVMax[1]=fVMax[2]=10000;
104 //_______________________________________________________________________
105 AliGenerator::AliGenerator(Int_t npart):
123 fVertexSmear(kNoSmear),
124 fVertexSource(kInternal),
131 fCollisionGeometry(0)
134 // Standard constructor
137 if (gAlice->GetDebug()>0)
138 printf("\n AliGenerator Constructor initializing number of particles \n\n");
139 gAlice->SetGenerator(this);
142 SetThetaRange(); ResetBit(kThetaRange);
143 SetPhiRange(); ResetBit(kPhiRange);
144 SetMomentumRange(); ResetBit(kMomentumRange);
145 SetPtRange(); ResetBit(kPtRange);
146 SetYRange(); ResetBit(kYRange);
150 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
151 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
152 fVertex[0]=fVertex[1]=fVertex[2]=0;
154 fVMin[0]=fVMin[1]=fVMin[2]=0;
155 fVMax[0]=fVMax[1]=fVMax[2]=10000;
157 SetNumberParticles(npart);
159 AliConfig::Instance()->Add(this);
162 //_______________________________________________________________________
163 AliGenerator::AliGenerator(const AliGenerator &gen):
183 fVertexSmear(kNoSmear),
184 fVertexSource(kInternal),
198 //_______________________________________________________________________
199 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
202 // Assignment operator
208 //_______________________________________________________________________
209 void AliGenerator::Copy(AliGenerator &/* gen */) const
212 // Copy *this onto gen
214 Fatal("Copy","Not implemented!\n");
217 //_______________________________________________________________________
218 AliGenerator::~AliGenerator()
231 //_______________________________________________________________________
232 void AliGenerator::Init()
235 // Dummy initialisation
239 //_______________________________________________________________________
240 void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
243 // Set the vertex for the generated tracks
250 //_______________________________________________________________________
251 void AliGenerator::SetOrigin(const TLorentzVector &o)
254 // Set the vertex for the generated tracks
261 //_______________________________________________________________________
262 void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
265 // Set the spread of the vertex
272 //_______________________________________________________________________
273 void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
276 // Set the momentum range for the generated particles
280 SetBit(kMomentumRange);
283 //_______________________________________________________________________
284 void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
287 // Set the Pt range for the generated particles
294 //_______________________________________________________________________
295 void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
298 // Set the Phi range for the generated particles
300 fPhiMin = TMath::Pi()*phimin/180;
301 fPhiMax = TMath::Pi()*phimax/180;
305 //_______________________________________________________________________
306 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
309 // Set the Rapidity range for the generated particles
316 //_______________________________________________________________________
317 void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
318 Float_t vymin, Float_t vymax,
319 Float_t vzmin, Float_t vzmax)
322 // Set the vertex range for the generated particles
324 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
325 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
326 SetBit(kVertexRange);
329 //_______________________________________________________________________
330 void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
333 // Set the theta range for the generated particles
335 fThetaMin = TMath::Pi()*thetamin/180;
336 fThetaMax = TMath::Pi()*thetamax/180;
340 void AliGenerator::Vertex()
343 // Obtain vertex for current event from external source or calculated (internal)
345 if (fVertexSource == kInternal) {
347 } else if (fVertexSource == kContainer) {
349 } else if (fVertexSource == kExternal) {
354 //_______________________________________________________________________
355 void AliGenerator::VertexExternal()
358 // Obtain vertex from external source
360 // Should be something like fVertex = gAlice->GetVertex()
362 fVertex[0]=fVertex[1]=fVertex[2]=0;
365 //_______________________________________________________________________
366 void AliGenerator::VertexInternal()
369 // Obtain calculated vertex
370 // Default is gaussian smearing
376 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
378 for (j=0; j < 3; j++) {
379 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
380 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
383 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
387 //_______________________________________________________________________
388 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
389 Float_t *pmom, Float_t *vpos, Float_t *polar,
390 Float_t tof, TMCProcess mech, Int_t &ntr,
391 Float_t weight, Int_t is)
394 // Loads one track on the stack
398 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
399 mech, ntr, weight, is);
401 gAlice->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
402 mech, ntr, weight, is);
405 //_______________________________________________________________________
406 void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
407 Double_t px, Double_t py, Double_t pz, Double_t e,
408 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
409 Double_t polx, Double_t poly, Double_t polz,
410 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
413 // Loads one track on the stack
417 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
418 polx, poly, polz, mech, ntr, weight, is);
420 gAlice->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
421 polx, poly, polz, mech, ntr, weight, is);
425 //_______________________________________________________________________
426 void AliGenerator:: KeepTrack(Int_t itrack)
429 // Declare a track permanent on the stack
432 fStack->KeepTrack(itrack);
434 gAlice->KeepTrack(itrack);
438 //_______________________________________________________________________
439 void AliGenerator:: SetHighWaterMark(Int_t nt)
442 // Internal function to set the maximum index used in the stack
445 fStack->SetHighWaterMark(nt);
447 gAlice->SetHighWaterMark(nt);
450 void AliGenerator::FinishRun()