Hammer
1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
|
Multidimensional histogram class with Tensor as cell bins. More...
#include <Histogram.hh>
Classes | |
class | Bin |
Bin class with Tensor contents. More... | |
Public Types | |
using | DataType = std::vector< Bin > |
using | ElementType = Bin |
using | reference = ElementType & |
using | const_reference = const ElementType & |
using | iterator = DataType::iterator |
using | const_iterator = DataType::const_iterator |
Public Member Functions | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
reference | operator[] (PositionType pos) |
const_reference | operator[] (PositionType pos) const |
size_t | rank () const |
dimensionality of the histograms More... | |
IndexType | dim (IndexType index) const |
dimension of a specific coordinate More... | |
const IndexList & | dims () const |
get the dimensions of all the coordinates at once More... | |
const std::string & | name () const |
get the histogram name More... | |
template<typename... Args> | |
void | fillBin (const Tensor &value, Args...rest) |
set the value of a histogram bin based on the bin indices More... | |
void | fillBin (const Tensor &value, const IndexList &position) |
set the value of a histogram bin based on the bin indices More... | |
void | clear () |
reset the histogram More... | |
void | clearData () |
reset the histogram contents but not the shape of the histogram More... | |
template<typename... Args> | |
const Tensor & | getWeight (Args...rest) const |
get the value of a histogram bin based on an index of the bin More... | |
template<typename... Args> | |
const Tensor & | getSquaredWeight (Args...rest) const |
get the value of a histogram bin based on an index of the bin More... | |
template<typename... Args> | |
size_t | getNumEvents (Args...rest) const |
get the value of a histogram bin based on an index of the bin More... | |
Histogram & | operator+= (const Histogram &other) |
std::unique_ptr < Serial::FBHistogramBuilder > | write (flatbuffers::FlatBufferBuilder *msgwriter) const |
write the contents of the histogram for serialization More... | |
void | read (const Serial::FBHistogram *msgreader, const HistogramDefinition &def) |
read the contents of the histogram for serialization More... | |
const LabelsList & | getLabelVector () const |
IOHistogram | evalToList (const Tensor &externalData) const |
std::unique_ptr< Histogram > | collapseIntoNew (const std::string &newName, const HistogramDefinition &newDef, const std::set< uint16_t > &collapsedIndexPositions) const |
Constructors | |
Histogram () | |
constructor More... | |
Histogram (const Histogram &other)=default | |
Histogram & | operator= (const Histogram &other)=default |
Histogram (Histogram &&other)=default | |
Histogram & | operator= (Histogram &&other)=default |
virtual | ~Histogram () |
destructor More... | |
Protected Member Functions | |
Bin & | element (const IndexList &indices) |
convert the indices into the position in the flattened contents into vector organized as row-major More... | |
const Bin & | element (const IndexList &indices) const |
access an element given its coordinates (const version) More... | |
size_t | numValues () const |
the number of elements (product of all the dimensions) More... | |
Log & | getLog () const |
logging facility More... | |
Private Member Functions | |
void | setDefinition (const HistogramDefinition &def) |
set the dimensions of the various coordinates More... | |
void | setName (const std::string &name) |
give the histogram a name More... | |
void | setDefaultValue (const Tensor &value) |
set the value to be used for out-of-bounds coordinates if extrapolation is off More... | |
void | setDefaultValue (const IndexList &defaultDims, const LabelsList &defaultLabels) |
void | initHistogram () |
allocate and initialize the histogram More... | |
Private Attributes | |
const HistogramDefinition * | _definition |
DataType | _data |
std::string | _name |
MultiDimensional::LabeledIndexing < MultiDimensional::AlignedIndexing > | _defaultTensorIndexing |
std::string | _defaultTensorName |
bool | _initialized |
whether the grid is initialized More... | |
Friends | |
std::unique_ptr< Histogram > | makeHistogram (const std::string &, const HistogramDefinition &, const Tensor &) |
std::unique_ptr< Histogram > | makeHistogram (const std::string &, const HistogramDefinition &, const IndexList &, const LabelsList &) |
Related Functions | |
(Note that these are not member functions.) | |
makeHistogram | |
makeHistogram | |
Multidimensional histogram class with Tensor as cell bins.
Contains the tensor version of an histogram defined by the user
Definition at line 39 of file Histogram.hh.
using Hammer::Histogram::const_iterator = DataType::const_iterator |
Definition at line 126 of file Histogram.hh.
using Hammer::Histogram::const_reference = const ElementType& |
Definition at line 123 of file Histogram.hh.
using Hammer::Histogram::DataType = std::vector<Bin> |
Definition at line 120 of file Histogram.hh.
using Hammer::Histogram::ElementType = Bin |
Definition at line 121 of file Histogram.hh.
using Hammer::Histogram::iterator = DataType::iterator |
Definition at line 125 of file Histogram.hh.
using Hammer::Histogram::reference = ElementType& |
Definition at line 122 of file Histogram.hh.
Hammer::Histogram::Histogram | ( | ) |
constructor
[in] | withErrors | whether to track squared weights |
Definition at line 95 of file Histogram.cc.
|
default |
|
default |
|
virtual |
destructor
Definition at line 99 of file Histogram.cc.
Histogram::iterator Hammer::Histogram::begin | ( | ) |
Definition at line 111 of file Histogram.cc.
Histogram::const_iterator Hammer::Histogram::begin | ( | ) | const |
Definition at line 115 of file Histogram.cc.
void Hammer::Histogram::clear | ( | ) |
reset the histogram
Definition at line 171 of file Histogram.cc.
void Hammer::Histogram::clearData | ( | ) |
reset the histogram contents but not the shape of the histogram
Definition at line 216 of file Histogram.cc.
unique_ptr< Histogram > Hammer::Histogram::collapseIntoNew | ( | const std::string & | newName, |
const HistogramDefinition & | newDef, | ||
const std::set< uint16_t > & | collapsedIndexPositions | ||
) | const |
Definition at line 375 of file Histogram.cc.
dimension of a specific coordinate
[in] | index | the coordinate index |
Definition at line 143 of file Histogram.cc.
const IndexList & Hammer::Histogram::dims | ( | ) | const |
get the dimensions of all the coordinates at once
Definition at line 147 of file Histogram.cc.
|
protected |
convert the indices into the position in the flattened contents into vector organized as row-major
[in] | indices | index of coordinate in multidimensional histogram |
[in] | indices | the list of coordinates, 0-based |
Definition at line 189 of file Histogram.cc.
|
protected |
access an element given its coordinates (const version)
[in] | indices | the list of coordinates, 0-based |
Definition at line 199 of file Histogram.cc.
Histogram::iterator Hammer::Histogram::end | ( | ) |
Definition at line 119 of file Histogram.cc.
Histogram::const_iterator Hammer::Histogram::end | ( | ) | const |
Definition at line 123 of file Histogram.cc.
IOHistogram Hammer::Histogram::evalToList | ( | const Tensor & | externalData | ) | const |
void Hammer::Histogram::fillBin | ( | const Tensor & | value, |
Args... | rest | ||
) |
set the value of a histogram bin based on the bin indices
[in] | value | value of the bin |
[in] | rest | variadic argument with remaining indices |
Definition at line 22 of file HistogramDefs.hh.
set the value of a histogram bin based on the bin indices
[in] | value | value of the bin |
[in] | position | list of coordinates |
Definition at line 181 of file Histogram.cc.
const LabelsList & Hammer::Histogram::getLabelVector | ( | ) | const |
Definition at line 329 of file Histogram.cc.
|
protected |
size_t Hammer::Histogram::getNumEvents | ( | Args... | rest | ) | const |
get the value of a histogram bin based on an index of the bin
[in] | rest | variadic argument with remaining indices |
Definition at line 41 of file HistogramDefs.hh.
const Tensor & Hammer::Histogram::getSquaredWeight | ( | Args... | rest | ) | const |
get the value of a histogram bin based on an index of the bin
[in] | rest | variadic argument with remaining indices |
Definition at line 36 of file HistogramDefs.hh.
const Tensor & Hammer::Histogram::getWeight | ( | Args... | rest | ) | const |
get the value of a histogram bin based on an index of the bin
[in] | rest | variadic argument with remaining indices |
Definition at line 31 of file HistogramDefs.hh.
|
private |
allocate and initialize the histogram
Definition at line 209 of file Histogram.cc.
const string & Hammer::Histogram::name | ( | ) | const |
|
protected |
the number of elements (product of all the dimensions)
Definition at line 135 of file Histogram.cc.
Histogram::reference Hammer::Histogram::operator[] | ( | PositionType | pos | ) |
Definition at line 127 of file Histogram.cc.
Histogram::const_reference Hammer::Histogram::operator[] | ( | PositionType | pos | ) | const |
Definition at line 131 of file Histogram.cc.
size_t Hammer::Histogram::rank | ( | ) | const |
dimensionality of the histograms
Definition at line 139 of file Histogram.cc.
void Hammer::Histogram::read | ( | const Serial::FBHistogram * | msgreader, |
const HistogramDefinition & | def | ||
) |
read the contents of the histogram for serialization
[in] | msgreader | the reader object |
[in] | def | the location where to write |
Definition at line 269 of file Histogram.cc.
|
private |
set the value to be used for out-of-bounds coordinates if extrapolation is off
[in] | value | the default value |
Definition at line 155 of file Histogram.cc.
|
private |
Definition at line 163 of file Histogram.cc.
|
private |
set the dimensions of the various coordinates
[in] | def | the dimensions list (its size specifies the histogram dimensionality) |
Definition at line 107 of file Histogram.cc.
|
private |
unique_ptr< Serial::FBHistogramBuilder > Hammer::Histogram::write | ( | flatbuffers::FlatBufferBuilder * | msgwriter | ) | const |
write the contents of the histogram for serialization
[in] | msgwriter | the writer object |
Definition at line 225 of file Histogram.cc.
|
friend |
Definition at line 393 of file Histogram.cc.
|
friend |
Definition at line 402 of file Histogram.cc.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[in] | name | |
[in] | def | |
[in] | defaultValue |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[in] | name | |
[in] | def | |
[in] | defaultTensorDims | |
[in] | defaultTensorLabels |
|
private |
Definition at line 268 of file Histogram.hh.
|
private |
Definition at line 272 of file Histogram.hh.
|
private |
Definition at line 273 of file Histogram.hh.
|
private |
Definition at line 267 of file Histogram.hh.
|
private |
whether the grid is initialized
Definition at line 276 of file Histogram.hh.
|
private |
Definition at line 270 of file Histogram.hh.