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