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