herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
Statistics::Counter Class Reference

A (weighted) counter. More...

#include <Counter.h>

Inheritance diagram for Statistics::Counter:

Public Member Functions

 Counter ()
 Construct a new counter.
 
virtual ~Counter ()
 Destruct a counter.
 
void initialize ()
 Initialize this counter.
 
void reset ()
 Reset this counter.
 
void finalize ()
 Finalize this counter.
 
void open (size_t id)
 Open the counter for the next event of the given id.
 
void close ()
 Close the counter and update the overall statistics.
 
void count (double weight, size_t id)
 Book a contribution to the current event.
 
Counteroperator+= (const Counter &other)
 Add a counter to this counter.
 
Counteroperator-= (const Counter &other)
 Subtract a counter from this counter.
 
double sumOfWeights () const
 Return the sum of weights.
 
double sumOfSquaredWeights () const
 Return the sum of squared weights.
 
double sumOfEventWeights () const
 Return the sum of weights before the next event occured.
 
size_t eventId () const
 Return the current event id.
 
bool isOpen () const
 Return true, if this counter is open.
 
bool isClosed () const
 Return true, if this counter is closed.
 
double average (double nPoints) const
 Given a number of sampled points, return the average of this counter.
 
double varianceOfAverage (double nPoints) const
 Given a number of sampled points, return the variance of the average of this counter.
 
void fromXML (const XML::Element &)
 Fill counter data from an XML element.
 
XML::Element toXML () const
 Return an XML element for the data of this counter.
 

Private Attributes

double theSumOfWeights
 The sum of weights counted.
 
double theSumOfSquaredWeights
 The sum of squared weights counted.
 
double theSumOfEventWeights
 The sum of weights counted before the next event occured; within one event, all weights are considered to be 100% correlated.
 
size_t theEventId
 The current event id.
 

Detailed Description

A (weighted) counter.

Author
Simon Platzer

Definition at line 19 of file Counter.h.

Member Function Documentation

◆ count()

void Statistics::Counter::count ( double  weight,
size_t  id 
)

Book a contribution to the current event.

Implies close() and open(id) if the id is different from the currently considered event id.

◆ eventId()

size_t Statistics::Counter::eventId ( ) const
inline

Return the current event id.

Definition at line 101 of file Counter.h.

References theEventId.

Referenced by isOpen().

◆ finalize()

void Statistics::Counter::finalize ( )
inline

Finalize this counter.

Definition at line 48 of file Counter.h.

References close(), and isOpen().

◆ initialize()

void Statistics::Counter::initialize ( )
inline

Initialize this counter.

Definition at line 38 of file Counter.h.

◆ isClosed()

bool Statistics::Counter::isClosed ( ) const
inline

Return true, if this counter is closed.

Definition at line 111 of file Counter.h.

References isOpen().

◆ isOpen()

bool Statistics::Counter::isOpen ( ) const
inline

Return true, if this counter is open.

Definition at line 106 of file Counter.h.

References eventId().

Referenced by finalize(), and isClosed().

◆ reset()

void Statistics::Counter::reset ( )
inline

Reset this counter.

Definition at line 43 of file Counter.h.

References Counter().

◆ sumOfEventWeights()

double Statistics::Counter::sumOfEventWeights ( ) const
inline

Return the sum of weights before the next event occured.

Definition at line 96 of file Counter.h.

References theSumOfEventWeights.

◆ sumOfSquaredWeights()

double Statistics::Counter::sumOfSquaredWeights ( ) const
inline

Return the sum of squared weights.

Definition at line 91 of file Counter.h.

References theSumOfSquaredWeights.

◆ sumOfWeights()

double Statistics::Counter::sumOfWeights ( ) const
inline

Return the sum of weights.

Definition at line 86 of file Counter.h.

References theSumOfWeights.

Member Data Documentation

◆ theEventId

size_t Statistics::Counter::theEventId
private

The current event id.

The counter is closed if this is zero.

Definition at line 161 of file Counter.h.

Referenced by eventId().

◆ theSumOfEventWeights

double Statistics::Counter::theSumOfEventWeights
private

The sum of weights counted before the next event occured; within one event, all weights are considered to be 100% correlated.

Definition at line 156 of file Counter.h.

Referenced by sumOfEventWeights().

◆ theSumOfSquaredWeights

double Statistics::Counter::theSumOfSquaredWeights
private

The sum of squared weights counted.

Definition at line 149 of file Counter.h.

Referenced by sumOfSquaredWeights().

◆ theSumOfWeights

double Statistics::Counter::theSumOfWeights
private

The sum of weights counted.

Definition at line 144 of file Counter.h.

Referenced by sumOfWeights().


The documentation for this class was generated from the following file: