File indexing completed on 2026-08-06 09:24:27
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef MYSTATISTICS_Counter_hpp_included
0009 #define MYSTATISTICS_Counter_hpp_included
0010
0011 #include "Herwig/Utilities/XML/Element.h"
0012
0013 namespace Statistics {
0014
0015
0016
0017
0018
0019 class Counter {
0020
0021 public:
0022
0023
0024
0025
0026 Counter();
0027
0028
0029
0030
0031 virtual ~Counter();
0032
0033 public:
0034
0035
0036
0037
0038 void initialize() {}
0039
0040
0041
0042
0043 void reset() { *this = Counter(); }
0044
0045
0046
0047
0048 void finalize() { if ( isOpen() ) close(); }
0049
0050 public:
0051
0052
0053
0054
0055 void open(size_t id);
0056
0057
0058
0059
0060 void close();
0061
0062
0063
0064
0065
0066
0067 void count(double weight, size_t id);
0068
0069 public:
0070
0071
0072
0073
0074 Counter& operator+=(const Counter& other);
0075
0076
0077
0078
0079 Counter& operator-=(const Counter& other);
0080
0081 public:
0082
0083
0084
0085
0086 double sumOfWeights() const { return theSumOfWeights; }
0087
0088
0089
0090
0091 double sumOfSquaredWeights() const { return theSumOfSquaredWeights; }
0092
0093
0094
0095
0096 double sumOfEventWeights() const { return theSumOfEventWeights; }
0097
0098
0099
0100
0101 size_t eventId() const { return theEventId; }
0102
0103
0104
0105
0106 bool isOpen() const { return eventId() != 0; }
0107
0108
0109
0110
0111 bool isClosed() const { return !isOpen(); }
0112
0113 public:
0114
0115
0116
0117
0118
0119 double average(double nPoints) const;
0120
0121
0122
0123
0124
0125 double varianceOfAverage(double nPoints) const;
0126
0127 public:
0128
0129
0130
0131
0132 void fromXML(const XML::Element&);
0133
0134
0135
0136
0137 XML::Element toXML() const;
0138
0139 private:
0140
0141
0142
0143
0144 double theSumOfWeights;
0145
0146
0147
0148
0149 double theSumOfSquaredWeights;
0150
0151
0152
0153
0154
0155
0156 double theSumOfEventWeights;
0157
0158
0159
0160
0161 size_t theEventId;
0162
0163 };
0164
0165 }
0166
0167 #endif