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