Loading [MathJax]/extensions/tex2jax.js
hej is hosted by Hepforge, IPPP Durham
HEJ  2.3.0
High energy resummation for hadron colliders
CrossSectionAccumulator.hh
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <iterator>
9 #include <map>
10 #include <ostream>
11 #include <vector>
12 
13 #include "HEJ/event_types.hh"
14 
15 namespace HEJ {
16  class Event;
17 
19  template<typename T>
20  struct XSWithError {
21  T value = T{};
22  T error = T{};
23  };
24 
29  public:
32  void fill(Event const & ev);
35  void fill(double wt, event_type::EventType type);
38  void fill(double wt, double err, event_type::EventType type);
39 
53  void fill_correlated(std::vector<Event> const & evts);
55  template<class ConstIt>
56  void fill_correlated(ConstIt begin, ConstIt end);
58  void fill_correlated(double sum, double sum2, event_type::EventType type);
59 
61  auto begin() const {
62  return std::begin(xs_);
63  }
65  auto end() const {
66  return std::end(xs_);
67  }
69  XSWithError<double> const & total() const {
70  return total_;
71  }
74  return xs_.at(type);
75  }
78  return at(type);
79  }
80 
81  // method to scale total_ and xs_ after they have been filled
82  void scale(double xsscale);
83 
84  private:
85  std::map<event_type::EventType, XSWithError<double>> xs_;
86  XSWithError<double> total_;
87  };
88 
90  std::ostream& operator<<(std::ostream& os, const CrossSectionAccumulator& xs);
91 
92 // ------------ Implementation ------------
93 
94  template<class ConstIt>
95  void CrossSectionAccumulator::fill_correlated(ConstIt begin, ConstIt end){
96  if(std::distance(begin, end) < 2){ // only one event
97  fill(*begin);
98  return;
99  }
100  double sum = 0.;
101  double sum2 = 0.;
102  const auto type = begin->type();
103  for(; begin != end; ++begin){
104  double const wt = begin->central().weight;
105  sum += wt;
106  sum2 += wt*wt;
107  }
108  fill_correlated(sum, sum2, type);
109  }
110 } // namespace HEJ
Sum of Cross Section for different subproccess.
Definition: CrossSectionAccumulator.hh:28
void fill_correlated(std::vector< Event > const &evts)
Fill with multiple correlated weights.
XSWithError< double > const & at(event_type::EventType type) const
Cross Section and error of specific type.
Definition: CrossSectionAccumulator.hh:73
XSWithError< double > const & total() const
total Cross Section and error
Definition: CrossSectionAccumulator.hh:69
auto end() const
end of Cross Section and error for subprocesses
Definition: CrossSectionAccumulator.hh:65
void fill(double wt, event_type::EventType type)
auto begin() const
begin of Cross Section and error for subprocesses
Definition: CrossSectionAccumulator.hh:61
void scale(double xsscale)
XSWithError< double > const & operator[](event_type::EventType type) const
Cross Section and error of specific type.
Definition: CrossSectionAccumulator.hh:77
void fill(double wt, double err, event_type::EventType type)
void fill_correlated(double sum, double sum2, event_type::EventType type)
explicit version of fill_correlated() by giving sum(wt) and sum(wt^2)
void fill(Event const &ev)
An event with clustered jets.
Definition: Event.hh:51
Define different types of events.
EventType
Possible event types.
Definition: event_types.hh:19
Main HEJ 2 Namespace.
Definition: mainpage.dox:1
std::ostream & operator<<(std::ostream &os, const CrossSectionAccumulator &xs)
Print CrossSectionAccumulator to stream.
Collection of Cross Section with its uncertainty.
Definition: CrossSectionAccumulator.hh:20
T error
Squared error (Variance)
Definition: CrossSectionAccumulator.hh:22
T value
Cross Section.
Definition: CrossSectionAccumulator.hh:21