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