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