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