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