1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.11 2002/06/06 15:26:24 morsch
19 Correct child-selection for kPhiKK
21 Revision 1.10 2002/06/05 14:05:46 morsch
22 Decayer option kPhiKK for forced phi->K+K- decay added.
24 Revision 1.9 2002/05/30 14:58:29 morsch
25 Add pointer to AliGeometry to handle geometrical acceptance. (G. MArtinez)
27 Revision 1.8 2002/04/26 10:42:35 morsch
28 Case kNoDecayHeavy added. (N. Carrer)
30 Revision 1.7 2002/04/17 10:32:32 morsch
31 Coding Rule violations corrected.
33 Revision 1.6 2002/03/26 14:19:36 morsch
34 Saver calculation of rapdity.
36 Revision 1.5 2002/03/12 17:02:20 morsch
37 Change in calculation of rapidity, include case in which numerically e == pz.
39 Revision 1.4 2001/11/27 13:13:07 morsch
40 Maximum lifetime for long-lived particles to be put on the stack is parameter.
41 It can be set via SetMaximumLifetime(..).
43 Revision 1.3 2001/10/16 08:48:56 morsch
44 Common vertex related code moved to base class AliGenerator.
46 Revision 1.2 2001/10/15 08:15:51 morsch
47 Event vertex and vertex truncation setting moved into AliMC.
49 Revision 1.1 2001/07/13 10:56:00 morsch
50 AliGenMC base class for AliGenParam and AliGenPythia commonalities.
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
63 #include <TParticle.h>
70 // Default Constructor
72 SetChildMomentumRange();
78 SetGeometryAcceptance();
79 SetPdgCodeParticleforAcceptanceCut();
80 SetNumberOfAcceptedParticles();
83 AliGenMC::AliGenMC(Int_t npart)
88 SetChildMomentumRange();
96 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
98 SetGeometryAcceptance();
99 SetPdgCodeParticleforAcceptanceCut();
100 SetNumberOfAcceptedParticles();
103 AliGenMC::AliGenMC(const AliGenMC & mc)
108 AliGenMC::~AliGenMC()
113 void AliGenMC::Init()
117 switch (fForceDecay) {
118 case kSemiElectronic:
120 case kBJpsiDiElectron:
121 case kBPsiPrimeDiElectron:
122 fChildSelect[0] = kElectron;
127 case kBPsiPrimeDiMuon:
130 fChildSelect[0]=kMuonMinus;
133 fChildSelect[0]=kPiPlus;
134 fChildSelect[1]=kKPlus;
137 fChildSelect[0]=kKPlus;
147 Bool_t AliGenMC::ParentSelected(Int_t ip) const
149 // True if particle is in list of parent particles to be selected
150 for (Int_t i=0; i<8; i++)
152 if (fParentSelect.At(i) == ip) return kTRUE;
157 Bool_t AliGenMC::ChildSelected(Int_t ip) const
159 // True if particle is in list of decay products to be selected
160 for (Int_t i=0; i<5; i++)
162 if (fChildSelect.At(i) == ip) return kTRUE;
167 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
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();
177 Float_t mass = particle->GetCalcMass();
178 Float_t mt2 = pt * pt + mass * mass;
180 Float_t phi = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
183 if (TMath::Abs(pz) < e) {
184 y = 0.5*TMath::Log((e+pz)/(e-pz));
190 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
192 if (TMath::Abs(y) < 1.e10) {
199 y = (pz < 0) ? -y0 : y0;
203 // Primary particle cuts
205 // transverse momentum cut
206 if (pt > fPtMax || pt < fPtMin) {
207 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
212 if (p > fPMax || p < fPMin) {
213 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
218 if (theta > fThetaMax || theta < fThetaMin) {
219 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
224 if (y > fYMax || y < fYMin) {
225 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
230 if (phi > fPhiMax || phi < fPhiMin) {
231 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
236 // Decay product cuts
238 // transverse momentum cut
239 if (pt > fChildPtMax || pt < fChildPtMin) {
240 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
245 if (p > fChildPMax || p < fChildPMin) {
246 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
251 if (theta > fChildThetaMax || theta < fChildThetaMin) {
252 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
257 if (y > fChildYMax || y < fChildYMin) {
258 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
263 if (phi > fChildPhiMax || phi < fChildPhiMin) {
264 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
272 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
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;
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++;
286 if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
294 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
297 // If the particle is in a diffractive state, then take action accordingly
302 //rho_diff0 -- difficult to translate, return rho0
305 //pi_diffr+ -- change to pi+
308 //omega_di0 -- change to omega0
311 //phi_diff0 -- return phi0
314 //J/psi_di0 -- return J/psi
317 //n_diffr -- return neutron
320 //p_diffr+ -- return proton
323 //non diffractive state -- return code unchanged
327 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
329 // Assignment operator