Go to the source code of this file.
|
| void | TH1toResponse (const TH1 *mc_hist, const std::string &sample_title, nlohmann::json &response) |
| |
| void | TH2toResponse (const TH2 *mc_hist, const std::string &sample_title, nlohmann::json &response) |
| |
◆ TH1toResponse()
| void TH1toResponse |
( |
const TH1 * |
mc_hist, |
|
|
const std::string & |
sample_title, |
|
|
nlohmann::json & |
response |
|
) |
| |
Definition at line 150 of file NuDockServerBase.cpp.
152 auto hist1d =
dynamic_cast<const TH1D*
>(mc_hist);
157 const TAxis *ax = mc_hist->GetXaxis();
158 std::string xtitle = ax->GetTitle();
159 int nxbins = ax->GetNbins();
160 std::vector<double> xbins(nxbins+1);
161 std::vector<double> binvals(nxbins);
163 xbins[0] = ax->GetBinLowEdge(1);
164 for (
int ix = 1; ix <= nxbins; ++ix) {
165 xbins[ix] = ax->GetBinUpEdge(ix);
166 binvals[ix-1] = mc_hist->GetBinContent(ix);
168 response[
"axis_titles"][sample_title] = {xtitle};
169 response[
"bin_edges"][sample_title] = {xbins};
170 response[
"bin_values"][sample_title] = binvals;
Custom exception class used throughout MaCh3.
◆ TH2toResponse()
| void TH2toResponse |
( |
const TH2 * |
mc_hist, |
|
|
const std::string & |
sample_title, |
|
|
nlohmann::json & |
response |
|
) |
| |
Definition at line 174 of file NuDockServerBase.cpp.
176 auto hist2d =
dynamic_cast<const TH2D*
>(mc_hist);
181 const TAxis *x_axis = mc_hist->GetXaxis();
182 std::string xtitle = x_axis->GetTitle();
183 int nxbins = x_axis->GetNbins();
184 std::vector<double> xbins(nxbins+1);
186 const TAxis *y_axis = mc_hist->GetYaxis();
187 std::string ytitle = y_axis->GetTitle();
188 int nybins = y_axis->GetNbins();
189 std::vector<double> ybins(nybins+1);
191 std::vector<std::vector<double>> binvals(nxbins, std::vector<double>(nybins));
193 xbins[0] = x_axis->GetBinLowEdge(1);
194 ybins[0] = y_axis->GetBinLowEdge(1);
195 for (
int ix = 1; ix <= nxbins; ++ix) {
196 for (
int iy = 1; iy <= nybins; ++iy) {
197 xbins[ix] = x_axis->GetBinUpEdge(ix);
198 ybins[iy] = y_axis->GetBinUpEdge(iy);
199 binvals[ix-1][iy-1] = mc_hist->GetBinContent(ix, iy);
202 response[
"axis_titles"][sample_title] = {xtitle, ytitle};
203 response[
"bin_edges"][sample_title] = {xbins, ybins};
204 response[
"bin_values"][sample_title] = binvals;