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