hej is hosted by Hepforge, IPPP Durham
HEJ 2.1.4
High energy resummation for hadron colliders
Loading...
Searching...
No Matches
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
15namespace 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 private:
82 std::map<event_type::EventType, XSWithError<double>> xs_;
84 };
85
87 std::ostream& operator<<(std::ostream& os, const CrossSectionAccumulator& xs);
88
89// ------------ Implementation ------------
90
91 template<class ConstIt>
92 void CrossSectionAccumulator::fill_correlated(ConstIt begin, ConstIt end){
93 if(std::distance(begin, end) < 2){ // only one event
94 fill(*begin);
95 return;
96 }
97 double sum = 0.;
98 double sum2 = 0.;
99 const auto type = begin->type();
100 for(; begin != end; ++begin){
101 double const wt = begin->central().weight;
102 sum += wt;
103 sum2 += wt*wt;
104 }
105 fill_correlated(sum, sum2, type);
106 }
107} // 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.
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
XSWithError< double > const & total() const
total Cross Section and error
Definition: CrossSectionAccumulator.hh:69
XSWithError< double > const & operator[](event_type::EventType type) const
Cross Section and error of specific type.
Definition: CrossSectionAccumulator.hh:77
XSWithError< double > const & at(event_type::EventType type) const
Cross Section and error of specific type.
Definition: CrossSectionAccumulator.hh:73
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:47
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