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