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