]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenMC.cxx
Option to read gas pressure tables from LHC PR 674.
[u/mrichter/AliRoot.git] / EVGEN / AliGenMC.cxx
index 34b1e2e97e2559857588cdc85650b50dc3a86551..287ffcbda478a025cea6fe99bd49af6ecc1cf926 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-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(..).
+/* $Id$ */
 
-Revision 1.3  2001/10/16 08:48:56  morsch
-Common vertex related code moved to base class AliGenerator.
+// 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
 
-Revision 1.2  2001/10/15 08:15:51  morsch
-Event vertex and vertex truncation setting moved into AliMC.
-
-Revision 1.1  2001/07/13 10:56:00  morsch
-AliGenMC base class for AliGenParam and AliGenPythia commonalities.
-
-*/
+#include <TMath.h>
+#include <TPDGCode.h>
+#include <TParticle.h>
 
 #include "AliGenMC.h"
-#include "AliPDG.h"
-#include <TParticle.h>
 
- ClassImp(AliGenMC)
+ClassImp(AliGenMC)
 
 AliGenMC::AliGenMC()
-                 :AliGenerator()
+    :AliGenerator()
 {
 // Default Constructor
     SetCutOnChild();
@@ -47,10 +40,18 @@ AliGenMC::AliGenMC()
     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();
@@ -64,11 +65,19 @@ 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();
+    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()
@@ -87,6 +96,7 @@ void AliGenMC::Init()
     case kBPsiPrimeDiElectron:
        fChildSelect[0] = kElectron;    
        break;
+    case kHardMuons:   
     case kSemiMuonic:
     case kDiMuon:
     case kBJpsiDiMuon:
@@ -99,50 +109,58 @@ void AliGenMC::Init()
        fChildSelect[0]=kPiPlus;
        fChildSelect[1]=kKPlus;
        break;
+    case kPhiKK:
+       fChildSelect[0]=kKPlus;
+    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 mass  = particle->GetMass();
+    Float_t mass  = particle->GetCalcMass();
     Float_t mt2   = pt * pt + mass * mass;
+    Float_t phi   = particle->Phi();
     
-    Float_t phi   = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
     Double_t y, y0;
 
-    if (TMath::Abs(pz) != e) {
+    if (TMath::Abs(pz)  e) {
        y = 0.5*TMath::Log((e+pz)/(e-pz));
     } else {
        y = 1.e10;
@@ -228,12 +246,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
@@ -265,10 +305,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");
+}
+
+