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