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