Belle II Software development
ECLChargedPIDPhasespaceBinning Class Reference

Class to store the N dimensional phasespace binning of the MVA categorical training. More...

#include <ECLChargedPIDMVAWeights.h>

Inheritance diagram for ECLChargedPIDPhasespaceBinning:

Public Member Functions

 ECLChargedPIDPhasespaceBinning ()
 Default Constructor.
 
 ECLChargedPIDPhasespaceBinning (const std::vector< std::vector< float > > binEdges)
 Constructor.
 
 ~ECLChargedPIDPhasespaceBinning ()
 Destructor.
 
int getLinearisedBinIndex (const std::vector< float > values)
 Maps the vector of input values to a global bin index.
 

Private Member Functions

std::vector< int > getBinIndices (const std::vector< float > values)
 Maps the vector of input values to their bin index in N dimensions.
 
 ClassDef (ECLChargedPIDPhasespaceBinning, 1)
 ClassDef.
 

Private Attributes

std::vector< std::vector< float > > m_binEdges
 Vector of bin edges.
 
std::vector< int > m_nBins
 Vector of number of bins per dimension.
 

Detailed Description

Class to store the N dimensional phasespace binning of the MVA categorical training.

For example, 3D in (clusterTheta, p, charge).

Definition at line 36 of file ECLChargedPIDMVAWeights.h.

Constructor & Destructor Documentation

◆ ECLChargedPIDPhasespaceBinning() [1/2]

Default Constructor.

Needed for ROOT to stream the object.

Definition at line 43 of file ECLChargedPIDMVAWeights.h.

43{};

◆ ECLChargedPIDPhasespaceBinning() [2/2]

ECLChargedPIDPhasespaceBinning ( const std::vector< std::vector< float > > binEdges)
inline

Constructor.

Parameters
binEdgesvector of vectors of bin edges in the N dimensions.

Definition at line 49 of file ECLChargedPIDMVAWeights.h.

50 {
51 m_binEdges = binEdges;
52 for (auto dimensionBinEdges : binEdges) {
53 m_nBins.push_back(dimensionBinEdges.size() - 1);
54 }
55 }

◆ ~ECLChargedPIDPhasespaceBinning()

Destructor.

Definition at line 60 of file ECLChargedPIDMVAWeights.h.

60{};

Member Function Documentation

◆ getBinIndices()

std::vector< int > getBinIndices ( const std::vector< float > values)
inlineprivate

Maps the vector of input values to their bin index in N dimensions.

If the values lie outside the covered region -1 is returned.

Parameters
valuesN dimensional vector of values to be mapped to a global linear bin index.

Definition at line 88 of file ECLChargedPIDMVAWeights.h.

89 {
90 std::vector<int> binIndices(m_binEdges.size());
91
92 for (unsigned int i = 0; i < m_binEdges.size(); i++) {
93 std::vector<float> dimBinEdges = m_binEdges[i];
94 auto it = std::upper_bound(dimBinEdges.begin(), dimBinEdges.end(), values[i]);
95 if (it == dimBinEdges.end()) {
96 binIndices[i] = -1;
97 } else {
98 int index = std::distance(dimBinEdges.begin(), it) - 1;
99 binIndices[i] = index;
100 }
101 }
102 return binIndices;
103 }

◆ getLinearisedBinIndex()

int getLinearisedBinIndex ( const std::vector< float > values)
inline

Maps the vector of input values to a global bin index.

If any of the values lies outside the binning -1 is returned.

Parameters
valuesN dimensional vector of values to be mapped to a global linear bin index.

Definition at line 66 of file ECLChargedPIDMVAWeights.h.

67 {
68 int globalBin(-1);
69 std::vector<int> binIndices = getBinIndices(values);
70 for (unsigned int i = 0; i < binIndices.size(); i++) {
71 if (binIndices[i] < 0) return -1;
72 if (i == 0) {
73 globalBin = binIndices[i];
74 } else {
75 globalBin = globalBin * m_nBins[i] + binIndices[i];
76 }
77 }
78 return globalBin;
79 }

Member Data Documentation

◆ m_binEdges

std::vector<std::vector<float> > m_binEdges
private

Vector of bin edges.

One per dimension.

Definition at line 108 of file ECLChargedPIDMVAWeights.h.

◆ m_nBins

std::vector<int> m_nBins
private

Vector of number of bins per dimension.

Definition at line 113 of file ECLChargedPIDMVAWeights.h.


The documentation for this class was generated from the following file: