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