herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
Run.h
1// -*- C++ -*-
2//
3// Run.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_Run_hpp_included
9#define MYSTATISTICS_Run_hpp_included
10
11#include "Histogram.h"
12
13namespace Statistics {
14
19 class Run {
20
21 public:
22
26 Run();
27
31 explicit Run(const std::string& newName);
32
36 virtual ~Run();
37
38 public:
39
43 void initialize();
44
48 void reset();
49
53 void finalize(size_t newAttemptedPoints);
54
55 public:
56
60 void count(double weight) {
61 theSumOfWeights += weight;
62 theSumOfSquaredWeights += weight*weight;
63 }
64
68 Histogram& addHistogram(const std::string& newName,
69 const std::vector<double>& newBoundaries);
70
74 Histogram& addHistogram(const std::string& newName,
75 const std::vector<double>& newBoundaries,
76 const std::pair<double,double>& newPeriodicity);
77
81 Histogram& histogram(const std::string& histoName);
82
86 const Histogram& histogram(const std::string& histoName) const;
87
91 const std::map<std::string,Histogram>& histograms() const { return theHistograms; }
92
96 const std::string& name() const { return theName; }
97
101 void name(const std::string& newName) { theName = newName; }
102
106 size_t attemptedPoints() const { return theAttemptedPoints; }
107
111 double sumOfWeights() const { return theSumOfWeights; }
112
117
118 public:
119
123 Run& operator+=(const Run& other);
124
125 public:
126
130 void fromXML(const XML::Element&);
131
136
137 private:
138
142 std::string theName;
143
148
153
158
162 std::map<std::string,Histogram> theHistograms;
163
164
165 };
166
167}
168
169#endif // MYSTATISTICS_Run_hpp_included
A (one dimensional) histogram.
A simulation run.
Definition: Run.h:19
std::string theName
The name of the run.
Definition: Run.h:142
void finalize(size_t newAttemptedPoints)
Finalize this run.
double sumOfWeights() const
The sum of weights.
Definition: Run.h:111
Histogram & histogram(const std::string &histoName)
Return a given histogram.
virtual ~Run()
Destructor.
double sumOfSquaredWeights() const
The sum of squared weights.
Definition: Run.h:116
Run & operator+=(const Run &other)
Add a run to this run.
double theSumOfSquaredWeights
The sum of squared weights.
Definition: Run.h:157
const std::map< std::string, Histogram > & histograms() const
Return the histograms.
Definition: Run.h:91
void reset()
Reset this run.
Run()
Default constructor.
void name(const std::string &newName)
Set the name of the run.
Definition: Run.h:101
double theSumOfWeights
The sum of weights.
Definition: Run.h:152
size_t attemptedPoints() const
Return the total number of attempted points.
Definition: Run.h:106
XML::Element toXML() const
Return an XML element for the data of this run.
Histogram & addHistogram(const std::string &newName, const std::vector< double > &newBoundaries)
Add a histogram.
void count(double weight)
Add a point to this run.
Definition: Run.h:60
const Histogram & histogram(const std::string &histoName) const
Return a given histogram.
const std::string & name() const
Return the name of the run.
Definition: Run.h:96
void initialize()
Initialize this run.
Run(const std::string &newName)
Construct giving a name and seed.
std::map< std::string, Histogram > theHistograms
The histograms.
Definition: Run.h:162
Histogram & addHistogram(const std::string &newName, const std::vector< double > &newBoundaries, const std::pair< double, double > &newPeriodicity)
Add a histogram.
size_t theAttemptedPoints
The total number of attempted points.
Definition: Run.h:147
void fromXML(const XML::Element &)
Fill run data from an XML element.
Element represents a (tree of) XML elements.
Definition: Element.h:56