]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliGenerator.cxx
transition to newIO
[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
acd84897 16/* $Id$ */
4c039060 17
5d8718b8 18//-----------------------------------------------------------------
19// Generate the final state of the interaction as the input
20// to the MonteCarlo
21// Author: A.Morsch
22//-----------------------------------------------------------------
fe4da5cc 23//Begin_Html
24/*
1439f98e 25<img src="picts/AliGeneratorClass.gif">
fe4da5cc 26</pre>
27<br clear=left>
28<font size=+2 color=red>
29<p>The responsible person for this module is
30<a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
31</font>
32<pre>
33*/
34//End_Html
35// //
36///////////////////////////////////////////////////////////////////
116cbefd 37#include <TGenerator.h>
fe4da5cc 38
116cbefd 39#include "AliCollisionGeometry.h"
e2afb3b6 40#include "AliConfig.h"
fe4da5cc 41#include "AliGenerator.h"
42#include "AliRun.h"
69a313ec 43#include "AliStack.h"
44
fe4da5cc 45ClassImp(AliGenerator)
46
fe4da5cc 47
e2afb3b6 48//_______________________________________________________________________
49AliGenerator::AliGenerator():
50 fThetaMin(0),
51 fThetaMax(0),
52 fPhiMin(0),
53 fPhiMax(0),
54 fPMin(0),
55 fPMax(0),
56 fPtMin(0),
57 fPtMax(0),
58 fYMin(0),
59 fYMax(0),
60 fVMin(3),
61 fVMax(3),
62 fNpart(0),
63 fParentWeight(0),
64 fChildWeight(0),
65 fAnalog(0),
66 fVertexSmear(kNoSmear),
0b910a04 67 fVertexSource(kInternal),
e2afb3b6 68 fCutVertexZ(0),
69 fTrackIt(0),
70 fOrigin(3),
71 fOsigma(3),
72 fVertex(3),
2c5b3727 73 fStack(0),
74 fCollisionGeometry(0)
fe4da5cc 75{
aee8290b 76 //
77 // Default constructor
78 //
f98e49f0 79 if (gAlice) {
80 if (gAlice->GetDebug()>0)
81 printf("\n AliGenerator Default Constructor\n\n");
82 gAlice->SetGenerator(this);
83 }
84
de6d59e3 85 SetThetaRange(); ResetBit(kThetaRange);
86 SetPhiRange(); ResetBit(kPhiRange);
87 SetMomentumRange(); ResetBit(kMomentumRange);
88 SetPtRange(); ResetBit(kPtRange);
89 SetYRange(); ResetBit(kYRange);
fe4da5cc 90 SetNumberParticles();
4a3ba9d2 91 SetTrackingFlag();
f98e49f0 92 SetCutVertexZ();
93
de6d59e3 94
fe4da5cc 95 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
96 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
f89cabfe 97 fVertex[0]=fVertex[1]=fVertex[2]=0;
98
de6d59e3 99 fVMin[0]=fVMin[1]=fVMin[2]=0;
de6d59e3 100 fVMax[0]=fVMax[1]=fVMax[2]=10000;
fe4da5cc 101}
102
e2afb3b6 103//_______________________________________________________________________
104AliGenerator::AliGenerator(Int_t npart):
105 fThetaMin(0),
106 fThetaMax(0),
107 fPhiMin(0),
108 fPhiMax(0),
109 fPMin(0),
110 fPMax(0),
111 fPtMin(0),
112 fPtMax(0),
113 fYMin(0),
114 fYMax(0),
115 fVMin(3),
116 fVMax(3),
117 fNpart(0),
118 fParentWeight(0),
119 fChildWeight(0),
120 fAnalog(0),
121 fVertexSmear(kNoSmear),
0b910a04 122 fVertexSource(kInternal),
e2afb3b6 123 fCutVertexZ(0),
124 fTrackIt(0),
125 fOrigin(3),
126 fOsigma(3),
127 fVertex(3),
2c5b3727 128 fStack(0),
129 fCollisionGeometry(0)
fe4da5cc 130{
aee8290b 131 //
132 // Standard constructor
133 //
f98e49f0 134 if (gAlice) {
135 if (gAlice->GetDebug()>0)
136 printf("\n AliGenerator Constructor initializing number of particles \n\n");
137 gAlice->SetGenerator(this);
138 }
139
de6d59e3 140 SetThetaRange(); ResetBit(kThetaRange);
141 SetPhiRange(); ResetBit(kPhiRange);
142 SetMomentumRange(); ResetBit(kMomentumRange);
143 SetPtRange(); ResetBit(kPtRange);
144 SetYRange(); ResetBit(kYRange);
4a3ba9d2 145 SetTrackingFlag();
f98e49f0 146 SetCutVertexZ();
de6d59e3 147
fe4da5cc 148 fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
149 fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
f89cabfe 150 fVertex[0]=fVertex[1]=fVertex[2]=0;
151
fe4da5cc 152 fVMin[0]=fVMin[1]=fVMin[2]=0;
fe4da5cc 153 fVMax[0]=fVMax[1]=fVMax[2]=10000;
de6d59e3 154
155 SetNumberParticles(npart);
9e1a0ddb 156
69a313ec 157 AliConfig::Instance()->Add(this);
fe4da5cc 158}
159
e2afb3b6 160//_______________________________________________________________________
161AliGenerator::AliGenerator(const AliGenerator &gen):
162 TNamed(gen),
163 AliRndm(gen),
164 fThetaMin(0),
165 fThetaMax(0),
166 fPhiMin(0),
167 fPhiMax(0),
168 fPMin(0),
169 fPMax(0),
170 fPtMin(0),
171 fPtMax(0),
172 fYMin(0),
173 fYMax(0),
174 fVMin(3),
175 fVMax(3),
176 fNpart(0),
177 fParentWeight(0),
178 fChildWeight(0),
179 fAnalog(0),
180 fVertexSmear(kNoSmear),
0b910a04 181 fVertexSource(kInternal),
e2afb3b6 182 fCutVertexZ(0),
183 fTrackIt(0),
184 fOrigin(3),
185 fOsigma(3),
186 fVertex(3),
e2afb3b6 187 fStack(0)
aee8290b 188{
189 //
190 // Copy constructor
191 //
192 gen.Copy(*this);
193}
194
e2afb3b6 195//_______________________________________________________________________
aee8290b 196AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
197{
198 //
199 // Assignment operator
200 //
201 gen.Copy(*this);
202 return (*this);
203}
204
e2afb3b6 205//_______________________________________________________________________
8918e700 206void AliGenerator::Copy(AliGenerator &/* gen */) const
aee8290b 207{
208 //
209 // Copy *this onto gen
210 //
211 Fatal("Copy","Not implemented!\n");
212}
213
e2afb3b6 214//_______________________________________________________________________
fe4da5cc 215AliGenerator::~AliGenerator()
216{
aee8290b 217 //
218 // Destructor
219 //
fe4da5cc 220 fOrigin.Set(0);
221 fOsigma.Set(0);
a08cd31a 222 if (fMCEvGen) {
223 delete fMCEvGen;
224 fMCEvGen=0;
475e6235 225 }
fe4da5cc 226}
227
e2afb3b6 228//_______________________________________________________________________
fe4da5cc 229void AliGenerator::Init()
230{
aee8290b 231 //
232 // Dummy initialisation
233 //
fe4da5cc 234}
235
94de3818 236//_______________________________________________________________________
237void AliGenerator::SetOrigin(Float_t ox, Float_t oy, Float_t oz)
238{
239 //
240 // Set the vertex for the generated tracks
241 //
242 fOrigin[0]=ox;
243 fOrigin[1]=oy;
244 fOrigin[2]=oz;
245}
246
247//_______________________________________________________________________
248void AliGenerator::SetOrigin(const TLorentzVector &o)
249{
250 //
251 // Set the vertex for the generated tracks
252 //
253 fOrigin[0]=o[0];
254 fOrigin[1]=o[1];
255 fOrigin[2]=o[2];
256}
257
258//_______________________________________________________________________
259void AliGenerator::SetSigma(Float_t sx, Float_t sy, Float_t sz)
260{
261 //
262 // Set the spread of the vertex
263 //
264 fOsigma[0]=sx;
265 fOsigma[1]=sy;
266 fOsigma[2]=sz;
267}
268
269//_______________________________________________________________________
270void AliGenerator::SetMomentumRange(Float_t pmin, Float_t pmax)
271{
272 //
273 // Set the momentum range for the generated particles
274 //
275 fPMin = pmin;
276 fPMax = pmax;
277 SetBit(kMomentumRange);
278}
279
280//_______________________________________________________________________
281void AliGenerator::SetPtRange(Float_t ptmin, Float_t ptmax)
282{
283 //
284 // Set the Pt range for the generated particles
285 //
286 fPtMin = ptmin;
287 fPtMax = ptmax;
288 SetBit(kPtRange);
289}
290
291//_______________________________________________________________________
292void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
293{
294 //
295 // Set the Phi range for the generated particles
296 //
297 fPhiMin = TMath::Pi()*phimin/180;
c34578e7 298 fPhiMax = TMath::Pi()*phimax/180;
299 SetBit(kPhiRange);
94de3818 300}
301
302//_______________________________________________________________________
ca3a341c 303void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
94de3818 304{
305 //
306 // Set the Rapidity range for the generated particles
307 //
308 fYMin=ymin;
309 fYMax=ymax;
310 SetBit(kYRange);
311}
312
313//_______________________________________________________________________
314void AliGenerator::SetVRange(Float_t vxmin, Float_t vxmax,
315 Float_t vymin, Float_t vymax,
316 Float_t vzmin, Float_t vzmax)
317{
318 //
319 // Set the vertex range for the generated particles
320 //
321 fVMin[0]=vxmin; fVMin[1]=vymin; fVMin[2]=vzmin;
322 fVMax[0]=vxmax; fVMax[1]=vymax; fVMax[2]=vzmax;
323 SetBit(kVertexRange);
324}
fe4da5cc 325
94de3818 326//_______________________________________________________________________
327void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
328{
329 //
330 // Set the theta range for the generated particles
331 //
332 fThetaMin = TMath::Pi()*thetamin/180;
c34578e7 333 fThetaMax = TMath::Pi()*thetamax/180;
334 SetBit(kThetaRange);
94de3818 335}
f89cabfe 336
337void AliGenerator::Vertex()
338{
339 //
340 // Obtain vertex for current event from external source or calculated (internal)
341 //
342 if (fVertexSource == kInternal) {
343 VertexInternal();
0b910a04 344 } else if (fVertexSource == kContainer) {
345 ;
346 } else if (fVertexSource == kExternal) {
f89cabfe 347 VertexExternal();
348 }
349}
350
e2afb3b6 351//_______________________________________________________________________
f89cabfe 352void AliGenerator::VertexExternal()
353{
354 // Dummy !!!!!!
355 // Obtain vertex from external source
356 //
357 // Should be something like fVertex = gAlice->GetVertex()
358
359 fVertex[0]=fVertex[1]=fVertex[2]=0;
360}
361
e2afb3b6 362//_______________________________________________________________________
f89cabfe 363void AliGenerator::VertexInternal()
364{
365 //
366 // Obtain calculated vertex
367 // Default is gaussian smearing
368 Float_t random[6];
0b910a04 369 Float_t dv[3];
370 Int_t j;
371
372 dv[2] = 1.e10;
373 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
374 Rndm(random,6);
375 for (j=0; j < 3; j++) {
376 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
377 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
378 }
f89cabfe 379 }
0b910a04 380 for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
381
f89cabfe 382}
383
e2afb3b6 384//_______________________________________________________________________
642f15cf 385void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
69a313ec 386 Float_t *pmom, Float_t *vpos, Float_t *polar,
98490ea9 387 Float_t tof, TMCProcess mech, Int_t &ntr,
47c8bcbe 388 Float_t weight, Int_t is)
69a313ec 389{
116cbefd 390 //
391 // Loads one track on the stack
392 //
69a313ec 393
394 if (fStack)
642f15cf 395 fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
47c8bcbe 396 mech, ntr, weight, is);
69a313ec 397 else
642f15cf 398 gAlice->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
47c8bcbe 399 mech, ntr, weight, is);
69a313ec 400}
e2afb3b6 401
402//_______________________________________________________________________
642f15cf 403void AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
69a313ec 404 Double_t px, Double_t py, Double_t pz, Double_t e,
405 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
406 Double_t polx, Double_t poly, Double_t polz,
98490ea9 407 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
69a313ec 408{
116cbefd 409 //
410 // Loads one track on the stack
411 //
69a313ec 412
413 if (fStack)
642f15cf 414 fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
47c8bcbe 415 polx, poly, polz, mech, ntr, weight, is);
69a313ec 416 else
642f15cf 417 gAlice->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
47c8bcbe 418 polx, poly, polz, mech, ntr, weight, is);
69a313ec 419}
f89cabfe 420
69a313ec 421
e2afb3b6 422//_______________________________________________________________________
69a313ec 423void AliGenerator:: KeepTrack(Int_t itrack)
424{
116cbefd 425 //
426 // Declare a track permanent on the stack
427 //
69a313ec 428 if (fStack)
429 fStack->KeepTrack(itrack);
430 else
431 gAlice->KeepTrack(itrack);
432
433}
434
e2afb3b6 435//_______________________________________________________________________
69a313ec 436void AliGenerator:: SetHighWaterMark(Int_t nt)
437{
116cbefd 438 //
439 // Internal function to set the maximum index used in the stack
440 //
69a313ec 441 if (fStack)
442 fStack->SetHighWaterMark(nt);
443 else
444 gAlice->SetHighWaterMark(nt);
445
446}
0b910a04 447void AliGenerator::FinishRun()
448{
449 ;
450}