Public Member Functions | Protected Attributes | List of all members
ana::QuantileCutGenerator Class Reference

Class to Generate a ana::Cut that passes events that fall into the requested quantile in quantile axis. It is specialised via the constructor arguments. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-03-03/3FlavorAna/Cuts/QuantileCuts.h"

Public Member Functions

 QuantileCutGenerator (const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &quantile, const std::vector< std::vector< double >> &quantileBins)
 Class to Generate a Quantile ana::Cut that is specialised via the constructor arguments. More...
 
bool operator() (const caf::SRProxy *sr) const
 Defines the Cut this Instance generates. Returns true if the slice is in the quantile set in quantile. More...
 

Protected Attributes

HistAxis fIndependentAxis
 
HistAxis fQuantileAxis
 
unsigned int fQuantile
 
std::vector< std::vector< double > > fQuantileBins
 

Detailed Description

Class to Generate a ana::Cut that passes events that fall into the requested quantile in quantile axis. It is specialised via the constructor arguments.

Parameters
independentAxis- each bin on this axis will be treated independently (i.e. quantiles will be calculated for each independentAxis bin)
quantileAxis- the axis to split into quantiles. This is done separately for each independentAxis bin
quantile- the quantile to pass, other quantiles fail. The first quantile is 1
quantileBins- 2D array specifying quantileAxis quantile edges. 1st index is over independentAxis, second over quantile

Definition at line 56 of file QuantileCuts.h.

Constructor & Destructor Documentation

ana::QuantileCutGenerator::QuantileCutGenerator ( const HistAxis independentAxis,
const HistAxis quantileAxis,
const unsigned int quantile,
const std::vector< std::vector< double >> &  quantileBins 
)

Class to Generate a Quantile ana::Cut that is specialised via the constructor arguments.

Parameters
independentAxis- each bin on this axis will be split into the quantiles (i.e. a range of quantileAxis bins)
quantileAxis- the axis to split into quantiles. This is done separately for each independentAxis bin
quantile- the quantile to pass, other quantiles fail
quantileBins- 2D array specifying quantileAxis quantile edges. 1st index is over independentAxis, second over quantile

Definition at line 123 of file QuantileCuts.cxx.

References ana::assert(), om::cout, allTimeWatchdog::endl, fQuantile, fQuantileBins, ana::LabelsAndBins::NDimensions(), and gen_hdf5record::size.

Referenced by ana::QuantileCut().

126  :
127  fIndependentAxis(independentAxis), fQuantileAxis(quantileAxis), fQuantile(quantile), fQuantileBins(quantileBins)
128  {
129  if(independentAxis.NDimensions() != 1 ||
130  quantileAxis.NDimensions() != 1){
131  std::cout << "Error: QuantileCutGenerator not equipped for multi-dimensional axes." << std::endl;
132  abort();
133  }
134 
135  assert(fQuantileBins.size() > 0 && "fQuantileBins must have more than 0 bins in the independent variable");
136  //fQuantileBins[] has the TH1 binning schema
137  //fQuantileBins[].size = number of fQuantiles + 1 as we keep both the low edge and high edge
138  assert((fQuantile > 0 && fQuantile < fQuantileBins[0].size()) && "fQuantile must be > 0 and <= number of fQuantiles");
139  }
std::vector< std::vector< double > > fQuantileBins
Definition: QuantileCuts.h:70
unsigned int quantile(std::vector< std::vector< double >> v, float E, float hadEfrac)
Definition: Toy_analyses.C:480
OStream cout
Definition: OStream.cxx:6
assert(nhit_max >=nhit_nbins)

Member Function Documentation

bool ana::QuantileCutGenerator::operator() ( const caf::SRProxy sr) const

Defines the Cut this Instance generates. Returns true if the slice is in the quantile set in quantile.

Definition at line 141 of file QuantileCuts.cxx.

References ana::assert(), fIndependentAxis, fQuantile, fQuantileAxis, fQuantileBins, ana::LabelsAndBins::GetBinnings(), ana::_HistAxis< T >::GetVars(), makeTrainCVSamples::int, and sr.

141  {
142  double varX = fIndependentAxis.GetVars()[0](sr);
143  double varY = fQuantileAxis.GetVars()[0](sr);
144  unsigned int binX = (unsigned int)(fIndependentAxis.GetBinnings()[0].FindBin(varX));
145 
146  //fQuantileBins first index is independentAxis bin number, where 0 is underflow
147  assert(binX < fQuantileBins.size() && "binX >= fQuantileBins.size()");
148  std::vector<double> thisQuantilesBins = fQuantileBins[binX];
149  assert(fQuantile > 0 && fQuantile < thisQuantilesBins.size() && "fQuantile <= 0 || fQuantile >= thisQuantilesBins.size()");
150  double lowEdge=thisQuantilesBins[fQuantile-1];
151  double highEdge=thisQuantilesBins[fQuantile];
152  return varY >= lowEdge && varY < highEdge;
153  }
const std::vector< T > & GetVars() const
Definition: HistAxis.h:92
std::vector< std::vector< double > > fQuantileBins
Definition: QuantileCuts.h:70
caf::StandardRecord * sr
const std::vector< Binning > & GetBinnings() const
Definition: LabelsAndBins.h:69
assert(nhit_max >=nhit_nbins)

Member Data Documentation

HistAxis ana::QuantileCutGenerator::fIndependentAxis
protected

Definition at line 67 of file QuantileCuts.h.

Referenced by operator()().

unsigned int ana::QuantileCutGenerator::fQuantile
protected

Definition at line 69 of file QuantileCuts.h.

Referenced by operator()(), and QuantileCutGenerator().

HistAxis ana::QuantileCutGenerator::fQuantileAxis
protected

Definition at line 68 of file QuantileCuts.h.

Referenced by operator()().

std::vector<std::vector<double> > ana::QuantileCutGenerator::fQuantileBins
protected

Definition at line 70 of file QuantileCuts.h.

Referenced by operator()(), and QuantileCutGenerator().


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