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