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.8 2002/04/26 10:42:35 morsch
19 Case kNoDecayHeavy added. (N. Carrer)
21 Revision 1.7 2002/04/17 10:32:32 morsch
22 Coding Rule violations corrected.
24 Revision 1.6 2002/03/26 14:19:36 morsch
25 Saver calculation of rapdity.
27 Revision 1.5 2002/03/12 17:02:20 morsch
28 Change in calculation of rapidity, include case in which numerically e == pz.
30 Revision 1.4 2001/11/27 13:13:07 morsch
31 Maximum lifetime for long-lived particles to be put on the stack is parameter.
32 It can be set via SetMaximumLifetime(..).
34 Revision 1.3 2001/10/16 08:48:56 morsch
35 Common vertex related code moved to base class AliGenerator.
37 Revision 1.2 2001/10/15 08:15:51 morsch
38 Event vertex and vertex truncation setting moved into AliMC.
40 Revision 1.1 2001/07/13 10:56:00 morsch
41 AliGenMC base class for AliGenParam and AliGenPythia commonalities.
45 // Base class for generators using external MC generators.
46 // For example AliGenPythia using Pythia.
47 // Provides basic functionality: setting of kinematic cuts on
48 // decay products and particle selection.
49 // andreas.morsch@cern.ch
54 #include <TParticle.h>
61 // Default Constructor
63 SetChildMomentumRange();
69 SetGeometryAcceptance();
70 SetPdgCodeParticleforAcceptanceCut();
71 SetNumberOfAcceptedParticles();
74 AliGenMC::AliGenMC(Int_t npart)
79 SetChildMomentumRange();
87 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
89 SetGeometryAcceptance();
90 SetPdgCodeParticleforAcceptanceCut();
91 SetNumberOfAcceptedParticles();
94 AliGenMC::AliGenMC(const AliGenMC & mc)
104 void AliGenMC::Init()
108 switch (fForceDecay) {
109 case kSemiElectronic:
111 case kBJpsiDiElectron:
112 case kBPsiPrimeDiElectron:
113 fChildSelect[0] = kElectron;
118 case kBPsiPrimeDiMuon:
121 fChildSelect[0]=kMuonMinus;
124 fChildSelect[0]=kPiPlus;
125 fChildSelect[1]=kKPlus;
136 Bool_t AliGenMC::ParentSelected(Int_t ip) const
138 // True if particle is in list of parent particles to be selected
139 for (Int_t i=0; i<8; i++)
141 if (fParentSelect.At(i) == ip) return kTRUE;
146 Bool_t AliGenMC::ChildSelected(Int_t ip) const
148 // True if particle is in list of decay products to be selected
149 for (Int_t i=0; i<5; i++)
151 if (fChildSelect.At(i) == ip) return kTRUE;
156 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
158 // Perform kinematic selection
159 Float_t px = particle->Px();
160 Float_t py = particle->Py();
161 Float_t pz = particle->Pz();
162 Float_t e = particle->Energy();
163 Float_t pt = particle->Pt();
164 Float_t p = particle->P();
165 Float_t theta = particle->Theta();
166 Float_t mass = particle->GetMass();
167 Float_t mt2 = pt * pt + mass * mass;
169 Float_t phi = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
172 if (TMath::Abs(pz) < e) {
173 y = 0.5*TMath::Log((e+pz)/(e-pz));
179 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
181 if (TMath::Abs(y) < 1.e10) {
188 y = (pz < 0) ? -y0 : y0;
192 // Primary particle cuts
194 // transverse momentum cut
195 if (pt > fPtMax || pt < fPtMin) {
196 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
201 if (p > fPMax || p < fPMin) {
202 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
207 if (theta > fThetaMax || theta < fThetaMin) {
208 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
213 if (y > fYMax || y < fYMin) {
214 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
219 if (phi > fPhiMax || phi < fPhiMin) {
220 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
225 // Decay product cuts
227 // transverse momentum cut
228 if (pt > fChildPtMax || pt < fChildPtMin) {
229 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
234 if (p > fChildPMax || p < fChildPMin) {
235 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
240 if (theta > fChildThetaMax || theta < fChildThetaMin) {
241 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
246 if (y > fChildYMax || y < fChildYMin) {
247 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
252 if (phi > fChildPhiMax || phi < fChildPhiMin) {
253 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
261 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
263 Bool_t Check ; // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance
264 Int_t NumberOfPdgCodeParticleforAcceptanceCut=0;
265 Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0;
266 TParticle * particle;
268 for (i=0; i<np; i++) {
269 particle = (TParticle *) particles->At(i);
270 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
271 NumberOfPdgCodeParticleforAcceptanceCut++;
272 if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++;
275 if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
283 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
286 // If the particle is in a diffractive state, then take action accordingly
291 //rho_diff0 -- difficult to translate, return rho0
294 //pi_diffr+ -- change to pi+
297 //omega_di0 -- change to omega0
300 //phi_diff0 -- return phi0
303 //J/psi_di0 -- return J/psi
306 //n_diffr -- return neutron
309 //p_diffr+ -- return proton
312 //non diffractive state -- return code unchanged
316 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
318 // Assignment operator