4 std::ostringstream out;
6 out << std::fixed <<
val;
12 const std::vector<fhicl::ParameterSet> & selections,
13 const std::vector<double> & incident_bins,
14 const std::vector<double> & true_incident_bins,
15 size_t beam_energy_bin,
16 bool is_signal, std::pair<double, double> range)
28 ";Reconstructed KE (MeV)";
30 inc_name =
"sample_" + name +
"_" +
37 inc_name =
"sample_" + name +
"_incident_hist_" +
std::to_string(beam_energy_bin);
45 true_incident_bins.size() - 1,
46 &true_incident_bins[0]);
48 for (
auto it = selections.begin(); it != selections.end(); ++it) {
51 sel_name =
"sample_" + name +
"_" +
57 sel_name =
"sample_" + name +
"_selected_" +
62 std::vector<std::vector<double>> selected_bins
63 = it->get<std::vector<std::vector<double>>>(
"RecoBins");
64 if (selected_bins.size() == 1) {
66 sel_name.c_str(), title.c_str(), selected_bins[0].size() - 1,
67 &selected_bins[0][0]);
69 else if (selected_bins.size() == 2) {
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]);
75 else if (selected_bins.size() == 3) {
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]);
107 TH1 * sel_hist = (TH1 *)it->second;
112 if (sel_hist->GetNbinsY() > 1) ++nAxes;
113 if (sel_hist->GetNbinsZ() > 1) ++nAxes;
117 name.c_str(), sel_hist->GetTitle(),
118 sel_hist->GetNbinsX(), 0, sel_hist->GetNbinsX());
121 else if (nAxes == 2) {
123 name.c_str(), sel_hist->GetTitle(),
124 sel_hist->GetNbinsX(), 0, sel_hist->GetNbinsX(),
125 sel_hist->GetNbinsY(), 0, sel_hist->GetNbinsY());
128 else if (nAxes == 3) {
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());
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);
149 rebinned->GetXaxis()->SetBinLabel(i, bin_label.c_str());
151 rebinned->SetBinContent(i, sel_hist->GetBinContent(i));
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);
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);
170 rebinned->GetYaxis()->SetBinLabel(j, bin_label.c_str());
171 rebinned->SetBinContent(i, j, sel_hist->GetBinContent(i, j));
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);
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);
190 rebinned->GetYaxis()->SetBinLabel(j, bin_label.c_str());
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);
198 rebinned->GetZaxis()->SetBinLabel(
k, bin_label.c_str());
200 rebinned->SetBinContent(i, j,
k, sel_hist->GetBinContent(i, j,
k));
212 for (
int i = 1; i <= it->second->GetNbinsX(); ++i) {
213 it->second->SetBinContent(i,
fSelectionHists[it->first]->GetBinContent(i));
void RefillRebinnedHists()
void Rebin1D(TH1 *sel_hist, TH1 *rebinned)
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.})
std::map< int, TH1 * > fSelectionHistsRebinned
std::map< int, TH1 * > fSelectionHists
void Rebin3D(TH1 *sel_hist, TH1 *rebinned)
std::string PreciseToString(const double val, const int n=2)
std::string to_string(ModuleType const mt)
void Rebin2D(TH1 *sel_hist, TH1 *rebinned)