]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliGenerator.cxx
Class version incremented
[u/mrichter/AliRoot.git] / STEER / AliGenerator.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
acd84897 16/* $Id$ */
4c039060 17
5d8718b8 18//-----------------------------------------------------------------
19// Generate the final state of the interaction as the input
20// to the MonteCarlo
21// Author: A.Morsch
22//-----------------------------------------------------------------
fe4da5cc 23//Begin_Html
24/*
1439f98e 25<img src="picts/AliGeneratorClass.gif">
fe4da5cc 26</pre>
27<br clear=left>
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>.
31</font>
32<pre>
33*/
34//End_Html
35// //
36///////////////////////////////////////////////////////////////////
116cbefd 37#include <TGenerator.h>
fe4da5cc 38
116cbefd 39#include "AliCollisionGeometry.h"
e2afb3b6 40#include "AliConfig.h"
fe4da5cc 41#include "AliGenerator.h"
42#include "AliRun.h"
69a313ec 43#include "AliStack.h"
44
fe4da5cc 45ClassImp(AliGenerator)
46
47TGenerator* AliGenerator::fgMCEvGen=0;
48
e2afb3b6 49//_______________________________________________________________________
50AliGenerator::AliGenerator():
51 fThetaMin(0),
52 fThetaMax(0),
53 fPhiMin(0),
54 fPhiMax(0),
55 fPMin(0),
56 fPMax(0),
57 fPtMin(0),
58 fPtMax(0),
59 fYMin(0),
60 fYMax(0),
61 fVMin(3),
62 fVMax(3),
63 fNpart(0),
64 fParentWeight(0),
65 fChildWeight(0),
66 fAnalog(0),
67 fVertexSmear(kNoSmear),
68 fVertexSource(kExternal),
69 fCutVertexZ(0),
70 fTrackIt(0),
71 fOrigin(3),
72 fOsigma(3),
73 fVertex(3),
74 fEventVertex(0),
2c5b3727 75 fStack(0),
76 fCollisionGeometry(0)
fe4da5cc 77{
aee8290b 78 //
79 // Default constructor
80 //
f98e49f0 81 if (gAlice) {
82 if (gAlice->GetDebug()>0)
83 printf("\n AliGenerator Default Constructor\n\n");
84 gAlice->SetGenerator(this);
85 }
86
de6d59e3 87 SetThetaRange(); ResetBit(kThetaRange);
88 SetPhiRange(); ResetBit(kPhiRange);
89 SetMomentumRange(); ResetBit(kMomentumRange);
90 SetPtRange(); ResetBit(kPtRange);
91 SetYRange(); ResetBit(kYRange);
fe4da5cc 92 SetNumberParticles();
4a3ba9d2 93 SetTrackingFlag();
f98e49f0 94 SetCutVertexZ();
95
de6d59e3 96
fe4da5cc 97 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
98 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
f89cabfe 99 fVertex[0]=fVertex[1]=fVertex[2]=0;
100
de6d59e3 101 fVMin[0]=fVMin[1]=fVMin[2]=0;
de6d59e3 102 fVMax[0]=fVMax[1]=fVMax[2]=10000;
fe4da5cc 103}
104
e2afb3b6 105//_______________________________________________________________________
106AliGenerator::AliGenerator(Int_t npart):
107 fThetaMin(0),
108 fThetaMax(0),
109 fPhiMin(0),
110 fPhiMax(0),
111 fPMin(0),
112 fPMax(0),
113 fPtMin(0),
114 fPtMax(0),
115 fYMin(0),
116 fYMax(0),
117 fVMin(3),
118 fVMax(3),
119 fNpart(0),
120 fParentWeight(0),
121 fChildWeight(0),
122 fAnalog(0),
123 fVertexSmear(kNoSmear),
124 fVertexSource(kExternal),
125 fCutVertexZ(0),
126 fTrackIt(0),
127 fOrigin(3),
128 fOsigma(3),
129 fVertex(3),
130 fEventVertex(0),
2c5b3727 131 fStack(0),
132 fCollisionGeometry(0)
fe4da5cc 133{
aee8290b 134 //
135 // Standard constructor
136 //
f98e49f0 137 if (gAlice) {
138 if (gAlice->GetDebug()>0)
139 printf("\n AliGenerator Constructor initializing number of particles \n\n");
140 gAlice->SetGenerator(this);
141 }
142
de6d59e3 143 SetThetaRange(); ResetBit(kThetaRange);
144 SetPhiRange(); ResetBit(kPhiRange);
145 SetMomentumRange(); ResetBit(kMomentumRange);
146 SetPtRange(); ResetBit(kPtRange);
147 SetYRange(); ResetBit(kYRange);
4a3ba9d2 148 SetTrackingFlag();
f98e49f0 149 SetCutVertexZ();
de6d59e3 150
fe4da5cc 151 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
152 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
f89cabfe 153 fVertex[0]=fVertex[1]=fVertex[2]=0;
154
fe4da5cc 155 fVMin[0]=fVMin[1]=fVMin[2]=0;
fe4da5cc 156 fVMax[0]=fVMax[1]=fVMax[2]=10000;
de6d59e3 157
158 SetNumberParticles(npart);
9e1a0ddb 159
69a313ec 160 AliConfig::Instance()->Add(this);
fe4da5cc 161}
162
e2afb3b6 163//_______________________________________________________________________
164AliGenerator::AliGenerator(const AliGenerator &gen):
165 TNamed(gen),
166 AliRndm(gen),
167 fThetaMin(0),
168 fThetaMax(0),
169 fPhiMin(0),
170 fPhiMax(0),
171 fPMin(0),
172 fPMax(0),
173 fPtMin(0),
174 fPtMax(0),
175 fYMin(0),
176 fYMax(0),
177 fVMin(3),
178 fVMax(3),
179 fNpart(0),
180 fParentWeight(0),
181 fChildWeight(0),
182 fAnalog(0),
183 fVertexSmear(kNoSmear),
184 fVertexSource(kExternal),
185 fCutVertexZ(0),
186 fTrackIt(0),
187 fOrigin(3),
188 fOsigma(3),
189 fVertex(3),
190 fEventVertex(0),
191 fStack(0)
aee8290b 192{
193 //
194 // Copy constructor
195 //
196 gen.Copy(*this);
197}
198
e2afb3b6 199//_______________________________________________________________________
aee8290b 200AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
201{
202 //
203 // Assignment operator
204 //
205 gen.Copy(*this);
206 return (*this);
207}
208
e2afb3b6 209//_______________________________________________________________________
8918e700 210void AliGenerator::Copy(AliGenerator &/* gen */) const
aee8290b 211{
212 //
213 // Copy *this onto gen
214 //
215 Fatal("Copy","Not implemented!\n");
216}
217
e2afb3b6 218//_______________________________________________________________________
fe4da5cc 219AliGenerator::~AliGenerator()
220{
aee8290b 221 //
222 // Destructor
223 //
fe4da5cc 224 fOrigin.Set(0);
225 fOsigma.Set(0);
475e6235 226 if (fgMCEvGen) {
227 delete fgMCEvGen;
228 fgMCEvGen=0;
229 }
fe4da5cc 230}
231
e2afb3b6 232//_______________________________________________________________________
fe4da5cc 233void AliGenerator::Init()
234{
aee8290b 235 //
236 // Dummy initialisation
237 //
fe4da5cc 238}
239
94de3818 240//_______________________________________________________________________
241void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
242{
243 //
244 // Set the vertex for the generated tracks
245 //
246 fOrigin[0]=ox;
247 fOrigin[1]=oy;
248 fOrigin[2]=oz;
249}
250
251//_______________________________________________________________________
252void AliGenerator::SetOrigin(const TLorentzVector &o)
253{
254 //
255 // Set the vertex for the generated tracks
256 //
257 fOrigin[0]=o[0];
258 fOrigin[1]=o[1];
259 fOrigin[2]=o[2];
260}
261
262//_______________________________________________________________________
263void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
264{
265 //
266 // Set the spread of the vertex
267 //
268 fOsigma[0]=sx;
269 fOsigma[1]=sy;
270 fOsigma[2]=sz;
271}
272
273//_______________________________________________________________________
274void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
275{
276 //
277 // Set the momentum range for the generated particles
278 //
279 fPMin = pmin;
280 fPMax = pmax;
281 SetBit(kMomentumRange);
282}
283
284//_______________________________________________________________________
285void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
286{
287 //
288 // Set the Pt range for the generated particles
289 //
290 fPtMin = ptmin;
291 fPtMax = ptmax;
292 SetBit(kPtRange);
293}
294
295//_______________________________________________________________________
296void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
297{
298 //
299 // Set the Phi range for the generated particles
300 //
301 fPhiMin = TMath::Pi()*phimin/180;
c34578e7 302 fPhiMax = TMath::Pi()*phimax/180;
303 SetBit(kPhiRange);
94de3818 304}
305
306//_______________________________________________________________________
ca3a341c 307void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
94de3818 308{
309 //
310 // Set the Rapidity range for the generated particles
311 //
312 fYMin=ymin;
313 fYMax=ymax;
314 SetBit(kYRange);
315}
316
317//_______________________________________________________________________
318void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
319 Float_t vymin, Float_t vymax,
320 Float_t vzmin, Float_t vzmax)
321{
322 //
323 // Set the vertex range for the generated particles
324 //
325 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
326 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
327 SetBit(kVertexRange);
328}
fe4da5cc 329
94de3818 330//_______________________________________________________________________
331void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
332{
333 //
334 // Set the theta range for the generated particles
335 //
336 fThetaMin = TMath::Pi()*thetamin/180;
c34578e7 337 fThetaMax = TMath::Pi()*thetamax/180;
338 SetBit(kThetaRange);
94de3818 339}
f89cabfe 340
341void AliGenerator::Vertex()
342{
343 //
344 // Obtain vertex for current event from external source or calculated (internal)
345 //
346 if (fVertexSource == kInternal) {
347 VertexInternal();
348 } else {
349 VertexExternal();
350 }
351}
352
e2afb3b6 353//_______________________________________________________________________
f89cabfe 354void AliGenerator::VertexExternal()
355{
356 // Dummy !!!!!!
357 // Obtain vertex from external source
358 //
359 // Should be something like fVertex = gAlice->GetVertex()
360
361 fVertex[0]=fVertex[1]=fVertex[2]=0;
362}
363
e2afb3b6 364//_______________________________________________________________________
f89cabfe 365void AliGenerator::VertexInternal()
366{
367 //
368 // Obtain calculated vertex
369 // Default is gaussian smearing
370 Float_t random[6];
371 Rndm(random,6);
372 for (Int_t j = 0; j<3 ; j++) {
373 fVertex[j]=
374 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
375 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
376 }
377}
378
e2afb3b6 379//_______________________________________________________________________
69a313ec 380void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
381 Float_t *pmom, Float_t *vpos, Float_t *polar,
98490ea9 382 Float_t tof, TMCProcess mech, Int_t &ntr,
47c8bcbe 383 Float_t weight, Int_t is)
69a313ec 384{
116cbefd 385 //
386 // Loads one track on the stack
387 //
69a313ec 388
389 if (fStack)
390 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
47c8bcbe 391 mech, ntr, weight, is);
69a313ec 392 else
393 gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
47c8bcbe 394 mech, ntr, weight, is);
69a313ec 395}
e2afb3b6 396
397//_______________________________________________________________________
69a313ec 398void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
399 Double_t px, Double_t py, Double_t pz, Double_t e,
400 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
401 Double_t polx, Double_t poly, Double_t polz,
98490ea9 402 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
69a313ec 403{
116cbefd 404 //
405 // Loads one track on the stack
406 //
69a313ec 407
408 if (fStack)
409 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
47c8bcbe 410 polx, poly, polz, mech, ntr, weight, is);
69a313ec 411 else
412 gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
47c8bcbe 413 polx, poly, polz, mech, ntr, weight, is);
69a313ec 414}
f89cabfe 415
69a313ec 416
e2afb3b6 417//_______________________________________________________________________
69a313ec 418void AliGenerator:: KeepTrack(Int_t itrack)
419{
116cbefd 420 //
421 // Declare a track permanent on the stack
422 //
69a313ec 423 if (fStack)
424 fStack->KeepTrack(itrack);
425 else
426 gAlice->KeepTrack(itrack);
427
428}
429
e2afb3b6 430//_______________________________________________________________________
69a313ec 431void AliGenerator:: SetHighWaterMark(Int_t nt)
432{
116cbefd 433 //
434 // Internal function to set the maximum index used in the stack
435 //
69a313ec 436 if (fStack)
437 fStack->SetHighWaterMark(nt);
438 else
439 gAlice->SetHighWaterMark(nt);
440
441}