herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Utilities
Statistics
Statistics/Histogram.h
1
// -*- C++ -*-
2
//
3
// Histogram.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_Histogram_hpp_included
9
#define MYSTATISTICS_Histogram_hpp_included
10
11
#include <map>
12
#include <vector>
13
#include <string>
14
#include <iostream>
15
16
#include "EventContribution.h"
17
#include "Bin.h"
18
19
namespace
Statistics {
20
25
class
Histogram
{
26
27
public
:
28
32
Histogram
();
33
37
virtual
~Histogram
();
38
43
Histogram
(
const
std::string& newName,
44
const
std::vector<double>& newBoundaries,
45
bool
newNoUnderflow =
false
,
46
bool
newNoOverflow =
false
);
47
52
Histogram
(
const
std::string& newName,
53
const
std::vector<double>& newBoundaries,
54
const
std::pair<double,double>& newPeriodicity);
55
59
static
std::vector<double>
regularBinEdges
(
double
lower,
double
upper,
size_t
nBins);
60
64
static
std::vector<double>
logBinEdges
(
double
lower,
double
upper,
size_t
nBins);
65
66
public
:
67
71
void
initialize
();
72
76
void
reset
();
77
81
void
finalize
();
82
83
public
:
84
88
bool
count
(
EventContribution
event,
size_t
id
);
89
90
public
:
91
95
bool
isCompatible
(
const
Histogram
& other)
const
;
96
100
Histogram
&
operator+=
(
const
Histogram
& other);
101
105
Histogram
&
operator-=
(
const
Histogram
& other);
106
107
public
:
108
112
const
std::string&
name
()
const
{
return
theName
; }
113
117
const
Bin
&
underflow
()
const
{
return
theUnderflow
; }
118
122
const
std::vector<Bin>&
bins
()
const
{
return
theBins
; }
123
127
const
Bin
&
overflow
()
const
{
return
theOverflow
; }
128
132
bool
noUnderflow
()
const
{
return
theNoUnderflow
; }
133
137
bool
noOverflow
()
const
{
return
theNoOverflow
; }
138
139
143
bool
isPeriodic
()
const
{
return
theIsPeriodic
; }
144
148
const
std::pair<double,double>&
periodicity
()
const
{
return
thePeriodicity
; }
149
150
public
:
151
155
void
fromXML
(
const
XML::Element
&);
156
160
XML::Element
toXML
()
const
;
161
162
private
:
163
167
std::string
theName
;
168
172
Bin
theUnderflow
;
173
177
std::vector<Bin>
theBins
;
178
182
Bin
theOverflow
;
183
187
bool
theNoUnderflow
;
188
192
bool
theNoOverflow
;
193
197
bool
theIsPeriodic
;
198
202
std::pair<double,double>
thePeriodicity
;
203
207
void
fillBinMap
();
208
212
Bin
&
binByIndex
(
int
);
213
217
std::map<double,int>
binMap
;
218
219
};
220
221
}
222
223
#endif
// MYSTATISTICS_Histogram_hpp_included
Statistics::Bin
A bin in a (one dimensional) histogram.
Definition:
Bin.h:23
Statistics::EventContribution
A pointlike or boxlike eventContribution; serves to define the EventContribution concept.
Definition:
EventContribution.h:19
Statistics::Histogram
A (one dimensional) histogram.
Definition:
Statistics/Histogram.h:25
Statistics::Histogram::theName
std::string theName
The id of the histogram.
Definition:
Statistics/Histogram.h:167
Statistics::Histogram::theUnderflow
Bin theUnderflow
The underflow bin.
Definition:
Statistics/Histogram.h:172
Statistics::Histogram::finalize
void finalize()
Finalize this histogram.
Statistics::Histogram::operator+=
Histogram & operator+=(const Histogram &other)
Add a histogram to this histogram.
Statistics::Histogram::isPeriodic
bool isPeriodic() const
Return true, if the quantity considered is periodic.
Definition:
Statistics/Histogram.h:143
Statistics::Histogram::count
bool count(EventContribution event, size_t id)
Book a contribution to the current event.
Statistics::Histogram::theNoUnderflow
bool theNoUnderflow
True, if there is no underflow.
Definition:
Statistics/Histogram.h:187
Statistics::Histogram::bins
const std::vector< Bin > & bins() const
Return the bins.
Definition:
Statistics/Histogram.h:122
Statistics::Histogram::underflow
const Bin & underflow() const
Return the underflow bin.
Definition:
Statistics/Histogram.h:117
Statistics::Histogram::theBins
std::vector< Bin > theBins
The bins.
Definition:
Statistics/Histogram.h:177
Statistics::Histogram::toXML
XML::Element toXML() const
Return an XML element for the data of this histogram.
Statistics::Histogram::noOverflow
bool noOverflow() const
True, if there is no overflow.
Definition:
Statistics/Histogram.h:137
Statistics::Histogram::operator-=
Histogram & operator-=(const Histogram &other)
Subtract a histogram from this histogram.
Statistics::Histogram::noUnderflow
bool noUnderflow() const
True, if there is no underflow.
Definition:
Statistics/Histogram.h:132
Statistics::Histogram::Histogram
Histogram(const std::string &newName, const std::vector< double > &newBoundaries, bool newNoUnderflow=false, bool newNoOverflow=false)
Constructor giving a name and bin boundaries; bin boundaries are subsequent boundaries.
Statistics::Histogram::theNoOverflow
bool theNoOverflow
True, if there is no overflow.
Definition:
Statistics/Histogram.h:192
Statistics::Histogram::thePeriodicity
std::pair< double, double > thePeriodicity
The periodicity of the quantity considered.
Definition:
Statistics/Histogram.h:202
Statistics::Histogram::binMap
std::map< double, int > binMap
Map bin upper boundaries to bins.
Definition:
Statistics/Histogram.h:217
Statistics::Histogram::theIsPeriodic
bool theIsPeriodic
True, if the quantity considered is periodic.
Definition:
Statistics/Histogram.h:197
Statistics::Histogram::binByIndex
Bin & binByIndex(int)
Return a bin by index.
Statistics::Histogram::fromXML
void fromXML(const XML::Element &)
Fill histogram data from an XML element.
Statistics::Histogram::regularBinEdges
static std::vector< double > regularBinEdges(double lower, double upper, size_t nBins)
Create equally spaced bin edges.
Statistics::Histogram::Histogram
Histogram()
Default constructor.
Statistics::Histogram::overflow
const Bin & overflow() const
Return the overflow bin.
Definition:
Statistics/Histogram.h:127
Statistics::Histogram::logBinEdges
static std::vector< double > logBinEdges(double lower, double upper, size_t nBins)
Create logarithmicaly spaced bin edges.
Statistics::Histogram::isCompatible
bool isCompatible(const Histogram &other) const
Return true, if this histogram is compatible with another one.
Statistics::Histogram::initialize
void initialize()
Initialize this histogram.
Statistics::Histogram::periodicity
const std::pair< double, double > & periodicity() const
Return the periodicity interval, if appropriate.
Definition:
Statistics/Histogram.h:148
Statistics::Histogram::reset
void reset()
Reset this histogram.
Statistics::Histogram::name
const std::string & name() const
Return the id of the histogram.
Definition:
Statistics/Histogram.h:112
Statistics::Histogram::Histogram
Histogram(const std::string &newName, const std::vector< double > &newBoundaries, const std::pair< double, double > &newPeriodicity)
Constructor giving a name, bin boundaries and periodicity interval; bin boundaries are subsequent bou...
Statistics::Histogram::theOverflow
Bin theOverflow
The overflow bin.
Definition:
Statistics/Histogram.h:182
Statistics::Histogram::fillBinMap
void fillBinMap()
Fill the bin map.
Statistics::Histogram::~Histogram
virtual ~Histogram()
Destructor.
XML::Element
Element represents a (tree of) XML elements.
Definition:
Element.h:56
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6