19#include "marley/marley_root.hh"
21std::unique_ptr<marley::GridNeutrinoSource>
22 marley_root::make_root_neutrino_source(
int pdg_code,
const TH1* th1)
26 +
" to marley_root::make_root_neutrino_source");
27 return std::unique_ptr<marley::GridNeutrinoSource>(
nullptr);
33 size_t n_bins = th1->GetNbinsX() + 1;
34 std::vector<double> Es(n_bins);
35 std::vector<double> PDs(n_bins);
38 for (
size_t b = 1; b <= n_bins; ++b) {
39 Es.at(b - 1) = th1->GetBinLowEdge(b);
41 PDs.at(b - 1) = th1->GetBinContent(b);
47 for (
size_t c = 0; c < n_bins - 1; ++c) {
48 double width = Es.at(c + 1) - Es.at(c);
49 if (width <= 0)
throw marley::Error(std::string(
"Invalid bin width")
50 + std::to_string(width) +
" encountered when creating a TH1 neutrino"
64 auto source = std::make_unique<marley::GridNeutrinoSource>(
66 ::InterpolationMethod::Constant);
70std::unique_ptr<marley::GridNeutrinoSource>
71 marley_root::make_root_neutrino_source(
int pdg_code,
const TGraph* tg)
75 +
" to marley_root::make_root_neutrino_source");
76 return std::unique_ptr<marley::GridNeutrinoSource>(
nullptr);
79 size_t num_points = tg->GetN();
80 std::vector<double> Es(num_points);
81 std::vector<double> PDs(num_points);
84 for(
size_t p = 0; p < num_points; ++p) {
85 tg->GetPoint(p, Es.at(p), PDs.at(p));
89 auto source = std::make_unique<marley::GridNeutrinoSource>(Es, PDs,
Base class for all exceptions thrown by MARLEY functions.
One-dimensional function y(x) defined using a grid of ordered pairs (x,y) and an interpolation rule.
InterpolationMethod
Method to use for interpolating between (x,y) grid points.