herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Utilities
Statistics
Counter.h
1
// -*- C++ -*-
2
//
3
// Counter.hpp is a part of myStatistics
4
// Copyright (C) 2012-2019 Simon Platzer, The Herwig Collaboration
5
//
6
// myStatistics is licenced under version 3 of the GPL, see COPYING for details.
7
//
8
#ifndef MYSTATISTICS_Counter_hpp_included
9
#define MYSTATISTICS_Counter_hpp_included
10
11
#include "Herwig/Utilities/XML/Element.h"
12
13
namespace
Statistics {
14
19
class
Counter
{
20
21
public
:
22
26
Counter
();
27
31
virtual
~Counter
();
32
33
public
:
34
38
void
initialize
() {}
39
43
void
reset
() { *
this
=
Counter
(); }
44
48
void
finalize
() {
if
(
isOpen
() )
close
(); }
49
50
public
:
51
55
void
open
(
size_t
id
);
56
60
void
close
();
61
67
void
count
(
double
weight,
size_t
id
);
68
69
public
:
70
74
Counter
&
operator+=
(
const
Counter
& other);
75
79
Counter
&
operator-=
(
const
Counter
& other);
80
81
public
:
82
86
double
sumOfWeights
()
const
{
return
theSumOfWeights
; }
87
91
double
sumOfSquaredWeights
()
const
{
return
theSumOfSquaredWeights
; }
92
96
double
sumOfEventWeights
()
const
{
return
theSumOfEventWeights
; }
97
101
size_t
eventId
()
const
{
return
theEventId
; }
102
106
bool
isOpen
()
const
{
return
eventId
() != 0; }
107
111
bool
isClosed
()
const
{
return
!
isOpen
(); }
112
113
public
:
114
119
double
average
(
double
nPoints)
const
;
120
125
double
varianceOfAverage
(
double
nPoints)
const
;
126
127
public
:
128
132
void
fromXML
(
const
XML::Element
&);
133
137
XML::Element
toXML
()
const
;
138
139
private
:
140
144
double
theSumOfWeights
;
145
149
double
theSumOfSquaredWeights
;
150
156
double
theSumOfEventWeights
;
157
161
size_t
theEventId
;
162
163
};
164
165
}
166
167
#endif
// MYSTATISTICS_Counter_hpp_included
Statistics::Counter
A (weighted) counter.
Definition:
Counter.h:19
Statistics::Counter::Counter
Counter()
Construct a new counter.
Statistics::Counter::theSumOfSquaredWeights
double theSumOfSquaredWeights
The sum of squared weights counted.
Definition:
Counter.h:149
Statistics::Counter::sumOfSquaredWeights
double sumOfSquaredWeights() const
Return the sum of squared weights.
Definition:
Counter.h:91
Statistics::Counter::varianceOfAverage
double varianceOfAverage(double nPoints) const
Given a number of sampled points, return the variance of the average of this counter.
Statistics::Counter::theSumOfEventWeights
double theSumOfEventWeights
The sum of weights counted before the next event occured; within one event, all weights are considere...
Definition:
Counter.h:156
Statistics::Counter::average
double average(double nPoints) const
Given a number of sampled points, return the average of this counter.
Statistics::Counter::sumOfWeights
double sumOfWeights() const
Return the sum of weights.
Definition:
Counter.h:86
Statistics::Counter::isClosed
bool isClosed() const
Return true, if this counter is closed.
Definition:
Counter.h:111
Statistics::Counter::toXML
XML::Element toXML() const
Return an XML element for the data of this counter.
Statistics::Counter::operator+=
Counter & operator+=(const Counter &other)
Add a counter to this counter.
Statistics::Counter::finalize
void finalize()
Finalize this counter.
Definition:
Counter.h:48
Statistics::Counter::theEventId
size_t theEventId
The current event id.
Definition:
Counter.h:161
Statistics::Counter::initialize
void initialize()
Initialize this counter.
Definition:
Counter.h:38
Statistics::Counter::reset
void reset()
Reset this counter.
Definition:
Counter.h:43
Statistics::Counter::sumOfEventWeights
double sumOfEventWeights() const
Return the sum of weights before the next event occured.
Definition:
Counter.h:96
Statistics::Counter::open
void open(size_t id)
Open the counter for the next event of the given id.
Statistics::Counter::close
void close()
Close the counter and update the overall statistics.
Statistics::Counter::eventId
size_t eventId() const
Return the current event id.
Definition:
Counter.h:101
Statistics::Counter::operator-=
Counter & operator-=(const Counter &other)
Subtract a counter from this counter.
Statistics::Counter::theSumOfWeights
double theSumOfWeights
The sum of weights counted.
Definition:
Counter.h:144
Statistics::Counter::~Counter
virtual ~Counter()
Destruct a counter.
Statistics::Counter::isOpen
bool isOpen() const
Return true, if this counter is open.
Definition:
Counter.h:106
Statistics::Counter::fromXML
void fromXML(const XML::Element &)
Fill counter data from an XML element.
Statistics::Counter::count
void count(double weight, size_t id)
Book a contribution to the current event.
XML::Element
Element represents a (tree of) XML elements.
Definition:
Element.h:56
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6