24 #include "art_root_io/TFileDirectory.h" 25 #include "art_root_io/TFileService.h" 27 #include "cetlib_except/exception.h" 51 #include "marley/Integrator.hh" 52 #include "marley/marley_root.hh" 53 #include "marley/marley_utils.hh" 60 constexpr
int MAX_UNIFORM_ENERGY_ITERATIONS = 1000;
64 constexpr
double ONE = 1.;
68 constexpr
int NUM_INTEGRATION_SAMPLING_POINTS = 100;
72 constexpr
double MeV_to_erg = 1.6021766208e-6;
75 constexpr std::array<int, 4> NU_X_PDG_CODES{
76 marley_utils::MUON_NEUTRINO,
77 marley_utils::MUON_ANTINEUTRINO,
78 marley_utils::TAU_NEUTRINO,
79 marley_utils::TAU_ANTINEUTRINO,
84 bool is_nux(
int pdg_code)
91 const std::regex rx_comment_or_empty = std::regex(
"\\s*(#.*)?");
95 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source, marley::Generator& gen);
100 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source,
101 marley::Generator& gen,
102 double& source_integ,
103 double& tot_xs_integ);
107 double integrate(
const std::function<
double(
double)>&
f,
double x_min,
double x_max);
123 std::set<std::string>
operator()() {
return {
"marley_parameters"}; }
131 Comment(
"Configuration for selecting the vertex location(s)")};
140 Name(
"sampling_mode"),
141 Comment(
"Technique to use when sampling times and energies. Valid" 142 " options are \"histogram\", \"uniform time\"," 143 " and \"uniform energy\""),
144 std::string(
"histogram")
148 Name(
"nu_per_event"),
149 Comment(
"The number of neutrino vertices to generate in" 155 Name(
"spectrum_file_format"),
156 Comment(
"Format to assume for the neutrino spectrum file." 157 " Valid options are \"th2d\" (a ROOT file containing a " 158 " TH2D object) and \"fit\" (an ASCII text file containing" 159 " fit parameters for each time bin). This parameter is not" 165 Name(
"spectrum_file"),
166 Comment(
"Name of a file that contains a representation" 167 " of the incident (not cross section weighted) neutrino spectrum" 168 " as a function of time and energy.")};
171 Name(
"pinching_parameter_type"),
172 Comment(
"Type of pinching parameter to assume when parsing" 173 " the time-dependent fit parameters for the incident neutrino" 174 " spectrum. Valid options are \"alpha\" and \"beta\". This" 175 " parameter is not case-sensitive."),
177 auto spectrum_file_format = marley_utils::to_lowercase(spectrum_file_format_());
178 return (spectrum_file_format ==
"fit");
183 Comment(
"Name of the TH2D object to use to represent the" 184 " incident neutrino spectrum. This value should match the" 185 " name of the TH2D as given in the ROOT file specified" 186 " in the \"spectrum_file\" parameter. The TH2D should use " 187 " time bins on the X axis (seconds) and energy bins on the " 190 auto spectrum_file_format = marley_utils::to_lowercase(spectrum_file_format_());
191 return (spectrum_file_format ==
"th2d");
196 Comment(
"Minimum allowed neutrino energy (MeV) for a \"fit\" format" 199 auto spectrum_file_format = marley_utils::to_lowercase(spectrum_file_format_());
200 return (spectrum_file_format ==
"fit");
205 Comment(
"Maximum allowed neutrino energy (MeV) for a \"fit\" format" 208 auto spectrum_file_format = marley_utils::to_lowercase(spectrum_file_format_());
209 return (spectrum_file_format ==
"fit");
231 : fEmean(Emean), fAlpha(alpha), fLuminosity(luminosity)
235 double Emean()
const {
return fEmean; }
237 double Alpha()
const {
return fAlpha; }
254 template <
typename It>
281 , fNueFitParams(Emean_nue, alpha_nue, lum_nue)
282 , fNuebarFitParams(Emean_nuebar, alpha_nuebar, lum_nuebar)
283 , fNuxFitParams(Emean_nux, alpha_nux, lum_nux)
289 double Time()
const {
return fTime; }
299 else if (pdg_code == marley_utils::ELECTRON_ANTINEUTRINO) {
302 else if (is_nux(pdg_code)) {
308 <<
"Invalid neutrino" 309 <<
" PDG code " << pdg_code <<
" encountered in MARLEYTimeGen" 310 <<
"::TimeFit::GetFitParametersMemberPointer()";
320 return this->*GetFitParametersMemberPointer(pdg_code);
333 template <
typename It>
337 return marley::IteratorToMember<It, FitParameters>(
iterator,
338 GetFitParametersMemberPointer(pdg_code));
365 const TLorentzVector& vertex_pos);
375 const TLorentzVector& vertex_pos);
381 const TLorentzVector& vertex_pos);
526 ,
fEvent(
new marley::Event)
539 fEventTree = tfs->make<TTree>(
"MARLEY_event_tree",
"Neutrino events generated by MARLEY");
551 produces<std::vector<simb::MCTruth>>();
552 produces<std::vector<sim::SupernovaTruth>>();
553 produces<art::Assns<simb::MCTruth, sim::SupernovaTruth>>();
554 produces<sumdata::RunData, art::InRun>();
567 const TLorentzVector& vertex_pos)
579 double E_nu =
fEvent->projectile().total_energy();
581 TH1D* t_hist =
fSpectrumHist->ProjectionX(
"dummy_time_hist", E_bin_index, E_bin_index);
582 double* time_bin_weights = t_hist->GetArray();
585 std::discrete_distribution<int> time_dist;
586 std::discrete_distribution<int>::param_type time_params(
587 time_bin_weights, &(time_bin_weights[t_hist->GetNbinsX() + 1]));
588 int time_bin_index = gen.sample_from_distribution(time_dist, time_params);
591 double t_min = t_hist->GetBinLowEdge(time_bin_index);
592 double t_max = t_min + t_hist->GetBinWidth(time_bin_index);
594 fTNu = gen.uniform_random_double(t_min, t_max,
false);
610 double t_min = time_axis->GetBinLowEdge(1);
611 double t_max = time_axis->GetBinLowEdge(time_axis->GetNbins() + 1);
613 fTNu = gen.uniform_random_double(t_min, t_max,
false);
618 double E_nu =
fEvent->projectile().total_energy();
620 TH1D* t_hist =
fSpectrumHist->ProjectionX(
"dummy_time_hist", E_bin_index, E_bin_index);
621 int t_bin_index = t_hist->FindBin(
fTNu);
622 double weight_bias = t_hist->GetBinContent(t_bin_index) * (t_max - t_min) /
623 (t_hist->Integral() * t_hist->GetBinWidth(t_bin_index));
632 TH1D* t_hist =
fSpectrumHist->ProjectionX(
"dummy_time_hist");
633 double* time_bin_weights = t_hist->GetArray();
636 std::discrete_distribution<int> time_dist;
637 std::discrete_distribution<int>::param_type time_params(
638 time_bin_weights, &(time_bin_weights[t_hist->GetNbinsX() + 1]));
639 int time_bin_index = gen.sample_from_distribution(time_dist, time_params);
642 double t_min = t_hist->GetBinLowEdge(time_bin_index);
643 double t_max = t_min + t_hist->GetBinWidth(time_bin_index);
645 fTNu = gen.uniform_random_double(t_min, t_max,
false);
650 double E_min = energy_axis->GetBinLowEdge(1);
651 double E_max = energy_axis->GetBinLowEdge(energy_axis->GetNbins() + 1);
653 double E_nu = std::numeric_limits<double>::lowest();
663 TH1D* energy_spect =
fSpectrumHist->ProjectionY(
"energy_spect", time_bin_index, time_bin_index);
669 marley_root::make_root_neutrino_source(marley_utils::ELECTRON_NEUTRINO, energy_spect);
670 double new_source_E_min = nu_source->get_Emin();
671 double new_source_E_max = nu_source->get_Emax();
672 gen.set_source(std::move(nu_source));
675 double E_pdf_integ = integrate([&gen](
double E_nu) ->
double {
return gen.E_pdf(E_nu); },
681 double weight_bias = (gen.E_pdf(E_nu) / E_pdf_integ) * (E_max - E_min);
689 throw cet::exception(
"MARLEYTimeGen") <<
"Unrecognized sampling mode" 690 <<
" encountered in evgen::MarleyTimeGen::produce()";
706 std::unique_ptr<std::vector<simb::MCTruth>> truthcol(
new std::vector<simb::MCTruth>);
708 std::unique_ptr<std::vector<sim::SupernovaTruth>> sn_truthcol(
709 new std::vector<sim::SupernovaTruth>);
711 std::unique_ptr<art::Assns<simb::MCTruth, sim::SupernovaTruth>> truth_assns(
721 TLorentzVector vertex_pos =
fVertexSampler->sample_vertex_pos(*geo);
724 fTNu = std::numeric_limits<double>::lowest();
734 <<
"Invalid spectrum file" 735 <<
" format encountered in evgen::MarleyTimeGen::produce()";
742 truthcol->push_back(truth);
744 sn_truthcol->push_back(sn_truth);
754 e.
put(std::move(truthcol));
756 e.
put(std::move(sn_truthcol));
758 e.
put(std::move(truth_assns));
769 fVertexSampler = std::make_unique<evgen::ActiveVolumeVertexSampler>(
770 p().vertex_, *seed_service, *geom_service,
"MARLEY_Vertex_Sampler");
775 fMarleyHelper = std::make_unique<MARLEYHelper>(marley_pset, *seed_service,
"MARLEY");
781 const std::string& samp_mode_str = p().sampling_mode_();
782 if (samp_mode_str ==
"histogram")
784 else if (samp_mode_str ==
"uniform time")
786 else if (samp_mode_str ==
"uniform energy")
789 throw cet::exception(
"MARLEYTimeGen") <<
"Invalid sampling mode \"" << samp_mode_str <<
"\"" 790 <<
" specified for the MARLEYTimeGen module.";
792 MF_LOG_INFO(
"MARLEYTimeGen") << fNeutrinosPerEvent <<
" neutrino vertices" 793 <<
" will be generated for each art::Event using the \"" 794 << samp_mode_str <<
"\" sampling mode.";
798 std::string spectrum_file_format = marley_utils::to_lowercase(p().spectrum_file_format_());
800 if (spectrum_file_format ==
"th2d")
802 else if (spectrum_file_format ==
"fit") {
805 std::string pinch_type;
806 if (!p().pinching_parameter_type_(pinch_type)) {
807 throw cet::exception(
"MARLEYTimeGen") <<
"Missing pinching parameter" 808 <<
" type for a \"fit\" format spectrum file";
811 marley_utils::to_lowercase_inplace(pinch_type);
812 if (pinch_type ==
"alpha")
814 else if (pinch_type ==
"beta")
817 throw cet::exception(
"MARLEYTimeGen") <<
"Invalid pinching parameter type \"" << pinch_type
818 <<
"\" specified for the MARLEYTimeGen module.";
822 <<
"Missing minimum energy for a \"fit\" format spectrum" 823 <<
" used by the MARLEYTimeGen module.";
827 <<
"Missing maximum energy for a \"fit\" format spectrum" 828 <<
" used by the MARLEYTimeGen module.";
832 <<
"Maximum energy is less than the minimum energy for" 833 <<
" a \"fit\" format spectrum used by the MARLEYTimeGen module.";
837 <<
"Invalid spectrum file format \"" << p().spectrum_file_format_()
838 <<
"\" specified for the MARLEYTimeGen module.";
841 std::string full_spectrum_file_name = fMarleyHelper->find_file(p().spectrum_file_(),
"spectrum");
843 marley::Generator& gen = fMarleyHelper->get_generator();
848 std::unique_ptr<TFile> spectrum_file =
849 std::make_unique<TFile>(full_spectrum_file_name.c_str(),
"read");
850 TH2D* temp_h2 =
nullptr;
851 std::string namecycle;
852 if (!p().namecycle_(namecycle)) {
854 <<
" a TH2D spectrum file";
857 spectrum_file->GetObject(namecycle.c_str(), temp_h2);
869 TH1D* energy_spect =
fSpectrumHist->ProjectionY(
"energy_spect");
875 std::unique_ptr<marley::NeutrinoSource> nu_source =
876 marley_root::make_root_neutrino_source(marley_utils::ELECTRON_NEUTRINO, energy_spect);
886 gen.set_source(std::move(nu_source));
896 std::ifstream fit_file(full_spectrum_file_name);
899 bool found_end =
false;
904 int lines_checked = 0;
906 double old_time = std::numeric_limits<double>::lowest();
908 while (line = marley_utils::get_next_line(fit_file, rx_comment_or_empty,
false, lines_checked),
909 line_num += lines_checked,
912 MF_LOG_WARNING(
"MARLEYTimeGen") <<
"Trailing content after last time" 913 <<
" bin found on line " << line_num
914 <<
" of the spectrum file " << full_spectrum_file_name;
918 double Emean_nue, alpha_nue, luminosity_nue;
919 double Emean_nuebar, alpha_nuebar, luminosity_nuebar;
920 double Emean_nux, alpha_nux, luminosity_nux;
921 std::istringstream iss(line);
922 bool ok_first =
static_cast<bool>(iss >> time);
924 if (time <= old_time)
926 <<
"Time bin left edges given in the spectrum file must be" 927 <<
" strictly increasing. Invalid time bin value found on line " << line_num
928 <<
" of the spectrum file " << full_spectrum_file_name;
932 bool ok_rest =
static_cast<bool>(iss >> Emean_nue >> alpha_nue >> luminosity_nue >>
933 Emean_nuebar >> alpha_nuebar >> luminosity_nuebar >>
934 Emean_nux >> alpha_nux >> luminosity_nux);
958 <<
"Parse error on line " << line_num <<
" of the spectrum file " 959 << full_spectrum_file_name;
965 if (num_time_bins < 2)
967 <<
"Missing right edge for the final time bin in the spectrum file " 968 << full_spectrum_file_name <<
". Unable to guess a bin width for the " 973 double delta_t_bin =
fTimeFits.back().Time() -
fTimeFits.at(num_time_bins - 2).Time();
975 double last_bin_right_edge =
fTimeFits.back().Time() + delta_t_bin;
981 <<
" edge for the final time bin in the spectrum file " << full_spectrum_file_name
982 <<
". Assuming a width of " << delta_t_bin <<
" s for the final bin.";
987 std::vector<std::unique_ptr<marley::NeutrinoSource>> fit_sources;
994 auto temp_source = std::make_unique<marley::FunctionNeutrinoSource>(
995 marley_utils::ELECTRON_NEUTRINO,
998 [&fit_sources,
this](
double E_nu) ->
double {
1000 for (
size_t s = 0; s < fit_sources.size(); ++s) {
1002 const TimeFit& current_fit = this->fTimeFits.at(s);
1003 const auto& current_source = fit_sources.at(s);
1011 if (lum <= 0.)
continue;
1013 flux += lum * current_source->pdf(E_nu);
1018 double flux_integ = 0.;
1019 double tot_xs_integ = 0.;
1020 flux_averaged_total_xs(*temp_source, gen, flux_integ, tot_xs_integ);
1031 <<
"Unrecognized neutrino spectrum" 1032 <<
" file format \"" << p().spectrum_file_format_() <<
"\" encountered" 1033 <<
" in evgen::MarleyTimeGen::reconfigure()";
1036 MF_LOG_INFO(
"MARLEYTimeGen") <<
"The flux-averaged total cross section" 1037 <<
" predicted by MARLEY for the current supernova spectrum is " 1044 const TLorentzVector& vertex_pos)
1052 size_t time_bin_index = std::numeric_limits<size_t>::max();
1059 int source_pdg_code = gen.get_source().get_pid();
1061 const auto fit_params_begin =
1063 const auto fit_params_end =
1069 std::discrete_distribution<size_t> time_dist(lum_begin, lum_end);
1073 time_bin_index = gen.sample_from_distribution(time_dist);
1077 int last_time_index = 0;
1079 std::uniform_int_distribution<size_t> uid(0, last_time_index);
1081 time_bin_index = gen.sample_from_distribution(uid);
1085 throw cet::exception(
"MARLEYTimeGen") <<
"Unrecognized sampling mode" 1086 <<
" encountered in evgen::MarleyTimeGen::produce()";
1095 double t_min =
fTimeFits.at(time_bin_index).Time();
1096 double t_max =
fTimeFits.at(time_bin_index + 1).Time();
1098 fTNu = gen.uniform_random_double(t_min, t_max,
false);
1104 const auto& fit =
fTimeFits.at(time_bin_index);
1111 gen.set_source(std::move(nu_source));
1126 double weight_bias = time_dist.probabilities().at(time_bin_index) / (t_max - t_min) *
1135 double E_nu = std::numeric_limits<double>::lowest();
1146 double nu_source_E_min = nu_source->get_Emin();
1147 double nu_source_E_max = nu_source->get_Emax();
1148 gen.set_source(std::move(nu_source));
1152 double E_pdf_integ = integrate(
1153 [&gen](
double E_nu) ->
double {
return gen.E_pdf(E_nu); }, nu_source_E_min, nu_source_E_max);
1157 double weight_bias = (gen.E_pdf(E_nu) / E_pdf_integ) * (
fFitEmax -
fFitEmin);
1164 throw cet::exception(
"MARLEYTimeGen") <<
"Unrecognized sampling mode" 1165 <<
" encountered in evgen::MarleyTimeGen::produce()";
1180 double beta = nue_parameters.
Alpha();
1185 <<
"Unreognized pinching parameter" 1186 <<
" type encountered in evgen::MarleyTimeGen::source_from_time_fit()";
1190 std::unique_ptr<marley::NeutrinoSource> nu_source =
1191 std::make_unique<marley::BetaFitNeutrinoSource>(
1201 const TLorentzVector& vertex_pos)
1215 if (j >= MAX_UNIFORM_ENERGY_ITERATIONS) {
1217 <<
"Exceeded the maximum of " << MAX_UNIFORM_ENERGY_ITERATIONS
1218 <<
" while attempting to sample" 1219 <<
" a neutrino energy uniformly.";
1222 E_nu = gen.uniform_random_double(E_min, E_max,
false);
1227 for (
const auto& react : gen.get_reactions()) {
1228 total_xs += react->total_xs(marley_utils::ELECTRON_NEUTRINO, E_nu);
1232 }
while (total_xs <= 0.);
1236 std::unique_ptr<marley::NeutrinoSource> nu_source =
1237 std::make_unique<marley::MonoNeutrinoSource>(marley_utils::ELECTRON_NEUTRINO, E_nu);
1238 gen.set_source(std::move(nu_source));
1252 fTimeFits.emplace_back(time, 0., 0., 0., 0., 0., 0., 0., 0., 0.);
1262 std::vector<double> temp_times;
1264 temp_times.push_back(fit.Time());
1269 if (temp_times.size() < 2)
return;
1272 int num_bins = temp_times.size() - 1;
1278 tfs->make<TH1D>(
"NueEmission",
1279 "Number of emitted #nu_{e}; time (s); number of neutrinos in time bin",
1283 tfs->make<TH1D>(
"NuebarEmission",
1284 "Number of emitted #bar{#nu}_{e}; time (s); number of neutrinos in" 1289 tfs->make<TH1D>(
"NuxEmission",
1290 "Number of emitted #nu_{x}; time (s); number of neutrinos in time bin",
1295 for (
size_t b = 1; b < temp_times.size(); ++b) {
1296 const TimeFit& current_fit = fTimeFits.at(b - 1);
1297 const TimeFit& next_fit = fTimeFits.at(b);
1298 double bin_deltaT = next_fit.
Time() - current_fit.
Time();
1300 const auto& nue_params = current_fit.
GetFitParameters(marley_utils::ELECTRON_NEUTRINO);
1301 const auto& nuebar_params = current_fit.
GetFitParameters(marley_utils::ELECTRON_ANTINEUTRINO);
1302 const auto& nux_params = current_fit.
GetFitParameters(marley_utils::MUON_NEUTRINO);
1307 double num_nue = 0.;
1308 double num_nuebar = 0.;
1309 double num_nux = 0.;
1310 if (nue_params.Emean() != 0.)
1311 num_nue = nue_params.
Luminosity() * bin_deltaT / (nue_params.Emean() * MeV_to_erg);
1312 if (nuebar_params.Emean() != 0.)
1313 num_nuebar = nuebar_params.Luminosity() * bin_deltaT / (nuebar_params.Emean() * MeV_to_erg);
1314 if (nux_params.Emean() != 0.)
1315 num_nux = nux_params.Luminosity() * bin_deltaT / (nux_params.Emean() * MeV_to_erg);
1317 nue_hist->SetBinContent(b, num_nue);
1318 nuebar_hist->SetBinContent(b, num_nuebar);
1319 nux_hist->SetBinContent(b, num_nux);
1327 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source,
1328 marley::Generator& gen,
1329 double& source_integ,
1330 double& tot_xs_integ)
1333 source_integ = integrate([&nu_source](
double E_nu) ->
double {
return nu_source.pdf(E_nu); },
1334 nu_source.get_Emin(),
1335 nu_source.get_Emax());
1337 tot_xs_integ = integrate(
1338 [&nu_source, &gen](
double E_nu) ->
double {
1340 for (
const auto& react : gen.get_reactions()) {
1341 xs += react->total_xs(marley_utils::ELECTRON_NEUTRINO, E_nu);
1343 return xs * nu_source.pdf(E_nu);
1345 nu_source.get_Emin(),
1346 nu_source.get_Emax());
1348 return tot_xs_integ / source_integ;
1351 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source, marley::Generator& gen)
1353 double dummy1, dummy2;
1354 return flux_averaged_total_xs(nu_source, gen, dummy1, dummy2);
1357 double integrate(
const std::function<
double(
double)>&
f,
double x_min,
double x_max)
1359 static marley::Integrator integrator(NUM_INTEGRATION_SAMPLING_POINTS);
1360 return integrator.num_integrate(
f, x_min, x_max);
double fLuminosity
Luminosity (erg / s)
SubRunNumber_t subRun() const
SpectrumFileFormat
Enumerated type that defines the allowed neutrino spectrum input file formats.
virtual void produce(art::Event &e) override
LArSoft interface to the MARLEY (Model of Argon Reaction Low Energy Yields) supernova neutrino event ...
FitParameters fNuebarFitParams
Fitting parameters for electron antineutrinos in this time bin.
SpectrumFileFormat fSpectrumFileFormat
Format to assume for the neutrino spectrum input file.
uint_fast32_t fEventNumber
Event number from the art::Event being processed.
double Alpha() const
Pinching parameter (dimensionless)
Stores fitting parameters for all neutrino types from a single time bin in a "fit"-format spectrum fi...
TimeFit(double time, double Emean_nue, double alpha_nue, double lum_nue, double Emean_nuebar, double alpha_nuebar, double lum_nuebar, double Emean_nux, double alpha_nux, double lum_nux)
double fTime
Time bin low edge (s)
void create_truths_time_fit(simb::MCTruth &mc_truth, sim::SupernovaTruth &sn_truth, const TLorentzVector &vertex_pos)
Create simb::MCTruth and sim::SupernovaTruth objects using a neutrino spectrum described by a previou...
void set_Alpha(double alpha)
Set the pinching parameter.
virtual void reconfigure(const Parameters &p)
EDProducer(fhicl::ParameterSet const &pset)
std::set< std::string > operator()()
PinchParamType fPinchType
The pinching parameter convention to use when interpreting the time-dependent fits.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
double fEmean
Mean neutrino energy (MeV)
FitParameters fNueFitParams
Fitting parameters for electron neutrinos in this time bin.
Stores parsed fit parameters from a single time bin and neutrino type in a "fit"-format spectrum file...
std::unique_ptr< evgen::ActiveVolumeVertexSampler > fVertexSampler
Algorithm that allows us to sample vertex locations within the active volume(s) of the detector...
std::unique_ptr< evgen::MARLEYHelper > fMarleyHelper
Object that provides an interface to the MARLEY event generator.
double fFluxAveragedCrossSection
Flux-averaged total cross section (fm2, average is taken over all energies and times for all defined ...
double fWeight
Statistical weight for the current MARLEY neutrino vertex.
TTree * fEventTree
The event TTree created by MARLEY.
double Time() const
Returns the low edge (in s) of the time bin that uses these fit parameters.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
void set_Luminosity(double lum)
Set the luminosity (erg / s)
uint_fast32_t fSubRunNumber
Subrun number from the art::Event being processed.
Arrival times were sampled uniformly.
Algorithm that samples vertex locations uniformly within the active volume of a detector. It is fully experiment-agnostic and multi-TPC aware.
uint_fast32_t fRunNumber
Run number from the art::Event being processed.
std::unique_ptr< marley::NeutrinoSource > source_from_time_fit(const TimeFit &fit)
Create a MARLEY neutrino source object using a set of fit parameters for a particular time bin...
double fAlpha
Pinching parameter.
FitParameters fNuxFitParams
Fitting parameters for non-electron-flavor neutrinos in this time bin.
#define DEFINE_ART_MODULE(klass)
TimeGenSamplingMode
Enumerated type that defines the allowed ways that a neutrino's energy and arrival time may be sample...
static marley::IteratorToMember< It, double > make_luminosity_iterator(It it)
Converts an iterator that points to a FitParameters object into an iterator that points to that objec...
void create_truths_th2d(simb::MCTruth &mc_truth, sim::SupernovaTruth &sn_truth, const TLorentzVector &vertex_pos)
Create simb::MCTruth and sim::SupernovaTruth objects using spectrum information from a ROOT TH2D...
double fTNu
Time since the supernova core bounce for the current MARLEY neutrino vertex.
PinchParamType
Enumerated type that defines the pinching parameter conventions that are understood by this module...
void set_Emean(double Emean)
Set the mean neutrino energy (MeV)
virtual void beginRun(art::Run &run) override
static FitParameters TimeFit::* GetFitParametersMemberPointer(int pdg_code)
Helper function that returns a pointer-to-member for the FitParameters object appropriate for a given...
simb::MCTruth make_uniform_energy_mctruth(double E_min, double E_max, double &E_nu, const TLorentzVector &vertex_pos)
Creates a simb::MCTruth object using a uniformly-sampled neutrino energy.
double fFitEmax
Maximum neutrino energy to consider when using a "fit"-format spectrum file.
EventNumber_t event() const
static marley::IteratorToMember< It, FitParameters > make_FitParameters_iterator(int pdg_code, It iterator)
Converts an iterator that points to a TimeFit object into an iterator that points to the appropriate ...
MarleyTimeGen(const Parameters &p)
const FitParameters & GetFitParameters(int pdg_code) const
Retrieves fit parameters for a specific neutrino type for this time bin.
FitParameters(double Emean, double alpha, double luminosity)
auto const & get_PSet() const
#define MF_LOG_INFO(category)
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
double Luminosity() const
Luminosity (erg / s)
std::unique_ptr< TH2D > fSpectrumHist
ROOT TH2D that contains the time-dependent spectrum to use when sampling neutrino times and energies...
std::unique_ptr< marley::Event > fEvent
unique_ptr to the current event created by MARLEY
unsigned int fNeutrinosPerEvent
The number of MARLEY neutrino vertices to generate in each art::Event.
Stores extra MC truth information that is recorded when generating events using a time-dependent supe...
Collection of configuration parameters for the module.
Sample directly from cross-section weighted spectrum.
TimeGenSamplingMode fSamplingMode
Represents the sampling mode to use when selecting neutrino times and energies.
double fFitEmin
Minimum neutrino energy to consider when using a "fit"-format spectrum file.
void make_final_timefit(double time)
Helper function that makes a final dummy TimeFit object so that the final real time bin can have a ri...
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::vector< TimeFit > fTimeFits
Vector that contains the fit parameter information for each time bin when using a "fit"-format spectr...
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Event generator information.
#define MF_LOG_WARNING(category)
void make_nu_emission_histograms() const
Makes ROOT histograms showing the emitted neutrinos in each time bin when using a "fit"-format spectr...
Namespace collecting geometry-related classes utilities.
Event Generation using GENIE, cosmics or single particles.
Neutrino energies were sampled uniformly.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
double Emean() const
Mean neutrino energy (MeV)