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