Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EventInfo.hh
Go to the documentation of this file.
1 #ifndef ICHiggsTauTau_EventInfo_hh
2 #define ICHiggsTauTau_EventInfo_hh
3 
4 #ifdef __CINT__
5 typedef char __signed;
6 typedef char int8_t;
7 #endif
8 
9 #include <string>
10 #include <map>
11 #include <iostream>
13 #include "Rtypes.h"
14 
15 namespace ic {
16 
21 class EventInfo {
22  private:
23  typedef std::map<std::string, double> SDMap;
24  typedef std::map<std::string, bool> SBMap;
25  typedef std::map<std::size_t, float> TBMap;
26 
27  public:
28  EventInfo();
29  virtual ~EventInfo();
30  virtual void Print() const;
31 
33 
34  inline bool is_data() const { return is_data_; }
36 
38  inline unsigned long long event() const { return event_; }
39 
41  inline int run() const { return run_; }
42 
44  inline int lumi_block() const { return lumi_block_; }
45 
47  inline int bunch_crossing() const { return bunch_crossing_; }
48 
50  inline double jet_rho() const { return jet_rho_; }
51 
53  inline double lepton_rho() const { return lepton_rho_; }
54 
56  inline double gen_ht() const { return gen_ht_; }
57 
58 
60  inline double gen_mll() const { return gen_mll_; }
61 
63  inline unsigned n_outgoing_partons() const { return n_outgoing_partons_; }
64 
67  inline unsigned good_vertices() const { return good_vertices_; }
70 
72  inline void set_is_data(bool const& is_data) { is_data_ = is_data; }
74 
76  inline void set_event(unsigned long long const& event) { event_ = event; }
77 
79  inline void set_run(int const& run) { run_ = run; }
80 
82  inline void set_lumi_block(int const& lumi_block) {
83  lumi_block_ = lumi_block;
84  }
85 
87  inline void set_bunch_crossing(int const& bunch_crossing) {
88  bunch_crossing_ = bunch_crossing;
89  }
90 
92  inline void set_jet_rho(double const& jet_rho) { jet_rho_ = jet_rho; }
93 
95  inline void set_lepton_rho(double const& lepton_rho) {
96  lepton_rho_ = lepton_rho;
97  }
98 
100  inline void set_gen_ht(double const& gen_ht) { gen_ht_ = gen_ht; }
101 
102 
104  inline void set_gen_mll(double const& gen_mll) { gen_mll_ = gen_mll; }
105 
107  inline void set_n_outgoing_partons(unsigned const& n_outgoing_partons) { n_outgoing_partons_ = n_outgoing_partons; }
108 
110  inline void set_good_vertices(unsigned const& good_vertices) {
111  good_vertices_ = good_vertices;
112  }
115 
121  inline double weight(std::string label) const {
122  SDMap::const_iterator it = weights_.find(label);
123  if (it != weights_.end()) {
124  return it->second;
125  } else {
126  std::cerr << "Weight \"" << label << "\" not found!" << std::endl;
127  return 1.0;
128  }
129  }
130 
135  inline bool weight_defined(std::string label) const {
136  SDMap::const_iterator it = weights_.find(label);
137  return it != weights_.end();
138  }
139 
146  inline void set_weight(std::string const& label, double const& weight,
147  bool const& enabled) {
148  if (weight != weight) {
149  std::cerr << " -- weight " << label << " has NAN value, setting to 1..."
150  << std::endl;
151  weights_[label] = 1.;
152  } else {
153  weights_[label] = weight;
154  }
155  weight_status_[label] = enabled;
156  }
157 
165  inline void set_weight(std::string label, double const& weight) {
166  bool enabled = true;
167  if (label.size() > 0) {
168  if (label.at(0) == '!') {
169  label.erase(0, 1);
170  enabled = false;
171  }
172  }
173  if (weight != weight) {
174  std::cerr << " -- weight " << label << " has NAN value, setting to 1..."
175  << std::endl;
176  weights_[label] = 1.0;
177  } else {
178  weights_[label] = weight;
179  }
180  weight_status_[label] = enabled;
181  }
182 
184  inline double total_weight() const {
185  SDMap::const_iterator it;
186  double weight = 1.0;
187  for (it = weights_.begin(); it != weights_.end(); ++it) {
188  SBMap::const_iterator st_it = weight_status_.find(it->first);
189  if (st_it != weight_status_.end()) {
190  if (!st_it->second) continue;
191  }
192  weight = it->second * weight;
193  }
194  return weight;
195  }
196 
198  inline bool weight_is_enabled(std::string label) {
199  if (weight_defined(label)) {
200  return weight_status_[label];
201  } else {
202  return false;
203  }
204  }
205 
207  inline void enable_weight(std::string label) {
208  if (weight_defined(label)) {
209  weight_status_[label] = true;
210  }
211  }
212 
214  inline void disable_weight(std::string label) {
215  if (weight_defined(label)) {
216  weight_status_[label] = false;
217  }
218  }
221 
223  inline std::map<std::size_t, float> const& filters() const {
226  return filters_;
227  }
228 
230  inline void set_filters(std::map<std::size_t, float> const& filters) {
231  filters_ = filters;
232  }
233 
236  inline void set_filter_result(std::string const& label, bool const& result) {
237  filters_[CityHash64(label)] = result;
238  }
239 
241  inline bool filter_result(std::string const& label) {
242  TBMap::const_iterator it = filters_.find(CityHash64(label));
243  if (it != filters_.end()) {
244  return it->second;
245  } else {
246  std::cerr << "Filter \"" << label << "\" not found!" << std::endl;
247  return true;
248  }
249  }
250 
252  inline bool total_filter_result() const {
253  TBMap::const_iterator it;
254  bool result = true;
255  for (it = filters_.begin(); it != filters_.end(); ++it) {
256  result = it->second && result;
257  }
258  return result;
259  }
262  private:
263  bool is_data_;
264  unsigned long long event_;
265  int run_;
266  int lumi_block_;
267  int bunch_crossing_;
268  double jet_rho_;
269  double lepton_rho_;
270  double gen_ht_;
271  unsigned n_outgoing_partons_;
272  double gen_mll_;
273  SDMap weights_;
274  SBMap weight_status_;
275  unsigned good_vertices_;
276  TBMap filters_;
277 
278  #ifndef SKIP_CINT_DICT
279  public:
280  ClassDef(EventInfo, 7);
281  #endif
282 };
283 }
285 #endif
void set_weight(std::string const &label, double const &weight, bool const &enabled)
Add a new weight, overriding any existing value with the same label.
Definition: EventInfo.hh:146
void set_is_data(bool const &is_data)
If event is real data returns true, otherwise false
Definition: EventInfo.hh:73
std::map< std::size_t, float > const & filters() const
Get the map containing all filter results. The map key is the hash of the original string chosen to i...
Definition: EventInfo.hh:225
void set_filter_result(std::string const &label, bool const &result)
Set the filter result for label to result, overwriting any existing filter result with this label...
Definition: EventInfo.hh:236
uint64 CityHash64(const char *buf, size_t len)
Definition: city.cc:200
double jet_rho() const
Energy density used for the jet energy corrections in this event.
Definition: EventInfo.hh:50
unsigned n_outgoing_partons() const
Number of outgoing partons at generator level, used for combining n-jet binned samples with inclusive...
Definition: EventInfo.hh:63
void set_n_outgoing_partons(unsigned const &n_outgoing_partons)
Number of outgoing partons at generator level, used for combining n-jet binned samples with inclusive...
Definition: EventInfo.hh:107
virtual ~EventInfo()
Definition: EventInfo.cc:18
void set_filters(std::map< std::size_t, float > const &filters)
Set the complete filter result map to a new value.
Definition: EventInfo.hh:230
void set_gen_ht(double const &gen_ht)
Generator level HT, used for combining HT binned samples with inclusive samples.
Definition: EventInfo.hh:100
double weight(std::string label) const
Get the the value of a specific weight.
Definition: EventInfo.hh:121
unsigned good_vertices() const
Number of reconstructed vertices passing some baseline quality requirements.
Definition: EventInfo.hh:67
void set_lepton_rho(double const &lepton_rho)
Energy density used for calculating lepton isolation in this event.
Definition: EventInfo.hh:95
void set_run(int const &run)
Run number.
Definition: EventInfo.hh:79
double gen_mll() const
Generator level M_ll.
Definition: EventInfo.hh:60
int lumi_block() const
Lumisection number.
Definition: EventInfo.hh:44
void set_gen_mll(double const &gen_mll)
Generator level M_ll.
Definition: EventInfo.hh:104
double total_weight() const
Calculate the product of all stored and enabled weights.
Definition: EventInfo.hh:184
bool is_data() const
If event is real data returns true, otherwise false
Definition: EventInfo.hh:35
bool weight_defined(std::string label) const
Check if a specific weight is defined.
Definition: EventInfo.hh:135
Definition: CaloJet.hh:9
double gen_ht() const
Generator level HT, used for combining HT binned samples with inclusive samples.
Definition: EventInfo.hh:56
void set_weight(std::string label, double const &weight)
Add a new weight.
Definition: EventInfo.hh:165
virtual void Print() const
Definition: EventInfo.cc:20
Stores core event information such as run, lumi and event number, as well as event weights and filter...
Definition: EventInfo.hh:21
double lepton_rho() const
Energy density used for calculating lepton isolation in this event.
Definition: EventInfo.hh:53
void set_lumi_block(int const &lumi_block)
Lumisection number.
Definition: EventInfo.hh:82
unsigned long long event() const
Event number.
Definition: EventInfo.hh:38
bool total_filter_result() const
Returns true if all filter results are true, false otherwise.
Definition: EventInfo.hh:252
bool weight_is_enabled(std::string label)
Return true if the weight with label is enabled, false otherwise.
Definition: EventInfo.hh:198
void set_good_vertices(unsigned const &good_vertices)
Number of reconstructed vertices passing some baseline quality requirements.
Definition: EventInfo.hh:110
void set_event(unsigned long long const &event)
Event number.
Definition: EventInfo.hh:76
void disable_weight(std::string label)
Disable the weight with label in the total_weight() calculation.
Definition: EventInfo.hh:214
void enable_weight(std::string label)
Enable the weight with label in the total_weight() calculation.
Definition: EventInfo.hh:207
bool filter_result(std::string const &label)
Get the filter result for label, return true if not defined.
Definition: EventInfo.hh:241
int bunch_crossing() const
Bunch crossing number.
Definition: EventInfo.hh:47
void set_bunch_crossing(int const &bunch_crossing)
Bunch crossing number.
Definition: EventInfo.hh:87
void set_jet_rho(double const &jet_rho)
Energy density used for the jet energy corrections in this event.
Definition: EventInfo.hh:92
ClassDef(EventInfo, 7)
int run() const
Run number.
Definition: EventInfo.hh:41