27 #include "cetlib_except/exception.h" 54 #include "marley/marley_root.hh" 55 #include "marley/marley_utils.hh" 56 #include "marley/Integrator.hh" 63 constexpr
int MAX_UNIFORM_ENERGY_ITERATIONS = 1000;
67 constexpr
double ONE = 1.;
71 constexpr
int NUM_INTEGRATION_SAMPLING_POINTS = 100;
75 constexpr
double MeV_to_erg = 1.6021766208e-6;
78 constexpr std::array<int, 4> NU_X_PDG_CODES
80 marley_utils::MUON_NEUTRINO, marley_utils::MUON_ANTINEUTRINO,
81 marley_utils::TAU_NEUTRINO, marley_utils::TAU_ANTINEUTRINO,
86 bool is_nux(
int pdg_code) {
92 const std::regex rx_comment_or_empty = std::regex(
"\\s*(#.*)?");
96 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source,
97 marley::Generator& gen);
102 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source,
103 marley::Generator& gen,
double& source_integ,
double& tot_xs_integ);
107 double integrate(
const std::function<
double(
double)>&
f,
double x_min,
127 Comment(
"Configuration for selecting the vertex location(s)")
131 Name(
"marley_parameters"),
132 Comment(
"Configuration for the MARLEY generator. Note that for" 133 " MARLEYTimeGen, the source configuration given here is ignored.")
143 Name(
"sampling_mode"),
144 Comment(
"Technique to use when sampling times and energies. Valid" 145 " options are \"histogram\", \"uniform time\"," 146 " and \"uniform energy\""),
147 std::string(
"histogram")
151 Name(
"nu_per_event"),
152 Comment(
"The number of neutrino vertices to generate in" 158 Name(
"spectrum_file_format"),
159 Comment(
"Format to assume for the neutrino spectrum file." 160 " Valid options are \"th2d\" (a ROOT file containing a " 161 " TH2D object) and \"fit\" (an ASCII text file containing" 162 " fit parameters for each time bin). This parameter is not" 168 Name(
"spectrum_file"),
169 Comment(
"Name of a file that contains a representation" 170 " of the incident (not cross section weighted) neutrino spectrum" 171 " as a function of time and energy.")
175 Name(
"pinching_parameter_type"),
176 Comment(
"Type of pinching parameter to assume when parsing" 177 " the time-dependent fit parameters for the incident neutrino" 178 " spectrum. Valid options are \"alpha\" and \"beta\". This" 179 " parameter is not case-sensitive."),
181 auto spectrum_file_format
183 return (spectrum_file_format ==
"fit");
189 Comment(
"Name of the TH2D object to use to represent the" 190 " incident neutrino spectrum. This value should match the" 191 " name of the TH2D as given in the ROOT file specified" 192 " in the \"spectrum_file\" parameter. The TH2D should use " 193 " time bins on the X axis (seconds) and energy bins on the " 196 auto spectrum_file_format
198 return (spectrum_file_format ==
"th2d");
204 Comment(
"Minimum allowed neutrino energy (MeV) for a \"fit\" format" 207 auto spectrum_file_format
209 return (spectrum_file_format ==
"fit");
215 Comment(
"Maximum allowed neutrino energy (MeV) for a \"fit\" format" 218 auto spectrum_file_format
220 return (spectrum_file_format ==
"fit");
247 : fEmean(Emean), fAlpha(alpha), fLuminosity(luminosity) {}
250 double Emean()
const {
return fEmean; }
252 double Alpha()
const {
return fAlpha; }
269 template<
typename It>
static marley::IteratorToMember<It,
286 TimeFit(
double time,
double Emean_nue,
double alpha_nue,
287 double lum_nue,
double Emean_nuebar,
double alpha_nuebar,
288 double lum_nuebar,
double Emean_nux,
double alpha_nux,
289 double lum_nux) : fTime(time),
290 fNueFitParams(Emean_nue, alpha_nue, lum_nue),
291 fNuebarFitParams(Emean_nuebar, alpha_nuebar, lum_nuebar),
292 fNuxFitParams(Emean_nux, alpha_nux, lum_nux) {}
297 double Time()
const {
return fTime; }
307 if (pdg_code == marley_utils::ELECTRON_NEUTRINO) {
310 else if (pdg_code == marley_utils::ELECTRON_ANTINEUTRINO) {
313 else if ( is_nux(pdg_code) )
319 <<
" PDG code " << pdg_code <<
" encountered in MARLEYTimeGen" 320 <<
"::TimeFit::GetFitParametersMemberPointer()";
330 return this->*GetFitParametersMemberPointer(pdg_code);
343 template<
typename It>
static marley::IteratorToMember<It,
347 return marley::IteratorToMember<It, TimeFit, FitParameters>(
348 iterator, GetFitParametersMemberPointer(pdg_code) );
373 double& E_nu,
const TLorentzVector& vertex_pos);
542 "Neutrino events generated by MARLEY");
554 produces< std::vector<simb::MCTruth> >();
555 produces< std::vector<sim::SupernovaTruth> >();
556 produces< art::Assns<simb::MCTruth, sim::SupernovaTruth> >();
557 produces< sumdata::RunData, art::InRun >();
569 std::unique_ptr<sumdata::RunData>
572 run.
put(std::move(runcol));
591 double E_nu =
fEvent->projectile().total_energy();
593 TH1D* t_hist =
fSpectrumHist->ProjectionX(
"dummy_time_hist", E_bin_index,
595 double* time_bin_weights = t_hist->GetArray();
598 std::discrete_distribution<int> time_dist;
599 std::discrete_distribution<int>::param_type time_params(time_bin_weights,
600 &(time_bin_weights[t_hist->GetNbinsX() + 1]));
601 int time_bin_index = gen.sample_from_distribution(time_dist, time_params);
604 double t_min = t_hist->GetBinLowEdge(time_bin_index);
605 double t_max = t_min + t_hist->GetBinWidth(time_bin_index);
607 fTNu = gen.uniform_random_double(t_min, t_max,
false);
626 double t_min = time_axis->GetBinLowEdge(1);
627 double t_max = time_axis->GetBinLowEdge(time_axis->GetNbins() + 1);
629 fTNu = gen.uniform_random_double(t_min, t_max,
false);
634 double E_nu =
fEvent->projectile().total_energy();
636 TH1D* t_hist =
fSpectrumHist->ProjectionX(
"dummy_time_hist", E_bin_index,
638 int t_bin_index = t_hist->FindBin(
fTNu);
639 double weight_bias = t_hist->GetBinContent(t_bin_index) * (t_max - t_min)
640 / ( t_hist->Integral() * t_hist->GetBinWidth(t_bin_index) );
651 TH1D* t_hist =
fSpectrumHist->ProjectionX(
"dummy_time_hist");
652 double* time_bin_weights = t_hist->GetArray();
655 std::discrete_distribution<int> time_dist;
656 std::discrete_distribution<int>::param_type time_params(time_bin_weights,
657 &(time_bin_weights[t_hist->GetNbinsX() + 1]));
658 int time_bin_index = gen.sample_from_distribution(time_dist, time_params);
661 double t_min = t_hist->GetBinLowEdge(time_bin_index);
662 double t_max = t_min + t_hist->GetBinWidth(time_bin_index);
664 fTNu = gen.uniform_random_double(t_min, t_max,
false);
669 double E_min = energy_axis->GetBinLowEdge(1);
670 double E_max = energy_axis->GetBinLowEdge(energy_axis->GetNbins() + 1);
672 double E_nu = std::numeric_limits<double>::lowest();
682 TH1D* energy_spect =
fSpectrumHist->ProjectionY(
"energy_spect",
683 time_bin_index, time_bin_index);
688 auto nu_source = marley_root::make_root_neutrino_source(
689 marley_utils::ELECTRON_NEUTRINO, energy_spect);
690 double new_source_E_min = nu_source->get_Emin();
691 double new_source_E_max = nu_source->get_Emax();
692 gen.set_source(std::move(nu_source));
695 double E_pdf_integ = integrate([&gen](
double E_nu)
696 ->
double {
return gen.E_pdf(E_nu); }, new_source_E_min,
701 double weight_bias = (gen.E_pdf(E_nu) / E_pdf_integ) * (E_max - E_min);
710 throw cet::exception(
"MARLEYTimeGen") <<
"Unrecognized sampling mode" 711 <<
" encountered in evgen::MarleyTimeGen::produce()";
728 std::unique_ptr< std::vector<simb::MCTruth> >
729 truthcol(
new std::vector<simb::MCTruth>);
731 std::unique_ptr< std::vector<sim::SupernovaTruth> >
732 sn_truthcol(
new std::vector<sim::SupernovaTruth>);
734 std::unique_ptr< art::Assns<simb::MCTruth, sim::SupernovaTruth> >
744 TLorentzVector vertex_pos =
fVertexSampler->sample_vertex_pos(*geo);
747 fTNu = std::numeric_limits<double>::lowest();
757 <<
" format encountered in evgen::MarleyTimeGen::produce()";
764 truthcol->push_back(truth);
766 sn_truthcol->push_back(sn_truth);
772 truthcol->size() - 1, truthcol->size());
776 e.
put(std::move(truthcol));
778 e.
put(std::move(sn_truthcol));
780 e.
put(std::move(truth_assns));
791 fVertexSampler = std::make_unique<evgen::ActiveVolumeVertexSampler>(
792 p().vertex_, *seed_service, *geom_service,
"MARLEY_Vertex_Sampler");
795 fMarleyHelper = std::make_unique<MARLEYHelper>(p().marley_parameters_,
796 *seed_service,
"MARLEY");
802 const std::string& samp_mode_str = p().sampling_mode_();
803 if (samp_mode_str ==
"histogram")
805 else if (samp_mode_str ==
"uniform time")
807 else if (samp_mode_str ==
"uniform energy")
810 <<
"Invalid sampling mode \"" << samp_mode_str <<
"\"" 811 <<
" specified for the MARLEYTimeGen module.";
813 LOG_INFO(
"MARLEYTimeGen") << fNeutrinosPerEvent <<
" neutrino vertices" 814 <<
" will be generated for each art::Event using the \"" << samp_mode_str
815 <<
"\" sampling mode.";
819 std::string spectrum_file_format = marley_utils::to_lowercase(
820 p().spectrum_file_format_());
822 if (spectrum_file_format ==
"th2d")
824 else if (spectrum_file_format ==
"fit") {
827 std::string pinch_type;
828 if ( !p().pinching_parameter_type_(pinch_type) ) {
829 throw cet::exception(
"MARLEYTimeGen") <<
"Missing pinching parameter" 830 <<
" type for a \"fit\" format spectrum file";
833 marley_utils::to_lowercase_inplace(pinch_type);
837 <<
"Invalid pinching parameter type \"" << pinch_type
838 <<
"\" specified for the MARLEYTimeGen module.";
841 <<
"Missing minimum energy for a \"fit\" format spectrum" 842 <<
" used by the MARLEYTimeGen module.";
845 <<
"Missing maximum energy for a \"fit\" format spectrum" 846 <<
" used by the MARLEYTimeGen module.";
849 <<
"Maximum energy is less than the minimum energy for" 850 <<
" a \"fit\" format spectrum used by the MARLEYTimeGen module.";
853 <<
"Invalid spectrum file format \"" << p().spectrum_file_format_()
854 <<
"\" specified for the MARLEYTimeGen module.";
857 std::string full_spectrum_file_name
858 = fMarleyHelper->find_file(p().spectrum_file_(),
"spectrum");
860 marley::Generator& gen = fMarleyHelper->get_generator();
865 std::unique_ptr<TFile> spectrum_file
866 = std::make_unique<TFile>(full_spectrum_file_name.c_str(),
"read");
867 TH2D* temp_h2 =
nullptr;
868 std::string namecycle;
869 if ( !p().namecycle_(namecycle) ) {
871 <<
" a TH2D spectrum file";
874 spectrum_file->GetObject(namecycle.c_str(), temp_h2);
886 TH1D* energy_spect =
fSpectrumHist->ProjectionY(
"energy_spect");
892 std::unique_ptr<marley::NeutrinoSource> nu_source
893 = marley_root::make_root_neutrino_source(marley_utils::ELECTRON_NEUTRINO,
898 * flux_averaged_total_xs(*nu_source, gen);
906 gen.set_source(std::move(nu_source));
916 std::ifstream fit_file(full_spectrum_file_name);
919 bool found_end =
false;
924 int lines_checked = 0;
926 double old_time = std::numeric_limits<double>::lowest();
928 while ( line = marley_utils::get_next_line(fit_file, rx_comment_or_empty,
929 false, lines_checked), line_num += lines_checked, !line.empty() )
932 LOG_WARNING(
"MARLEYTimeGen") <<
"Trailing content after last time" 933 <<
" bin found on line " << line_num <<
" of the spectrum file " 934 << full_spectrum_file_name;
938 double Emean_nue, alpha_nue, luminosity_nue;
939 double Emean_nuebar, alpha_nuebar, luminosity_nuebar;
940 double Emean_nux, alpha_nux, luminosity_nux;
941 std::istringstream iss(line);
942 bool ok_first =
static_cast<bool>( iss >> time );
945 <<
"Time bin left edges given in the spectrum file must be" 946 <<
" strictly increasing. Invalid time bin value found on line " 947 << line_num <<
" of the spectrum file " << full_spectrum_file_name;
948 else old_time = time;
950 bool ok_rest =
static_cast<bool>( iss >> Emean_nue >> alpha_nue
951 >> luminosity_nue >> Emean_nuebar >> alpha_nuebar >> luminosity_nuebar
952 >> Emean_nux >> alpha_nux >> luminosity_nux
959 fTimeFits.emplace_back(time, Emean_nue, alpha_nue, luminosity_nue,
960 Emean_nuebar, alpha_nuebar, luminosity_nuebar, Emean_nux,
961 alpha_nux, luminosity_nux);
968 else throw cet::exception(
"MARLEYTimeGen") <<
"Parse error on line " 969 << line_num <<
" of the spectrum file " << full_spectrum_file_name;
976 <<
"Missing right edge for the final time bin in the spectrum file " 977 << full_spectrum_file_name <<
". Unable to guess a bin width for the " 982 double delta_t_bin =
fTimeFits.back().Time()
983 -
fTimeFits.at(num_time_bins - 2).Time();
985 double last_bin_right_edge =
fTimeFits.back().Time() + delta_t_bin;
990 <<
" edge for the final time bin in the spectrum file " 991 << full_spectrum_file_name <<
". Assuming a width of " 992 << delta_t_bin <<
" s for the final bin.";
998 std::vector< std::unique_ptr< marley::NeutrinoSource > > fit_sources;
1005 auto temp_source = std::make_unique<marley::FunctionNeutrinoSource>(
1007 [&fit_sources,
this](
double E_nu) ->
double {
1009 for (
size_t s = 0;
s < fit_sources.size(); ++
s) {
1011 const TimeFit& current_fit = this->fTimeFits.at(
s);
1012 const auto& current_source = fit_sources.at(
s);
1014 current_source->get_pid() );
1021 if (lum <= 0.)
continue;
1023 flux += lum * current_source->pdf(E_nu);
1029 double flux_integ = 0.;
1030 double tot_xs_integ = 0.;
1031 flux_averaged_total_xs(*temp_source, gen, flux_integ, tot_xs_integ);
1035 * tot_xs_integ / flux_integ;
1042 throw cet::exception(
"MARLEYTimeGen") <<
"Unrecognized neutrino spectrum" 1043 <<
" file format \"" << p().spectrum_file_format_() <<
"\" encountered" 1044 <<
" in evgen::MarleyTimeGen::reconfigure()";
1047 LOG_INFO(
"MARLEYTimeGen") <<
"The flux-averaged total cross section" 1048 <<
" predicted by MARLEY for the current supernova spectrum is " 1070 int source_pdg_code = gen.get_source().get_pid();
1082 std::discrete_distribution<size_t> time_dist(lum_begin, lum_end);
1087 time_bin_index = gen.sample_from_distribution(time_dist);
1091 int last_time_index = 0;
1093 std::uniform_int_distribution<size_t> uid(0, last_time_index);
1095 time_bin_index = gen.sample_from_distribution(uid);
1099 throw cet::exception(
"MARLEYTimeGen") <<
"Unrecognized sampling mode" 1100 <<
" encountered in evgen::MarleyTimeGen::produce()";
1109 double t_min =
fTimeFits.at(time_bin_index).Time();
1110 double t_max =
fTimeFits.at(time_bin_index + 1).Time();
1112 fTNu = gen.uniform_random_double(t_min, t_max,
false);
1118 const auto& fit =
fTimeFits.at(time_bin_index);
1126 gen.set_source(std::move(nu_source));
1142 double weight_bias = time_dist.probabilities().at(time_bin_index)
1143 / (t_max - t_min) * (
fTimeFits.back().Time()
1154 double E_nu = std::numeric_limits<double>::lowest();
1166 double nu_source_E_min = nu_source->get_Emin();
1167 double nu_source_E_max = nu_source->get_Emax();
1168 gen.set_source(std::move(nu_source));
1172 double E_pdf_integ = integrate([&gen](
double E_nu)
1173 ->
double {
return gen.E_pdf(E_nu); }, nu_source_E_min,
1178 double weight_bias = (gen.E_pdf(E_nu) / E_pdf_integ)
1187 throw cet::exception(
"MARLEYTimeGen") <<
"Unrecognized sampling mode" 1188 <<
" encountered in evgen::MarleyTimeGen::produce()";
1194 std::unique_ptr<marley::NeutrinoSource>
1208 throw cet::exception(
"MARLEYTimeGen") <<
"Unreognized pinching parameter" 1209 <<
" type encountered in evgen::MarleyTimeGen::source_from_time_fit()";
1213 std::unique_ptr<marley::NeutrinoSource> nu_source
1214 = std::make_unique<marley::BetaFitNeutrinoSource>(
1223 double E_max,
double& E_nu,
const TLorentzVector& vertex_pos)
1237 if (j >= MAX_UNIFORM_ENERGY_ITERATIONS) {
1238 throw cet::exception(
"MARLEYTimeGen") <<
"Exceeded the maximum of " 1239 << MAX_UNIFORM_ENERGY_ITERATIONS <<
" while attempting to sample" 1240 <<
" a neutrino energy uniformly.";
1243 E_nu = gen.uniform_random_double(E_min, E_max,
false);
1248 for (
const auto& react : gen.get_reactions()) {
1249 total_xs += react->total_xs(marley_utils::ELECTRON_NEUTRINO, E_nu);
1253 }
while (total_xs <= 0.);
1257 std::unique_ptr<marley::NeutrinoSource> nu_source
1258 = std::make_unique<marley::MonoNeutrinoSource>(
1259 marley_utils::ELECTRON_NEUTRINO, E_nu);
1260 gen.set_source(std::move(nu_source));
1274 fTimeFits.emplace_back(time, 0., 0., 0., 0., 0., 0., 0., 0., 0.);
1284 std::vector<double> temp_times;
1285 for (
const auto& fit :
fTimeFits) temp_times.push_back(fit.Time());
1290 if (temp_times.size() < 2)
return;
1293 int num_bins = temp_times.size() - 1;
1298 TH1D* nue_hist = tfs->
make<TH1D>(
"NueEmission",
1299 "Number of emitted #nu_{e}; time (s); number of neutrinos in time bin",
1300 num_bins, temp_times.data());
1301 TH1D* nuebar_hist = tfs->
make<TH1D>(
"NuebarEmission",
1302 "Number of emitted #bar{#nu}_{e}; time (s); number of neutrinos in" 1303 " time bin", num_bins, temp_times.data());
1304 TH1D* nux_hist = tfs->
make<TH1D>(
"NuxEmission",
1305 "Number of emitted #nu_{x}; time (s); number of neutrinos in time bin",
1306 num_bins, temp_times.data());
1309 for (
size_t b = 1; b < temp_times.size(); ++b) {
1310 const TimeFit& current_fit = fTimeFits.at(b - 1);
1311 const TimeFit& next_fit = fTimeFits.at(b);
1312 double bin_deltaT = next_fit.
Time() - current_fit.
Time();
1315 marley_utils::ELECTRON_NEUTRINO);
1317 marley_utils::ELECTRON_ANTINEUTRINO);
1319 marley_utils::MUON_NEUTRINO);
1324 double num_nue = 0.;
1325 double num_nuebar = 0.;
1326 double num_nux = 0.;
1327 if (nue_params.Emean() != 0.) num_nue = nue_params.
Luminosity()
1328 * bin_deltaT / (nue_params.Emean() * MeV_to_erg);
1329 if (nuebar_params.Emean() != 0.) num_nuebar = nuebar_params.Luminosity()
1330 * bin_deltaT / (nuebar_params.Emean() * MeV_to_erg);
1331 if (nux_params.Emean() != 0.) num_nux = nux_params.Luminosity()
1332 * bin_deltaT / (nux_params.Emean() * MeV_to_erg);
1334 nue_hist->SetBinContent(b, num_nue);
1335 nuebar_hist->SetBinContent(b, num_nuebar);
1336 nux_hist->SetBinContent(b, num_nux);
1346 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source,
1347 marley::Generator& gen,
double& source_integ,
double& tot_xs_integ)
1350 source_integ = integrate(
1351 [&nu_source](
double E_nu) ->
double {
return nu_source.pdf(E_nu); },
1352 nu_source.get_Emin(), nu_source.get_Emax()
1355 tot_xs_integ = integrate(
1356 [&nu_source, &gen](
double E_nu) ->
double 1359 for (
const auto& react : gen.get_reactions()) {
1360 xs += react->total_xs(marley_utils::ELECTRON_NEUTRINO, E_nu);
1362 return xs * nu_source.pdf(E_nu);
1363 }, nu_source.get_Emin(), nu_source.get_Emax()
1366 return tot_xs_integ / source_integ;
1369 double flux_averaged_total_xs(marley::NeutrinoSource& nu_source,
1370 marley::Generator& gen)
1372 double dummy1, dummy2;
1373 return flux_averaged_total_xs(nu_source, gen, dummy1, dummy2);
1376 double integrate(
const std::function<
double(
double)>&
f,
double x_min,
1379 static marley::Integrator integrator(NUM_INTEGRATION_SAMPLING_POINTS);
1380 return integrator.num_integrate(
f, x_min, x_max);
double fLuminosity
Luminosity (erg / s)
SubRunNumber_t subRun() const
#define LOG_INFO(category)
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.
fhicl::Atom< std::string > sampling_mode_
virtual void reconfigure(const Parameters &p)
PinchParamType fPinchType
The pinching parameter convention to use when interpreting the time-dependent fits.
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...
art::ProductID put(std::unique_ptr< PROD > &&)
std::unique_ptr< evgen::ActiveVolumeVertexSampler > fVertexSampler
Algorithm that allows us to sample vertex locations within the active volume(s) of the detector...
fhicl::Atom< std::string > module_type_
std::unique_ptr< evgen::MARLEYHelper > fMarleyHelper
Object that provides an interface to the MARLEY event generator.
static marley::IteratorToMember< It, TimeFit, 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 ...
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.
ProductID put(std::unique_ptr< PROD > &&product)
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...
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
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...
fhicl::Table< evgen::MARLEYHelper::Config > marley_parameters_
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.
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
fhicl::OptionalAtom< double > fit_Emax_
EventNumber_t event() const
MarleyTimeGen(const Parameters &p)
const FitParameters & GetFitParameters(int pdg_code) const
Retrieves fit parameters for a specific neutrino type for this time bin.
static marley::IteratorToMember< It, FitParameters, double > make_luminosity_iterator(It it)
Converts an iterator that points to a FitParameters object into an iterator that points to that objec...
FitParameters(double Emean, double alpha, double luminosity)
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
fhicl::OptionalAtom< std::string > namecycle_
#define LOG_WARNING(category)
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...
fhicl::Atom< std::string > spectrum_file_format_
std::unique_ptr< marley::Event > fEvent
unique_ptr to the current event created by MARLEY
T * make(ARGS...args) const
Utility object to perform functions of association.
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...
fhicl::Atom< unsigned int > nu_per_event_
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
fhicl::OptionalAtom< std::string > pinching_parameter_type_
std::vector< TimeFit > fTimeFits
Vector that contains the fit parameter information for each time bin when using a "fit"-format spectr...
fhicl::Table< evgen::ActiveVolumeVertexSampler::Config > vertex_
Event generator information.
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
fhicl::Atom< std::string > spectrum_file_
cet::coded_exception< error, detail::translate > exception
fhicl::OptionalAtom< double > fit_Emin_
double Emean() const
Mean neutrino energy (MeV)