]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenMC.cxx
Decayer option kPhiKK for forced phi->K+K- decay added.
[u/mrichter/AliRoot.git] / EVGEN / AliGenMC.cxx
index 9d20778194b5438dcddf7adb5489338ac2b65d65..d1e97a933cd6f5999837fb8511d62bcc985206f3 100644 (file)
 
 /*
 $Log$
+Revision 1.9  2002/05/30 14:58:29  morsch
+Add pointer to AliGeometry to handle geometrical acceptance. (G. MArtinez)
+
+Revision 1.8  2002/04/26 10:42:35  morsch
+Case kNoDecayHeavy added. (N. Carrer)
+
+Revision 1.7  2002/04/17 10:32:32  morsch
+Coding Rule violations corrected.
+
+Revision 1.6  2002/03/26 14:19:36  morsch
+Saver calculation of rapdity.
+
+Revision 1.5  2002/03/12 17:02:20  morsch
+Change in calculation of rapidity, include case in which numerically e == pz.
+
+Revision 1.4  2001/11/27 13:13:07  morsch
+Maximum lifetime for long-lived particles to be put on the stack is parameter.
+It can be set via SetMaximumLifetime(..).
+
 Revision 1.3  2001/10/16 08:48:56  morsch
 Common vertex related code moved to base class AliGenerator.
 
@@ -26,8 +45,15 @@ AliGenMC base class for AliGenParam and AliGenPythia commonalities.
 
 */
 
+// Base class for generators using external MC generators.
+// For example AliGenPythia using Pythia.
+// Provides basic functionality: setting of kinematic cuts on 
+// decay products and particle selection.
+// andreas.morsch@cern.ch
+
 #include "AliGenMC.h"
 #include "AliPDG.h"
+#include <TMath.h>
 #include <TParticle.h>
 
  ClassImp(AliGenMC)
@@ -43,6 +69,9 @@ AliGenMC::AliGenMC()
     SetChildThetaRange(); 
     SetChildYRange(); 
     SetMaximumLifetime();
+    SetGeometryAcceptance();
+    SetPdgCodeParticleforAcceptanceCut();
+    SetNumberOfAcceptedParticles();
 }
 
 AliGenMC::AliGenMC(Int_t npart)
@@ -60,6 +89,9 @@ AliGenMC::AliGenMC(Int_t npart)
     fChildSelect.Set(8);
     for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
     SetMaximumLifetime();
+    SetGeometryAcceptance();
+    SetPdgCodeParticleforAcceptanceCut();
+    SetNumberOfAcceptedParticles();
 }
 
 AliGenMC::AliGenMC(const AliGenMC & mc)
@@ -95,34 +127,37 @@ void AliGenMC::Init()
        fChildSelect[0]=kPiPlus;
        fChildSelect[1]=kKPlus;
        break;
+    case kPhiKK:
+    case kOmega:       
     case kAll:
     case kNoDecay:
+    case kNoDecayHeavy:
        break;
     }
 }
 
 
-Bool_t AliGenMC::ParentSelected(Int_t ip)
+Bool_t AliGenMC::ParentSelected(Int_t ip) const
 {
 // True if particle is in list of parent particles to be selected
     for (Int_t i=0; i<8; i++)
     {
-       if (fParentSelect[i]==ip) return kTRUE;
+       if (fParentSelect.At(i) == ip) return kTRUE;
     }
     return kFALSE;
 }
 
-Bool_t AliGenMC::ChildSelected(Int_t ip)
+Bool_t AliGenMC::ChildSelected(Int_t ip) const
 {
 // True if particle is in list of decay products to be selected
     for (Int_t i=0; i<5; i++)
     {
-       if (fChildSelect[i]==ip) return kTRUE;
+       if (fChildSelect.At(i) == ip) return kTRUE;
     }
     return kFALSE;
 }
 
-Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag)
+Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
 {
 // Perform kinematic selection
     Float_t px    = particle->Px();
@@ -132,14 +167,29 @@ Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag)
     Float_t pt    = particle->Pt();
     Float_t p     = particle->P();
     Float_t theta = particle->Theta();
+    Float_t mass  = particle->GetMass();
+    Float_t mt2   = pt * pt + mass * mass;
+    
     Float_t phi   = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
-    Float_t y;
+    Double_t y, y0;
+
+    if (TMath::Abs(pz) <  e) {
+       y = 0.5*TMath::Log((e+pz)/(e-pz));
+    } else {
+       y = 1.e10;
+    }
     
-    if ( (e-pz)<=0 || (e+pz)<=0 ) {
-       return kFALSE;
+    if (mt2) {
+       y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
     } else {
-      y = 0.5*TMath::Log((e+pz)/(e-pz));
+       if (TMath::Abs(y) < 1.e10) {
+           y0 = y;
+       } else {
+           y0 = 1.e10;
+       }
     }
+      
+    y = (pz < 0) ? -y0 : y0;
     
     if (flag == 0) {
 //
@@ -209,12 +259,32 @@ Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag)
        }
     }
     
-    
-
     return kTRUE;
 }
 
-Int_t AliGenMC::CheckPDGCode(Int_t pdgcode)
+Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
+{
+  Bool_t Check ;  // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance
+  Int_t NumberOfPdgCodeParticleforAcceptanceCut=0;
+  Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0;
+  TParticle * particle;
+  Int_t i;
+  for (i=0; i<np; i++) {
+    particle =  (TParticle *) particles->At(i);
+    if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
+      NumberOfPdgCodeParticleforAcceptanceCut++;
+      if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++;
+    }   
+  }
+  if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
+    Check = kTRUE;
+  else
+    Check = kFALSE;
+
+  return Check;
+}
+
+Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
 {
 //
 //  If the particle is in a diffractive state, then take action accordingly