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