CovarianceBinUtility.h
Go to the documentation of this file.
1 //
2 // Created by Brian Rebel on 11/29/18.
3 // Utilities to handle mapping of bins to energy for covariance matrix applications
4 //
5 
6 #ifndef CMF_COVARIANCEBINUTILITY_H
7 #define CMF_COVARIANCEBINUTILITY_H
8 
9 // Framework includes
11 #include "cetlib_except/exception.h"
12 #include "fhiclcpp/ParameterSet.h"
13 
16 
17 #include "TMatrixD.h"
18 
19 #include <map>
20 
21 namespace cmf {
23 
24  public:
25 
27 
28  void Initialize(fhicl::ParameterSet const& pset);
29 
30  double const& NuMuLowEdge() { return fNuMuLowEdge; }
31  double const& NuELowEdge(cmf::MetaData const& md);
32  double const& NuELowEdge(cmf::SelectionType_t const& sel,
33  cmf::DetType_t const& det);
34  double const& NCLowEdge(cmf::DetType_t const& det);
35  double const& SelectionLowEdge(cmf::MetaData const& md);
36  double const& SelectionLowEdge(cmf::SelectionType_t const& sel,
37  cmf::DetType_t const& det);
38  std::map<double, int> const& NuMuHighEdges() { return fNuMuHighEdges; }
39  std::map<double, int> const& NuEHighEdges(cmf::DetType_t const& det);
40  std::map<double, int> const& NCHighEdges(cmf::DetType_t const& det);
41  std::map<double, int> const& SelectionHighEdges(cmf::MetaData const& md);
42  std::map<double, int> const& SelectionHighEdges(long const& key);
43  std::vector<cmf::DetBeamBins> const& DetectorBeamBins() { return fDBBins; }
44 
45  void SelectionHistBinning(cmf::MetaData const& md,
48  cmf::DetType_t const& det,
49  cmf::Spectrum & bins);
50 
51  int KeyToOffset (long const& key,
52  bool allSels=false);
53 
54  int EnergyToHistogramBin(double const& energy,
55  cmf::MetaData const& md);
56  int EnergyToBin (double const& energy,
57  cmf::MetaData const& md);
58  double BinToEnergy (int const& bin,
59  bool allSels=false);
60  int LogicalBinToSelectionBin(int logicalBin, cmf::MetaData md);
61 
62  cmf::DetType_t BinToDetector (int const& bin,
63  bool allSels=false);
64  cmf::SelectionType_t BinToSelection(int const& bin,
65  bool allSels=false);
66  cmf::BeamType_t BinToBeamType (int const& bin,
67  bool allSels=false);
68  long BinToKey (int const& bin,
69  bool allSels=false);
70 
71  size_t TotalBins(bool allSels=false);
72 
74  BeamType_t const& beamDetType_t);
75 
76  // Find Empty bins in a covariance matrix
77  std::vector<int> EmptyBins(TMatrixD mat);
78 
79  // removes any empty rows and colums from the matrix
80  TMatrixD CompactMatrix(TMatrixD mat, std::vector<int> emptyBins);
81 
82  private:
84 
86 
87  std::map<double, int> EnergyBinMap(std::vector<double> const& vec);
88 
89  void SetBinning(fhicl::ParameterSet const& fBinConfig, cmf::SelectionType_t const& selType);
90 
91  static void FillBinToEnergyMap(std::map<double, int> const& selectionHighEdges,
92  std::map<int, double> & selectionBinToEnergy,
93  double lowestBound);
94 
95  void FillOffsetAndBinMaps(std::map<long, int> & offsetMap,
96  std::vector<long> & binMap,
97  cmf::SelectionUtility::DetBeamSelSet const& detBeamSelSet);
98 
99  int NumSelectionBins(cmf::SelectionType_t const& selType,
100  cmf::DetType_t const& detType);
101 
102  int KeyToOffset(long const& key,
103  std::map<long, int> const& offsetMap);
104 
105  // Method to check things, usually commented out
106  //void CheckBinToEnergyMapping();
107 
108  std::map<int, double> const& SelectionBinToEnergy(long key);
109 
110  double fNuMuLowEdge; ///< low side of the first numu bin
111  std::map<double, int> fNuMuHighEdges; ///< high side of the numu bins
112  double fNuENDLowEdge; ///< low side of the first nue bin in ND
113  std::map<double, int> fNuENDHighEdges; ///< high side of the nue bins in ND
114  double fNuEFDLowEdge; ///< low side of the first nune bin in FD
115  std::map<double, int> fNuEFDHighEdges; ///< high side of the nue bins in FD
116  double fNuEPeriphLowEdge; ///< low side of the first nue bin in FD
117  std::map<double, int> fNuEPeriphHighEdges; ///< high side of the nue bins in FD
118  double fNCLowEdge; ///< low side of the first nc bin
119  std::map<double, int> fNCHighEdges; ///< high side of the nc bins
120  double fNCNDLowEdge; ///< low side of the first nc bin in ND
121  std::map<double, int> fNCNDHighEdges; ///< high side of the nc bins in ND (2020ana)
122  double fNCFDLowEdge; ///< low side of the first nc bin in FD
123  std::map<double, int> fNCFDHighEdges; ///< high side of the nc bins in FD (2020ana)
124  std::map<int, double> fNuMuBinToEnergy; ///< map energy bin to central value
125  std::map<int, double> fNuENDBinToEnergy; ///< map energy bin to central value
126  std::map<int, double> fNuEFDBinToEnergy; ///< map energy bin to central value
127  std::map<int, double> fNuEPeriphBinToEnergy; ///< map energy bin to central value
128  std::map<int, double> fNCNDBinToEnergy; ///< map energy bin to central value (2020ana)
129  std::map<int, double> fNCFDBinToEnergy; ///< map energy bin to central value (2020ana)
130  std::map<long, int> fOffsetMap; ///< map of keys to offset for different samples
131  std::map<long, int> fAllSelsOffsetMap; ///< map of keys to offset for different samples
132  std::vector<long> fBinToKey; ///< map bin numbers to keys for different samples
133  std::vector<long> fAllSelsBinToKey; ///< map bin numbers to keys for different samples
134  std::vector<cmf::DetBeamBins> fDBBins; ///< vector associating detector/beam with bins
135 
136  };
137 } // cmf namespace
138 
139 
140 #endif //CMF_COVARIANCEBINUTILITY_H
std::map< int, double > const & SelectionBinToEnergy(long key)
std::vector< int > EmptyBins(TMatrixD mat)
std::map< double, int > const & NuMuHighEdges()
int KeyToOffset(long const &key, bool allSels=false)
std::map< double, int > fNuMuHighEdges
high side of the numu bins
std::map< double, int > fNCHighEdges
high side of the nc bins
std::vector< cmf::DetBeamBins > fDBBins
vector associating detector/beam with bins
int LogicalBinToSelectionBin(int logicalBin, cmf::MetaData md)
double fNuEFDLowEdge
low side of the first nune bin in FD
double fNuMuLowEdge
low side of the first numu bin
double const & SelectionLowEdge(cmf::MetaData const &md)
void FillOffsetAndBinMaps(std::map< long, int > &offsetMap, std::vector< long > &binMap, cmf::SelectionUtility::DetBeamSelSet const &detBeamSelSet)
std::vector< double > Spectrum
Definition: Constants.h:746
TMatrixD CompactMatrix(TMatrixD mat, std::vector< int > emptyBins)
enum cmf::det_type DetType_t
std::vector< cmf::DetBeamBins > const & DetectorBeamBins()
long BinToKey(int const &bin, bool allSels=false)
void SelectionHistBinning(cmf::MetaData const &md, cmf::Spectrum &bins)
std::map< int, double > fNuEPeriphBinToEnergy
map energy bin to central value
std::map< int, double > fNuMuBinToEnergy
map energy bin to central value
void SetBinning(fhicl::ParameterSet const &fBinConfig, cmf::SelectionType_t const &selType)
enum cmf::sel_type SelectionType_t
std::map< double, int > EnergyBinMap(std::vector< double > const &vec)
double fNCNDLowEdge
low side of the first nc bin in ND
std::vector< long > fAllSelsBinToKey
map bin numbers to keys for different samples
std::map< int, double > fNCNDBinToEnergy
map energy bin to central value (2020ana)
int EnergyToBin(double const &energy, cmf::MetaData const &md)
double BinToEnergy(int const &bin, bool allSels=false)
std::map< double, int > fNuEPeriphHighEdges
high side of the nue bins in FD
cmf::DetBeamBins DetBeamToBins(DetType_t const &det, BeamType_t const &beamDetType_t)
std::map< double, int > fNCFDHighEdges
high side of the nc bins in FD (2020ana)
std::vector< long > fBinToKey
map bin numbers to keys for different samples
std::map< double, int > fNuEFDHighEdges
high side of the nue bins in FD
cmf::SelectionType_t BinToSelection(int const &bin, bool allSels=false)
double energy
Definition: plottest35.C:25
std::map< double, int > fNuENDHighEdges
high side of the nue bins in ND
void Initialize(fhicl::ParameterSet const &pset)
const Binning bins
Float_t mat
Definition: plot.C:39
std::map< double, int > const & NCHighEdges(cmf::DetType_t const &det)
std::map< long, int > fAllSelsOffsetMap
map of keys to offset for different samples
float bin[41]
Definition: plottest35.C:14
std::map< int, double > fNuENDBinToEnergy
map energy bin to central value
double fNuEPeriphLowEdge
low side of the first nue bin in FD
size_t TotalBins(bool allSels=false)
std::map< long, int > fOffsetMap
map of keys to offset for different samples
Module to combine a set of results into a single file currently only does one data product type at a ...
Definition: Event.cxx:24
double const & NuELowEdge(cmf::MetaData const &md)
std::map< double, int > const & SelectionHighEdges(cmf::MetaData const &md)
double const & NCLowEdge(cmf::DetType_t const &det)
std::map< int, double > fNuEFDBinToEnergy
map energy bin to central value
std::map< int, double > fNCFDBinToEnergy
map energy bin to central value (2020ana)
std::map< double, int > fNCNDHighEdges
high side of the nc bins in ND (2020ana)
cmf::DetType_t BinToDetector(int const &bin, bool allSels=false)
enum cmf::beam_type BeamType_t
int EnergyToHistogramBin(double const &energy, cmf::MetaData const &md)
static void FillBinToEnergyMap(std::map< double, int > const &selectionHighEdges, std::map< int, double > &selectionBinToEnergy, double lowestBound)
double fNuENDLowEdge
low side of the first nue bin in ND
std::set< cmf::SelectionUtility::DetBeamSels > DetBeamSelSet
double fNCLowEdge
low side of the first nc bin
double fNCFDLowEdge
low side of the first nc bin in FD
std::map< double, int > const & NuEHighEdges(cmf::DetType_t const &det)
int NumSelectionBins(cmf::SelectionType_t const &selType, cmf::DetType_t const &detType)
cmf::BeamType_t BinToBeamType(int const &bin, bool allSels=false)
static CovarianceBinUtility * Instance()