]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenMC.cxx
Event vertex and vertex truncation setting moved into AliMC.
[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.1  2001/07/13 10:56:00  morsch
19 AliGenMC base class for AliGenParam and AliGenPythia commonalities.
20
21 */
22
23 #include "AliGenMC.h"
24 #include "AliPDG.h"
25 #include <TParticle.h>
26
27  ClassImp(AliGenMC)
28
29 AliGenMC::AliGenMC()
30                  :AliGenerator()
31 {
32 // Default Constructor
33     SetCutOnChild();
34     SetChildMomentumRange();
35     SetChildPtRange();
36     SetChildPhiRange();
37     SetChildThetaRange(); 
38     SetChildYRange(); 
39 }
40
41 AliGenMC::AliGenMC(Int_t npart)
42                  :AliGenerator(npart)
43 {
44 //  Constructor
45     SetCutOnChild();
46     SetChildMomentumRange();
47     SetChildPtRange();
48     SetChildPhiRange();
49     SetChildThetaRange();
50     SetChildYRange(); 
51     SetCutVertexZ();
52 // 
53     fParentSelect.Set(8);
54     fChildSelect.Set(8);
55     for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
56     
57 }
58
59 AliGenMC::AliGenMC(const AliGenMC & mc)
60 {
61 // copy constructor
62 }
63
64 AliGenMC::~AliGenMC()
65 {
66 // Destructor
67 }
68
69 void AliGenMC::Init()
70 {
71 //
72 //  Initialization
73     switch (fForceDecay) {
74     case kSemiElectronic:
75     case kDiElectron:
76     case kBJpsiDiElectron:
77     case kBPsiPrimeDiElectron:
78         fChildSelect[0]=kElectron;      
79         break;
80     case kSemiMuonic:
81     case kDiMuon:
82     case kBJpsiDiMuon:
83     case kBPsiPrimeDiMuon:
84     case kPiToMu:
85     case kKaToMu:
86         fChildSelect[0]=kMuonMinus;
87         break;
88     case kHadronicD:
89         fChildSelect[0]=kPiPlus;
90         fChildSelect[1]=kKPlus;
91         break;
92     case kAll:
93     case kNoDecay:
94         break;
95     }
96 }
97
98
99 Bool_t AliGenMC::ParentSelected(Int_t ip)
100 {
101 // True if particle is in list of parent particles to be selected
102     for (Int_t i=0; i<8; i++)
103     {
104         if (fParentSelect[i]==ip) return kTRUE;
105     }
106     return kFALSE;
107 }
108
109 Bool_t AliGenMC::ChildSelected(Int_t ip)
110 {
111 // True if particle is in list of decay products to be selected
112     for (Int_t i=0; i<5; i++)
113     {
114         if (fChildSelect[i]==ip) return kTRUE;
115     }
116     return kFALSE;
117 }
118
119 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag)
120 {
121 // Perform kinematic selection
122     Float_t px    = particle->Px();
123     Float_t py    = particle->Py();
124     Float_t pz    = particle->Pz();
125     Float_t  e    = particle->Energy();
126     Float_t pt    = particle->Pt();
127     Float_t p     = particle->P();
128     Float_t theta = particle->Theta();
129     Float_t phi   = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
130     Float_t y;
131     
132     if ( (e-pz)<=0 || (e+pz)<=0 ) {
133         return kFALSE;
134     } else {
135       y = 0.5*TMath::Log((e+pz)/(e-pz));
136     }
137     
138     if (flag == 0) {
139 //
140 // Primary particle cuts
141 //
142 //  transverse momentum cut    
143         if (pt > fPtMax || pt < fPtMin) {
144 //          printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
145             return kFALSE;
146         }
147 //
148 // momentum cut
149         if (p > fPMax || p < fPMin) {
150 //          printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
151             return kFALSE;
152         }
153 //
154 // theta cut
155         if (theta > fThetaMax || theta < fThetaMin) {
156 //          printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
157             return kFALSE;
158         }
159 //
160 // rapidity cut
161         if (y > fYMax || y < fYMin) {
162 //          printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
163             return kFALSE;
164         }
165 //
166 // phi cut
167         if (phi > fPhiMax || phi < fPhiMin) {
168 //          printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
169             return kFALSE;
170         }
171     } else {
172 //
173 // Decay product cuts
174 //
175 //  transverse momentum cut    
176         if (pt > fChildPtMax || pt < fChildPtMin) {
177 //          printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
178             return kFALSE;
179         }
180 //
181 // momentum cut
182         if (p > fChildPMax || p < fChildPMin) {
183 //          printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
184             return kFALSE;
185         }
186 //
187 // theta cut
188         if (theta > fChildThetaMax || theta < fChildThetaMin) {
189 //          printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
190             return kFALSE;
191         }
192 //
193 // rapidity cut
194         if (y > fChildYMax || y < fChildYMin) {
195 //          printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
196             return kFALSE;
197         }
198 //
199 // phi cut
200         if (phi > fChildPhiMax || phi < fChildPhiMin) {
201 //          printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
202             return kFALSE;
203         }
204     }
205     
206     
207
208     return kTRUE;
209 }
210
211 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode)
212 {
213 //
214 //  If the particle is in a diffractive state, then take action accordingly
215   switch (pdgcode) {
216   case 91:
217     return 92;
218   case 110:
219     //rho_diff0 -- difficult to translate, return rho0
220     return 113;
221   case 210:
222     //pi_diffr+ -- change to pi+
223     return 211;
224   case 220:
225     //omega_di0 -- change to omega0
226     return 223;
227   case 330:
228     //phi_diff0 -- return phi0
229     return 333;
230   case 440:
231     //J/psi_di0 -- return J/psi
232     return 443;
233   case 2110:
234     //n_diffr -- return neutron
235     return 2112;
236   case 2210:
237     //p_diffr+ -- return proton
238     return 2212;
239   }
240   //non diffractive state -- return code unchanged
241   return pdgcode;
242 }
243           
244 AliGenMC& AliGenMC::operator=(const  AliGenMC& rhs)
245 {
246 // Assignment operator
247     return *this;
248 }
249