Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

HepMC_helper.h

Go to the documentation of this file.
00001 //=================================================
00002 //
00003 // HepMC_helper
00004 //
00005 // this .h file contains a number of useful utilities
00006 // (predicate functions and constants) for manipulating
00007 // the HepMC record.
00008 //
00009 // The PDG particle id for some common particles is
00010 // defined for convenience; this can be changed when an
00011 // official ATLAS mechanism is defined.
00012 //
00013 // Everything lives in the HepMC_helper namespace
00014 //
00015 // PELC: Added << operator for simple dump of a Particle
00016 //  (this lives outside the namespace at the end)
00017 // PS:   
00018 //       Added SelectSpecifiedCharge class
00019 //
00020 // Authors: Hywel Phillips, Peter Clarke, Peter Sherwood
00021 //
00022 //
00023 //===================================================
00024 
00025 #ifndef __ATLFAST_HEPMC_HELPER_H
00026 #define __ATLFAST_HEPMC_HELPER_H
00027 
00028 #include <vector>
00029 #include <iostream>
00030 #include <cmath>
00031 #include <float.h>
00032 
00033 #include "HepMC/GenParticle.h"
00034 #include "HepMC/GenVertex.h"
00035 #include "HepMC/ParticleDataTable.h"
00036 #include "HepMC/IO_PDG_ParticleDataTable.h"
00037 
00038 #include "GaudiKernel/MsgStream.h"
00039 
00040 #include "AtlfastCode/ChargeService.h"
00041 #include "AtlfastCode/ReconstructedParticle.h"
00042 namespace HepMC_helper {
00043 
00044   // The most common particle types are defined here as constants
00045   // just for our convenience
00046   //
00047   // An enum is not used because the user may well wish to supply
00048   // other values in general.
00049   //
00050   // In due course this should be replced by a ParticleID object
00051   // or some other general solution.
00052   
00053   const int DQUARK = 1;
00054   const int UQUARK = 2;
00055   const int SQUARK = 3;
00056   const int CQUARK = 4;
00057   const int BQUARK = 5;
00058   const int TQUARK = 6;
00059   
00060   const int ELECTRON = 11;
00061   const int NU_E     = 12;
00062   const int ELECTRON_NEUTRINO = 12;
00063   const int MUON     = 13;
00064   const int NU_MU    = 14;
00065   const int MUON_NEUTRINO = 14;
00066   const int TAU      = 15;
00067   const int NU_TAU   = 16;
00068   const int TAU_NEUTRINO = 16;
00069   
00070   const int GLUON    = 21;
00071   const int PHOTON   = 22;
00072   const int GAMMA    = 22;
00073   const int Z0       = 23;
00074   const int W        = 24;
00075   const int HIGGS    = 25;
00076   
00077   const int CHARGED_PION = 211;
00078   const int PI0 = 111;
00079   const int K0  = 311;
00080   const int CHARGED_KAON = 321;
00081   const int K0_L = 130;
00082   const int K0_S = 310;
00083 
00084   typedef HepMC::GenParticle Particle;
00085   
00086   
00087   //it seems like a good idea to have an PABC for the selectors
00088   //so you can pass the selector to the STL routines via the interface.
00089   //Unfortunaetly this does not work because the STL does  not wnat a pointer
00090   //or reference to the selector, but the selector itself. Passing it an
00091   //IMC selector (rather than a pointer or reference) does not work. PS.
00092   //*************************************************************************
00093   //*                                                                       *
00094   //*                 Interface class for MC selectors                      **
00095   //*                                                                       *
00096   //*************************************************************************
00097   class IMCselector{
00098   public:
00099     virtual IMCselector* create() const = 0;
00100     virtual bool operator()( const Particle* const) const = 0;
00101     virtual bool operator()( const Particle& p )    const = 0;
00102     virtual ~IMCselector(){};
00103   };
00104   //Using this class to wrap IMCselectors solves the problem mentioned above
00105   //*************************************************************************
00106   //*                                                                       *
00107   //*                      class MCselectorWrapper                          **
00108   //*                                                                       *
00109   //*************************************************************************
00110   class MCselectorWrapper{
00111   public:
00112     MCselectorWrapper(const IMCselector* selector): m_selector(selector){}
00113     bool operator()(const Particle* const p){ 
00114       return (*m_selector)(p) ;
00115     }
00116     const HepMC_helper::IMCselector* asIMCselector() const {return m_selector;}
00117   private:
00118     const IMCselector* m_selector;
00119   };
00120   //*************************************************************************
00121   //*                                                                       *
00122   //*           class All: public IMCselector                               **
00123   //*                                                                       *
00124   //*************************************************************************
00125   class All: public IMCselector {
00126     
00127   public:
00128     All() { } 
00129     IMCselector* create() const {return new All();}
00130     bool operator()( const Particle* const p )const;
00131     bool operator()( const Particle& p ) const {return this->operator()(&p);} 
00132   };
00133   //*************************************************************************
00134   //*                                                                       *
00135   //*  class IsFinalState                                                   **
00136   //*                                                                       *
00137   //* this predicate returns true if the input has no decay vertex          *
00138   //* i.e. the particle belongs to the final state.                         *
00139   //*                                                                       *
00140   //*************************************************************************
00141   class IsFinalState: public IMCselector {
00142     
00143   public:
00144     IsFinalState() { } 
00145     IMCselector* create() const  {return new IsFinalState();}
00146     bool operator()( const Particle* const p )const;
00147     bool operator()( const Particle& p ) const {return this->operator()(&p);} 
00148   };
00149   //*************************************************************************
00150   //*                                                                       *
00151   //*  class IsStatusxx                                                     *
00152   //*                                                                       **
00153   //* this predicate returns true if the input has status 21                *
00154   //* used in some very implementation dependent AtlfastFortran code        *
00155   //*                                                                       *
00156   //*************************************************************************
00157   class IsStatusxx: public IMCselector {   
00158   public:
00159     IsStatusxx(int stat):m_stat(stat) { } 
00160     IMCselector* create() const  {return new IsStatusxx(*this);}
00161     bool operator()( const Particle* const p )const;
00162     bool operator()( const Particle& p ) const {return this->operator()(&p);} 
00163   private:
00164     int m_stat;
00165   };
00166   
00167   //*************************************************************************
00168   //*                                                                       *
00169   //*                     class SelectType                                  **
00170   //*Note: it is charge blind, ie. is selects particle and anti-particle    *
00171   //*                                                                       *
00172   //*************************************************************************
00173   class SelectType: public IMCselector{
00174   public:
00175     SelectType( vector<int> requiredTypes);
00176     SelectType( int requiredType);
00177     SelectType(const SelectType& src );
00178     ~SelectType(){ }
00179     
00180     IMCselector* create() const {return new SelectType(*this);}
00181     
00182     bool operator() ( const Particle* const p ) const;
00183     bool operator()( const Particle& p ) const {return this->operator()(&p);} 
00184   private:      
00185     std::vector<int>  m_requiredTypes ;
00186   };
00187   //*************************************************************************
00188   //*                                                                       *
00189   //*                     class RejectType                                  **
00190   //*Note: it is charge blind, ie. is rejects particle and anti-particle    *
00191   //*                                                                       *
00192   //*************************************************************************
00193   
00194   class RejectType: public IMCselector{    
00195   public:
00196     RejectType( vector<int> ids);
00197     RejectType( int id);
00198     RejectType(const RejectType& src );
00199     ~RejectType(){  }
00200     
00201     
00202     IMCselector* create() const {return new RejectType(*this);}
00203     
00204     bool operator() ( const Particle* const p ) const{
00205       return !m_selectType(p);}
00206     bool operator()( const Particle& p ) const {return this->operator()(&p);} 
00207   private:
00208     SelectType m_selectType;
00209   };
00210   //*************************************************************************
00211   //*                                                                       *
00212   //*                     class Unseen                                      **
00213   //*                                                                       *
00214   //*************************************************************************
00215   class Unseen: public IMCselector {      
00216   public:
00217     // Constructors
00218     Unseen( vector<int> requiredTypes,
00219             double muonPtMax=6.0,
00220             double muonEtaMax=2.5);
00221     
00222     Unseen(const Unseen& src );
00223     // Destructor
00224     ~Unseen(){}
00225     IMCselector* create() const {return new Unseen(*this);}
00226     // The operator() method to determine acceptability of particle
00227     bool operator() ( const Particle* const p )const;
00228     bool operator() ( const Particle& p ) const {return this->operator()(&p);} 
00229   private:
00230     SelectType m_seltype;
00231     double m_muonPtMax ;
00232     double m_muonEtaMax ;
00233     IsFinalState m_ifs;
00234   };
00235   //*************************************************************************
00236   //*                                                                       *
00237   //*                     class IsCharged                                   **
00238   //*                                                                       *
00239   //*************************************************************************  
00240   class IsCharged:public IMCselector{
00241   private:
00242     Atlfast::ChargeService  m_chargeService;
00243   public:
00244     IsCharged() {}
00245     IMCselector* create() const  {return new IsCharged(*this);}
00246     bool operator() ( const Particle* const p )const;
00247     bool operator() ( const Particle& p ) const {return this->operator()(&p);} 
00248   };
00249   //*************************************************************************
00250   //*                                                                       *
00251   //*                     class MCCuts                                      **
00252   //*                                                                       *
00253   //*************************************************************************  
00254   class MCCuts: public IMCselector{
00255   public:
00256     MCCuts(double ptMin, double etaMax): m_ptMin(ptMin),m_etaMax(etaMax){}
00257     IMCselector* create() const  {return new MCCuts(*this);}
00258 
00259     bool operator() ( const Particle* const p )const;
00260     bool operator() ( const Particle& p ) const {return this->operator()(&p);} 
00261   private:
00262     double m_ptMin;
00263     double m_etaMax;
00264   };
00265   //*************************************************************************
00266   //*                                                                       *
00267   //*                     class SelectJetTag                                **
00268   //*                                                                       *
00269   //*************************************************************************  
00270   class SelectJetTag: public IMCselector {
00271   public:
00272     friend 
00273       MsgStream& operator<<(MsgStream&, const SelectJetTag&);
00274     // Constructor
00275     SelectJetTag(int id, double pt, double eta);
00276     // Destructor
00277     ~SelectJetTag(){};
00278     // The operator() method to determine acceptability of particle
00279     IMCselector* create() const {return new SelectJetTag(*this);}
00280     bool operator() ( const Particle* const p ) const;
00281     bool operator() ( const Particle& p ) const {return this->operator()(&p);} 
00282   private:
00283     int    m_id ;
00284     double m_ptMin ;
00285     double m_etaMax ;
00286   };
00287   //*************************************************************************
00288   //*                                                                       *
00289   //*                     class TauTag                                      **
00290   //*                                                                       *
00291   //*************************************************************************  
00292   class SelectTauTag: public IMCselector {
00293   public:
00294     friend 
00295       MsgStream& operator<<(MsgStream&, const SelectTauTag&);
00296     // Constructor
00297     SelectTauTag(double pt, double eta);
00298     // Destructor
00299     ~SelectTauTag(){};
00300     // The operator() method to determine acceptability of particle
00301     IMCselector* create() const {return new SelectTauTag(*this);}
00302     bool operator() ( const Particle* const p ) const;
00303     bool operator() ( const Particle& p ) const {return this->operator()(&p);} 
00304   private:
00305     SelectJetTag  m_jetTagSelector;
00306   };
00307   //*************************************************************************
00308   //*                                                                       *
00309   //*                     class SelectZ0                                    **
00310   //*                                                                       *
00311   //*************************************************************************  
00312   class SelectZ0: public IMCselector {
00313   public:
00314     friend 
00315       MsgStream& operator<<(MsgStream&, const SelectZ0&);
00316     // Constructor
00317     SelectZ0(double pt, double eta):m_kineCuts(eta, pt),m_z0Type(Z0){}
00318     // Destructor
00319     ~SelectZ0(){};
00320     // The operator() method to determine acceptability of particle
00321     IMCselector* create() const {return new SelectZ0(*this);}
00322     bool operator() ( const Particle* const p ) const;
00323     bool operator() ( const Particle& p ) const {return this->operator()(&p);} 
00324   private:
00325     MCCuts m_kineCuts;
00326     SelectType m_z0Type;
00327     int m_id ;    
00328     double m_ptMin ;
00329     double m_etaMax ;
00330   };
00331   //*************************************************************************
00332   //*                                                                       *
00333   //*                     class BFieldCutter                                **
00334   //*                                                                       *
00335   //*************************************************************************  
00336   class BFieldCutter: public IMCselector {
00337   public:
00338     
00339     BFieldCutter(bool fieldOn):m_chargeService(Atlfast::ChargeService()){
00340       m_ptCut = (fieldOn)? 0.5:0.0;
00341     }
00342    
00343     IMCselector* create() const {return new BFieldCutter(*this);}
00344     bool operator()( const Particle* const )const;
00345     bool operator()( const Particle& p ) const {return this->operator()(&p);} 
00346     
00347   private:
00348     double m_ptCut;
00349     Atlfast::ChargeService m_chargeService;    
00350   };
00351   //*************************************************************************
00352   //*                                                                       *
00353   //*                     class NCutter                                     **
00354   //*                                                                       *
00355   //*************************************************************************  
00356   class NCutter: public IMCselector {
00357     typedef  vector<IMCselector*> Selectors;
00358   private:
00359     Selectors m_selectors;
00360     
00361   public:
00362     // Constructors
00363     NCutter() {m_selectors.push_back( new All() );   }
00364     
00365     NCutter(const Selectors selectors){
00366     Selectors::const_iterator i=selectors.begin();
00367     for(; i != selectors.end(); ++i) m_selectors.push_back((*i)->create());
00368     }
00369 
00370     NCutter(const IMCselector* selector){ 
00371       m_selectors.push_back(selector->create() );
00372     }    
00373     
00374     NCutter( const NCutter& src ):IMCselector(){
00375       Selectors::const_iterator i=(src.m_selectors).begin();
00376       for(;i != (src.m_selectors).end(); ++i){
00377         m_selectors.push_back((*i)->create());
00378       }
00379     }  
00380     // Destructor
00381     ~NCutter() {
00382       Selectors::iterator i=m_selectors.begin();
00383       for(; i != m_selectors.end(); ++i) delete(*i);
00384     }
00385 
00386     IMCselector* create() const {return new NCutter(*this);}
00387     bool operator() ( const Particle* const ) const ;
00388     bool operator() ( const Particle& p ) const {return this->operator()(&p);} 
00389   };
00390   //*************************************************************************
00391   //*                                                                       *
00392   //*                     class AscendingEta                                **
00393   //*                                                                       *
00394   //*************************************************************************  
00395   class AscendingEta {
00396   public:
00397     bool operator() 
00398       ( const Particle* const a, 
00399         const Particle* const b ) const;
00400     bool operator() 
00401       ( const Particle& a, 
00402         const Particle& b ) const;
00403   };
00404   
00405   
00406 }  // closing the namespace
00407 #endif
00408 
00409 
00410 
00411 
00412 
00413 
00414 
00415 
00416 
00417 

Generated on Wed Jan 23 12:58:32 2002 for Atlfast by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001