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