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