herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
statistics.h
1// -*- C++ -*-
2//
3// statistics.h is part of ExSample -- A Library for Sampling Sudakov-Type Distributions
4//
5// Copyright (C) 2008-2019 Simon Platzer -- simon.plaetzer@desy.de, The Herwig Collaboration
6//
7// ExSample is licenced under version 3 of the GPL, see COPYING for details.
8// Please respect the MCnet academic guidelines, see GUIDELINES for details.
9//
10//
11#ifndef EXSAMPLE_statistics_h_included
12#define EXSAMPLE_statistics_h_included
13
14#include "utility.h"
15
16namespace exsample {
17
20 class statistics {
21
22 public:
23
26
29 void presampled(double weight);
30
33 void select(double weight,
34 bool calculate_integral = true);
35
37 void accept(double weight) {
38 ++accepted_;
39 if (weight < 0) ++accepted_negative_;
40 }
41
43 void reject(double weight) {
44 --accepted_;
45 if (weight < 0) --accepted_negative_;
46 }
47
49 void reset();
50
53 std::pair<double,double> current() const;
54
56 double average_weight() const {
57 return (n_iterations_ == 0 ? 0. : average_weight_/n_iterations_);
58 }
59
61 double average_abs_weight() const {
63 }
64
66 double average_weight_variance() const {
68 }
69
71 unsigned long iteration_points() const { return iteration_points_; }
72
74 unsigned long n_iterations() const { return n_iterations_; }
75
77 unsigned long attempted() const { return attempted_; }
78
80 unsigned long accepted() const { return accepted_; }
81
83 unsigned long accepted_negative() const { return accepted_negative_; }
84
86 double sum_weights() const { return sum_weights_; }
87
89 double sum_abs_weights() const { return sum_abs_weights_; }
90
92 double sum_weights_squared() const { return sum_weights_squared_; }
93
95 double max_weight() const { return max_weight_; }
96
97 public:
98
100 template<class OStream>
101 void put(OStream& os) const;
102
104 template<class IStream>
105 void get(IStream& is);
106
107 private:
108
111
114
117
119 unsigned long iteration_points_;
120
122 unsigned long attempted_;
123
125 unsigned long accepted_;
126
128 unsigned long accepted_negative_;
129
132
135
138
141
143 unsigned long n_iterations_;
144
145 };
146
147}
148
149#include "statistics.icc"
150
151#endif // EXSAMPLE_statistics_h_included
statistics is a helper class for keeping track of event generation statistics.
Definition: statistics.h:20
double max_weight() const
the maximum weight
Definition: statistics.h:95
double average_weight_variance_
the variance of the weight
Definition: statistics.h:116
double sum_abs_weights() const
the sum of absolute values of the weights
Definition: statistics.h:89
double sum_abs_weights_
the sum of absolute values of the weights
Definition: statistics.h:134
void select(double weight, bool calculate_integral=true)
indicate that a weight has been selected; optionally preven the weight from entering the caluclation ...
unsigned long accepted_negative_
the total number of acceptet events with negative weights
Definition: statistics.h:128
unsigned long accepted_
the total number of finally accepted events in this bin
Definition: statistics.h:125
double average_abs_weight() const
the average absolute weight
Definition: statistics.h:61
double average_weight_variance() const
the variance of the weight
Definition: statistics.h:66
double average_weight() const
the average weight
Definition: statistics.h:56
void get(IStream &is)
get from istream
unsigned long accepted_negative() const
the total number of acceptet events with negative weights
Definition: statistics.h:83
double sum_weights_squared_
the sum of weights squared
Definition: statistics.h:137
unsigned long accepted() const
the total number of finally accepted events in this bin
Definition: statistics.h:80
unsigned long attempted() const
the total number of attempted in this bin
Definition: statistics.h:77
void presampled(double weight)
update the statistics for a weight encountered during presampling
statistics()
default constructor
double max_weight_
the maximum weight
Definition: statistics.h:140
void put(OStream &os) const
put ostream
unsigned long attempted_
the total number of attempted in this bin
Definition: statistics.h:122
double average_abs_weight_
the average absolute weight
Definition: statistics.h:113
unsigned long n_iterations() const
the number of iterations
Definition: statistics.h:74
double sum_weights_squared() const
the sum of weights squared
Definition: statistics.h:92
void reset()
reset the statistics object
unsigned long iteration_points_
the number of points in this iteration
Definition: statistics.h:119
unsigned long iteration_points() const
the number of points in this iteration
Definition: statistics.h:71
unsigned long n_iterations_
the number of iterations used to calculate the integral
Definition: statistics.h:143
void accept(double weight)
indicate that a point has been accepted
Definition: statistics.h:37
double average_weight_
the average weight
Definition: statistics.h:110
double sum_weights() const
the sum of weights
Definition: statistics.h:86
void reject(double weight)
reject a prviously accepted event
Definition: statistics.h:43
double sum_weights_
the sum of weights
Definition: statistics.h:131
std::pair< double, double > current() const
return the integral's estimate and its uncertainty at the currently accumulated statistics