Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Met.cc
Go to the documentation of this file.
1 #include "../interface/Met.hh"
2 #include <map>
3 #include <string>
4 #include <vector>
5 #include "../interface/city.h"
6 #include "boost/format.hpp"
7 
8 namespace ic {
10  : ic::Candidate(),
11  sum_et_(0.),
12  et_sig_(0.),
13  xx_sig_(0.),
14  xy_sig_(0.),
15  yx_sig_(0.),
16  yy_sig_(0.) {}
17 
18  Met::~Met() {}
19 
20  void Met::Print() const {
22 
23  std::cout << "--corrected METs--" << std::endl;
24  UBMmap::const_iterator uf_it;
25  for (uf_it = correctedmets_.begin(); uf_it != correctedmets_.end(); ++uf_it) {
26  std::cout << boost::format("%-30s %-30s\n") %
27  UnHashMetCor(uf_it->first) % uf_it->second;
28  }
29  }
30 
31  void Met::SetCorrectedMet(std::string const& name, ic::Met::BasicMet const& factor) {
32  correctedmets_[CityHash64(name)] = factor;
33  }
34 
35  void Met::SetShiftedMet(std::string const& name, ic::Met::BasicMet const& factor) {
36  shiftedmets_[CityHash64(name)] = factor;
37  }
38 
39  ic::Met::BasicMet Met::GetCorrectedMet(std::string const& name) const {
40  UBMmap::const_iterator iter = correctedmets_.find(CityHash64(name));
41  if (iter != correctedmets_.end()) {
42  return iter->second;
43  } else {
44  std::cerr << "Warning in <Met::GetCorrectedMet>: MET \"" << name
45  << "\" not found" << std::endl;
47  tmp.px=0;
48  tmp.py=0;
49  tmp.sumet=0;
50  return tmp;
51  }
52  }
53 
54  ic::Met::BasicMet Met::GetShiftedMet(std::string const& name) const {
55  UBMmap::const_iterator iter = shiftedmets_.find(CityHash64(name));
56  if (iter != shiftedmets_.end()) {
57  return iter->second;
58  } else {
59  std::cerr << "Warning in <Met::GetShiftedMet>: MET \"" << name
60  << "\" not found" << std::endl;
62  tmp.px=0;
63  tmp.py=0;
64  tmp.sumet=0;
65  return tmp;
66  }
67  }
68 
69  std::string Met::UnHashMetCor(std::size_t cor) const {
70  static TSmap dict;
71  static bool is_set = false;
72  if (!is_set) {
73  dict[CityHash64("Raw")] = "Raw";
74  dict[CityHash64("Type1")] = "Type1";
75  dict[CityHash64("Type01")] = "Type01";
76  dict[CityHash64("TypeXY")] = "TypeXY";
77  dict[CityHash64("Type1XY")] = "Type1XY";
78  dict[CityHash64("Type01XY")] = "Type01XY";
79  dict[CityHash64("Type1Smear")] = "Type1Smear";
80  dict[CityHash64("Type01Smear")] = "Type01Smear";
81  dict[CityHash64("Type1SmearXY")] = "Type1SmearXY";
82  dict[CityHash64("Type01SmearXY")] = "Type01SmearXY";
83  dict[CityHash64("RawCalo")] = "RawCalo";
84  }
85  is_set = true;
86  TSmap::const_iterator it = dict.find(cor);
87  if (it != dict.end()) {
88  return it->second;
89  } else {
90  std::cerr << "Warning in <Met>: Unable to unhash \"" << cor
91  << "\", returning empty string" << std::endl;
92  }
93  return "";
94  }
95 
96  std::string Met::UnHashMetUnc(std::size_t unc) const {
97  static TSmap dict;
98  static bool is_set = false;
99  if (!is_set) {
100  dict[CityHash64("JetResUp")] = "JetResUp";
101  dict[CityHash64("JetResDown")] = "JetResDown";
102  dict[CityHash64("JetEnUp")] = "JetEnUp";
103  dict[CityHash64("JetEnDown")] = "JetEnDown";
104  dict[CityHash64("MuonEnUp")] = "MuonEnUp";
105  dict[CityHash64("MuonEnDown")] = "MuonEnDown";
106  dict[CityHash64("ElectronEnUp")] = "ElectronEnUp";
107  dict[CityHash64("ElectronEnDown")] = "ElectronEnDown";
108  dict[CityHash64("TauEnUp")] = "TauEnUp";
109  dict[CityHash64("TauEnDown")] = "TauEnDown";
110  dict[CityHash64("UnclusteredEnUp")] = "UnclusteredEnUp";
111  dict[CityHash64("UnclusteredEnDown")] = "UnclusteredEnDown";
112  dict[CityHash64("PhotonEnUp")] = "PhotonEnUp";
113  dict[CityHash64("PhotonEnDown")] = "PhotonEnDown";
114  dict[CityHash64("NoShift")] = "NoShift";
115  }
116  is_set = true;
117  TSmap::const_iterator it = dict.find(unc);
118  if (it != dict.end()) {
119  return it->second;
120  } else {
121  std::cerr << "Warning in <Met>: Unable to unhash \"" << unc
122  << "\", returning empty string" << std::endl;
123  }
124  return "";
125  }
126 
127  std::ostream& operator<<(std::ostream& os,const ic::Met::BasicMet& met)
128  {
129  return os << " pt=" << met.pt() << " phi=" << met.phi() << " sumet=" << met.sumet << std::endl;
130  }
131 
132 }//namespace
double sumet
Definition: Met.hh:18
virtual void Print() const
Definition: Met.cc:20
ic::Met::BasicMet GetCorrectedMet(std::string const &name) const
Returns a specific correction factor if name is defined, otherwise returns zero.
Definition: Met.cc:39
virtual ~Met()
Definition: Met.cc:18
uint64 CityHash64(const char *buf, size_t len)
Definition: city.cc:200
Stores a four-momentum, charge and identifier, and is the base class for most other physics objects...
Definition: Candidate.hh:13
ic::Met::BasicMet GetShiftedMet(std::string const &name) const
Returns a specific correction factor if name is defined, otherwise returns zero.
Definition: Met.cc:54
Definition: CaloJet.hh:9
double px
Definition: Met.hh:18
double phi() const
Definition: Met.hh:20
double pt() const
Definition: Met.hh:19
Met()
Definition: Met.cc:9
void SetCorrectedMet(std::string const &name, ic::Met::BasicMet const &value)
Store a corrected met, overwriting any existing value with label name
Definition: Met.cc:31
void SetShiftedMet(std::string const &name, ic::Met::BasicMet const &value)
Store a shifted met, overwriting any existing value with label name
Definition: Met.cc:35
std::ostream & operator<<(std::ostream &os, const ic::Met::BasicMet &met)
Definition: Met.cc:127
double py
Definition: Met.hh:18
virtual void Print() const
Definition: Candidate.cc:9