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 149 of file NuDockServerBase.cpp.
151 auto hist1d =
dynamic_cast<const TH1D*
>(mc_hist);
156 const TAxis *ax = mc_hist->GetXaxis();
157 std::string xtitle = ax->GetTitle();
158 int nxbins = ax->GetNbins();
159 std::vector<double> xbins(nxbins+1);
160 std::vector<double> binvals(nxbins);
162 xbins[0] = ax->GetBinLowEdge(1);
163 for (
int ix = 1; ix <= nxbins; ++ix) {
164 xbins[ix] = ax->GetBinUpEdge(ix);
165 binvals[ix-1] = mc_hist->GetBinContent(ix);
167 response[
"axis_titles"][sample_title] = {xtitle};
168 response[
"bin_edges"][sample_title] = {xbins};
169 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 173 of file NuDockServerBase.cpp.
175 auto hist2d =
dynamic_cast<const TH2D*
>(mc_hist);
180 const TAxis *x_axis = mc_hist->GetXaxis();
181 std::string xtitle = x_axis->GetTitle();
182 int nxbins = x_axis->GetNbins();
183 std::vector<double> xbins(nxbins+1);
185 const TAxis *y_axis = mc_hist->GetYaxis();
186 std::string ytitle = y_axis->GetTitle();
187 int nybins = y_axis->GetNbins();
188 std::vector<double> ybins(nybins+1);
190 std::vector<std::vector<double>> binvals(nxbins, std::vector<double>(nybins));
192 xbins[0] = x_axis->GetBinLowEdge(1);
193 ybins[0] = y_axis->GetBinLowEdge(1);
194 for (
int ix = 1; ix <= nxbins; ++ix) {
195 for (
int iy = 1; iy <= nybins; ++iy) {
196 xbins[ix] = x_axis->GetBinUpEdge(ix);
197 ybins[iy] = y_axis->GetBinUpEdge(iy);
198 binvals[ix-1][iy-1] = mc_hist->GetBinContent(ix, iy);
201 response[
"axis_titles"][sample_title] = {xtitle, ytitle};
202 response[
"bin_edges"][sample_title] = {xbins, ybins};
203 response[
"bin_values"][sample_title] = binvals;