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