![]() |
MaCh3
2.4.2
Reference Guide
|
KS: Class handling binning for multiple samples. More...
#include <Samples/BinningHandler.h>
Public Member Functions | |
| BinningHandler () | |
| Constructor. More... | |
| virtual | ~BinningHandler () |
| destructor More... | |
| int | FindGlobalBin (const int iSample, const std::vector< const double * > &KinVar, const std::vector< int > &NomBin) const |
| Find Global bin including. More... | |
| int | FindNominalBin (const int iSample, const int iDim, const double Var) const |
| Find the nominal bin for a given variable in a given sample and dimension. More... | |
| int | GetGlobalBinSafe (const int iSample, const std::vector< int > &Bins) const |
| Get gloabl bin based on sample, and dimension of each sample with additional checks. More... | |
| int | GetBinSafe (const int iSample, const std::vector< int > &Bins) const |
| Get gloabl bin based on sample, and dimension of each sample without any safety checks. More... | |
| int | GetNBins () const |
| Get total number of bins over all samples/kinematic bins etc. More... | |
| int | GetNBins (const int iSample) const |
| Get total number of bins over for a given sample. More... | |
| std::string | GetBinName (const int GlobalBin) const |
| Get fancy name for a given bin, to help match it with global properties. More... | |
| std::string | GetBinName (const int iSample, const int SampleBin) const |
| Get fancy name for a given bin, to help match it with global properties. More... | |
| std::string | GetBinName (const int iSample, const std::vector< int > &Bins) const |
| Get fancy name for a given bin, to help match it with global properties. More... | |
| std::vector< double > | GetBinEdges (const int iSample, const int iDim) const |
| Get N-dim bin edges for a given sample. More... | |
| int | GetNAxisBins (const int iSample, const int iDim) const |
| Get Number of N-axis bins for a given sample. More... | |
| bool | IsUniform (const int iSample) const |
| Tells whether given sample is using unform binning. More... | |
| int | GetSampleStartBin (const int iSample) const |
| Get bin number corresponding to where given sample starts. More... | |
| int | GetSampleEndBin (const int iSample) const |
| Get bin number corresponding to where given sample ends. More... | |
| const std::vector< BinInfo > | GetNonUniformBins (const int iSample) const |
| Return NonUnifomr bins to for example check extent etc. More... | |
| void | SetGlobalBinNumbers () |
| Sets the GlobalOffset for each SampleBinningInfo to enable linearization of multiple 2D binning samples. More... | |
| void | SetupSampleBinning (const YAML::Node &Settings, SampleInfo &SingleSample) |
| Function to setup the binning of your sample histograms and the underlying arrays that get handled in fillArray() and fillArray_MP(). More... | |
Private Attributes | |
| int | TotalNumberOfBins |
| Total number of bins. More... | |
| std::vector< SampleBinningInfo > | SampleBinning |
| Binning info for individual sample. More... | |
KS: Class handling binning for multiple samples.
Each sample can define its own binning in an arbitrary number of dimensions. Internally, every sample's multi-dimensional binning is linearised into a single 1D array. All samples are then concatenated into one global bin index space, allowing the entire analysis to be treated as a single large vector of bins.
The concept of a "global bin" refers to the position of a bin in this linearised, analysis-wide bin index space. Local (sample) bins are always enumerated starting from zero, while global bins span all samples consecutively.
Example layout of global bins with offsets:
MaCh3 supports Uniform and Non-Uniform binning scheme
In the non-uniform scheme, bin sizes may vary along each dimension, but all bins are required to be axis-aligned hyper-rectangles. Arbitrary or irregular bin shapes are not supported like banana-shape.
Example of Uniform
Example of Non-Uniform
Since MaCh3 supports event migration bin finding algorithm must be fast to efficiently be able find bin during running fit. MaCh3 is caching nominal bin with idea that during fit migration should be around this nominal bin. Thus MaCh3 first checks if after shift event falls into Nom-bin and later adjacent. If not backs to binary search.
In case of uniform binning above algorithm is easy to test as one performs it for every dimension independently i.e. find X-bin, then Y etc. After which can find bin in flattened 1D space.
Internally, non-uniform binning is implemented using two levels:
For a given event, the bin-finding algorithm proceeds as follows:
Definition at line 121 of file BinningHandler.h.
| BinningHandler::BinningHandler | ( | ) |
Constructor.
Definition at line 4 of file BinningHandler.cpp.
|
inlinevirtual |
| int BinningHandler::FindGlobalBin | ( | const int | iSample, |
| const std::vector< const double * > & | KinVar, | ||
| const std::vector< int > & | NomBin | ||
| ) | const |
Find Global bin including.
| iSample | index of a given sample |
| KinVar | Vector of pointers to kinematic variable like Erec |
| NomBin | Vector of nominal bin indices for this event, one per dimension. |
Definition at line 42 of file BinningHandler.cpp.
| int BinningHandler::FindNominalBin | ( | const int | iSample, |
| const int | iDim, | ||
| const double | Var | ||
| ) | const |
Find the nominal bin for a given variable in a given sample and dimension.
| iSample | Sample index |
| iDim | Dimension index (0 = X, 1 = Y, ...) |
| Var | Kinematic variable value |
Definition at line 79 of file BinningHandler.cpp.
|
inline |
Get N-dim bin edges for a given sample.
| iSample | index of a given sample |
| iDim | dimension for which we extract bin edges |
Definition at line 171 of file BinningHandler.h.
| std::string BinningHandler::GetBinName | ( | const int | GlobalBin | ) | const |
Get fancy name for a given bin, to help match it with global properties.
| GlobalBin | Global Bin integrated over all samples |
Definition at line 210 of file BinningHandler.cpp.
| std::string BinningHandler::GetBinName | ( | const int | iSample, |
| const int | SampleBin | ||
| ) | const |
Get fancy name for a given bin, to help match it with global properties.
| iSample | index of a given sample |
| SampleBin | Global Bin for a given sample |
Definition at line 156 of file BinningHandler.cpp.
| std::string BinningHandler::GetBinName | ( | const int | iSample, |
| const std::vector< int > & | Bins | ||
| ) | const |
Get fancy name for a given bin, to help match it with global properties.
| iSample | index of a given sample |
| Bins | Vector of bin indices along each dimension |
Definition at line 144 of file BinningHandler.cpp.
| int BinningHandler::GetBinSafe | ( | const int | iSample, |
| const std::vector< int > & | Bins | ||
| ) | const |
Get gloabl bin based on sample, and dimension of each sample without any safety checks.
| iSample | index of a given sample |
| Bins | Vector of bin indices along each dimension |
Definition at line 95 of file BinningHandler.cpp.
| int BinningHandler::GetGlobalBinSafe | ( | const int | iSample, |
| const std::vector< int > & | Bins | ||
| ) | const |
Get gloabl bin based on sample, and dimension of each sample with additional checks.
| iSample | index of a given sample |
| Bins | Vector of bin indices along each dimension |
Definition at line 102 of file BinningHandler.cpp.
| int BinningHandler::GetNAxisBins | ( | const int | iSample, |
| const int | iDim | ||
| ) | const |
Get Number of N-axis bins for a given sample.
| iSample | index of a given sample |
| iDim | dimension for which we extract number of bins |
Definition at line 218 of file BinningHandler.cpp.
|
inline |
Get total number of bins over all samples/kinematic bins etc.
Definition at line 153 of file BinningHandler.h.
|
inline |
| const std::vector< BinInfo > BinningHandler::GetNonUniformBins | ( | const int | iSample | ) | const |
Return NonUnifomr bins to for example check extent etc.
Definition at line 237 of file BinningHandler.cpp.
| int BinningHandler::GetSampleEndBin | ( | const int | iSample | ) | const |
Get bin number corresponding to where given sample ends.
| iSample | index of a given sample |
Definition at line 115 of file BinningHandler.cpp.
| int BinningHandler::GetSampleStartBin | ( | const int | iSample | ) | const |
Get bin number corresponding to where given sample starts.
| iSample | index of a given sample |
Definition at line 109 of file BinningHandler.cpp.
| bool BinningHandler::IsUniform | ( | const int | iSample | ) | const |
Tells whether given sample is using unform binning.
| iSample | index of a given sample |
Definition at line 230 of file BinningHandler.cpp.
| void BinningHandler::SetGlobalBinNumbers | ( | ) |
Sets the GlobalOffset for each SampleBinningInfo to enable linearization of multiple 2D binning samples.
Definition at line 126 of file BinningHandler.cpp.
| void BinningHandler::SetupSampleBinning | ( | const YAML::Node & | Settings, |
| SampleInfo & | SingleSample | ||
| ) |
Function to setup the binning of your sample histograms and the underlying arrays that get handled in fillArray() and fillArray_MP().
Definition at line 13 of file BinningHandler.cpp.
|
private |
Binning info for individual sample.
Definition at line 199 of file BinningHandler.h.
|
private |
Total number of bins.
Definition at line 197 of file BinningHandler.h.