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