Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Jet.cc
Go to the documentation of this file.
1 #include "../interface/Jet.hh"
2 #include <map>
3 #include <string>
4 #include <vector>
5 #include "../interface/city.h"
6 #include "boost/format.hpp"
7 
8 namespace ic {
9 
10 // Constructors/Destructors
12  : Candidate::Candidate(),
13  uncorrected_energy_(0.),
14  jet_area_(0.),
15  parton_flavour_(0) {}
16 
18 
19  void Jet::Print() const {
21  std::cout << "--JEC Factors--" << std::endl;
22  UFmap::const_iterator uf_it;
23  for (uf_it = jec_factors_.begin(); uf_it != jec_factors_.end(); ++uf_it) {
24  std::cout << boost::format("%-30s %-30s\n") %
25  UnHashJecFactor(uf_it->first) % uf_it->second;
26  }
27  }
28 
29  void Jet::SetJecFactor(std::string const& name, float const& factor) {
30  jec_factors_[CityHash64(name)] = factor;
31  }
32 
33  float Jet::GetJecFactor(std::string const& name) const {
34  UFmap::const_iterator iter = jec_factors_.find(CityHash64(name));
35  if (iter != jec_factors_.end()) {
36  return iter->second;
37  } else {
38  std::cerr << "Warning in <Jet::GetJecFactor>: JEC Factor \"" << name
39  << "\" not found" << std::endl;
40  return 0.0;
41  }
42  }
43 
44  void Jet::SetBDiscriminator(std::string const& name, float const& value) {
45  b_discriminators_[CityHash64(name)] = value;
46  }
47 
48  float Jet::GetBDiscriminator(std::string const& name) const {
49  UFmap::const_iterator iter = b_discriminators_.find(CityHash64(name));
50  if (iter != b_discriminators_.end()) {
51  return iter->second;
52  } else {
53  std::cerr << "Warning in <Jet::GetBDiscriminator>: Algorithm \"" << name
54  << "\" not found" << std::endl;
55  return 0.0;
56  }
57  }
58 
59  std::string Jet::UnHashJecFactor(std::size_t jec) const {
60  static TSmap dict;
61  static bool is_set = false;
62  if (!is_set) {
63  dict[CityHash64("Uncorrected")] = "Uncorrected";
64  dict[CityHash64("L1Offset")] = "L1Offset";
65  dict[CityHash64("L1FastJet")] = "L1FastJet";
66  dict[CityHash64("L2Relative")] = "L2Relative";
67  dict[CityHash64("L3Absolute")] = "L3Absolute";
68  dict[CityHash64("L2L3Residual")] = "L2L3Residual";
69  }
70  is_set = true;
71  TSmap::const_iterator it = dict.find(jec);
72  if (it != dict.end()) {
73  return it->second;
74  } else {
75  std::cerr << "Warning in <Jet>: Unable to unhash \"" << jec
76  << "\", returning empty string" << std::endl;
77  }
78  return "";
79  }
80 
81  std::string Jet::UnHashDiscr(std::size_t dis) const {
82  static TSmap dict;
83  static bool is_set = false;
84  if (!is_set) {
85  dict[CityHash64("combinedSecondaryVertexBJetTags")] =
86  "combinedSecondaryVertexBJetTags";
87  dict[CityHash64("pfCombinedSecondaryVertexV2BJetTags")] =
88  "pfCombinedSecondaryVertexV2BJetTags";
89  dict[CityHash64("combinedSecondaryVertexMVABJetTags")] =
90  "combinedSecondaryVertexMVABJetTags";
91  dict[CityHash64("jetBProbabilityBJetTags")] = "jetBProbabilityBJetTags";
92  dict[CityHash64("jetProbabilityBJetTags")] = "jetProbabilityBJetTags";
93  dict[CityHash64("simpleSecondaryVertexHighEffBJetTags")] =
94  "simpleSecondaryVertexHighEffBJetTags";
95  dict[CityHash64("simpleSecondaryVertexHighPurBJetTags")] =
96  "simpleSecondaryVertexHighPurBJetTags";
97  dict[CityHash64("softMuonBJetTags")] = "softMuonBJetTags";
98  dict[CityHash64("softMuonByIP3dBJetTags")] = "softMuonByIP3dBJetTags";
99  dict[CityHash64("softMuonByPtBJetTags")] = "softMuonByPtBJetTags";
100  dict[CityHash64("trackCountingHighEffBJetTags")] =
101  "trackCountingHighEffBJetTags";
102  dict[CityHash64("trackCountingHighPurBJetTags")] =
103  "trackCountingHighPurBJetTags";
104  }
105  is_set = true;
106  TSmap::const_iterator it = dict.find(dis);
107  if (it != dict.end()) {
108  return it->second;
109  } else {
110  std::cerr << "Warning in <Jet>: Unable to unhash \"" << dis
111  << "\", returning empty string" << std::endl;
112  }
113  return "";
114  }
115  }
Jet()
Definition: Jet.cc:11
uint64 CityHash64(const char *buf, size_t len)
Definition: city.cc:200
float GetJecFactor(std::string const &name) const
Returns a specific correction factor if name is defined, otherwise returns zero.
Definition: Jet.cc:33
void SetBDiscriminator(std::string const &name, float const &value)
Store a b-tagging discriminator, overwriting any existing value with label name
Definition: Jet.cc:44
Stores a four-momentum, charge and identifier, and is the base class for most other physics objects...
Definition: Candidate.hh:13
Definition: CaloJet.hh:9
void SetJecFactor(std::string const &name, float const &value)
Store a jet energy correction factor, overwriting any existing value with label name ...
Definition: Jet.cc:29
virtual void Print() const
Definition: Jet.cc:19
virtual ~Jet()
Definition: Jet.cc:17
virtual void Print() const
Definition: Candidate.cc:9
float GetBDiscriminator(std::string const &name) const
Returns a specific discriminator value if name is defined, otherwise returns zero.
Definition: Jet.cc:48