herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
Distribution.h
1 // -*- C++ -*-
2 //
3 // Distribution.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_Distribution_hpp_included
9 #define MYSTATISTICS_Distribution_hpp_included
10 
11 #include "Histogram.h"
12 
13 #include <iostream>
14 
15 namespace Statistics {
16 
21  class Distribution {
22 
23  public:
24 
28  struct DistributionBin {
29 
34 
39  DistributionBin(const Bin& bin,
40  double nPoints);
41 
46 
51 
56 
61 
65  void fromXML(const XML::Element&);
66 
70  XML::Element toXML() const;
71 
75  std::pair<double,double> boundaries;
76 
80  double value;
81 
85  double errorSquared;
86 
87  };
88 
89  public:
90 
94  Distribution();
95 
99  explicit Distribution(const Histogram& histo,
100  double nPoints);
101 
105  virtual ~Distribution();
106 
107  public:
108 
112  const std::string& name() const { return theName; }
113 
117  const std::vector<DistributionBin>& bins() const { return theBins; }
118 
119  public:
120 
124  bool isCompatible(const Distribution& other) const;
125 
129  Distribution& operator+=(const Distribution& other);
130 
134  Distribution& operator-=(const Distribution& other);
135 
139  Distribution& operator*=(const Distribution& other);
140 
144  Distribution& operator/=(const Distribution& other);
145 
146  public:
147 
151  void fromXML(const XML::Element&);
152 
156  XML::Element toXML() const;
157 
158  public:
159 
164  void toMakePlots(const std::string& analysis,
165  const std::string& options = "") const;
166 
171  void toMakePlots(const std::string& analysis,
172  const Distribution& lower,
173  const Distribution& upper,
174  const std::string& options = "") const;
175 
180  void appendToMakePlots(std::ostream& os,
181  const std::string& analysis,
182  const std::string& options = "") const;
183 
188  void appendToMakePlots(std::ostream& os,
189  const std::string& analysis,
190  const Distribution& lower,
191  const Distribution& upper,
192  const std::string& options = "") const;
193 
194  private:
195 
199  std::string theName;
200 
204  std::vector<DistributionBin> theBins;
205 
206  };
207 
208 }
209 
210 #endif // MYSTATISTICS_Distribution_hpp_included
A (one dimensional) histogram.
A (one dimensional) distribution.
Definition: Distribution.h:21
A bin in a (one dimensional) histogram.
Definition: Bin.h:22
DistributionBin & operator*=(const DistributionBin &other)
Multiply two distributionBins.
Distribution()
Default constructor.
DistributionBin & operator/=(const DistributionBin &other)
Divide two distributionBins.
void appendToMakePlots(std::ostream &os, const std::string &analysis, const std::string &options="") const
Write out data ready for make-plots, given an analysis name and plot options.
Definition: Bin.h:16
XML::Element toXML() const
Return an XML element for the data of this distribution.
std::string theName
The name of the distribution.
Definition: Distribution.h:199
double errorSquared
The bin error squared.
Definition: Distribution.h:85
Element represents a (tree of) XML elements.
Definition: Element.h:56
const std::string & name() const
Return the name of the distribution.
Definition: Distribution.h:112
std::vector< DistributionBin > theBins
The bins in the distribution.
Definition: Distribution.h:204
DistributionBin & operator+=(const DistributionBin &other)
Add two distributionBins.
virtual ~Distribution()
Destructor.
DistributionBin & operator-=(const DistributionBin &other)
Subtract two distributionBins.
void toMakePlots(const std::string &analysis, const std::string &options="") const
Write out data ready for make-plots, given an analysis name and plot options.
void fromXML(const XML::Element &)
Fill distribution data from an XML element.
std::pair< double, double > boundaries
The bin boundaries.
Definition: Distribution.h:75
bool isCompatible(const Distribution &other) const
Return true, if this distribution is compatible with another one.
const std::vector< DistributionBin > & bins() const
Return the bins in the distribution.
Definition: Distribution.h:117