Public Member Functions | Private Member Functions | Private Attributes | List of all members
protoana::ThinSliceSample Class Reference

#include <ThinSliceSample.h>

Public Member Functions

 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.})
 
 ~ThinSliceSample ()
 
void SetFactor (double f)
 
const std::map< int, TH1 * > & GetSelectionHists () const
 
const std::map< int, std::vector< TH1 * > > & GetShifts (std::string syst_name) const
 
const std::map< int, std::vector< TSpline3 * > > & GetSplines (std::string syst_name) const
 
const std::map< std::string, std::map< int, std::vector< TSpline3 * > > > & GetAllSplines () const
 
void SetSystematicSplines (const std::map< std::string, std::map< int, std::vector< TSpline3 * >>> &input)
 
double GetSplineWeight (std::string syst_name, double par_val, int selection_ID, double val) const
 
void AddSystematicShift (TH1 *hist, std::string syst_name, int selection_ID)
 
void SaveSystematics (std::string syst_name, TDirectory *dir)
 
const std::map< int, TH1 * > & GetRebinnedSelectionHists () const
 
TH1 * GetSelectionHist (int id)
 
TH1D & GetTrueIncidentHist ()
 
TH1 * GetRebinnedSelectionHist (int id)
 
const std::stringGetName () const
 
const int & GetFluxType () const
 
const double & GetNominalFlux () const
 
const double & GetVariedFlux () const
 
void AddFlux (double val=1.)
 
void AddVariedFlux (double val=1.)
 
void FillSystematicShift (std::string syst_name, int selection_ID, const std::vector< double > &vals)
 
void FillSystematicShift (std::string syst_name, int selection_ID, const std::vector< double > &vals, const std::vector< double > &weights)
 
void SetSystematicVals (std::string syst_name, std::vector< double > &vals)
 
void MakeSystematicSplines (std::string syst_name)
 
void AddIncidentEnergies (const std::vector< double > &vals, double weight=1.)
 
void AddESliceEnergies (const std::pair< double, double > &vals, double weight=1.)
 
void FillTrueIncidentHist (const std::vector< double > &vals, double weight=1.)
 
void FillSelectionHist (int id, double val, double weight=1.)
 
template<size_t N>
void FillSelectionHist (int id, const double(&vals)[N], double weight=1.)
 
void FillHistFromIncidentEnergies (TH1D &hist)
 
void FillESliceHist (TH1D &hist)
 
void ScaleHists (double val)
 
void ScaleIncidentEnergies (double val)
 
void ScaleESliceEnergies (double val)
 
void Reset ()
 
void ScaleVariedFlux (double val)
 
void ScaleToDataMC ()
 
void SetDataMCScale (double val)
 
void SetFactorAndScale (double val)
 
void ExtraFactor (double val)
 
double GetFactor ()
 
void ResetFactor ()
 
void SetFactorToBestFit ()
 
double GetBestFitFactor ()
 
void SetBestFit ()
 
bool CheckIsSignal ()
 
bool CheckInSignalRange (double val)
 
double RangeLowEnd ()
 
double RangeHighEnd ()
 
const std::pair< double, double > & GetRange () const
 
void RefillRebinnedHists ()
 
void MakeRebinnedHists ()
 

Private Member Functions

void Rebin1D (TH1 *sel_hist, TH1 *rebinned)
 
void Rebin2D (TH1 *sel_hist, TH1 *rebinned)
 
void Rebin3D (TH1 *sel_hist, TH1 *rebinned)
 

Private Attributes

double fFactor = 1.
 
double fBestFitFactor = 1.
 
bool fBestFitIsSet = false
 
std::string fSampleName
 
int fFluxType
 
double fNominalFlux = 0.
 
double fVariedFlux = 0.
 
double fDataMCScale = 1.
 
bool fIsSignal
 
std::pair< double, double > fRange
 
std::map< int, TH1 * > fSelectionHists
 
TH1D fTrueIncidentHist
 
std::map< int, TH1 * > fSelectionHistsRebinned
 
bool fMadeRebinned = false
 
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
 
std::map< std::string, std::map< int, std::vector< TH1 * > > > fSystematicShifts
 
std::map< std::string, std::vector< double > > fSystematicVals
 
std::vector< std::pair< double, double > > fIncidentEnergies
 
std::vector< std::pair< std::pair< double, double >, double > > fESliceEnergies
 

Detailed Description

Definition at line 23 of file ThinSliceSample.h.

Constructor & Destructor Documentation

protoana::ThinSliceSample::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.} 
)

Definition at line 10 of file ThinSliceSample.cxx.

17  : fSampleName(name),
18  fFluxType(flux_type),
19  fIsSignal(is_signal),
20  fRange(range) {
21 
22  std::string inc_name = "";
24  (is_signal ?
25  ("(" + protoana::PreciseToString(range.first) + " "
26  + protoana::PreciseToString(range.second) + ")") :
27  "") +
28  ";Reconstructed KE (MeV)";
29  if (is_signal) {
30  inc_name = "sample_" + name + "_" +
31  protoana::PreciseToString(range.first) + "_" +
32  protoana::PreciseToString(range.second) + "_" +
33  "_incident_hist_" +
34  std::to_string(beam_energy_bin);
35  }
36  else {
37  inc_name = "sample_" + name + "_incident_hist_" + std::to_string(beam_energy_bin);
38  }
39  inc_name += ("_" + std::to_string(beam_energy_bin));
40  //fIncidentHist = TH1D(inc_name.c_str(), title.c_str(), incident_bins.size() - 1,
41  // &incident_bins[0]);
42 
43  inc_name += "_true";
44  fTrueIncidentHist = TH1D(inc_name.c_str(), title.c_str(),
45  true_incident_bins.size() - 1,
46  &true_incident_bins[0]);
47 
48  for (auto it = selections.begin(); it != selections.end(); ++it) {
49  std::string sel_name = "";
50  if (is_signal) {
51  sel_name = "sample_" + name + "_" +
52  protoana::PreciseToString(range.first) + "_" +
53  protoana::PreciseToString(range.second) + "_selected_" +
54  it->get<std::string>("Name") + "_hist";
55  }
56  else {
57  sel_name = "sample_" + name + "_selected_" +
58  it->get<std::string>("Name") + "_hist";
59  }
60  sel_name += "_" + std::to_string(beam_energy_bin);
61 
62  std::vector<std::vector<double>> selected_bins
63  = it->get<std::vector<std::vector<double>>>("RecoBins");
64  if (selected_bins.size() == 1) {
65  fSelectionHists[it->get<int>("ID")] = new TH1D(
66  sel_name.c_str(), title.c_str(), selected_bins[0].size() - 1,
67  &selected_bins[0][0]);
68  }
69  else if (selected_bins.size() == 2) {
70  fSelectionHists[it->get<int>("ID")] = new TH2D(
71  sel_name.c_str(), title.c_str(),
72  selected_bins[0].size() - 1, &selected_bins[0][0],
73  selected_bins[1].size() - 1, &selected_bins[1][0]);
74  }
75  else if (selected_bins.size() == 3) {
76  fSelectionHists[it->get<int>("ID")] = new TH3D(
77  sel_name.c_str(), title.c_str(),
78  selected_bins[0].size() - 1, &selected_bins[0][0],
79  selected_bins[1].size() - 1, &selected_bins[1][0],
80  selected_bins[2].size() - 1, &selected_bins[2][0]);
81  }
82  /*else {
83  throw
84  }*/
85  }
87 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
std::pair< double, double > fRange
std::map< int, TH1 * > fSelectionHists
std::string PreciseToString(const double val, const int n=2)
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
protoana::ThinSliceSample::~ThinSliceSample ( )
inline

Definition at line 32 of file ThinSliceSample.h.

32 {};

Member Function Documentation

void protoana::ThinSliceSample::AddESliceEnergies ( const std::pair< double, double > &  vals,
double  weight = 1. 
)
inline

Definition at line 213 of file ThinSliceSample.h.

213  {
214  fESliceEnergies.push_back({vals, weight});
215  };
weight
Definition: test.py:257
std::vector< std::pair< std::pair< double, double >, double > > fESliceEnergies
void protoana::ThinSliceSample::AddFlux ( double  val = 1.)
inline

Definition at line 131 of file ThinSliceSample.h.

131  {
132  fNominalFlux += val;
133  fVariedFlux += val;
134  };
void protoana::ThinSliceSample::AddIncidentEnergies ( const std::vector< double > &  vals,
double  weight = 1. 
)
inline

Definition at line 208 of file ThinSliceSample.h.

208  {
209  for (auto v : vals)
210  fIncidentEnergies.push_back({v, weight});
211  };
weight
Definition: test.py:257
std::vector< std::pair< double, double > > fIncidentEnergies
void protoana::ThinSliceSample::AddSystematicShift ( TH1 *  hist,
std::string  syst_name,
int  selection_ID 
)
inline

Definition at line 65 of file ThinSliceSample.h.

66  {
67  fSystematicShifts[syst_name][selection_ID].push_back(hist);
68  };
std::map< std::string, std::map< int, std::vector< TH1 * > > > fSystematicShifts
auto selection_ID
void protoana::ThinSliceSample::AddVariedFlux ( double  val = 1.)
inline

Definition at line 136 of file ThinSliceSample.h.

136  {
137  fVariedFlux += val;
138  }
bool protoana::ThinSliceSample::CheckInSignalRange ( double  val)
inline

Definition at line 363 of file ThinSliceSample.h.

363  {return ((fRange.first < val) &&
364  (val <= fRange.second));};
std::pair< double, double > fRange
bool protoana::ThinSliceSample::CheckIsSignal ( )
inline

Definition at line 362 of file ThinSliceSample.h.

362 {return fIsSignal;};
void protoana::ThinSliceSample::ExtraFactor ( double  val)
inline

Definition at line 331 of file ThinSliceSample.h.

void protoana::ThinSliceSample::FillESliceHist ( TH1D &  hist)
inline

Definition at line 257 of file ThinSliceSample.h.

257  {
258  for (auto e : fESliceEnergies) {
259  std::pair<double, double> vals = e.first;
260  double w = e.second;
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)
264  //hist.AddBinContent(i, fFactor);
265  hist.AddBinContent(i, fFactor*w);
266  }
267  };
std::vector< std::pair< std::pair< double, double >, double > > fESliceEnergies
const double e
void protoana::ThinSliceSample::FillHistFromIncidentEnergies ( TH1D &  hist)
inline

Definition at line 250 of file ThinSliceSample.h.

250  {
251  for (auto vals : fIncidentEnergies) {
252  //hist.Fill(vals.first, fFactor/*vals.second*/);
253  hist.Fill(vals.first, fFactor*vals.second);
254  }
255  };
std::vector< std::pair< double, double > > fIncidentEnergies
void protoana::ThinSliceSample::FillSelectionHist ( int  id,
double  val,
double  weight = 1. 
)
inline

Definition at line 223 of file ThinSliceSample.h.

223  {
224  if (fSelectionHists.find(id) != fSelectionHists.end()) {
225  fSelectionHists.at(id)->Fill(val, weight);
226  }
227  };
weight
Definition: test.py:257
std::map< int, TH1 * > fSelectionHists
template<size_t N>
void protoana::ThinSliceSample::FillSelectionHist ( int  id,
const double(&)  vals[N],
double  weight = 1. 
)
inline

Definition at line 229 of file ThinSliceSample.h.

230  {
231  if (N < 1 || N > 3) {
232  std::string message = "Error: trying to fill hists with too many values";
233  message += std::to_string(N);
234  throw std::runtime_error(message);
235  }
236 
237  if (fSelectionHists.find(id) != fSelectionHists.end()) {
238  if (N == 1) {
239  fSelectionHists.at(id)->Fill(vals[0], weight);
240  }
241  else if (N == 2) {
242  ((TH2D*)fSelectionHists.at(id))->Fill(vals[0], vals[1], weight);
243  }
244  else if (N == 3) {
245  ((TH3D*)fSelectionHists.at(id))->Fill(vals[0], vals[1], vals[2], weight);
246  }
247  }
248  }
std::string string
Definition: nybbler.cc:12
weight
Definition: test.py:257
std::map< int, TH1 * > fSelectionHists
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void protoana::ThinSliceSample::FillSystematicShift ( std::string  syst_name,
int  selection_ID,
const std::vector< double > &  vals 
)
inline

Definition at line 140 of file ThinSliceSample.h.

142  {
143  if (vals.size() !=
144  fSystematicShifts[syst_name][selection_ID].size()) {
145  std::string message = "ThinSliceSample: Input systematic shift values and number of shift hists differ";
146  throw std::runtime_error(message);
147  }
148 
149  for (size_t i = 0; i < vals.size(); ++i) {
150  fSystematicShifts[syst_name][selection_ID][i]->Fill(vals[i]);
151  }
152  };
std::map< std::string, std::map< int, std::vector< TH1 * > > > fSystematicShifts
std::string string
Definition: nybbler.cc:12
auto selection_ID
void protoana::ThinSliceSample::FillSystematicShift ( std::string  syst_name,
int  selection_ID,
const std::vector< double > &  vals,
const std::vector< double > &  weights 
)
inline

Definition at line 154 of file ThinSliceSample.h.

157  {
158  if (vals.size() !=
159  fSystematicShifts[syst_name][selection_ID].size()) {
160  std::string message = "ThinSliceSample: Input systematic shift values and number of shift hists differ";
161  throw std::runtime_error(message);
162  }
163 
164  for (size_t i = 0; i < vals.size(); ++i) {
165  fSystematicShifts[syst_name][selection_ID][i]->Fill(vals[i], weights[i]);
166  }
167  };
std::map< std::string, std::map< int, std::vector< TH1 * > > > fSystematicShifts
std::string string
Definition: nybbler.cc:12
auto selection_ID
void protoana::ThinSliceSample::FillTrueIncidentHist ( const std::vector< double > &  vals,
double  weight = 1. 
)
inline

Definition at line 217 of file ThinSliceSample.h.

217  {
218  for (size_t i = 0; i < vals.size(); ++i) {
219  fTrueIncidentHist.Fill(vals.at(i), weight);
220  }
221  };
weight
Definition: test.py:257
const std::map<std::string, std::map<int, std::vector<TSpline3 *> > >& protoana::ThinSliceSample::GetAllSplines ( ) const
inline

Definition at line 51 of file ThinSliceSample.h.

51  {
52  return fSystematicSplines;
53  };
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
double protoana::ThinSliceSample::GetBestFitFactor ( )
inline

Definition at line 349 of file ThinSliceSample.h.

349  {
350  return fBestFitFactor;
351  };
double protoana::ThinSliceSample::GetFactor ( void  )
inline

Definition at line 335 of file ThinSliceSample.h.

335  {
336  return fFactor;
337  };
const int& protoana::ThinSliceSample::GetFluxType ( ) const
inline

Definition at line 119 of file ThinSliceSample.h.

119  {
120  return fFluxType;
121  };
const std::string& protoana::ThinSliceSample::GetName ( void  ) const
inline

Definition at line 115 of file ThinSliceSample.h.

115  {
116  return fSampleName;
117  };
const double& protoana::ThinSliceSample::GetNominalFlux ( ) const
inline

Definition at line 123 of file ThinSliceSample.h.

123  {
124  return fNominalFlux;
125  };
const std::pair<double, double>& protoana::ThinSliceSample::GetRange ( ) const
inline

Definition at line 368 of file ThinSliceSample.h.

368 {return fRange;};
std::pair< double, double > fRange
TH1* protoana::ThinSliceSample::GetRebinnedSelectionHist ( int  id)
inline

Definition at line 111 of file ThinSliceSample.h.

111  {
112  return fSelectionHistsRebinned.at(id);
113  };
std::map< int, TH1 * > fSelectionHistsRebinned
const std::map<int, TH1 *>& protoana::ThinSliceSample::GetRebinnedSelectionHists ( ) const
inline

Definition at line 89 of file ThinSliceSample.h.

89  {
91  };
std::map< int, TH1 * > fSelectionHistsRebinned
TH1* protoana::ThinSliceSample::GetSelectionHist ( int  id)
inline

Definition at line 93 of file ThinSliceSample.h.

93  {
94  return fSelectionHists.at(id);
95  };
std::map< int, TH1 * > fSelectionHists
const std::map<int, TH1 *>& protoana::ThinSliceSample::GetSelectionHists ( ) const
inline

Definition at line 36 of file ThinSliceSample.h.

36  {
37  return fSelectionHists;
38  };
std::map< int, TH1 * > fSelectionHists
const std::map<int, std::vector<TH1 *> >& protoana::ThinSliceSample::GetShifts ( std::string  syst_name) const
inline

Definition at line 41 of file ThinSliceSample.h.

41  {
42  return fSystematicShifts.at(syst_name);
43  };
std::map< std::string, std::map< int, std::vector< TH1 * > > > fSystematicShifts
const std::map<int, std::vector<TSpline3 *> >& protoana::ThinSliceSample::GetSplines ( std::string  syst_name) const
inline

Definition at line 46 of file ThinSliceSample.h.

46  {
47  return fSystematicSplines.at(syst_name);
48  };
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
double protoana::ThinSliceSample::GetSplineWeight ( std::string  syst_name,
double  par_val,
int  selection_ID,
double  val 
) const
inline

Definition at line 59 of file ThinSliceSample.h.

60  {
61  int bin = fSelectionHists.at(selection_ID)->FindBin(val);
62  return fSystematicSplines.at(syst_name).at(selection_ID).at(bin-1)->Eval(par_val);
63  };
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
std::map< int, TH1 * > fSelectionHists
auto selection_ID
QTextStream & bin(QTextStream &s)
TH1D& protoana::ThinSliceSample::GetTrueIncidentHist ( )
inline

Definition at line 102 of file ThinSliceSample.h.

102  {
103  return fTrueIncidentHist;
104  };
const double& protoana::ThinSliceSample::GetVariedFlux ( ) const
inline

Definition at line 127 of file ThinSliceSample.h.

127  {
128  return fVariedFlux;
129  };
void protoana::ThinSliceSample::MakeRebinnedHists ( )

Definition at line 89 of file ThinSliceSample.cxx.

89  {
90  if (!fMadeRebinned) {
91  //std::string inc_name = fIncidentHist.GetName();
92  //inc_name += "Rebinned";
93  //fIncidentHistRebinned = TH1D(inc_name.c_str(), fIncidentHist.GetTitle(),
94  // fIncidentHist.GetNbinsX(), 0, fIncidentHist.GetNbinsX());
95  //for (int i = 1; i <= fIncidentHist.GetNbinsX(); ++i) {
96  // fIncidentHistRebinned.SetBinContent(i, fIncidentHist.GetBinContent(i));
97 
98  // double low_edge = fIncidentHist.GetXaxis()->GetBinLowEdge(i);
99  // double up_edge = fIncidentHist.GetXaxis()->GetBinUpEdge(i);
100  // std::string bin_label = (low_edge < 0. ? "< 0." :
101  // (protoana::PreciseToString(low_edge, 0) + " - " +
102  // protoana::PreciseToString(up_edge, 0)));
103  // fIncidentHistRebinned.GetXaxis()->SetBinLabel(i, bin_label.c_str());
104  //}
105 
106  for (auto it = fSelectionHists.begin(); it != fSelectionHists.end(); ++it) {
107  TH1 * sel_hist = (TH1 *)it->second;
108  std::string name = sel_hist->GetName();
109  name += "Rebinned";
110 
111  size_t nAxes = 1;
112  if (sel_hist->GetNbinsY() > 1) ++nAxes;
113  if (sel_hist->GetNbinsZ() > 1) ++nAxes;
114 
115  if (nAxes == 1) {
116  fSelectionHistsRebinned[it->first] = new TH1D(
117  name.c_str(), sel_hist->GetTitle(),
118  sel_hist->GetNbinsX(), 0, sel_hist->GetNbinsX());
119  Rebin1D(sel_hist, fSelectionHistsRebinned[it->first]);
120  }
121  else if (nAxes == 2) {
122  fSelectionHistsRebinned[it->first] = new TH2D(
123  name.c_str(), sel_hist->GetTitle(),
124  sel_hist->GetNbinsX(), 0, sel_hist->GetNbinsX(),
125  sel_hist->GetNbinsY(), 0, sel_hist->GetNbinsY());
126  Rebin2D(sel_hist, fSelectionHistsRebinned[it->first]);
127  }
128  else if (nAxes == 3) {
129  fSelectionHistsRebinned[it->first] = new TH3D(
130  name.c_str(), sel_hist->GetTitle(),
131  sel_hist->GetNbinsX(), 0, sel_hist->GetNbinsX(),
132  sel_hist->GetNbinsY(), 0, sel_hist->GetNbinsY(),
133  sel_hist->GetNbinsZ(), 0, sel_hist->GetNbinsZ());
134  Rebin3D(sel_hist, fSelectionHistsRebinned[it->first]);
135  }
136  }
137 
138  fMadeRebinned = true;
139  }
140 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
void Rebin1D(TH1 *sel_hist, TH1 *rebinned)
std::map< int, TH1 * > fSelectionHistsRebinned
std::map< int, TH1 * > fSelectionHists
void Rebin3D(TH1 *sel_hist, TH1 *rebinned)
void Rebin2D(TH1 *sel_hist, TH1 *rebinned)
void protoana::ThinSliceSample::MakeSystematicSplines ( std::string  syst_name)
inline

Definition at line 173 of file ThinSliceSample.h.

173  {
174  for (auto it2 = fSystematicShifts[syst_name].begin();
175  it2 != fSystematicShifts[syst_name].end(); ++it2) {
176  int selection_ID = it2->first;
177  std::vector<TH1*> hists = it2->second;
178  TH1D * selection_hist = (TH1D*)fSelectionHists[selection_ID];
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) {
183  vars.push_back(1.);
184  }
185  else {
186  vars.push_back(
187  hists[j]->GetBinContent(i)/selection_hist->GetBinContent(i));
188  }
189  }
190  //if (do_insert)
191  vars.insert(vars.begin() + vars.size()/2, 1.);
192  std::string spline_name = selection_hist->GetName();
193  spline_name += "_" + syst_name + "_Spline_" + std::to_string(i);
194  fSystematicSplines[syst_name][selection_ID].push_back(
195  new TSpline3(spline_name.c_str(), &fSystematicVals[syst_name][0],
196  &vars[0], vars.size()));
197  }
198  }
199  };
std::map< std::string, std::map< int, std::vector< TH1 * > > > fSystematicShifts
std::string string
Definition: nybbler.cc:12
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
std::map< std::string, std::vector< double > > fSystematicVals
std::map< int, TH1 * > fSelectionHists
auto selection_ID
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
double protoana::ThinSliceSample::RangeHighEnd ( )
inline

Definition at line 366 of file ThinSliceSample.h.

366 {return fRange.second;};
std::pair< double, double > fRange
double protoana::ThinSliceSample::RangeLowEnd ( )
inline

Definition at line 365 of file ThinSliceSample.h.

365 {return fRange.first;};
std::pair< double, double > fRange
void protoana::ThinSliceSample::Rebin1D ( TH1 *  sel_hist,
TH1 *  rebinned 
)
private

Definition at line 142 of file ThinSliceSample.cxx.

142  {
143  for (int i = 1; i <= sel_hist->GetNbinsX(); ++i) {
144  double low_x = sel_hist->GetXaxis()->GetBinLowEdge(i);
145  double up_x = sel_hist->GetXaxis()->GetBinUpEdge(i);
146  std::string bin_label = (low_x < 0. ? "< 0." :
147  (protoana::PreciseToString(low_x, 0) + " - " +
148  protoana::PreciseToString(up_x, 0)));
149  rebinned->GetXaxis()->SetBinLabel(i, bin_label.c_str());
150 
151  rebinned->SetBinContent(i, sel_hist->GetBinContent(i));
152  }
153 }
std::string string
Definition: nybbler.cc:12
std::string PreciseToString(const double val, const int n=2)
void protoana::ThinSliceSample::Rebin2D ( TH1 *  sel_hist,
TH1 *  rebinned 
)
private

Definition at line 155 of file ThinSliceSample.cxx.

155  {
156  for (int i = 1; i <= sel_hist->GetNbinsX(); ++i) {
157  double low_x = sel_hist->GetXaxis()->GetBinLowEdge(i);
158  double up_x = sel_hist->GetXaxis()->GetBinUpEdge(i);
159  std::string bin_label = (low_x < 0. ? "< 0." :
160  (protoana::PreciseToString(low_x, 0) + " - " +
161  protoana::PreciseToString(up_x, 0)));
162  rebinned->GetXaxis()->SetBinLabel(
163  i, bin_label.c_str());
164  for (int j = 1; j <= sel_hist->GetNbinsY(); ++j) {
165  double low_y = sel_hist->GetYaxis()->GetBinLowEdge(j);
166  double up_y = sel_hist->GetYaxis()->GetBinUpEdge(j);
167  std::string y_label = (low_y < 0. ? "< 0." :
168  (protoana::PreciseToString(low_y, 0) + " - " +
169  protoana::PreciseToString(up_y, 0)));
170  rebinned->GetYaxis()->SetBinLabel(j, bin_label.c_str());
171  rebinned->SetBinContent(i, j, sel_hist->GetBinContent(i, j));
172  }
173  }
174 }
std::string string
Definition: nybbler.cc:12
std::string PreciseToString(const double val, const int n=2)
void protoana::ThinSliceSample::Rebin3D ( TH1 *  sel_hist,
TH1 *  rebinned 
)
private

Definition at line 176 of file ThinSliceSample.cxx.

176  {
177  for (int i = 1; i <= sel_hist->GetNbinsX(); ++i) {
178  double low_x = sel_hist->GetXaxis()->GetBinLowEdge(i);
179  double up_x = sel_hist->GetXaxis()->GetBinUpEdge(i);
180  std::string bin_label = (low_x < 0. ? "< 0." :
181  (protoana::PreciseToString(low_x, 0) + " - " +
182  protoana::PreciseToString(up_x, 0)));
183  rebinned->GetXaxis()->SetBinLabel(i, bin_label.c_str());
184  for (int j = 1; j <= sel_hist->GetNbinsY(); ++j) {
185  double low_y = sel_hist->GetYaxis()->GetBinLowEdge(j);
186  double up_y = sel_hist->GetYaxis()->GetBinUpEdge(j);
187  std::string y_label = (low_y < 0. ? "< 0." :
188  (protoana::PreciseToString(low_y, 0) + " - " +
189  protoana::PreciseToString(up_y, 0)));
190  rebinned->GetYaxis()->SetBinLabel(j, bin_label.c_str());
191 
192  for (int k = 1; k <= sel_hist->GetNbinsY(); ++k) {
193  double low_z = sel_hist->GetYaxis()->GetBinLowEdge(k);
194  double up_z = sel_hist->GetYaxis()->GetBinUpEdge(k);
195  std::string y_label = (low_z < 0. ? "< 0." :
196  (protoana::PreciseToString(low_z, 0) + " - " +
197  protoana::PreciseToString(up_z, 0)));
198  rebinned->GetZaxis()->SetBinLabel(k, bin_label.c_str());
199 
200  rebinned->SetBinContent(i, j, k, sel_hist->GetBinContent(i, j, k));
201  }
202  }
203  }
204 }
std::string string
Definition: nybbler.cc:12
std::string PreciseToString(const double val, const int n=2)
void protoana::ThinSliceSample::RefillRebinnedHists ( )

Definition at line 206 of file ThinSliceSample.cxx.

206  {
207  //for (int i = 1; i <= fIncidentHist.GetNbinsX(); ++i) {
208  // fIncidentHistRebinned.SetBinContent(i, fIncidentHist.GetBinContent(i));
209  //}
210  for (auto it = fSelectionHistsRebinned.begin();
211  it != fSelectionHistsRebinned.end(); ++it) {
212  for (int i = 1; i <= it->second->GetNbinsX(); ++i) {
213  it->second->SetBinContent(i, fSelectionHists[it->first]->GetBinContent(i));
214  }
215  }
216 }
std::map< int, TH1 * > fSelectionHistsRebinned
std::map< int, TH1 * > fSelectionHists
void protoana::ThinSliceSample::Reset ( void  )
inline

Definition at line 292 of file ThinSliceSample.h.

292  {
293  fVariedFlux = 0.;
294  for (auto it = fSelectionHists.begin(); it != fSelectionHists.end(); ++it) {
295  it->second->Reset();
296  }
297 
298  fTrueIncidentHist.Reset();
299 
300  fIncidentEnergies.clear();
301  fESliceEnergies.clear();
302  fFactor = 1.;
303  };
std::vector< std::pair< double, double > > fIncidentEnergies
std::vector< std::pair< std::pair< double, double >, double > > fESliceEnergies
std::map< int, TH1 * > fSelectionHists
void protoana::ThinSliceSample::ResetFactor ( )
inline

Definition at line 339 of file ThinSliceSample.h.

339  {
340  ScaleHists(1./fFactor);
341  fVariedFlux *= (1./fFactor);
342  fFactor = 1.;
343  };
void ScaleHists(double val)
void protoana::ThinSliceSample::SaveSystematics ( std::string  syst_name,
TDirectory *  dir 
)
inline

Definition at line 70 of file ThinSliceSample.h.

70  {
71  dir->cd();
72  //for (auto it = fSystematicShifts[syst_name].begin();
73  // it != fSystematicShifts[syst_name].end(); ++it) {
74  // for (size_t i = 0; i < it->second.size(); ++i) {
75  // it->second[i]->Write();
76  // }
77  //}
78  for (auto it = fSystematicSplines[syst_name].begin();
79  it != fSystematicSplines[syst_name].end(); ++it) {
80  for (size_t i = 0; i < it->second.size(); ++i) {
81  TCanvas c(it->second[i]->GetName(), "");
82  it->second[i]->Draw();
83  std::string name = syst_name + std::to_string(i);
84  c.Write(syst_name.c_str());
85  }
86  }
87  };
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
string dir
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void protoana::ThinSliceSample::ScaleESliceEnergies ( double  val)
inline

Definition at line 285 of file ThinSliceSample.h.

285  {
286  for (auto it = fESliceEnergies.begin();
287  it != fESliceEnergies.end(); ++it) {
288  it->second *= val;
289  }
290  };
std::vector< std::pair< std::pair< double, double >, double > > fESliceEnergies
void protoana::ThinSliceSample::ScaleHists ( double  val)
inline

Definition at line 269 of file ThinSliceSample.h.

269  {
270  for (auto it = fSelectionHists.begin(); it != fSelectionHists.end(); ++it) {
271  it->second->Scale(val);
272  }
274 
275  fTrueIncidentHist.Scale(val);
276  };
std::map< int, TH1 * > fSelectionHists
void protoana::ThinSliceSample::ScaleIncidentEnergies ( double  val)
inline

Definition at line 278 of file ThinSliceSample.h.

278  {
279  for (auto it = fIncidentEnergies.begin();
280  it != fIncidentEnergies.end(); ++it) {
281  it->second *= val;
282  }
283  };
std::vector< std::pair< double, double > > fIncidentEnergies
void protoana::ThinSliceSample::ScaleToDataMC ( )
inline

Definition at line 309 of file ThinSliceSample.h.

void protoana::ThinSliceSample::ScaleVariedFlux ( double  val)
inline

Definition at line 305 of file ThinSliceSample.h.

305  {
306  fVariedFlux *= val;
307  };
void protoana::ThinSliceSample::SetBestFit ( )
inline

Definition at line 353 of file ThinSliceSample.h.

353  {
354  if (fBestFitIsSet) {
355  return;
356  }
357 
359  fBestFitIsSet = true;
360  };
void protoana::ThinSliceSample::SetDataMCScale ( double  val)
inline

Definition at line 316 of file ThinSliceSample.h.

void protoana::ThinSliceSample::SetFactor ( double  f)
inline
void protoana::ThinSliceSample::SetFactorAndScale ( double  val)
inline

Definition at line 324 of file ThinSliceSample.h.

void protoana::ThinSliceSample::SetFactorToBestFit ( )
inline

Definition at line 345 of file ThinSliceSample.h.

345  {
347  };
void SetFactorAndScale(double val)
void protoana::ThinSliceSample::SetSystematicSplines ( const std::map< std::string, std::map< int, std::vector< TSpline3 * >>> &  input)
inline

Definition at line 55 of file ThinSliceSample.h.

55  {
57  };
std::map< std::string, std::map< int, std::vector< TSpline3 * > > > fSystematicSplines
static int input(void)
Definition: code.cpp:15695
void protoana::ThinSliceSample::SetSystematicVals ( std::string  syst_name,
std::vector< double > &  vals 
)
inline

Definition at line 169 of file ThinSliceSample.h.

169  {
170  fSystematicVals[syst_name] = vals;
171  };
std::map< std::string, std::vector< double > > fSystematicVals

Member Data Documentation

double protoana::ThinSliceSample::fBestFitFactor = 1.
private

Definition at line 374 of file ThinSliceSample.h.

bool protoana::ThinSliceSample::fBestFitIsSet = false
private

Definition at line 375 of file ThinSliceSample.h.

double protoana::ThinSliceSample::fDataMCScale = 1.
private

Definition at line 380 of file ThinSliceSample.h.

std::vector<std::pair<std::pair<double, double>, double> > protoana::ThinSliceSample::fESliceEnergies
private

Definition at line 408 of file ThinSliceSample.h.

double protoana::ThinSliceSample::fFactor = 1.
private

Definition at line 374 of file ThinSliceSample.h.

int protoana::ThinSliceSample::fFluxType
private

Definition at line 377 of file ThinSliceSample.h.

std::vector<std::pair<double, double> > protoana::ThinSliceSample::fIncidentEnergies
private

Definition at line 407 of file ThinSliceSample.h.

bool protoana::ThinSliceSample::fIsSignal
private

Definition at line 381 of file ThinSliceSample.h.

bool protoana::ThinSliceSample::fMadeRebinned = false
private

Definition at line 393 of file ThinSliceSample.h.

double protoana::ThinSliceSample::fNominalFlux = 0.
private

Definition at line 378 of file ThinSliceSample.h.

std::pair<double, double> protoana::ThinSliceSample::fRange
private

Definition at line 382 of file ThinSliceSample.h.

std::string protoana::ThinSliceSample::fSampleName
private

Definition at line 376 of file ThinSliceSample.h.

std::map<int, TH1 *> protoana::ThinSliceSample::fSelectionHists
private

Definition at line 387 of file ThinSliceSample.h.

std::map<int, TH1 *> protoana::ThinSliceSample::fSelectionHistsRebinned
private

Definition at line 390 of file ThinSliceSample.h.

std::map<std::string, std::map<int, std::vector<TH1 *> > > protoana::ThinSliceSample::fSystematicShifts
private

Definition at line 403 of file ThinSliceSample.h.

std::map<std::string, std::map<int, std::vector<TSpline3 *> > > protoana::ThinSliceSample::fSystematicSplines
private

Definition at line 401 of file ThinSliceSample.h.

std::map<std::string, std::vector<double> > protoana::ThinSliceSample::fSystematicVals
private

Definition at line 404 of file ThinSliceSample.h.

TH1D protoana::ThinSliceSample::fTrueIncidentHist
private

Definition at line 389 of file ThinSliceSample.h.

double protoana::ThinSliceSample::fVariedFlux = 0.
private

Definition at line 379 of file ThinSliceSample.h.


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