herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
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 
13 namespace 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 
116  double sumOfSquaredWeights() const { return theSumOfSquaredWeights; }
117 
118  public:
119 
123  Run& operator+=(const Run& other);
124 
125  public:
126 
130  void fromXML(const XML::Element&);
131 
135  XML::Element toXML() const;
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.
void reset()
Reset this run.
void finalize(size_t newAttemptedPoints)
Finalize this run.
Histogram & histogram(const std::string &histoName)
Return a given histogram.
Definition: Bin.h:16
Run & operator+=(const Run &other)
Add a run to this run.
double sumOfSquaredWeights() const
The sum of squared weights.
Definition: Run.h:116
Histogram & addHistogram(const std::string &newName, const std::vector< double > &newBoundaries)
Add a histogram.
void fromXML(const XML::Element &)
Fill run data from an XML element.
A simulation run.
Definition: Run.h:19
double theSumOfWeights
The sum of weights.
Definition: Run.h:152
void count(double weight)
Add a point to this run.
Definition: Run.h:60
void name(const std::string &newName)
Set the name of the run.
Definition: Run.h:101
const std::string & name() const
Return the name of the run.
Definition: Run.h:96
Run()
Default constructor.
std::string theName
The name of the run.
Definition: Run.h:142
Element represents a (tree of) XML elements.
Definition: Element.h:56
double sumOfWeights() const
The sum of weights.
Definition: Run.h:111
void initialize()
Initialize this run.
double theSumOfSquaredWeights
The sum of squared weights.
Definition: Run.h:157
XML::Element toXML() const
Return an XML element for the data of this run.
const std::map< std::string, Histogram > & histograms() const
Return the histograms.
Definition: Run.h:91
size_t theAttemptedPoints
The total number of attempted points.
Definition: Run.h:147
size_t attemptedPoints() const
Return the total number of attempted points.
Definition: Run.h:106
std::map< std::string, Histogram > theHistograms
The histograms.
Definition: Run.h:162
virtual ~Run()
Destructor.