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