CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetCorrFactors.h
Go to the documentation of this file.
1 #ifndef DataFormats_PatCandidates_JetCorrFactors_h
2 #define DataFormats_PatCandidates_JetCorrFactors_h
3 
31 #include <vector>
32 #include <string>
33 #include <math.h>
34 
35 namespace pat {
36 
38 
39  public:
40  // jet energy correction factor. For flavor independent jet energy corrections the
41  // std::vector<float> holds just a single entry. From the first flavor dependent entry
42  // in the chain on it holds five floats corresponding to the flavors: none, gluon, uds,
43  // charm, bottom; in this case the entry for none will be set to -1; the std::string
44  // indicates the correction level according to jetMET definitions.
45  typedef std::pair<std::string, std::vector<float> > CorrectionFactor;
46  // order of flavor dependent CorrectionFactors
47  enum Flavor { GLUON, UDS, CHARM, BOTTOM, NONE };
48  // number of maximally available flavor types
49  static const unsigned int MAX_FLAVORS = 4;
50 
51  public:
52  // default Constructor
54  // constructor by value
55  JetCorrFactors(const std::string& label, const std::vector<CorrectionFactor>& jec);
56 
57  // instance label of the jet energy corrections set
58  std::string jecSet() const { return label_; }
59  // correction level from unsigned int
60  std::string jecLevel(const unsigned int& level) const { return jec_.at(level).first; };
61  // correction level from std::string
62  int jecLevel(const std::string& level) const;
63  // jet energy correction flavor from enum
64  std::string jecFlavor(const Flavor& flavor) const;
65  // jet energy correction flavor from std::string
66  Flavor jecFlavor(std::string flavor) const;
67 
68  // correction factor up to a given level and flavor (per default the flavor is NONE)
69  float correction(unsigned int level, Flavor flavor=NONE) const;
70  // a list of the labels of all correction levels according to jetMET definitions, separated by '\n'
71  std::string correctionLabelString() const;
72  // a vector of the labels of all correction levels according to jetMET definitions
73  std::vector<std::string> correctionLabels() const;
74  // label of a specific correction factor according to jetMET definitions; for overflow a string ERROR is returned
75  std::string correctionLabel(unsigned int level) const { return (level<jec_.size() ? jec_.at(level).first : std::string("ERROR")); };
76  // check whether CorrectionFactor is flavor independent or not
77  bool flavorDependent(unsigned int level) const { return (level<jec_.size() ? jec_.at(level).second.size()==MAX_FLAVORS : false); };
78  // number of available correction factors
79  unsigned int numberOfCorrectionLevels() const { return jec_.size(); };
80  // print function for debugging
81  void print() const;
82 
83  private:
84  // check consistency of input vector
85  bool flavorDependent(const CorrectionFactor& jec) const { return (jec.second.size()==MAX_FLAVORS); }
86  // check consistency of input vector
87  bool flavorIndependent(const CorrectionFactor& jec) const { return (jec.second.size()==1); }
88  // check consistency of input vector
89  bool isValid(const CorrectionFactor& jec) const { return (flavorDependent(jec) || flavorIndependent(jec)); }
90 
91  private:
92  // instance label of jet energy correction factors
93  std::string label_;
94  // vector of CorrectionFactors. NOTE: the correction factors are expected to appear
95  // nested; they may appear in arbitary number and order according to the configuration
96  // of the jetCorrFactors module. CorrectionFactors appear in two versions: as a single
97  // float (for flavor independent corrections) or as a std::vector of four floats (for
98  // flavor dependent corrections). Due to the nested structure of the CorrectionFactors
99  // from the first flavor dependent CorrectionFactor in the chain on each correction is
100  // flavor dependent.
101  std::vector<CorrectionFactor> jec_;
102  };
103 }
104 
105 #endif
float correction(unsigned int level, Flavor flavor=NONE) const
unsigned int numberOfCorrectionLevels() const
bool flavorIndependent(const CorrectionFactor &jec) const
std::vector< std::string > correctionLabels() const
std::string jecLevel(const unsigned int &level) const
std::vector< CorrectionFactor > jec_
std::string jecSet() const
std::string correctionLabelString() const
Class for the storage of jet correction factors.
bool isValid(const CorrectionFactor &jec) const
std::pair< std::string, std::vector< float > > CorrectionFactor
std::string jecFlavor(const Flavor &flavor) const
std::string correctionLabel(unsigned int level) const
static const unsigned int MAX_FLAVORS
bool flavorDependent(unsigned int level) const
tuple level
Definition: testEve_cfg.py:34
bool flavorDependent(const CorrectionFactor &jec) const