]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenMC.cxx
Use CalcMass()
[u/mrichter/AliRoot.git] / EVGEN / AliGenMC.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  2002/06/06 15:26:24  morsch
19 Correct child-selection for kPhiKK
20
21 Revision 1.10  2002/06/05 14:05:46  morsch
22 Decayer option kPhiKK for forced phi->K+K- decay added.
23
24 Revision 1.9  2002/05/30 14:58:29  morsch
25 Add pointer to AliGeometry to handle geometrical acceptance. (G. MArtinez)
26
27 Revision 1.8  2002/04/26 10:42:35  morsch
28 Case kNoDecayHeavy added. (N. Carrer)
29
30 Revision 1.7  2002/04/17 10:32:32  morsch
31 Coding Rule violations corrected.
32
33 Revision 1.6  2002/03/26 14:19:36  morsch
34 Saver calculation of rapdity.
35
36 Revision 1.5  2002/03/12 17:02:20  morsch
37 Change in calculation of rapidity, include case in which numerically e == pz.
38
39 Revision 1.4  2001/11/27 13:13:07  morsch
40 Maximum lifetime for long-lived particles to be put on the stack is parameter.
41 It can be set via SetMaximumLifetime(..).
42
43 Revision 1.3  2001/10/16 08:48:56  morsch
44 Common vertex related code moved to base class AliGenerator.
45
46 Revision 1.2  2001/10/15 08:15:51  morsch
47 Event vertex and vertex truncation setting moved into AliMC.
48
49 Revision 1.1  2001/07/13 10:56:00  morsch
50 AliGenMC base class for AliGenParam and AliGenPythia commonalities.
51
52 */
53
54 // Base class for generators using external MC generators.
55 // For example AliGenPythia using Pythia.
56 // Provides basic functionality: setting of kinematic cuts on 
57 // decay products and particle selection.
58 // andreas.morsch@cern.ch
59
60 #include "AliGenMC.h"
61 #include "AliPDG.h"
62 #include <TMath.h>
63 #include <TParticle.h>
64
65  ClassImp(AliGenMC)
66
67 AliGenMC::AliGenMC()
68                  :AliGenerator()
69 {
70 // Default Constructor
71     SetCutOnChild();
72     SetChildMomentumRange();
73     SetChildPtRange();
74     SetChildPhiRange();
75     SetChildThetaRange(); 
76     SetChildYRange(); 
77     SetMaximumLifetime();
78     SetGeometryAcceptance();
79     SetPdgCodeParticleforAcceptanceCut();
80     SetNumberOfAcceptedParticles();
81 }
82
83 AliGenMC::AliGenMC(Int_t npart)
84                  :AliGenerator(npart)
85 {
86 //  Constructor
87     SetCutOnChild();
88     SetChildMomentumRange();
89     SetChildPtRange();
90     SetChildPhiRange();
91     SetChildThetaRange();
92     SetChildYRange(); 
93 // 
94     fParentSelect.Set(8);
95     fChildSelect.Set(8);
96     for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
97     SetMaximumLifetime();
98     SetGeometryAcceptance();
99     SetPdgCodeParticleforAcceptanceCut();
100     SetNumberOfAcceptedParticles();
101 }
102
103 AliGenMC::AliGenMC(const AliGenMC & mc)
104 {
105 // copy constructor
106 }
107
108 AliGenMC::~AliGenMC()
109 {
110 // Destructor
111 }
112
113 void AliGenMC::Init()
114 {
115 //
116 //  Initialization
117     switch (fForceDecay) {
118     case kSemiElectronic:
119     case kDiElectron:
120     case kBJpsiDiElectron:
121     case kBPsiPrimeDiElectron:
122         fChildSelect[0] = kElectron;    
123         break;
124     case kSemiMuonic:
125     case kDiMuon:
126     case kBJpsiDiMuon:
127     case kBPsiPrimeDiMuon:
128     case kPiToMu:
129     case kKaToMu:
130         fChildSelect[0]=kMuonMinus;
131         break;
132     case kHadronicD:
133         fChildSelect[0]=kPiPlus;
134         fChildSelect[1]=kKPlus;
135         break;
136     case kPhiKK:
137         fChildSelect[0]=kKPlus;
138     case kOmega:        
139     case kAll:
140     case kNoDecay:
141     case kNoDecayHeavy:
142         break;
143     }
144 }
145
146
147 Bool_t AliGenMC::ParentSelected(Int_t ip) const
148 {
149 // True if particle is in list of parent particles to be selected
150     for (Int_t i=0; i<8; i++)
151     {
152         if (fParentSelect.At(i) == ip) return kTRUE;
153     }
154     return kFALSE;
155 }
156
157 Bool_t AliGenMC::ChildSelected(Int_t ip) const
158 {
159 // True if particle is in list of decay products to be selected
160     for (Int_t i=0; i<5; i++)
161     {
162         if (fChildSelect.At(i) == ip) return kTRUE;
163     }
164     return kFALSE;
165 }
166
167 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
168 {
169 // Perform kinematic selection
170     Float_t px    = particle->Px();
171     Float_t py    = particle->Py();
172     Float_t pz    = particle->Pz();
173     Float_t  e    = particle->Energy();
174     Float_t pt    = particle->Pt();
175     Float_t p     = particle->P();
176     Float_t theta = particle->Theta();
177     Float_t mass  = particle->GetCalcMass();
178     Float_t mt2   = pt * pt + mass * mass;
179     
180     Float_t phi   = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
181     Double_t y, y0;
182
183     if (TMath::Abs(pz) <  e) {
184         y = 0.5*TMath::Log((e+pz)/(e-pz));
185     } else {
186         y = 1.e10;
187     }
188     
189     if (mt2) {
190         y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
191     } else {
192         if (TMath::Abs(y) < 1.e10) {
193             y0 = y;
194         } else {
195             y0 = 1.e10;
196         }
197     }
198       
199     y = (pz < 0) ? -y0 : y0;
200     
201     if (flag == 0) {
202 //
203 // Primary particle cuts
204 //
205 //  transverse momentum cut    
206         if (pt > fPtMax || pt < fPtMin) {
207 //          printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
208             return kFALSE;
209         }
210 //
211 // momentum cut
212         if (p > fPMax || p < fPMin) {
213 //          printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
214             return kFALSE;
215         }
216 //
217 // theta cut
218         if (theta > fThetaMax || theta < fThetaMin) {
219 //          printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
220             return kFALSE;
221         }
222 //
223 // rapidity cut
224         if (y > fYMax || y < fYMin) {
225 //          printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
226             return kFALSE;
227         }
228 //
229 // phi cut
230         if (phi > fPhiMax || phi < fPhiMin) {
231 //          printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
232             return kFALSE;
233         }
234     } else {
235 //
236 // Decay product cuts
237 //
238 //  transverse momentum cut    
239         if (pt > fChildPtMax || pt < fChildPtMin) {
240 //          printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
241             return kFALSE;
242         }
243 //
244 // momentum cut
245         if (p > fChildPMax || p < fChildPMin) {
246 //          printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
247             return kFALSE;
248         }
249 //
250 // theta cut
251         if (theta > fChildThetaMax || theta < fChildThetaMin) {
252 //          printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
253             return kFALSE;
254         }
255 //
256 // rapidity cut
257         if (y > fChildYMax || y < fChildYMin) {
258 //          printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
259             return kFALSE;
260         }
261 //
262 // phi cut
263         if (phi > fChildPhiMax || phi < fChildPhiMin) {
264 //          printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
265             return kFALSE;
266         }
267     }
268     
269     return kTRUE;
270 }
271
272 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
273 {
274   Bool_t Check ;  // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance
275   Int_t NumberOfPdgCodeParticleforAcceptanceCut=0;
276   Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0;
277   TParticle * particle;
278   Int_t i;
279   for (i=0; i<np; i++) {
280     particle =  (TParticle *) particles->At(i);
281     if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
282       NumberOfPdgCodeParticleforAcceptanceCut++;
283       if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++;
284     }   
285   }
286   if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
287     Check = kTRUE;
288   else
289     Check = kFALSE;
290
291   return Check;
292 }
293
294 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
295 {
296 //
297 //  If the particle is in a diffractive state, then take action accordingly
298   switch (pdgcode) {
299   case 91:
300     return 92;
301   case 110:
302     //rho_diff0 -- difficult to translate, return rho0
303     return 113;
304   case 210:
305     //pi_diffr+ -- change to pi+
306     return 211;
307   case 220:
308     //omega_di0 -- change to omega0
309     return 223;
310   case 330:
311     //phi_diff0 -- return phi0
312     return 333;
313   case 440:
314     //J/psi_di0 -- return J/psi
315     return 443;
316   case 2110:
317     //n_diffr -- return neutron
318     return 2112;
319   case 2210:
320     //p_diffr+ -- return proton
321     return 2212;
322   }
323   //non diffractive state -- return code unchanged
324   return pdgcode;
325 }
326           
327 AliGenMC& AliGenMC::operator=(const  AliGenMC& rhs)
328 {
329 // Assignment operator
330     return *this;
331 }
332