1 #ifndef THINSLICESAMPLE_hh 2 #define THINSLICESAMPLE_hh 8 #include "TDirectory.h" 26 const std::vector<fhicl::ParameterSet> & selections,
27 const std::vector<double> & incident_bins,
28 const std::vector<double> & true_incident_bins,
29 size_t beam_energy_bin,
30 bool is_signal =
false, std::pair<double, double> range = {0., 0.});
40 const std::map<int, std::vector<TH1 *>> &
45 const std::map<int, std::vector<TSpline3 *>> &
50 const std::map<std::string, std::map<int, std::vector<TSpline3 *>>> &
80 for (
size_t i = 0; i < it->second.size(); ++i) {
81 TCanvas
c(it->second[i]->GetName(),
"");
82 it->second[i]->Draw();
84 c.Write(syst_name.c_str());
142 const std::vector<double> & vals) {
145 std::string message =
"ThinSliceSample: Input systematic shift values and number of shift hists differ";
146 throw std::runtime_error(message);
149 for (
size_t i = 0; i < vals.size(); ++i) {
156 const std::vector<double> & vals,
157 const std::vector<double> & weights) {
160 std::string message =
"ThinSliceSample: Input systematic shift values and number of shift hists differ";
161 throw std::runtime_error(message);
164 for (
size_t i = 0; i < vals.size(); ++i) {
177 std::vector<TH1*>
hists = it2->second;
179 for (
int i = 1; i <= selection_hist->GetNbinsX(); ++i) {
180 std::vector<double> vars;
181 for (
size_t j = 0; j < hists.size(); ++j) {
182 if (selection_hist->GetBinContent(i) < 1.e-5) {
187 hists[j]->GetBinContent(i)/selection_hist->GetBinContent(i));
191 vars.insert(vars.begin() + vars.size()/2, 1.);
192 std::string spline_name = selection_hist->GetName();
196 &vars[0], vars.size()));
218 for (
size_t i = 0; i < vals.size(); ++i) {
231 if (N < 1 || N > 3) {
234 throw std::runtime_error(message);
253 hist.Fill(vals.first,
fFactor*vals.second);
259 std::pair<double, double> vals =
e.first;
261 int last_bin = hist.FindBin(vals.first);
262 int first_bin = hist.FindBin(vals.second);
263 for (
int i = first_bin; i <= last_bin; ++i)
265 hist.AddBinContent(i,
fFactor*w);
271 it->second->Scale(val);
364 (val <=
fRange.second));};
384 void Rebin1D(TH1 * sel_hist, TH1 * rebinned);
385 void Rebin2D(TH1 * sel_hist, TH1 * rebinned);
386 void Rebin3D(TH1 * sel_hist, TH1 * rebinned);
400 std::map<std::string, std::map<int, std::vector<TSpline3 *>>>
402 std::map<std::string, std::map<int, std::vector<TH1 *>>>
std::map< std::string, std::map< int, std::vector< TH1 * > > > fSystematicShifts
void FillSystematicShift(std::string syst_name, int selection_ID, const std::vector< double > &vals, const std::vector< double > &weights)
void AddESliceEnergies(const std::pair< double, double > &vals, double weight=1.)
void FillESliceHist(TH1D &hist)
const std::pair< double, double > & GetRange() const
void AddVariedFlux(double val=1.)
void ScaleVariedFlux(double val)
TH1 * GetRebinnedSelectionHist(int id)
void RefillRebinnedHists()
std::pair< double, double > fRange
double GetBestFitFactor()
void ScaleIncidentEnergies(double val)
const double & GetVariedFlux() const
const std::map< int, std::vector< TH1 * > > & GetShifts(std::string syst_name) const
void AddIncidentEnergies(const std::vector< double > &vals, double weight=1.)
std::vector< std::pair< double, double > > fIncidentEnergies
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
std::vector< std::pair< std::pair< double, double >, double > > fESliceEnergies
void AddFlux(double val=1.)
double GetSplineWeight(std::string syst_name, double par_val, int selection_ID, double val) const
void ExtraFactor(double val)
TH1 * GetSelectionHist(int id)
std::map< std::string, std::vector< double > > fSystematicVals
void SetDataMCScale(double val)
TH1D & GetTrueIncidentHist()
void Rebin1D(TH1 *sel_hist, TH1 *rebinned)
const std::map< int, TH1 * > & GetSelectionHists() const
const std::map< int, TH1 * > & GetRebinnedSelectionHists() const
void SaveSystematics(std::string syst_name, TDirectory *dir)
ThinSliceSample(std::string name, int flux_type, const std::vector< fhicl::ParameterSet > &selections, const std::vector< double > &incident_bins, const std::vector< double > &true_incident_bins, size_t beam_energy_bin, bool is_signal=false, std::pair< double, double > range={0., 0.})
void SetSystematicSplines(const std::map< std::string, std::map< int, std::vector< TSpline3 * >>> &input)
std::map< int, TH1 * > fSelectionHistsRebinned
const double & GetNominalFlux() const
const std::map< int, std::vector< TSpline3 * > > & GetSplines(std::string syst_name) const
std::map< int, TH1 * > fSelectionHists
void SetFactorAndScale(double val)
void FillSelectionHist(int id, double val, double weight=1.)
void FillTrueIncidentHist(const std::vector< double > &vals, double weight=1.)
void Rebin3D(TH1 *sel_hist, TH1 *rebinned)
void MakeSystematicSplines(std::string syst_name)
void ScaleESliceEnergies(double val)
void SetFactorToBestFit()
void SetSystematicVals(std::string syst_name, std::vector< double > &vals)
const int & GetFluxType() const
void ScaleHists(double val)
QTextStream & bin(QTextStream &s)
bool CheckInSignalRange(double val)
void FillSystematicShift(std::string syst_name, int selection_ID, const std::vector< double > &vals)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::string PreciseToString(const double val, const int n=2)
void AddSystematicShift(TH1 *hist, std::string syst_name, int selection_ID)
void FillHistFromIncidentEnergies(TH1D &hist)
const std::string & GetName() const
std::string to_string(ModuleType const mt)
const std::map< std::string, std::map< int, std::vector< TSpline3 * > > > & GetAllSplines() const
void FillSelectionHist(int id, const double(&vals)[N], double weight=1.)
void Rebin2D(TH1 *sel_hist, TH1 *rebinned)