baseAnalysis.h

Go to the documentation of this file.
00001 #ifndef baseAnalysis_H
00002 #define baseAnalysis_H
00003 
00004 #include <string>
00005 #include <map>
00006 #include <vector>
00007 #include <iostream>
00008 
00009 #include "HepMC/GenEvent.h"
00010 
00011 #include "fastjet/PseudoJet.hh"
00012 #include "fastjet/JetDefinition.hh"
00013 
00014 // forward declarations
00015 namespace fastjet {
00016   class ClusterSequence;
00017 }
00018 namespace HepPDT {
00019   class ParticleDataTable;
00020 }
00021 class TFile;
00022 class TH1D;
00023 
00024 //sj//enum RETURN{FAILURE=-1, SUCCESS=1, CHARGED=2, NOTCHARGED=3, FINALSTATEPARTICLE=4};
00025 
00026 /**
00027 @class baseAnalysis.h
00028 @brief Base class for all  HepMCanalysis classes to implement common 
00029        functionality and interfaces.
00030 
00031 @author Cano Ay Dec 2008 */
00032 
00033 class baseAnalysis
00034 {
00035  public:
00036 
00037   baseAnalysis();
00038   virtual ~baseAnalysis();
00039   
00040   virtual int Finalize();
00041   virtual int Finalize(TFile* output);
00042   //virtual TH1D* popHisto(std::vector<TH1D*>);
00043   virtual TH1D* popHisto();
00044 
00045   virtual int Init(double maxeta=2.5, double minpt=0.5) { std::cout << "baseAnalysis: WARNING: You have called the dummy function Init()." << std::endl; return 0;};
00046   virtual int Process(HepMC::GenEvent* hepmcevt) { std::cout << "baseAnalysis: WARNING: You have called the dummy function Process()." << std::endl; return 0;} ;
00047   //virtual std::vector<TH1D*> averagedHistograms() {TH1D* temp; std::vector<TH1D*> temp_vec; temp_vec.clear(); temp_vec.push_back(temp); return temp_vec;} ;
00048   virtual std::vector<TH1D*> averagedHistograms() {return m_histVector;} ;
00049 
00050   /** Initialize FastJet Algorithm*/
00051   int InitJetFinder(double coneRadius, double overlapThreshold, double jet_ptmin, double lepton_ptmin, double DeltaR_lepton_track);
00052   int FindJetableParticles(HepMC::GenEvent* hepmcevt);
00053   int FindJet(HepMC::GenEvent* hepmcevt);
00054   int DeleteJetObject(HepMC::GenEvent* hepmcevt);
00055   std::vector<fastjet::PseudoJet> GetJet(HepMC::GenEvent* hepmcevt);
00056   virtual void SetJet(std::vector<fastjet::PseudoJet>* inclusive_jets) {m_inclusive_jets=*inclusive_jets;};
00057 
00058   /** Calculate Missing Et*/
00059   int FindMissingEt(HepMC::GenEvent* hepmcevt);
00060   int ClearMissingEt(HepMC::GenEvent* hepmcevt);
00061 
00062   /** Clear some values from the event */
00063   int ClearEvent(HepMC::GenEvent* hepmcevt);
00064 
00065   /** Set the Output filename*/  
00066   inline int setOutpuFileName(const char* filename){ m_outputFileName=filename; return 0;};
00067   
00068   /** Set the directory name in Output root file*/  
00069   inline int setOutpuRootDir(const char* dirname){ m_outputRootDir=dirname; return 0;};
00070 
00071   /** Check some special neutral Particles */
00072   inline bool IsNeutrino(int pid) { if( abs(pid)==12 || abs(pid)==14 || abs(pid)==16) return true; else return false; };
00073   inline bool IsGamma(int pid) { if( abs(pid)==22 ) return true; else return false; };
00074   inline bool IsNeutron(int pid) { if( abs(pid)==2112 ) return true; else return false; };
00075   inline bool IsK0(int pid) { if( abs(pid)==130 || abs(pid)==310 || abs(pid)==311 ) return true; else return false; };
00076   inline bool IsPi0(int pid) { if( abs(pid)==111 || abs(pid)==113 || abs(pid)==221 ) return true; else return false; };
00077   inline bool IsElectron(int pid) { if( abs(pid)==11 ) return true; else return false; };
00078   inline bool IsMuon(int pid) { if( abs(pid)==13 ) return true; else return false; };
00079   inline bool IsGluon(int pid) { if( abs(pid)==21 ) return true; else return false; };
00080 
00081 
00082   /** Check if neutral particle*/  
00083   inline int chargedParticle(int pid) { 
00084     if( IsNeutrino(pid) || IsGamma(pid) || IsNeutron(pid) || IsK0(pid) || IsPi0(pid) || IsGluon(pid) || abs(pid)== 94 || abs(pid)==1000039 || abs(pid) ==1000022 || abs(pid) ==39 || abs(pid) ==5100022) //above neutral particles and some "special" neutral particles
00085       {return false;} 
00086     else 
00087       {return true;}
00088     return 0;};
00089   
00090   /** Check if final state particle*/
00091   virtual int IsFinalStateParticle(HepMC::GenParticle *p);
00092 
00093   /** Set the maximum allowed eta range*/  
00094   inline int setMaxEtaCut(double maxeta){ m_max_eta=maxeta; return 0;};
00095   
00096   /** Set maximum pt of tracks */  
00097   inline int setMinPtCut(double minpt){ m_min_pt=minpt; return 0;};
00098   
00099   /** Initialization of histograms  */ 
00100   TH1D* initHist(std::string name, std::string title, std::string xlabel, int nrBins=100, double xmin=0., double xmax=100.) ;
00101   TH1D* initHistVariableBin(std::string name, std::string title, std::string xlabel, int nbin, double nbinRange[]) ;
00102   
00103   /** check if mother decayed into daugther */ 
00104   bool checkDaughter(HepMC::GenParticle* mother, HepMC::GenParticle* daughter, int maxGenerations=-1) ;
00105   
00106   /** check if the track comes from a specific particle e.g. pid(W-Boson)=24 */ 
00107   bool trackfromPID(int pid,HepMC::GenParticle* track, int maxGenerations=-1) ;
00108 
00109   /** calculate the rapidity of a particle */
00110   inline double getRapidity(HepMC::GenEvent::particle_const_iterator p) {
00111     double e = (*p)->momentum().e();
00112     double pz = (*p)->momentum().pz();
00113     double rapidity = 0.5 * log((e + pz) / (e - pz));
00114     return rapidity;
00115   };
00116 
00117  protected:
00118   
00119   /** jet finding */
00120   fastjet::JetDefinition::Plugin*   m_plugin;
00121   fastjet::JetDefinition*           m_jetDef;
00122 
00123   std::vector<fastjet::PseudoJet>  m_input_particles;
00124   std::vector<fastjet::PseudoJet> m_inclusive_jets;
00125   fastjet::ClusterSequence* m_clust_seq;
00126 
00127   std::map< std::string, int > m_histCounter;
00128   std::vector<TH1D*> m_histVector;
00129   std::vector<TH1D*> m_histVectorVariableBin;  
00130   std::string m_outputFileName;
00131   std::string m_outputRootDir;
00132 
00133   //for jet finder
00134   double m_coneRadius;
00135   double m_overlapThreshold;
00136   double m_jet_ptmin;
00137   double m_lepton_ptmin;
00138   double m_DeltaR_lepton_track;
00139   bool m_Jetfinder_enabled;
00140   
00141   // specify the maximum eta of tracks
00142   double m_max_eta;
00143   double m_min_pt;
00144 
00145   // for calculation of the missing energy
00146   double exMissTruth;
00147   double eyMissTruth;
00148   double etMissTruth;
00149   double etsumMissTruth;
00150   
00151   const HepPDT::ParticleDataTable* m_particleTable;
00152 };
00153 
00154 #endif

Generated on Mon Jan 4 15:22:34 2010 for HepMCAnalysis by  doxygen 1.4.7