]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenMC.cxx
Option kBJpsi added.
[u/mrichter/AliRoot.git] / EVGEN / AliGenMC.cxx
index a587452625b00068e451ce480192186bd988e3fc..a3ff1e849bc36348609928f47b692026d2b9dc78 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.1  2001/07/13 10:56:00  morsch
-AliGenMC base class for AliGenParam and AliGenPythia commonalities.
+/* $Id$ */
 
-*/
+// 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 <TPDGCode.h>
 #include <TParticle.h>
 
- ClassImp(AliGenMC)
+#include "AliGenMC.h"
+
+ClassImp(AliGenMC)
 
 AliGenMC::AliGenMC()
-                 :AliGenerator()
+    :AliGenerator()
 {
 // Default Constructor
     SetCutOnChild();
@@ -36,10 +39,19 @@ AliGenMC::AliGenMC()
     SetChildPhiRange();
     SetChildThetaRange(); 
     SetChildYRange(); 
+    SetMaximumLifetime();
+    SetGeometryAcceptance();
+    SetPdgCodeParticleforAcceptanceCut();
+    SetNumberOfAcceptedParticles();
+    SetTarget();
+    SetProjectile();
+    fParentSelect.Set(8);
+    fChildSelect.Set(8);
+    fForceDecay = kAll;
 }
 
 AliGenMC::AliGenMC(Int_t npart)
-                 :AliGenerator(npart)
+    :AliGenerator(npart)
 {
 //  Constructor
     SetCutOnChild();
@@ -48,17 +60,24 @@ AliGenMC::AliGenMC(Int_t npart)
     SetChildPhiRange();
     SetChildThetaRange();
     SetChildYRange(); 
-    SetCutVertexZ();
 // 
     fParentSelect.Set(8);
     fChildSelect.Set(8);
     for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
-    
+    SetMaximumLifetime();
+    SetGeometryAcceptance();
+    SetPdgCodeParticleforAcceptanceCut();
+    SetNumberOfAcceptedParticles();
+    SetTarget();
+    SetProjectile();
+    fForceDecay = kAll;
 }
 
-AliGenMC::AliGenMC(const AliGenMC & mc)
+AliGenMC::AliGenMC(const AliGenMC & mc):
+    AliGenerator(mc)
 {
-// copy constructor
+// Copy constructor
+    mc.Copy(*this);
 }
 
 AliGenMC::~AliGenMC()
@@ -75,8 +94,9 @@ void AliGenMC::Init()
     case kDiElectron:
     case kBJpsiDiElectron:
     case kBPsiPrimeDiElectron:
-       fChildSelect[0]=kElectron;      
+       fChildSelect[0] = kElectron;    
        break;
+    case kHardMuons:   
     case kSemiMuonic:
     case kDiMuon:
     case kBJpsiDiMuon:
@@ -89,51 +109,78 @@ void AliGenMC::Init()
        fChildSelect[0]=kPiPlus;
        fChildSelect[1]=kKPlus;
        break;
+    case kPhiKK:
+       fChildSelect[0]=kKPlus;
+       break;
+    case kBJpsi:
+       fChildSelect[0]=443;
+       break;
+    case kOmega:       
     case kAll:
     case kNoDecay:
+    case kNoDecayHeavy:
        break;
     }
+
+    if (fZTarget != 0 && fAProjectile != 0) 
+    {
+       fDyBoost    = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) / 
+                                        (Double_t(fZTarget)    * Double_t(fAProjectile)));
+    }
 }
 
 
-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();
-    Float_t py    = particle->Py();
     Float_t pz    = particle->Pz();
     Float_t  e    = particle->Energy();
     Float_t pt    = particle->Pt();
     Float_t p     = particle->P();
     Float_t theta = particle->Theta();
-    Float_t phi   = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
-    Float_t y;
+    Float_t mass  = particle->GetCalcMass();
+    Float_t mt2   = pt * pt + mass * mass;
+    Float_t phi   = particle->Phi();
     
-    if ( (e-pz)<=0 || (e+pz)<=0 ) {
-       return kFALSE;
+    Double_t y, y0;
+
+    if (TMath::Abs(pz) <  e) {
+       y = 0.5*TMath::Log((e+pz)/(e-pz));
+    } else {
+       y = 1.e10;
+    }
+    
+    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) {
 //
@@ -203,12 +250,34 @@ 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)
+{
+// Check the geometrical acceptance for particle.
+
+  Bool_t check ;  
+  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
@@ -240,10 +309,52 @@ Int_t AliGenMC::CheckPDGCode(Int_t pdgcode)
   //non diffractive state -- return code unchanged
   return pdgcode;
 }
+
+void AliGenMC::Boost()
+{
+//
+// Boost cms into LHC lab frame
+//
+
+    Double_t beta  = TMath::TanH(fDyBoost);
+    Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
+    Double_t gb    = gamma * beta;
+
+    //    printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
+    
+    Int_t i;
+    Int_t np = fParticles->GetEntriesFast();
+    for (i = 0; i < np; i++) 
+    {
+       TParticle* iparticle = (TParticle*) fParticles->At(i);
+
+       Double_t e   = iparticle->Energy();
+       Double_t px  = iparticle->Px();
+       Double_t py  = iparticle->Py();
+       Double_t pz  = iparticle->Pz();
+
+       Double_t eb  = gamma * e -      gb * pz;
+       Double_t pzb =   -gb * e +   gamma * pz;
+
+       iparticle->SetMomentum(px, py, pzb, eb);
+    }
+}
+
+
          
 AliGenMC& AliGenMC::operator=(const  AliGenMC& rhs)
 {
 // Assignment operator
+    rhs.Copy(*this);
     return *this;
 }
 
+void AliGenMC::Copy(TObject&) const
+{
+    //
+    // Copy 
+    //
+    Fatal("Copy","Not implemented!\n");
+}
+
+