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 | |
16 | /* |
17 | $Log$ |
98490ea9 |
18 | Revision 1.20 2002/10/29 14:26:49 hristov |
19 | Code clean-up (F.Carminati) |
20 | |
e2afb3b6 |
21 | Revision 1.19 2002/03/12 11:06:03 morsch |
22 | Add particle status code to argument list of SetTrack(..). |
23 | |
47c8bcbe |
24 | Revision 1.18 2002/02/18 19:23:00 hristov |
25 | Put protection in the destructor |
26 | |
475e6235 |
27 | Revision 1.17 2001/11/26 15:46:35 morsch |
28 | Set default value for vertex truncation in constructor. |
29 | |
f98e49f0 |
30 | Revision 1.16 2001/10/16 08:45:37 morsch |
31 | All vertex truncation and event vertex moved here. |
32 | |
c34578e7 |
33 | Revision 1.15 2001/07/28 10:43:41 hristov |
34 | Default argument initialised once |
35 | |
7e6859a4 |
36 | Revision 1.14 2001/07/27 17:13:12 morsch |
37 | - SetTrack, KeepTrack and SetHighWaterMark methods added to delegate to local |
38 | stack or stack owned by AliRun. (Piotr Skowronski, A.M.) |
39 | - Changes needed for afterburners (Piotr Skowronski) |
40 | |
69a313ec |
41 | Revision 1.13 2001/05/16 14:57:22 alibrary |
42 | New files for folders and Stack |
43 | |
9e1a0ddb |
44 | Revision 1.12 2001/02/02 11:12:50 morsch |
45 | Add Vertex() method that allows to get vertex from merging manager, if needed. |
46 | |
f89cabfe |
47 | Revision 1.11 2001/01/26 19:58:48 hristov |
48 | Major upgrade of AliRoot code |
49 | |
2ab0c725 |
50 | Revision 1.10 2000/12/21 15:30:18 fca |
51 | Correcting coding convention violations |
52 | |
b23a502f |
53 | Revision 1.9 2000/10/04 10:08:01 fca |
54 | Correction of minor typing mistakes |
55 | |
ca3a341c |
56 | Revision 1.8 2000/10/02 21:28:14 fca |
57 | Removal of useless dependecies via forward declarations |
58 | |
94de3818 |
59 | Revision 1.7 2000/07/12 08:56:25 fca |
60 | Coding convention correction and warning removal |
61 | |
8918e700 |
62 | Revision 1.6 2000/07/11 18:24:59 fca |
63 | Coding convention corrections + few minor bug fixes |
64 | |
aee8290b |
65 | Revision 1.5 2000/06/08 13:34:50 fca |
66 | Better control of momentum range in GenBox |
67 | |
de6d59e3 |
68 | Revision 1.4 1999/09/29 09:24:29 fca |
69 | Introduction of the Copyright and cvs Log |
70 | |
4c039060 |
71 | */ |
72 | |
fe4da5cc |
73 | /////////////////////////////////////////////////////////////////// |
74 | // // |
75 | // Generate the final state of the interaction as the input // |
76 | // to the MonteCarlo // |
77 | // |
78 | //Begin_Html |
79 | /* |
1439f98e |
80 | <img src="picts/AliGeneratorClass.gif"> |
fe4da5cc |
81 | </pre> |
82 | <br clear=left> |
83 | <font size=+2 color=red> |
84 | <p>The responsible person for this module is |
85 | <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>. |
86 | </font> |
87 | <pre> |
88 | */ |
89 | //End_Html |
90 | // // |
91 | /////////////////////////////////////////////////////////////////// |
e2afb3b6 |
92 | #include "TGenerator.h" |
fe4da5cc |
93 | |
e2afb3b6 |
94 | #include "AliConfig.h" |
fe4da5cc |
95 | #include "AliGenerator.h" |
96 | #include "AliRun.h" |
69a313ec |
97 | #include "AliStack.h" |
98 | |
fe4da5cc |
99 | ClassImp(AliGenerator) |
100 | |
101 | TGenerator* AliGenerator::fgMCEvGen=0; |
102 | |
e2afb3b6 |
103 | //_______________________________________________________________________ |
104 | AliGenerator::AliGenerator(): |
105 | fThetaMin(0), |
106 | fThetaMax(0), |
107 | fPhiMin(0), |
108 | fPhiMax(0), |
109 | fPMin(0), |
110 | fPMax(0), |
111 | fPtMin(0), |
112 | fPtMax(0), |
113 | fYMin(0), |
114 | fYMax(0), |
115 | fVMin(3), |
116 | fVMax(3), |
117 | fNpart(0), |
118 | fParentWeight(0), |
119 | fChildWeight(0), |
120 | fAnalog(0), |
121 | fVertexSmear(kNoSmear), |
122 | fVertexSource(kExternal), |
123 | fCutVertexZ(0), |
124 | fTrackIt(0), |
125 | fOrigin(3), |
126 | fOsigma(3), |
127 | fVertex(3), |
128 | fEventVertex(0), |
129 | fStack(0) |
fe4da5cc |
130 | { |
aee8290b |
131 | // |
132 | // Default constructor |
133 | // |
f98e49f0 |
134 | if (gAlice) { |
135 | if (gAlice->GetDebug()>0) |
136 | printf("\n AliGenerator Default Constructor\n\n"); |
137 | gAlice->SetGenerator(this); |
138 | } |
139 | |
de6d59e3 |
140 | SetThetaRange(); ResetBit(kThetaRange); |
141 | SetPhiRange(); ResetBit(kPhiRange); |
142 | SetMomentumRange(); ResetBit(kMomentumRange); |
143 | SetPtRange(); ResetBit(kPtRange); |
144 | SetYRange(); ResetBit(kYRange); |
fe4da5cc |
145 | SetNumberParticles(); |
4a3ba9d2 |
146 | SetTrackingFlag(); |
f98e49f0 |
147 | SetCutVertexZ(); |
148 | |
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 | |
de6d59e3 |
154 | fVMin[0]=fVMin[1]=fVMin[2]=0; |
de6d59e3 |
155 | fVMax[0]=fVMax[1]=fVMax[2]=10000; |
fe4da5cc |
156 | } |
157 | |
e2afb3b6 |
158 | //_______________________________________________________________________ |
159 | AliGenerator::AliGenerator(Int_t npart): |
160 | fThetaMin(0), |
161 | fThetaMax(0), |
162 | fPhiMin(0), |
163 | fPhiMax(0), |
164 | fPMin(0), |
165 | fPMax(0), |
166 | fPtMin(0), |
167 | fPtMax(0), |
168 | fYMin(0), |
169 | fYMax(0), |
170 | fVMin(3), |
171 | fVMax(3), |
172 | fNpart(0), |
173 | fParentWeight(0), |
174 | fChildWeight(0), |
175 | fAnalog(0), |
176 | fVertexSmear(kNoSmear), |
177 | fVertexSource(kExternal), |
178 | fCutVertexZ(0), |
179 | fTrackIt(0), |
180 | fOrigin(3), |
181 | fOsigma(3), |
182 | fVertex(3), |
183 | fEventVertex(0), |
184 | fStack(0) |
fe4da5cc |
185 | { |
aee8290b |
186 | // |
187 | // Standard constructor |
188 | // |
f98e49f0 |
189 | if (gAlice) { |
190 | if (gAlice->GetDebug()>0) |
191 | printf("\n AliGenerator Constructor initializing number of particles \n\n"); |
192 | gAlice->SetGenerator(this); |
193 | } |
194 | |
de6d59e3 |
195 | SetThetaRange(); ResetBit(kThetaRange); |
196 | SetPhiRange(); ResetBit(kPhiRange); |
197 | SetMomentumRange(); ResetBit(kMomentumRange); |
198 | SetPtRange(); ResetBit(kPtRange); |
199 | SetYRange(); ResetBit(kYRange); |
4a3ba9d2 |
200 | SetTrackingFlag(); |
f98e49f0 |
201 | SetCutVertexZ(); |
de6d59e3 |
202 | |
fe4da5cc |
203 | fOrigin[0]=fOrigin[1]=fOrigin[2]=0; |
204 | fOsigma[0]=fOsigma[1]=fOsigma[2]=0; |
f89cabfe |
205 | fVertex[0]=fVertex[1]=fVertex[2]=0; |
206 | |
fe4da5cc |
207 | fVMin[0]=fVMin[1]=fVMin[2]=0; |
fe4da5cc |
208 | fVMax[0]=fVMax[1]=fVMax[2]=10000; |
de6d59e3 |
209 | |
210 | SetNumberParticles(npart); |
9e1a0ddb |
211 | |
69a313ec |
212 | AliConfig::Instance()->Add(this); |
fe4da5cc |
213 | } |
214 | |
e2afb3b6 |
215 | //_______________________________________________________________________ |
216 | AliGenerator::AliGenerator(const AliGenerator &gen): |
217 | TNamed(gen), |
218 | AliRndm(gen), |
219 | fThetaMin(0), |
220 | fThetaMax(0), |
221 | fPhiMin(0), |
222 | fPhiMax(0), |
223 | fPMin(0), |
224 | fPMax(0), |
225 | fPtMin(0), |
226 | fPtMax(0), |
227 | fYMin(0), |
228 | fYMax(0), |
229 | fVMin(3), |
230 | fVMax(3), |
231 | fNpart(0), |
232 | fParentWeight(0), |
233 | fChildWeight(0), |
234 | fAnalog(0), |
235 | fVertexSmear(kNoSmear), |
236 | fVertexSource(kExternal), |
237 | fCutVertexZ(0), |
238 | fTrackIt(0), |
239 | fOrigin(3), |
240 | fOsigma(3), |
241 | fVertex(3), |
242 | fEventVertex(0), |
243 | fStack(0) |
aee8290b |
244 | { |
245 | // |
246 | // Copy constructor |
247 | // |
248 | gen.Copy(*this); |
249 | } |
250 | |
e2afb3b6 |
251 | //_______________________________________________________________________ |
aee8290b |
252 | AliGenerator & AliGenerator::operator=(const AliGenerator &gen) |
253 | { |
254 | // |
255 | // Assignment operator |
256 | // |
257 | gen.Copy(*this); |
258 | return (*this); |
259 | } |
260 | |
e2afb3b6 |
261 | //_______________________________________________________________________ |
8918e700 |
262 | void AliGenerator::Copy(AliGenerator &/* gen */) const |
aee8290b |
263 | { |
264 | // |
265 | // Copy *this onto gen |
266 | // |
267 | Fatal("Copy","Not implemented!\n"); |
268 | } |
269 | |
e2afb3b6 |
270 | //_______________________________________________________________________ |
fe4da5cc |
271 | AliGenerator::~AliGenerator() |
272 | { |
aee8290b |
273 | // |
274 | // Destructor |
275 | // |
fe4da5cc |
276 | fOrigin.Set(0); |
277 | fOsigma.Set(0); |
475e6235 |
278 | if (fgMCEvGen) { |
279 | delete fgMCEvGen; |
280 | fgMCEvGen=0; |
281 | } |
fe4da5cc |
282 | } |
283 | |
e2afb3b6 |
284 | //_______________________________________________________________________ |
fe4da5cc |
285 | void AliGenerator::Init() |
286 | { |
aee8290b |
287 | // |
288 | // Dummy initialisation |
289 | // |
fe4da5cc |
290 | } |
291 | |
94de3818 |
292 | //_______________________________________________________________________ |
293 | void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz) |
294 | { |
295 | // |
296 | // Set the vertex for the generated tracks |
297 | // |
298 | fOrigin[0]=ox; |
299 | fOrigin[1]=oy; |
300 | fOrigin[2]=oz; |
301 | } |
302 | |
303 | //_______________________________________________________________________ |
304 | void AliGenerator::SetOrigin(const TLorentzVector &o) |
305 | { |
306 | // |
307 | // Set the vertex for the generated tracks |
308 | // |
309 | fOrigin[0]=o[0]; |
310 | fOrigin[1]=o[1]; |
311 | fOrigin[2]=o[2]; |
312 | } |
313 | |
314 | //_______________________________________________________________________ |
315 | void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz) |
316 | { |
317 | // |
318 | // Set the spread of the vertex |
319 | // |
320 | fOsigma[0]=sx; |
321 | fOsigma[1]=sy; |
322 | fOsigma[2]=sz; |
323 | } |
324 | |
325 | //_______________________________________________________________________ |
326 | void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax) |
327 | { |
328 | // |
329 | // Set the momentum range for the generated particles |
330 | // |
331 | fPMin = pmin; |
332 | fPMax = pmax; |
333 | SetBit(kMomentumRange); |
334 | } |
335 | |
336 | //_______________________________________________________________________ |
337 | void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax) |
338 | { |
339 | // |
340 | // Set the Pt range for the generated particles |
341 | // |
342 | fPtMin = ptmin; |
343 | fPtMax = ptmax; |
344 | SetBit(kPtRange); |
345 | } |
346 | |
347 | //_______________________________________________________________________ |
348 | void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax) |
349 | { |
350 | // |
351 | // Set the Phi range for the generated particles |
352 | // |
353 | fPhiMin = TMath::Pi()*phimin/180; |
c34578e7 |
354 | fPhiMax = TMath::Pi()*phimax/180; |
355 | SetBit(kPhiRange); |
94de3818 |
356 | } |
357 | |
358 | //_______________________________________________________________________ |
ca3a341c |
359 | void AliGenerator::SetYRange(Float_t ymin, Float_t ymax) |
94de3818 |
360 | { |
361 | // |
362 | // Set the Rapidity range for the generated particles |
363 | // |
364 | fYMin=ymin; |
365 | fYMax=ymax; |
366 | SetBit(kYRange); |
367 | } |
368 | |
369 | //_______________________________________________________________________ |
370 | void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax, |
371 | Float_t vymin, Float_t vymax, |
372 | Float_t vzmin, Float_t vzmax) |
373 | { |
374 | // |
375 | // Set the vertex range for the generated particles |
376 | // |
377 | fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin; |
378 | fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax; |
379 | SetBit(kVertexRange); |
380 | } |
fe4da5cc |
381 | |
94de3818 |
382 | //_______________________________________________________________________ |
383 | void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax) |
384 | { |
385 | // |
386 | // Set the theta range for the generated particles |
387 | // |
388 | fThetaMin = TMath::Pi()*thetamin/180; |
c34578e7 |
389 | fThetaMax = TMath::Pi()*thetamax/180; |
390 | SetBit(kThetaRange); |
94de3818 |
391 | } |
f89cabfe |
392 | |
393 | void AliGenerator::Vertex() |
394 | { |
395 | // |
396 | // Obtain vertex for current event from external source or calculated (internal) |
397 | // |
398 | if (fVertexSource == kInternal) { |
399 | VertexInternal(); |
400 | } else { |
401 | VertexExternal(); |
402 | } |
403 | } |
404 | |
e2afb3b6 |
405 | //_______________________________________________________________________ |
f89cabfe |
406 | void AliGenerator::VertexExternal() |
407 | { |
408 | // Dummy !!!!!! |
409 | // Obtain vertex from external source |
410 | // |
411 | // Should be something like fVertex = gAlice->GetVertex() |
412 | |
413 | fVertex[0]=fVertex[1]=fVertex[2]=0; |
414 | } |
415 | |
e2afb3b6 |
416 | //_______________________________________________________________________ |
f89cabfe |
417 | void AliGenerator::VertexInternal() |
418 | { |
419 | // |
420 | // Obtain calculated vertex |
421 | // Default is gaussian smearing |
422 | Float_t random[6]; |
423 | Rndm(random,6); |
424 | for (Int_t j = 0; j<3 ; j++) { |
425 | fVertex[j]= |
426 | fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())* |
427 | TMath::Sqrt(-2*TMath::Log(random[2*j+1])); |
428 | } |
429 | } |
430 | |
e2afb3b6 |
431 | //_______________________________________________________________________ |
69a313ec |
432 | void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg, |
433 | Float_t *pmom, Float_t *vpos, Float_t *polar, |
98490ea9 |
434 | Float_t tof, TMCProcess mech, Int_t &ntr, |
47c8bcbe |
435 | Float_t weight, Int_t is) |
69a313ec |
436 | { |
437 | |
438 | if (fStack) |
439 | fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof, |
47c8bcbe |
440 | mech, ntr, weight, is); |
69a313ec |
441 | else |
442 | gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof, |
47c8bcbe |
443 | mech, ntr, weight, is); |
69a313ec |
444 | } |
e2afb3b6 |
445 | |
446 | //_______________________________________________________________________ |
69a313ec |
447 | void AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg, |
448 | Double_t px, Double_t py, Double_t pz, Double_t e, |
449 | Double_t vx, Double_t vy, Double_t vz, Double_t tof, |
450 | Double_t polx, Double_t poly, Double_t polz, |
98490ea9 |
451 | TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) |
69a313ec |
452 | { |
453 | |
454 | if (fStack) |
455 | fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof, |
47c8bcbe |
456 | polx, poly, polz, mech, ntr, weight, is); |
69a313ec |
457 | else |
458 | gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof, |
47c8bcbe |
459 | polx, poly, polz, mech, ntr, weight, is); |
69a313ec |
460 | } |
f89cabfe |
461 | |
69a313ec |
462 | |
e2afb3b6 |
463 | //_______________________________________________________________________ |
69a313ec |
464 | void AliGenerator:: KeepTrack(Int_t itrack) |
465 | { |
466 | if (fStack) |
467 | fStack->KeepTrack(itrack); |
468 | else |
469 | gAlice->KeepTrack(itrack); |
470 | |
471 | } |
472 | |
e2afb3b6 |
473 | //_______________________________________________________________________ |
69a313ec |
474 | void AliGenerator:: SetHighWaterMark(Int_t nt) |
475 | { |
476 | if (fStack) |
477 | fStack->SetHighWaterMark(nt); |
478 | else |
479 | gAlice->SetHighWaterMark(nt); |
480 | |
481 | } |