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