]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliGenerator.cxx
Use local SetTrack, KeepTrack and SetHighWaterMark methods
[u/mrichter/AliRoot.git] / STEER / AliGenerator.cxx
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$
18 Revision 1.12  2001/02/02 11:12:50  morsch
19 Add Vertex() method that allows to get vertex from merging manager, if needed.
20
21 Revision 1.11  2001/01/26 19:58:48  hristov
22 Major upgrade of AliRoot code
23
24 Revision 1.10  2000/12/21 15:30:18  fca
25 Correcting coding convention violations
26
27 Revision 1.9  2000/10/04 10:08:01  fca
28 Correction of minor typing mistakes
29
30 Revision 1.8  2000/10/02 21:28:14  fca
31 Removal of useless dependecies via forward declarations
32
33 Revision 1.7  2000/07/12 08:56:25  fca
34 Coding convention correction and warning removal
35
36 Revision 1.6  2000/07/11 18:24:59  fca
37 Coding convention corrections + few minor bug fixes
38
39 Revision 1.5  2000/06/08 13:34:50  fca
40 Better control of momentum range in GenBox
41
42 Revision 1.4  1999/09/29 09:24:29  fca
43 Introduction of the Copyright and cvs Log
44
45 */
46
47 ///////////////////////////////////////////////////////////////////
48 //                                                               //
49 //    Generate the final state of the interaction as the input   //
50 //    to the MonteCarlo                                          //
51 //
52 //Begin_Html
53 /*
54 <img src="picts/AliGeneratorClass.gif">
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"
68 #include "TGenerator.h"
69 #include "AliRun.h"
70 #include "AliConfig.h"
71
72 ClassImp(AliGenerator)
73
74 TGenerator* AliGenerator::fgMCEvGen=0;
75
76 //____________________________________________________________
77 AliGenerator::AliGenerator()
78 {
79   //
80   // Default constructor
81   //
82     if (gAlice->GetDebug()>0)
83         printf("\n AliGenerator Default Constructor\n\n");
84     
85     gAlice->SetGenerator(this);
86     SetThetaRange(); ResetBit(kThetaRange);
87     SetPhiRange(); ResetBit(kPhiRange);
88     SetMomentumRange(); ResetBit(kMomentumRange);
89     SetPtRange(); ResetBit(kPtRange);
90     SetYRange(); ResetBit(kYRange);
91     SetNumberParticles();
92     SetTrackingFlag();
93
94     fOrigin.Set(3);
95     fOsigma.Set(3);
96     fVertex.Set(3);
97
98     fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
99     fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
100     fVertex[0]=fVertex[1]=fVertex[2]=0;
101
102     fVMin.Set(3);
103     fVMin[0]=fVMin[1]=fVMin[2]=0;
104     fVMax.Set(3);
105     fVMax[0]=fVMax[1]=fVMax[2]=10000;
106 }
107
108 //____________________________________________________________
109 AliGenerator::AliGenerator(Int_t npart)
110     : TNamed(" "," ")
111 {
112   //
113   // Standard constructor
114   //
115     if (gAlice->GetDebug()>0)
116         printf("\n AliGenerator Constructor initializing number of particles \n\n");
117     gAlice->SetGenerator(this);
118     SetThetaRange(); ResetBit(kThetaRange);
119     SetPhiRange(); ResetBit(kPhiRange);
120     SetMomentumRange(); ResetBit(kMomentumRange);
121     SetPtRange(); ResetBit(kPtRange);
122     SetYRange(); ResetBit(kYRange);
123     SetTrackingFlag();
124
125     fOrigin.Set(3);
126     fOsigma.Set(3);
127     fVertex.Set(3);
128
129     fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
130     fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
131     fVertex[0]=fVertex[1]=fVertex[2]=0;
132
133     fVMin.Set(3);
134     fVMin[0]=fVMin[1]=fVMin[2]=0;
135     fVMax.Set(3);
136     fVMax[0]=fVMax[1]=fVMax[2]=10000;
137
138     SetNumberParticles(npart);
139
140     AliConfig::Instance()->Add(this);    
141 }
142
143 //____________________________________________________________
144 AliGenerator::AliGenerator(const AliGenerator &gen) : TNamed(" "," ")
145 {
146   //
147   // Copy constructor
148   //
149   gen.Copy(*this);
150 }
151
152 //____________________________________________________________
153 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
154 {
155   //
156   // Assignment operator
157   //
158   gen.Copy(*this);
159   return (*this);
160 }
161
162 //____________________________________________________________
163 void AliGenerator::Copy(AliGenerator &/* gen */) const
164 {
165   //
166   // Copy *this onto gen
167   //
168   Fatal("Copy","Not implemented!\n");
169 }
170
171 //____________________________________________________________
172 AliGenerator::~AliGenerator()
173 {
174   //
175   // Destructor
176   //
177   fOrigin.Set(0);
178   fOsigma.Set(0);
179   delete fgMCEvGen;
180 }
181
182 void AliGenerator::Init()
183 {   
184   //
185   // Dummy initialisation
186   //
187 }
188
189 //_______________________________________________________________________
190 void 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 //_______________________________________________________________________
201 void 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 //_______________________________________________________________________
212 void 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 //_______________________________________________________________________
223 void 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 //_______________________________________________________________________
234 void 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 //_______________________________________________________________________
245 void 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 //_______________________________________________________________________
255 void AliGenerator::SetYRange(Float_t ymin, Float_t ymax)
256 {
257   //
258   // Set the Rapidity range for the generated particles
259   //
260   fYMin=ymin;
261   fYMax=ymax;
262   SetBit(kYRange);
263 }
264
265 //_______________________________________________________________________
266 void 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 }
277
278 //_______________________________________________________________________
279 void 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 }
287
288 void 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
301 void 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
311 void 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