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