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