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