CMS 3D CMS Logo

HepMCValidationHelper.h
Go to the documentation of this file.
1 #ifndef Validation_EventGenerator_HepMCValidationHelper
2 #define Validation_EventGenerator_HepMCValidationHelper
3 
4 #include <HepMC/GenEvent.h>
5 #include <vector>
6 #include "TLorentzVector.h"
7 
9  template <class T>
10  inline bool GreaterByE(const T& a1, const T& a2) {
11  return a1.E() > a2.E();
12  }
13 
14  //sort by descending pt
15  inline bool sortByPt(const HepMC::GenParticle* a, const HepMC::GenParticle* b) {
16  return a->momentum().perp() > b->momentum().perp();
17  }
18 
19  template <class T>
20  inline bool sortByPtRef(const T lhs, const T rhs) {
21  return lhs->pt() > rhs->pt();
22  }
23 
24  //sort by energy
25  inline bool sortByE(const HepMC::GenParticle* a, const HepMC::GenParticle* b) {
26  return a->momentum().e() > b->momentum().e();
27  }
28 
29  //sort by rapidity
30  inline bool sortByRapidity(const HepMC::GenParticle* a, const HepMC::GenParticle* b) {
31  const HepMC::FourVector& amom = a->momentum();
32  const HepMC::FourVector& bmom = b->momentum();
33  double rapa = 0.5 * std::log((amom.e() + amom.z()) / (amom.e() - amom.z()));
34  double rapb = 0.5 * std::log((bmom.e() + bmom.z()) / (bmom.e() - bmom.z()));
35  return rapa > rapb;
36  }
37 
38  //sort by pseudorapidity
40  return a->momentum().eta() > b->momentum().eta();
41  }
42 
43  void findDescendents(const HepMC::GenParticle* a, std::vector<const HepMC::GenParticle*>& descendents);
44 
45  //get all status 1 particles
46  void allStatus1(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status1);
47 
48  //get all status 2 particles
49  void allStatus2(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status2);
50 
51  //get all status 3 particles
52  void allStatus3(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status3);
53 
54  //given a collection of leptons and the collection of all particles in the event,
55  //get the collection of photons closer than deltaR from any of the leptons
56  void findFSRPhotons(const std::vector<const HepMC::GenParticle*>& leptons,
57  const std::vector<const HepMC::GenParticle*>& all,
58  double deltaR,
59  std::vector<const HepMC::GenParticle*>& photons);
60 
61  //given a collection of leptons and the collection of all particles in the event,
62  //get the collection of photons closer than deltaR from any of the leptons
63  void findFSRPhotons(const std::vector<const HepMC::GenParticle*>& leptons,
64  const HepMC::GenEvent* all,
65  double deltaR,
66  std::vector<const HepMC::GenParticle*>& photons);
67 
68  //returns true if a status 3 particle is a tau or if a status 1 particle is either an electron or a neutrino
70 
71  //returns true if a status 1 particle is a neutrino
72  bool isNeutrino(const HepMC::GenParticle* part);
73 
74  //returns true is status 3 particle is tau
75  bool isTau(const HepMC::GenParticle* part);
76 
77  //removes isolated leptons (their decay products in the case of taus) and possible fsr photons from the list of particles.
78  //this should result in a list of particles to be used for hadronic activity studies, such as construction of jets
79  //note: deltaR is both the cone in wich we compute "isolation" and the radius in which we look for fsr photons
81  double deltaR,
82  double sumPt,
83  std::vector<const HepMC::GenParticle*>& pruned);
84 
85  //get all status 1 particles
86  void allStatus1(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& status1);
87 
88  //get all visible status1 particles
89  void allVisibleParticles(const HepMC::GenEvent* all, std::vector<const HepMC::GenParticle*>& visible);
90 
91  //compute generated met
92  TLorentzVector genMet(const HepMC::GenEvent* all, double etamin = -9999., double etamax = 9999.);
93 
94 } // namespace HepMCValidationHelper
95 
96 #endif
bool isTau(const HepMC::GenParticle *part)
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
void removeIsolatedLeptons(const HepMC::GenEvent *all, double deltaR, double sumPt, std::vector< const HepMC::GenParticle *> &pruned)
bool sortByPt(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
bool isChargedLepton(const HepMC::GenParticle *part)
bool sortByPtRef(const T lhs, const T rhs)
bool sortByPseudoRapidity(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
void findFSRPhotons(const std::vector< const HepMC::GenParticle *> &leptons, const std::vector< const HepMC::GenParticle *> &all, double deltaR, std::vector< const HepMC::GenParticle *> &photons)
void findDescendents(const HepMC::GenParticle *a, std::vector< const HepMC::GenParticle *> &descendents)
void allVisibleParticles(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &visible)
bool sortByRapidity(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
part
Definition: HCALResponse.h:20
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
double b
Definition: hdecay.h:120
void allStatus3(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &status3)
bool isNeutrino(const HepMC::GenParticle *part)
bool sortByE(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
bool GreaterByE(const T &a1, const T &a2)
double a
Definition: hdecay.h:121
void allStatus1(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &status1)
long double T
void allStatus2(const HepMC::GenEvent *all, std::vector< const HepMC::GenParticle *> &status2)