CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Validation/EventGenerator/interface/HepMCValidationHelper.h

Go to the documentation of this file.
00001 #ifndef Validation_EventGenerator_HepMCValidationHelper 
00002 #define Validation_EventGenerator_HepMCValidationHelper 
00003 
00004 #include <HepMC/GenEvent.h>
00005 #include <vector>
00006 #include "TLorentzVector.h"
00007 
00008 namespace HepMCValidationHelper {
00009   template <class T> inline bool GreaterByE (const T& a1, const T& a2) {return a1.E() > a2.E();}
00010 
00011   //sort by descending pt 
00012   inline bool sortByPt(const HepMC::GenParticle* a , const HepMC::GenParticle* b) {return a->momentum().perp() > b->momentum().perp(); }
00013   
00014   //sort by energy
00015   inline bool sortByE(const HepMC::GenParticle* a , const HepMC::GenParticle* b) {return a->momentum().e() > b->momentum().e(); }
00016 
00017   //sort by rapidity
00018   inline bool sortByRapidity(const HepMC::GenParticle* a , const HepMC::GenParticle* b) {
00019     const HepMC::FourVector& amom = a->momentum(); 
00020     const HepMC::FourVector& bmom = b->momentum(); 
00021     double rapa = 0.5 * std::log( (amom.e() + amom.z()) / (amom.e() - amom.z()) ); 
00022     double rapb = 0.5 * std::log( (bmom.e() + bmom.z()) / (bmom.e() - bmom.z()) ); 
00023     return rapa > rapb;
00024   }
00025 
00026   //sort by pseudorapidity
00027   inline bool sortByPseudoRapidity(const HepMC::GenParticle* a , const HepMC::GenParticle* b) {return a->momentum().eta() > b->momentum().eta(); }
00028 
00029   void findDescendents(const HepMC::GenParticle* a, std::vector<const HepMC::GenParticle*>& descendents);
00030 
00031   //get all status 1 particles
00032   void allStatus1(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status1);
00033 
00034   //get all status 2 particles
00035   void allStatus2(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status2);
00036 
00037   //get all status 3 particles
00038   void allStatus3(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status3);
00039 
00040   //given a collection of leptons and the collection of all particles in the event, 
00041   //get the collection of photons closer than deltaR from any of the leptons
00042   void findFSRPhotons(const std::vector<const HepMC::GenParticle*>& leptons,
00043                       const std::vector<const HepMC::GenParticle*>& all,
00044                       double deltaR,
00045                       std::vector<const HepMC::GenParticle*>& photons);
00046  
00047   
00048   //given a collection of leptons and the collection of all particles in the event, 
00049   //get the collection of photons closer than deltaR from any of the leptons
00050   void findFSRPhotons(const std::vector<const HepMC::GenParticle*>& leptons, 
00051                       const HepMC::GenEvent* all,
00052                       double deltaR,
00053                       std::vector<const HepMC::GenParticle*>& photons);
00054 
00055   //returns true if a status 3 particle is a tau or if a status 1 particle is either an electron or a neutrino
00056   bool isChargedLepton(const HepMC::GenParticle* part);
00057 
00058   //returns true if a status 1 particle is a neutrino
00059   bool isNeutrino(const HepMC::GenParticle* part );
00060 
00061   //returns true is status 3 particle is tau
00062   bool isTau(const HepMC::GenParticle* part); 
00063   
00064   //removes isolated leptons (their decay products in the case of taus) and possible fsr photons from the list of particles.
00065   //this should result in a list of particles to be used for hadronic activity studies, such as construction of jets
00066   //note: deltaR is both the cone in wich we compute "isolation" and the radius in which we look for fsr photons 
00067   void removeIsolatedLeptons(const HepMC::GenEvent* all, double deltaR, double sumPt, std::vector<const HepMC::GenParticle*>& pruned);                     
00068   
00069   //get all status 1 particles
00070   void allStatus1(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status1);
00071 
00072   //get all visible status1 particles
00073   void allVisibleParticles(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& visible);
00074 
00075   //compute generated met
00076   TLorentzVector genMet(const HepMC::GenEvent* all, double etamin = -9999., double etamax = 9999.);                     
00077 
00078 }
00079 
00080 #endif