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