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