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