]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenMC.cxx
Typo corrected.
[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$
cf01ee36 18Revision 1.11 2002/06/06 15:26:24 morsch
19Correct child-selection for kPhiKK
20
027677ae 21Revision 1.10 2002/06/05 14:05:46 morsch
22Decayer option kPhiKK for forced phi->K+K- decay added.
23
00cb2f27 24Revision 1.9 2002/05/30 14:58:29 morsch
25Add pointer to AliGeometry to handle geometrical acceptance. (G. MArtinez)
26
65de9f86 27Revision 1.8 2002/04/26 10:42:35 morsch
28Case kNoDecayHeavy added. (N. Carrer)
29
d5f86442 30Revision 1.7 2002/04/17 10:32:32 morsch
31Coding Rule violations corrected.
32
62d0ae06 33Revision 1.6 2002/03/26 14:19:36 morsch
34Saver calculation of rapdity.
35
fef61e14 36Revision 1.5 2002/03/12 17:02:20 morsch
37Change in calculation of rapidity, include case in which numerically e == pz.
38
95450c6d 39Revision 1.4 2001/11/27 13:13:07 morsch
40Maximum lifetime for long-lived particles to be put on the stack is parameter.
41It can be set via SetMaximumLifetime(..).
42
47fc6bd5 43Revision 1.3 2001/10/16 08:48:56 morsch
44Common vertex related code moved to base class AliGenerator.
45
b80a8e41 46Revision 1.2 2001/10/15 08:15:51 morsch
47Event vertex and vertex truncation setting moved into AliMC.
48
dba8ac91 49Revision 1.1 2001/07/13 10:56:00 morsch
50AliGenMC base class for AliGenParam and AliGenPythia commonalities.
51
e36044d6 52*/
53
62d0ae06 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
e36044d6 60#include "AliGenMC.h"
61#include "AliPDG.h"
65de9f86 62#include <TMath.h>
e36044d6 63#include <TParticle.h>
64
65 ClassImp(AliGenMC)
66
67AliGenMC::AliGenMC()
68 :AliGenerator()
69{
70// Default Constructor
71 SetCutOnChild();
72 SetChildMomentumRange();
73 SetChildPtRange();
74 SetChildPhiRange();
75 SetChildThetaRange();
76 SetChildYRange();
47fc6bd5 77 SetMaximumLifetime();
65de9f86 78 SetGeometryAcceptance();
79 SetPdgCodeParticleforAcceptanceCut();
80 SetNumberOfAcceptedParticles();
e36044d6 81}
82
83AliGenMC::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;
47fc6bd5 97 SetMaximumLifetime();
65de9f86 98 SetGeometryAcceptance();
99 SetPdgCodeParticleforAcceptanceCut();
100 SetNumberOfAcceptedParticles();
e36044d6 101}
102
103AliGenMC::AliGenMC(const AliGenMC & mc)
104{
105// copy constructor
106}
107
108AliGenMC::~AliGenMC()
109{
110// Destructor
111}
112
113void AliGenMC::Init()
114{
115//
116// Initialization
117 switch (fForceDecay) {
118 case kSemiElectronic:
119 case kDiElectron:
120 case kBJpsiDiElectron:
121 case kBPsiPrimeDiElectron:
47fc6bd5 122 fChildSelect[0] = kElectron;
e36044d6 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;
00cb2f27 136 case kPhiKK:
027677ae 137 fChildSelect[0]=kKPlus;
62d0ae06 138 case kOmega:
e36044d6 139 case kAll:
140 case kNoDecay:
d5f86442 141 case kNoDecayHeavy:
e36044d6 142 break;
143 }
144}
145
146
62d0ae06 147Bool_t AliGenMC::ParentSelected(Int_t ip) const
e36044d6 148{
149// True if particle is in list of parent particles to be selected
150 for (Int_t i=0; i<8; i++)
151 {
62d0ae06 152 if (fParentSelect.At(i) == ip) return kTRUE;
e36044d6 153 }
154 return kFALSE;
155}
156
62d0ae06 157Bool_t AliGenMC::ChildSelected(Int_t ip) const
e36044d6 158{
159// True if particle is in list of decay products to be selected
160 for (Int_t i=0; i<5; i++)
161 {
62d0ae06 162 if (fChildSelect.At(i) == ip) return kTRUE;
e36044d6 163 }
164 return kFALSE;
165}
166
62d0ae06 167Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
e36044d6 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();
cf01ee36 177 Float_t mass = particle->GetCalcMass();
95450c6d 178 Float_t mt2 = pt * pt + mass * mass;
179
e36044d6 180 Float_t phi = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
95450c6d 181 Double_t y, y0;
182
fef61e14 183 if (TMath::Abs(pz) < e) {
95450c6d 184 y = 0.5*TMath::Log((e+pz)/(e-pz));
185 } else {
186 y = 1.e10;
187 }
e36044d6 188
95450c6d 189 if (mt2) {
190 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
e36044d6 191 } else {
95450c6d 192 if (TMath::Abs(y) < 1.e10) {
193 y0 = y;
194 } else {
195 y0 = 1.e10;
196 }
e36044d6 197 }
95450c6d 198
199 y = (pz < 0) ? -y0 : y0;
e36044d6 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
e36044d6 269 return kTRUE;
270}
271
65de9f86 272Bool_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
62d0ae06 294Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
e36044d6 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
327AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
328{
329// Assignment operator
330 return *this;
331}
332