]>
Commit | Line | Data |
---|---|---|
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 | /* $Id$ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
19 | // Generate the final state of the interaction as the input | |
20 | // to the MonteCarlo | |
21 | // Author: A.Morsch | |
22 | //----------------------------------------------------------------- | |
23 | //Begin_Html | |
24 | /* | |
25 | <img src="picts/AliGeneratorClass.gif"> | |
26 | </pre> | |
27 | <br clear=left> | |
28 | <font size=+2 color=red> | |
29 | <p>The responsible person for this module is | |
30 | <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>. | |
31 | </font> | |
32 | <pre> | |
33 | */ | |
34 | //End_Html | |
35 | // // | |
36 | /////////////////////////////////////////////////////////////////// | |
37 | #include <TGenerator.h> | |
38 | ||
39 | #include "AliCollisionGeometry.h" | |
40 | #include "AliConfig.h" | |
41 | #include "AliGenerator.h" | |
42 | #include "AliRun.h" | |
43 | #include "AliStack.h" | |
44 | ||
45 | ClassImp(AliGenerator) | |
46 | ||
47 | ||
48 | //_______________________________________________________________________ | |
49 | AliGenerator::AliGenerator(): | |
50 | fThetaMin(0), | |
51 | fThetaMax(0), | |
52 | fPhiMin(0), | |
53 | fPhiMax(0), | |
54 | fPMin(0), | |
55 | fPMax(0), | |
56 | fPtMin(0), | |
57 | fPtMax(0), | |
58 | fYMin(0), | |
59 | fYMax(0), | |
60 | fVMin(3), | |
61 | fVMax(3), | |
62 | fNpart(0), | |
63 | fParentWeight(0), | |
64 | fChildWeight(0), | |
65 | fAnalog(0), | |
66 | fVertexSmear(kNoSmear), | |
67 | fVertexSource(kInternal), | |
68 | fCutVertexZ(0), | |
69 | fTrackIt(0), | |
70 | fOrigin(3), | |
71 | fOsigma(3), | |
72 | fVertex(3), | |
73 | fStack(0), | |
74 | fCollisionGeometry(0) | |
75 | { | |
76 | // | |
77 | // Default constructor | |
78 | // | |
79 | if (gAlice) { | |
80 | if (gAlice->GetDebug()>0) | |
81 | printf("\n AliGenerator Default Constructor\n\n"); | |
82 | gAlice->SetGenerator(this); | |
83 | } | |
84 | ||
85 | SetThetaRange(); ResetBit(kThetaRange); | |
86 | SetPhiRange(); ResetBit(kPhiRange); | |
87 | SetMomentumRange(); ResetBit(kMomentumRange); | |
88 | SetPtRange(); ResetBit(kPtRange); | |
89 | SetYRange(); ResetBit(kYRange); | |
90 | SetNumberParticles(); | |
91 | SetTrackingFlag(); | |
92 | SetCutVertexZ(); | |
93 | ||
94 | ||
95 | fOrigin[0]=fOrigin[1]=fOrigin[2]=0; | |
96 | fOsigma[0]=fOsigma[1]=fOsigma[2]=0; | |
97 | fVertex[0]=fVertex[1]=fVertex[2]=0; | |
98 | ||
99 | fVMin[0]=fVMin[1]=fVMin[2]=0; | |
100 | fVMax[0]=fVMax[1]=fVMax[2]=10000; | |
101 | } | |
102 | ||
103 | //_______________________________________________________________________ | |
104 | AliGenerator::AliGenerator(Int_t npart): | |
105 | fThetaMin(0), | |
106 | fThetaMax(0), | |
107 | fPhiMin(0), | |
108 | fPhiMax(0), | |
109 | fPMin(0), | |
110 | fPMax(0), | |
111 | fPtMin(0), | |
112 | fPtMax(0), | |
113 | fYMin(0), | |
114 | fYMax(0), | |
115 | fVMin(3), | |
116 | fVMax(3), | |
117 | fNpart(0), | |
118 | fParentWeight(0), | |
119 | fChildWeight(0), | |
120 | fAnalog(0), | |
121 | fVertexSmear(kNoSmear), | |
122 | fVertexSource(kInternal), | |
123 | fCutVertexZ(0), | |
124 | fTrackIt(0), | |
125 | fOrigin(3), | |
126 | fOsigma(3), | |
127 | fVertex(3), | |
128 | fStack(0), | |
129 | fCollisionGeometry(0) | |
130 | { | |
131 | // | |
132 | // Standard constructor | |
133 | // | |
134 | if (gAlice) { | |
135 | if (gAlice->GetDebug()>0) | |
136 | printf("\n AliGenerator Constructor initializing number of particles \n\n"); | |
137 | gAlice->SetGenerator(this); | |
138 | } | |
139 | ||
140 | SetThetaRange(); ResetBit(kThetaRange); | |
141 | SetPhiRange(); ResetBit(kPhiRange); | |
142 | SetMomentumRange(); ResetBit(kMomentumRange); | |
143 | SetPtRange(); ResetBit(kPtRange); | |
144 | SetYRange(); ResetBit(kYRange); | |
145 | SetTrackingFlag(); | |
146 | SetCutVertexZ(); | |
147 | ||
148 | fOrigin[0]=fOrigin[1]=fOrigin[2]=0; | |
149 | fOsigma[0]=fOsigma[1]=fOsigma[2]=0; | |
150 | fVertex[0]=fVertex[1]=fVertex[2]=0; | |
151 | ||
152 | fVMin[0]=fVMin[1]=fVMin[2]=0; | |
153 | fVMax[0]=fVMax[1]=fVMax[2]=10000; | |
154 | ||
155 | SetNumberParticles(npart); | |
156 | ||
157 | AliConfig::Instance()->Add(this); | |
158 | } | |
159 | ||
160 | //_______________________________________________________________________ | |
161 | AliGenerator::AliGenerator(const AliGenerator &gen): | |
162 | TNamed(gen), | |
163 | AliRndm(gen), | |
164 | fThetaMin(0), | |
165 | fThetaMax(0), | |
166 | fPhiMin(0), | |
167 | fPhiMax(0), | |
168 | fPMin(0), | |
169 | fPMax(0), | |
170 | fPtMin(0), | |
171 | fPtMax(0), | |
172 | fYMin(0), | |
173 | fYMax(0), | |
174 | fVMin(3), | |
175 | fVMax(3), | |
176 | fNpart(0), | |
177 | fParentWeight(0), | |
178 | fChildWeight(0), | |
179 | fAnalog(0), | |
180 | fVertexSmear(kNoSmear), | |
181 | fVertexSource(kInternal), | |
182 | fCutVertexZ(0), | |
183 | fTrackIt(0), | |
184 | fOrigin(3), | |
185 | fOsigma(3), | |
186 | fVertex(3), | |
187 | fStack(0) | |
188 | { | |
189 | // | |
190 | // Copy constructor | |
191 | // | |
192 | gen.Copy(*this); | |
193 | } | |
194 | ||
195 | //_______________________________________________________________________ | |
196 | AliGenerator & AliGenerator::operator=(const AliGenerator &gen) | |
197 | { | |
198 | // | |
199 | // Assignment operator | |
200 | // | |
201 | gen.Copy(*this); | |
202 | return (*this); | |
203 | } | |
204 | ||
205 | //_______________________________________________________________________ | |
206 | void AliGenerator::Copy(AliGenerator &/* gen */) const | |
207 | { | |
208 | // | |
209 | // Copy *this onto gen | |
210 | // | |
211 | Fatal("Copy","Not implemented!\n"); | |
212 | } | |
213 | ||
214 | //_______________________________________________________________________ | |
215 | AliGenerator::~AliGenerator() | |
216 | { | |
217 | // | |
218 | // Destructor | |
219 | // | |
220 | fOrigin.Set(0); | |
221 | fOsigma.Set(0); | |
222 | if (fMCEvGen) { | |
223 | delete fMCEvGen; | |
224 | fMCEvGen=0; | |
225 | } | |
226 | } | |
227 | ||
228 | //_______________________________________________________________________ | |
229 | void AliGenerator::Init() | |
230 | { | |
231 | // | |
232 | // Dummy initialisation | |
233 | // | |
234 | } | |
235 | ||
236 | //_______________________________________________________________________ | |
237 | void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz) | |
238 | { | |
239 | // | |
240 | // Set the vertex for the generated tracks | |
241 | // | |
242 | fOrigin[0]=ox; | |
243 | fOrigin[1]=oy; | |
244 | fOrigin[2]=oz; | |
245 | } | |
246 | ||
247 | //_______________________________________________________________________ | |
248 | void AliGenerator::SetOrigin(const TLorentzVector &o) | |
249 | { | |
250 | // | |
251 | // Set the vertex for the generated tracks | |
252 | // | |
253 | fOrigin[0]=o[0]; | |
254 | fOrigin[1]=o[1]; | |
255 | fOrigin[2]=o[2]; | |
256 | } | |
257 | ||
258 | //_______________________________________________________________________ | |
259 | void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz) | |
260 | { | |
261 | // | |
262 | // Set the spread of the vertex | |
263 | // | |
264 | fOsigma[0]=sx; | |
265 | fOsigma[1]=sy; | |
266 | fOsigma[2]=sz; | |
267 | } | |
268 | ||
269 | //_______________________________________________________________________ | |
270 | void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax) | |
271 | { | |
272 | // | |
273 | // Set the momentum range for the generated particles | |
274 | // | |
275 | fPMin = pmin; | |
276 | fPMax = pmax; | |
277 | SetBit(kMomentumRange); | |
278 | } | |
279 | ||
280 | //_______________________________________________________________________ | |
281 | void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax) | |
282 | { | |
283 | // | |
284 | // Set the Pt range for the generated particles | |
285 | // | |
286 | fPtMin = ptmin; | |
287 | fPtMax = ptmax; | |
288 | SetBit(kPtRange); | |
289 | } | |
290 | ||
291 | //_______________________________________________________________________ | |
292 | void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax) | |
293 | { | |
294 | // | |
295 | // Set the Phi range for the generated particles | |
296 | // | |
297 | fPhiMin = TMath::Pi()*phimin/180; | |
298 | fPhiMax = TMath::Pi()*phimax/180; | |
299 | SetBit(kPhiRange); | |
300 | } | |
301 | ||
302 | //_______________________________________________________________________ | |
303 | void AliGenerator::SetYRange(Float_t ymin, Float_t ymax) | |
304 | { | |
305 | // | |
306 | // Set the Rapidity range for the generated particles | |
307 | // | |
308 | fYMin=ymin; | |
309 | fYMax=ymax; | |
310 | SetBit(kYRange); | |
311 | } | |
312 | ||
313 | //_______________________________________________________________________ | |
314 | void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax, | |
315 | Float_t vymin, Float_t vymax, | |
316 | Float_t vzmin, Float_t vzmax) | |
317 | { | |
318 | // | |
319 | // Set the vertex range for the generated particles | |
320 | // | |
321 | fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin; | |
322 | fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax; | |
323 | SetBit(kVertexRange); | |
324 | } | |
325 | ||
326 | //_______________________________________________________________________ | |
327 | void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax) | |
328 | { | |
329 | // | |
330 | // Set the theta range for the generated particles | |
331 | // | |
332 | fThetaMin = TMath::Pi()*thetamin/180; | |
333 | fThetaMax = TMath::Pi()*thetamax/180; | |
334 | SetBit(kThetaRange); | |
335 | } | |
336 | ||
337 | void AliGenerator::Vertex() | |
338 | { | |
339 | // | |
340 | // Obtain vertex for current event from external source or calculated (internal) | |
341 | // | |
342 | if (fVertexSource == kInternal) { | |
343 | VertexInternal(); | |
344 | } else if (fVertexSource == kContainer) { | |
345 | ; | |
346 | } else if (fVertexSource == kExternal) { | |
347 | VertexExternal(); | |
348 | } | |
349 | } | |
350 | ||
351 | //_______________________________________________________________________ | |
352 | void AliGenerator::VertexExternal() | |
353 | { | |
354 | // Dummy !!!!!! | |
355 | // Obtain vertex from external source | |
356 | // | |
357 | // Should be something like fVertex = gAlice->GetVertex() | |
358 | ||
359 | fVertex[0]=fVertex[1]=fVertex[2]=0; | |
360 | } | |
361 | ||
362 | //_______________________________________________________________________ | |
363 | void AliGenerator::VertexInternal() | |
364 | { | |
365 | // | |
366 | // Obtain calculated vertex | |
367 | // Default is gaussian smearing | |
368 | Float_t random[6]; | |
369 | Float_t dv[3]; | |
370 | Int_t j; | |
371 | ||
372 | dv[2] = 1.e10; | |
373 | while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) { | |
374 | Rndm(random,6); | |
375 | for (j=0; j < 3; j++) { | |
376 | dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())* | |
377 | TMath::Sqrt(-2*TMath::Log(random[2*j+1])); | |
378 | } | |
379 | } | |
380 | for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j]; | |
381 | ||
382 | } | |
383 | ||
384 | //_______________________________________________________________________ | |
385 | void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg, | |
386 | Float_t *pmom, Float_t *vpos, Float_t *polar, | |
387 | Float_t tof, TMCProcess mech, Int_t &ntr, | |
388 | Float_t weight, Int_t is) | |
389 | { | |
390 | // | |
391 | // Loads one track on the stack | |
392 | // | |
393 | ||
394 | if (fStack) | |
395 | fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof, | |
396 | mech, ntr, weight, is); | |
397 | else | |
398 | gAlice->PushTrack(done, parent, pdg, pmom, vpos, polar, tof, | |
399 | mech, ntr, weight, is); | |
400 | } | |
401 | ||
402 | //_______________________________________________________________________ | |
403 | void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg, | |
404 | Double_t px, Double_t py, Double_t pz, Double_t e, | |
405 | Double_t vx, Double_t vy, Double_t vz, Double_t tof, | |
406 | Double_t polx, Double_t poly, Double_t polz, | |
407 | TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) | |
408 | { | |
409 | // | |
410 | // Loads one track on the stack | |
411 | // | |
412 | ||
413 | if (fStack) | |
414 | fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof, | |
415 | polx, poly, polz, mech, ntr, weight, is); | |
416 | else | |
417 | gAlice->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof, | |
418 | polx, poly, polz, mech, ntr, weight, is); | |
419 | } | |
420 | ||
421 | ||
422 | //_______________________________________________________________________ | |
423 | void AliGenerator:: KeepTrack(Int_t itrack) | |
424 | { | |
425 | // | |
426 | // Declare a track permanent on the stack | |
427 | // | |
428 | if (fStack) | |
429 | fStack->KeepTrack(itrack); | |
430 | else | |
431 | gAlice->KeepTrack(itrack); | |
432 | ||
433 | } | |
434 | ||
435 | //_______________________________________________________________________ | |
436 | void AliGenerator:: SetHighWaterMark(Int_t nt) | |
437 | { | |
438 | // | |
439 | // Internal function to set the maximum index used in the stack | |
440 | // | |
441 | if (fStack) | |
442 | fStack->SetHighWaterMark(nt); | |
443 | else | |
444 | gAlice->SetHighWaterMark(nt); | |
445 | ||
446 | } | |
447 | void AliGenerator::FinishRun() | |
448 | { | |
449 | ; | |
450 | } |