Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:09

0001 #ifndef Validation_EventGenerator_HepMCValidationHelper
0002 #define Validation_EventGenerator_HepMCValidationHelper
0003 
0004 #include <HepMC/GenEvent.h>
0005 #include <vector>
0006 #include "TLorentzVector.h"
0007 
0008 namespace HepMCValidationHelper {
0009   template <class T>
0010   inline bool GreaterByE(const T& a1, const T& a2) {
0011     return a1.E() > a2.E();
0012   }
0013 
0014   //sort by descending pt
0015   inline bool sortByPt(const HepMC::GenParticle* a, const HepMC::GenParticle* b) {
0016     return a->momentum().perp() > b->momentum().perp();
0017   }
0018 
0019   template <class T>
0020   inline bool sortByPtRef(const T lhs, const T rhs) {
0021     return lhs->pt() > rhs->pt();
0022   }
0023 
0024   //sort by energy
0025   inline bool sortByE(const HepMC::GenParticle* a, const HepMC::GenParticle* b) {
0026     return a->momentum().e() > b->momentum().e();
0027   }
0028 
0029   //sort by rapidity
0030   inline bool sortByRapidity(const HepMC::GenParticle* a, const HepMC::GenParticle* b) {
0031     const HepMC::FourVector& amom = a->momentum();
0032     const HepMC::FourVector& bmom = b->momentum();
0033     double rapa = 0.5 * std::log((amom.e() + amom.z()) / (amom.e() - amom.z()));
0034     double rapb = 0.5 * std::log((bmom.e() + bmom.z()) / (bmom.e() - bmom.z()));
0035     return rapa > rapb;
0036   }
0037 
0038   //sort by pseudorapidity
0039   inline bool sortByPseudoRapidity(const HepMC::GenParticle* a, const HepMC::GenParticle* b) {
0040     return a->momentum().eta() > b->momentum().eta();
0041   }
0042 
0043   void findDescendents(const HepMC::GenParticle* a, std::vector<const HepMC::GenParticle*>& descendents);
0044 
0045   //get all status 1 particles
0046   void allStatus1(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status1);
0047 
0048   //get all status 2 particles
0049   void allStatus2(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status2);
0050 
0051   //get all status 3 particles
0052   void allStatus3(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status3);
0053 
0054   //given a collection of leptons and the collection of all particles in the event,
0055   //get the collection of photons closer than deltaR from any of the leptons
0056   void findFSRPhotons(const std::vector<const HepMC::GenParticle*>& leptons,
0057                       const std::vector<const HepMC::GenParticle*>& all,
0058                       double deltaR,
0059                       std::vector<const HepMC::GenParticle*>& photons);
0060 
0061   //given a collection of leptons and the collection of all particles in the event,
0062   //get the collection of photons closer than deltaR from any of the leptons
0063   void findFSRPhotons(const std::vector<const HepMC::GenParticle*>& leptons,
0064                       const HepMC::GenEvent* all,
0065                       double deltaR,
0066                       std::vector<const HepMC::GenParticle*>& photons);
0067 
0068   //returns true if a status 3 particle is a tau or if a status 1 particle is either an electron or a neutrino
0069   bool isChargedLepton(const HepMC::GenParticle* part);
0070 
0071   //returns true if a status 1 particle is a neutrino
0072   bool isNeutrino(const HepMC::GenParticle* part);
0073 
0074   //returns true is status 3 particle is tau
0075   bool isTau(const HepMC::GenParticle* part);
0076 
0077   //removes isolated leptons (their decay products in the case of taus) and possible fsr photons from the list of particles.
0078   //this should result in a list of particles to be used for hadronic activity studies, such as construction of jets
0079   //note: deltaR is both the cone in wich we compute "isolation" and the radius in which we look for fsr photons
0080   void removeIsolatedLeptons(const HepMC::GenEvent* all,
0081                              double deltaR,
0082                              double sumPt,
0083                              std::vector<const HepMC::GenParticle*>& pruned);
0084 
0085   //get all status 1 particles
0086   void allStatus1(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status1);
0087 
0088   //get all visible status1 particles
0089   void allVisibleParticles(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& visible);
0090 
0091   //compute generated met
0092   TLorentzVector genMet(const HepMC::GenEvent* all, double etamin = -9999., double etamax = 9999.);
0093 
0094 }  // namespace HepMCValidationHelper
0095 
0096 #endif