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