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