All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
evgen::MarleyTimeGen Class Reference
Inheritance diagram for evgen::MarleyTimeGen:

Classes

struct  Config
 Collection of configuration parameters for the module. More...
 
class  FitParameters
 Stores parsed fit parameters from a single time bin and neutrino type in a "fit"-format spectrum file. More...
 
struct  KeysToIgnore
 
class  TimeFit
 Stores fitting parameters for all neutrino types from a single time bin in a "fit"-format spectrum file. More...
 

Public Types

using Name = fhicl::Name
 
using Comment = fhicl::Comment
 
using Parameters = art::EDProducer::Table< Config, KeysToIgnore >
 

Public Member Functions

 MarleyTimeGen (const Parameters &p)
 
virtual void produce (art::Event &e) override
 
virtual void beginRun (art::Run &run) override
 
virtual void reconfigure (const Parameters &p)
 

Protected Types

enum  TimeGenSamplingMode { TimeGenSamplingMode::HISTOGRAM, TimeGenSamplingMode::UNIFORM_TIME, TimeGenSamplingMode::UNIFORM_ENERGY }
 Enumerated type that defines the allowed ways that a neutrino's energy and arrival time may be sampled. More...
 
enum  PinchParamType { PinchParamType::ALPHA, PinchParamType::BETA }
 Enumerated type that defines the pinching parameter conventions that are understood by this module. More...
 
enum  SpectrumFileFormat { SpectrumFileFormat::RootTH2D, SpectrumFileFormat::FIT }
 Enumerated type that defines the allowed neutrino spectrum input file formats. More...
 

Protected Member Functions

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. More...
 
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. More...
 
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. More...
 
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 previously-parsed "fit"-format file. More...
 
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 right edge. More...
 
void make_nu_emission_histograms () const
 Makes ROOT histograms showing the emitted neutrinos in each time bin when using a "fit"-format spectrum file. More...
 

Protected Attributes

std::unique_ptr
< evgen::MARLEYHelper
fMarleyHelper
 Object that provides an interface to the MARLEY event generator. More...
 
std::unique_ptr
< evgen::ActiveVolumeVertexSampler
fVertexSampler
 Algorithm that allows us to sample vertex locations within the active volume(s) of the detector. More...
 
std::unique_ptr< marley::Event > fEvent
 unique_ptr to the current event created by MARLEY More...
 
std::unique_ptr< TH2D > fSpectrumHist
 ROOT TH2D that contains the time-dependent spectrum to use when sampling neutrino times and energies. More...
 
std::vector< TimeFitfTimeFits
 Vector that contains the fit parameter information for each time bin when using a "fit"-format spectrum file. More...
 
TimeGenSamplingMode fSamplingMode
 Represents the sampling mode to use when selecting neutrino times and energies. More...
 
PinchParamType fPinchType
 The pinching parameter convention to use when interpreting the time-dependent fits. More...
 
SpectrumFileFormat fSpectrumFileFormat
 Format to assume for the neutrino spectrum input file. More...
 
TTree * fEventTree
 The event TTree created by MARLEY. More...
 
uint_fast32_t fRunNumber
 Run number from the art::Event being processed. More...
 
uint_fast32_t fSubRunNumber
 Subrun number from the art::Event being processed. More...
 
uint_fast32_t fEventNumber
 Event number from the art::Event being processed. More...
 
double fTNu
 Time since the supernova core bounce for the current MARLEY neutrino vertex. More...
 
double fWeight
 Statistical weight for the current MARLEY neutrino vertex. More...
 
double fFluxAveragedCrossSection
 Flux-averaged total cross section (fm2, average is taken over all energies and times for all defined reactions) used by MARLEY to generate neutrino vertices. More...
 
unsigned int fNeutrinosPerEvent
 The number of MARLEY neutrino vertices to generate in each art::Event. More...
 
double fFitEmin
 Minimum neutrino energy to consider when using a "fit"-format spectrum file. More...
 
double fFitEmax
 Maximum neutrino energy to consider when using a "fit"-format spectrum file. More...
 

Detailed Description

Definition at line 112 of file MARLEYTimeGen_module.cc.

Member Typedef Documentation

using evgen::MarleyTimeGen::Comment = fhicl::Comment

Definition at line 117 of file MARLEYTimeGen_module.cc.

using evgen::MarleyTimeGen::Name = fhicl::Name

Definition at line 116 of file MARLEYTimeGen_module.cc.

using evgen::MarleyTimeGen::Parameters = art::EDProducer::Table<Config, KeysToIgnore>

Definition at line 227 of file MARLEYTimeGen_module.cc.

Member Enumeration Documentation

Enumerated type that defines the pinching parameter conventions that are understood by this module.

Enumerator
ALPHA 
BETA 

Definition at line 464 of file MARLEYTimeGen_module.cc.

464 { ALPHA, BETA };

Enumerated type that defines the allowed neutrino spectrum input file formats.

Enumerator
RootTH2D 
FIT 

Definition at line 485 of file MARLEYTimeGen_module.cc.

485 { RootTH2D, FIT };

Enumerated type that defines the allowed ways that a neutrino's energy and arrival time may be sampled.

Enumerator
HISTOGRAM 
UNIFORM_TIME 
UNIFORM_ENERGY 

Definition at line 433 of file MARLEYTimeGen_module.cc.

433 { HISTOGRAM, UNIFORM_TIME, UNIFORM_ENERGY };

Constructor & Destructor Documentation

evgen::MarleyTimeGen::MarleyTimeGen ( const Parameters p)
explicit

Definition at line 529 of file MARLEYTimeGen_module.cc.

530  : EDProducer{ p.get_PSet() }, fEvent(new marley::Event), fRunNumber(0),
532 {
533  // Configure the module (including MARLEY itself) using the FHiCL parameters
534  this->reconfigure(p);
535 
536  // Create a ROOT TTree using the TFileService that will store the MARLEY
537  // event objects (useful for debugging purposes)
538  art::ServiceHandle<art::TFileService const> tfs;
539  fEventTree = tfs->make<TTree>("MARLEY_event_tree",
540  "Neutrino events generated by MARLEY");
541  fEventTree->Branch("event", "marley::Event", fEvent.get());
542 
543  // Add branches that give the art::Event run, subrun, and event numbers for
544  // easy match-ups between the MARLEY and art TTrees. All three are recorded
545  // as 32-bit unsigned integers.
546  fEventTree->Branch("run_number", &fRunNumber, "run_number/i");
547  fEventTree->Branch("subrun_number", &fSubRunNumber, "subrun_number/i");
548  fEventTree->Branch("event_number", &fEventNumber, "event_number/i");
549  fEventTree->Branch("tSN", &fTNu, "tSN/D");
550  fEventTree->Branch("weight", &fWeight, "weight/D");
551 
552  produces< std::vector<simb::MCTruth> >();
553  produces< std::vector<sim::SupernovaTruth> >();
554  produces< art::Assns<simb::MCTruth, sim::SupernovaTruth> >();
556 }
uint_fast32_t fEventNumber
Event number from the art::Event being processed.
virtual void reconfigure(const Parameters &p)
pdgs p
Definition: selectors.fcl:22
produces< sumdata::RunData, art::InRun >()
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.
uint_fast32_t fSubRunNumber
Subrun number from the art::Event being processed.
uint_fast32_t fRunNumber
Run number from the art::Event being processed.
double fTNu
Time since the supernova core bounce for the current MARLEY neutrino vertex.
std::unique_ptr< marley::Event > fEvent
unique_ptr to the current event created by MARLEY
art::ServiceHandle< art::TFileService > tfs

Member Function Documentation

void evgen::MarleyTimeGen::beginRun ( art::Run &  run)
overridevirtual

Definition at line 559 of file MARLEYTimeGen_module.cc.

559  {
560  art::ServiceHandle<geo::Geometry const> geo;
561  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
562 }
void evgen::MarleyTimeGen::create_truths_th2d ( simb::MCTruth &  mc_truth,
sim::SupernovaTruth sn_truth,
const TLorentzVector &  vertex_pos 
)
protected

Create simb::MCTruth and sim::SupernovaTruth objects using spectrum information from a ROOT TH2D.

Definition at line 565 of file MARLEYTimeGen_module.cc.

567 {
568  // Get a reference to the generator object created by MARLEY (we'll need
569  // to do a few fancy things with it other than just creating events)
570  marley::Generator& gen = fMarleyHelper->get_generator();
571 
573  {
574  // Generate a MARLEY event using the time-integrated spectrum
575  // (the generator was already configured to use it by reconfigure())
576  mc_truth = fMarleyHelper->create_MCTruth(vertex_pos,
577  fEvent.get());
578 
579  // Find the time distribution corresponding to the selected energy bin
580  double E_nu = fEvent->projectile().total_energy();
581  int E_bin_index = fSpectrumHist->GetYaxis()->FindBin(E_nu);
582  TH1D* t_hist = fSpectrumHist->ProjectionX("dummy_time_hist", E_bin_index,
583  E_bin_index);
584  double* time_bin_weights = t_hist->GetArray();
585 
586  // Sample a time bin from the distribution
587  std::discrete_distribution<int> time_dist;
588  std::discrete_distribution<int>::param_type time_params(time_bin_weights,
589  &(time_bin_weights[t_hist->GetNbinsX() + 1]));
590  int time_bin_index = gen.sample_from_distribution(time_dist, time_params);
591 
592  // Sample a time uniformly from within the selected time bin
593  double t_min = t_hist->GetBinLowEdge(time_bin_index);
594  double t_max = t_min + t_hist->GetBinWidth(time_bin_index);
595  // sample a time on [ t_min, t_max )
596  fTNu = gen.uniform_random_double(t_min, t_max, false);
597  // Unbiased sampling was used, so assign this neutrino vertex a
598  // unit statistical weight
599  fWeight = ONE;
600 
603  }
604 
606  {
607  // Generate a MARLEY event using the time-integrated spectrum
608  // (the generator was already configured to use it by reconfigure())
609  mc_truth = fMarleyHelper->create_MCTruth(vertex_pos,
610  fEvent.get());
611 
612  // Sample a time uniformly
613  TAxis* time_axis = fSpectrumHist->GetXaxis();
614  // underflow bin has index zero
615  double t_min = time_axis->GetBinLowEdge(1);
616  double t_max = time_axis->GetBinLowEdge(time_axis->GetNbins() + 1);
617  // sample a time on [ t_min, t_max )
618  fTNu = gen.uniform_random_double(t_min, t_max, false);
619 
620  // Get the value of the true dependent probability density (probability
621  // of the sampled time given the sampled energy) to use as a biasing
622  // correction in the neutrino vertex weight.
623  double E_nu = fEvent->projectile().total_energy();
624  int E_bin_index = fSpectrumHist->GetYaxis()->FindBin(E_nu);
625  TH1D* t_hist = fSpectrumHist->ProjectionX("dummy_time_hist", E_bin_index,
626  E_bin_index);
627  int t_bin_index = t_hist->FindBin(fTNu);
628  double weight_bias = t_hist->GetBinContent(t_bin_index) * (t_max - t_min)
629  / ( t_hist->Integral() * t_hist->GetBinWidth(t_bin_index) );
630 
631  fWeight = weight_bias;
632 
635  }
636 
638  {
639  // Select a time bin using the energy-integrated spectrum
640  TH1D* t_hist = fSpectrumHist->ProjectionX("dummy_time_hist");
641  double* time_bin_weights = t_hist->GetArray();
642 
643  // Sample a time bin from the distribution
644  std::discrete_distribution<int> time_dist;
645  std::discrete_distribution<int>::param_type time_params(time_bin_weights,
646  &(time_bin_weights[t_hist->GetNbinsX() + 1]));
647  int time_bin_index = gen.sample_from_distribution(time_dist, time_params);
648 
649  // Sample a time uniformly from within the selected time bin
650  double t_min = t_hist->GetBinLowEdge(time_bin_index);
651  double t_max = t_min + t_hist->GetBinWidth(time_bin_index);
652  // sample a time on [ t_min, t_max )
653  fTNu = gen.uniform_random_double(t_min, t_max, false);
654 
655  // Sample an energy uniformly over the entire allowed range
656  // underflow bin has index zero
657  TAxis* energy_axis = fSpectrumHist->GetYaxis();
658  double E_min = energy_axis->GetBinLowEdge(1);
659  double E_max = energy_axis->GetBinLowEdge(energy_axis->GetNbins() + 1);
660 
661  double E_nu = std::numeric_limits<double>::lowest();
662 
663  // Generate a MARLEY event using a uniformly sampled energy
664  mc_truth = make_uniform_energy_mctruth(E_min, E_max, E_nu, vertex_pos);
665 
666  // Get the value of the true dependent probability density (probability
667  // of the sampled energy given the sampled time) to use as a biasing
668  // correction in the neutrino vertex weight.
669  //
670  // Get a 1D projection of the energy spectrum for the sampled time bin
671  TH1D* energy_spect = fSpectrumHist->ProjectionY("energy_spect",
672  time_bin_index, time_bin_index);
673 
674  // Create a new MARLEY neutrino source object using this projection (this
675  // will create a normalized probability density that we can use) and load
676  // it into the generator.
677  auto nu_source = marley_root::make_root_neutrino_source(
678  marley_utils::ELECTRON_NEUTRINO, energy_spect);
679  double new_source_E_min = nu_source->get_Emin();
680  double new_source_E_max = nu_source->get_Emax();
681  gen.set_source(std::move(nu_source));
682  // NOTE: The marley::Generator object normalizes the E_pdf to unity
683  // automatically, but just in case, we redo it here.
684  double E_pdf_integ = integrate([&gen](double E_nu)
685  -> double { return gen.E_pdf(E_nu); }, new_source_E_min,
686  new_source_E_max);
687 
688  // Compute the likelihood ratio that we need to bias the neutrino vertex
689  // weight
690  double weight_bias = (gen.E_pdf(E_nu) / E_pdf_integ) * (E_max - E_min);
691 
692  fWeight = weight_bias;
693 
696  }
697 
698  else {
699  throw cet::exception("MARLEYTimeGen") << "Unrecognized sampling mode"
700  << " encountered in evgen::MarleyTimeGen::produce()";
701  }
702 
703 }
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.
Arrival times were sampled uniformly.
double fTNu
Time since the supernova core bounce for the current MARLEY neutrino vertex.
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.
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
Sample directly from cross-section weighted spectrum.
TimeGenSamplingMode fSamplingMode
Represents the sampling mode to use when selecting neutrino times and energies.
Neutrino energies were sampled uniformly.
void evgen::MarleyTimeGen::create_truths_time_fit ( simb::MCTruth &  mc_truth,
sim::SupernovaTruth sn_truth,
const TLorentzVector &  vertex_pos 
)
protected

Create simb::MCTruth and sim::SupernovaTruth objects using a neutrino spectrum described by a previously-parsed "fit"-format file.

Definition at line 1045 of file MARLEYTimeGen_module.cc.

1047 {
1048  // Get a reference to the generator object created by MARLEY (we'll need
1049  // to do a few fancy things with it other than just creating events)
1050  marley::Generator& gen = fMarleyHelper->get_generator();
1051 
1052  // Initialize the time bin index to something absurdly large. This will help
1053  // us detect strange bugs that arise when it is sampled incorrectly.
1054  size_t time_bin_index = std::numeric_limits<size_t>::max();
1055 
1056  // Create an object to represent the discrete time distribution given in
1057  // the spectrum file. Use the luminosity for each bin as its sampling weight.
1058  // This distribution will actually be used to sample a neutrino arrival time
1059  // unless we're using the uniform time sampling mode, in which case it will
1060  // be used to help calculate the neutrino vertex weight.
1061  int source_pdg_code = gen.get_source().get_pid();
1062 
1063  const auto fit_params_begin = TimeFit::make_FitParameters_iterator(
1064  source_pdg_code, fTimeFits.begin() );
1065  const auto fit_params_end = TimeFit::make_FitParameters_iterator(
1066  source_pdg_code, fTimeFits.end() );
1067 
1068  const auto lum_begin = FitParameters::make_luminosity_iterator(
1069  fit_params_begin);
1070  const auto lum_end = FitParameters::make_luminosity_iterator(
1071  fit_params_end);
1072 
1073  std::discrete_distribution<size_t> time_dist(lum_begin, lum_end);
1074 
1077  {
1078  time_bin_index = gen.sample_from_distribution(time_dist);
1079  }
1080 
1082  int last_time_index = 0;
1083  if (fTimeFits.size() > 0) last_time_index = fTimeFits.size() - 1;
1084  std::uniform_int_distribution<size_t> uid(0, last_time_index);
1085  // for c2: time_bin_index has already been declared
1086  time_bin_index = gen.sample_from_distribution(uid);
1087  }
1088 
1089  else {
1090  throw cet::exception("MARLEYTimeGen") << "Unrecognized sampling mode"
1091  << " encountered in evgen::MarleyTimeGen::produce()";
1092  }
1093 
1094  // Sample a time uniformly from within the selected time bin. Note that
1095  // the entries in fTimeFits use the time_ member to store the bin left
1096  // edges. The module creates fTimeFits in such a way that its last element
1097  // will always have luminosity_ == 0. (zero sampling weight), so we may
1098  // always add one to the sampled bin index without worrying about going
1099  // off the edge.
1100  double t_min = fTimeFits.at(time_bin_index).Time();
1101  double t_max = fTimeFits.at(time_bin_index + 1).Time();
1102  // sample a time on [ t_min, t_max )
1103  fTNu = gen.uniform_random_double(t_min, t_max, false);
1104 
1105  // Create a "beta-fit" neutrino source using the correct parameters for the
1106  // sampled time bin. This will be used to sample a neutrino energy unless
1107  // we're using the uniform time sampling mode. For uniform time sampling,
1108  // it will be used to determine the neutrino event weight.
1109  const auto& fit = fTimeFits.at(time_bin_index);
1110  std::unique_ptr<marley::NeutrinoSource> nu_source = source_from_time_fit(fit);
1111 
1114  {
1115  // Replace the generator's old source with the new one for the current
1116  // time bin
1117  gen.set_source(std::move(nu_source));
1118 
1119  // Generate a MARLEY event using the updated source
1120  mc_truth = fMarleyHelper->create_MCTruth(vertex_pos, fEvent.get());
1121 
1123  // Unbiased sampling creates neutrino vertices with unit weight
1124  fWeight = ONE;
1126  sim::kUnbiased);
1127  }
1128  else {
1129  // fSamplingMode == TimeGenSamplingMode::UNIFORM_TIME
1130 
1131  // Multiply by the likelihood ratio in order to correct for uniform
1132  // time sampling if we're using that biasing method
1133  double weight_bias = time_dist.probabilities().at(time_bin_index)
1134  / (t_max - t_min) * ( fTimeFits.back().Time()
1135  - fTimeFits.front().Time() );
1136 
1137  fWeight = weight_bias;
1140  }
1141  }
1142 
1144  {
1145  double E_nu = std::numeric_limits<double>::lowest();
1146  mc_truth = make_uniform_energy_mctruth(fFitEmin, fFitEmax, E_nu,
1147  vertex_pos);
1148 
1149  // Get the value of the true dependent probability density (probability
1150  // of the sampled energy given the sampled time) to use as a biasing
1151  // correction in the neutrino vertex weight.
1152 
1153  // Load the generator with the neutrino source that represents the
1154  // true (i.e., unbiased) energy probability distribution. This will
1155  // create a normalized probability density that we can use to determine
1156  // the neutrino vertex weight.
1157  double nu_source_E_min = nu_source->get_Emin();
1158  double nu_source_E_max = nu_source->get_Emax();
1159  gen.set_source(std::move(nu_source));
1160 
1161  // NOTE: The marley::Generator object normalizes the E_pdf to unity
1162  // automatically, but just in case, we redo it here.
1163  double E_pdf_integ = integrate([&gen](double E_nu)
1164  -> double { return gen.E_pdf(E_nu); }, nu_source_E_min,
1165  nu_source_E_max);
1166 
1167  // Compute the likelihood ratio that we need to bias the neutrino vertex
1168  // weight
1169  double weight_bias = (gen.E_pdf(E_nu) / E_pdf_integ)
1170  * (fFitEmax - fFitEmin);
1171 
1172  fWeight = weight_bias;
1175  }
1176 
1177  else {
1178  throw cet::exception("MARLEYTimeGen") << "Unrecognized sampling mode"
1179  << " encountered in evgen::MarleyTimeGen::produce()";
1180  }
1181 
1182 }
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.
Arrival times were sampled uniformly.
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...
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...
double fTNu
Time since the supernova core bounce for the current MARLEY neutrino vertex.
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 &quot;fit&quot;-format spectrum file.
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 ...
std::unique_ptr< marley::Event > fEvent
unique_ptr to the current event created by MARLEY
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 &quot;fit&quot;-format spectrum file.
std::vector< TimeFit > fTimeFits
Vector that contains the fit parameter information for each time bin when using a &quot;fit&quot;-format spectr...
Neutrino energies were sampled uniformly.
void evgen::MarleyTimeGen::make_final_timefit ( double  time)
protected

Helper function that makes a final dummy TimeFit object so that the final real time bin can have a right edge.

Definition at line 1260 of file MARLEYTimeGen_module.cc.

1261 {
1262  // The final time bin has zero luminosity, and therefore zero sampling
1263  // weight. We need it to be present so that the last nonzero weight bin
1264  // has a right edge.
1265  fTimeFits.emplace_back(time, 0., 0., 0., 0., 0., 0., 0., 0., 0.);
1266 }
std::vector< TimeFit > fTimeFits
Vector that contains the fit parameter information for each time bin when using a &quot;fit&quot;-format spectr...
void evgen::MarleyTimeGen::make_nu_emission_histograms ( ) const
protected

Makes ROOT histograms showing the emitted neutrinos in each time bin when using a "fit"-format spectrum file.

Definition at line 1269 of file MARLEYTimeGen_module.cc.

1270 {
1271  // To make a histogram with variable size bins, ROOT needs the bin
1272  // low edges to be contiguous in memory. This is not true of the
1273  // stored times in fTimeFits, so we'll need to make a temporary copy
1274  // of them.
1275  std::vector<double> temp_times;
1276  for (const auto& fit : fTimeFits) temp_times.push_back(fit.Time());
1277 
1278  // If, for some reason, there are fewer than two time bins, just return
1279  // without making the histograms.
1280  // TODO: consider throwing an exception here
1281  if (temp_times.size() < 2) return;
1282 
1283  // Get the number of time bins
1284  int num_bins = temp_times.size() - 1;
1285 
1286  // Create some ROOT TH1D objects using the TFileService. These will store
1287  // the number of emitted neutrinos of each type in each time bin
1288  art::ServiceHandle<art::TFileService const> tfs;
1289  TH1D* nue_hist = tfs->make<TH1D>("NueEmission",
1290  "Number of emitted #nu_{e}; time (s); number of neutrinos in time bin",
1291  num_bins, temp_times.data());
1292  TH1D* nuebar_hist = tfs->make<TH1D>("NuebarEmission",
1293  "Number of emitted #bar{#nu}_{e}; time (s); number of neutrinos in"
1294  " time bin", num_bins, temp_times.data());
1295  TH1D* nux_hist = tfs->make<TH1D>("NuxEmission",
1296  "Number of emitted #nu_{x}; time (s); number of neutrinos in time bin",
1297  num_bins, temp_times.data());
1298 
1299  // Load the histograms with the emitted neutrino counts
1300  for (size_t b = 1; b < temp_times.size(); ++b) {
1301  const TimeFit& current_fit = fTimeFits.at(b - 1);
1302  const TimeFit& next_fit = fTimeFits.at(b);
1303  double bin_deltaT = next_fit.Time() - current_fit.Time();
1304 
1305  const auto& nue_params = current_fit.GetFitParameters(
1306  marley_utils::ELECTRON_NEUTRINO);
1307  const auto& nuebar_params = current_fit.GetFitParameters(
1308  marley_utils::ELECTRON_ANTINEUTRINO);
1309  const auto& nux_params = current_fit.GetFitParameters(
1310  marley_utils::MUON_NEUTRINO);
1311 
1312  // Convert from bin luminosity to number of neutrinos by
1313  // multiplying by the bin time interval and dividing by the
1314  // mean neutrino energy
1315  double num_nue = 0.;
1316  double num_nuebar = 0.;
1317  double num_nux = 0.;
1318  if (nue_params.Emean() != 0.) num_nue = nue_params.Luminosity()
1319  * bin_deltaT / (nue_params.Emean() * MeV_to_erg);
1320  if (nuebar_params.Emean() != 0.) num_nuebar = nuebar_params.Luminosity()
1321  * bin_deltaT / (nuebar_params.Emean() * MeV_to_erg);
1322  if (nux_params.Emean() != 0.) num_nux = nux_params.Luminosity()
1323  * bin_deltaT / (nux_params.Emean() * MeV_to_erg);
1324 
1325  nue_hist->SetBinContent(b, num_nue);
1326  nuebar_hist->SetBinContent(b, num_nuebar);
1327  nux_hist->SetBinContent(b, num_nux);
1328  }
1329 
1330 }
std::vector< TimeFit > fTimeFits
Vector that contains the fit parameter information for each time bin when using a &quot;fit&quot;-format spectr...
art::ServiceHandle< art::TFileService > tfs
simb::MCTruth evgen::MarleyTimeGen::make_uniform_energy_mctruth ( double  E_min,
double  E_max,
double &  E_nu,
const TLorentzVector &  vertex_pos 
)
protected

Creates a simb::MCTruth object using a uniformly-sampled neutrino energy.

This function samples a reacting neutrino energy uniformly from the full range of energies allowed by the incident spectrum and the currently defined reactions.

Definition at line 1213 of file MARLEYTimeGen_module.cc.

1215 {
1216  marley::Generator& gen = fMarleyHelper->get_generator();
1217 
1218  // Sample an energy uniformly over the entire allowed range
1219  double total_xs;
1220  int j = 0;
1221  do {
1222  // We have to check that the cross section is nonzero for the sampled
1223  // energy (otherwise we'll generate an unphysical event). However, if the
1224  // user has given us a histogram that is below threshold, the
1225  // program could get stuck here endlessly, sampling rejected energy
1226  // after rejected energy. Just in case, we cap the total number of tries
1227  // and quit if things don't work out.
1228  if (j >= MAX_UNIFORM_ENERGY_ITERATIONS) {
1229  throw cet::exception("MARLEYTimeGen") << "Exceeded the maximum of "
1230  << MAX_UNIFORM_ENERGY_ITERATIONS << " while attempting to sample"
1231  << " a neutrino energy uniformly.";
1232  }
1233  // Sample an energy uniformly on [ E_min, E_max )
1234  E_nu = gen.uniform_random_double(E_min, E_max, false);
1235  total_xs = 0.;
1236  // Check that at least one defined reaction has a non-zero total
1237  // cross section at the sampled energy. If this is not the case, try
1238  // again.
1239  for (const auto& react : gen.get_reactions()) {
1240  total_xs += react->total_xs(marley_utils::ELECTRON_NEUTRINO, E_nu);
1241  }
1242 
1243  ++j;
1244  } while (total_xs <= 0.);
1245 
1246  // Replace the existing neutrino source with a monoenergetic one at the
1247  // neutrino energy that was just sampled above
1248  std::unique_ptr<marley::NeutrinoSource> nu_source
1249  = std::make_unique<marley::MonoNeutrinoSource>(
1250  marley_utils::ELECTRON_NEUTRINO, E_nu);
1251  gen.set_source(std::move(nu_source));
1252 
1253  // Generate a MARLEY event using the new monoenergetic source
1254  auto mc_truth = fMarleyHelper->create_MCTruth(vertex_pos, fEvent.get());
1255 
1256  return mc_truth;
1257 }
std::unique_ptr< evgen::MARLEYHelper > fMarleyHelper
Object that provides an interface to the MARLEY event generator.
std::unique_ptr< marley::Event > fEvent
unique_ptr to the current event created by MARLEY
void evgen::MarleyTimeGen::produce ( art::Event &  e)
overridevirtual

Definition at line 706 of file MARLEYTimeGen_module.cc.

707 {
708  art::ServiceHandle<geo::Geometry const> geo;
709 
710  // Get the run, subrun, and event numbers from the current art::Event
711  fRunNumber = e.run();
712  fSubRunNumber = e.subRun();
713  fEventNumber = e.event();
714 
715  // Prepare associations and vectors of truth objects that will be produced
716  // and loaded into the current art::Event
717  std::unique_ptr< std::vector<simb::MCTruth> >
718  truthcol(new std::vector<simb::MCTruth>);
719 
720  std::unique_ptr< std::vector<sim::SupernovaTruth> >
721  sn_truthcol(new std::vector<sim::SupernovaTruth>);
722 
723  std::unique_ptr< art::Assns<simb::MCTruth, sim::SupernovaTruth> >
724  truth_assns(new art::Assns<simb::MCTruth, sim::SupernovaTruth>);
725 
726  // Create temporary truth objects that we will use to load the event
727  simb::MCTruth truth;
728  sim::SupernovaTruth sn_truth;
729 
730  for (unsigned int n = 0; n < fNeutrinosPerEvent; ++n) {
731 
732  // Sample a primary vertex location for this event
733  TLorentzVector vertex_pos = fVertexSampler->sample_vertex_pos(*geo);
734 
735  // Reset the neutrino's time-since-supernova to a bogus value (for now)
736  fTNu = std::numeric_limits<double>::lowest();
737 
739  create_truths_th2d(truth, sn_truth, vertex_pos);
740  }
742  create_truths_time_fit(truth, sn_truth, vertex_pos);
743  }
744  else {
745  throw cet::exception("MARLEYTimeGen") << "Invalid spectrum file"
746  << " format encountered in evgen::MarleyTimeGen::produce()";
747  }
748 
749  // Write the marley::Event object to the event tree
750  fEventTree->Fill();
751 
752  // Add the truth objects to the appropriate vectors
753  truthcol->push_back(truth);
754 
755  sn_truthcol->push_back(sn_truth);
756 
757  // Associate the last entries in each of the truth object vectors (the
758  // truth objects that were just created for the current neutrino vertex)
759  // with each other
760  truth_assns->addSingle(art::PtrMaker<simb::MCTruth>{e}(truthcol->size() - 1),
761  art::PtrMaker<sim::SupernovaTruth>{e}(sn_truthcol->size() - 1));
762  }
763 
764  // Load the completed truth object vectors and associations into the event
765  e.put(std::move(truthcol));
766 
767  e.put(std::move(sn_truthcol));
768 
769  e.put(std::move(truth_assns));
770 }
SpectrumFileFormat fSpectrumFileFormat
Format to assume for the neutrino spectrum input file.
uint_fast32_t fEventNumber
Event number from the art::Event being processed.
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...
std::unique_ptr< evgen::ActiveVolumeVertexSampler > fVertexSampler
Algorithm that allows us to sample vertex locations within the active volume(s) of the detector...
TTree * fEventTree
The event TTree created by MARLEY.
uint_fast32_t fSubRunNumber
Subrun number from the art::Event being processed.
uint_fast32_t fRunNumber
Run number from the art::Event being processed.
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.
unsigned int fNeutrinosPerEvent
The number of MARLEY neutrino vertices to generate in each art::Event.
do i e
void evgen::MarleyTimeGen::reconfigure ( const Parameters p)
virtual

Definition at line 773 of file MARLEYTimeGen_module.cc.

774 {
775  const auto& seed_service = art::ServiceHandle<rndm::NuRandomService>();
776  const auto& geom_service = art::ServiceHandle<geo::Geometry const>();
777 
778  // Create a new evgen::ActiveVolumeVertexSampler object based on the current
779  // configuration
780  fVertexSampler = std::make_unique<evgen::ActiveVolumeVertexSampler>(
781  p().vertex_, *seed_service, *geom_service, "MARLEY_Vertex_Sampler");
782 
783  // Create a new marley::Generator object based on the current configuration
784  const fhicl::ParameterSet marley_pset = p.get_PSet()
785  .get< fhicl::ParameterSet >( "marley_parameters" );
786  fMarleyHelper = std::make_unique<MARLEYHelper>( marley_pset,
787  *seed_service, "MARLEY" );
788 
789  // Get the number of neutrino vertices per event from the FHiCL parameters
790  fNeutrinosPerEvent = p().nu_per_event_();
791 
792  // Determine the current sampling mode from the FHiCL parameters
793  const std::string& samp_mode_str = p().sampling_mode_();
794  if (samp_mode_str == "histogram")
796  else if (samp_mode_str == "uniform time")
798  else if (samp_mode_str == "uniform energy")
800  else throw cet::exception("MARLEYTimeGen")
801  << "Invalid sampling mode \"" << samp_mode_str << "\""
802  << " specified for the MARLEYTimeGen module.";
803 
804  MF_LOG_INFO("MARLEYTimeGen") << fNeutrinosPerEvent << " neutrino vertices"
805  << " will be generated for each art::Event using the \"" << samp_mode_str
806  << "\" sampling mode.";
807 
808  // Retrieve the time-dependent neutrino spectrum from the spectrum file.
809  // Use different methods depending on the file's format.
810  std::string spectrum_file_format = marley_utils::to_lowercase(
811  p().spectrum_file_format_());
812 
813  if (spectrum_file_format == "th2d")
815  else if (spectrum_file_format == "fit") {
817 
818  std::string pinch_type;
819  if ( !p().pinching_parameter_type_(pinch_type) ) {
820  throw cet::exception("MARLEYTimeGen") << "Missing pinching parameter"
821  << " type for a \"fit\" format spectrum file";
822  }
823 
824  marley_utils::to_lowercase_inplace(pinch_type);
825  if (pinch_type == "alpha") fPinchType = PinchParamType::ALPHA;
826  else if (pinch_type == "beta") fPinchType = PinchParamType::BETA;
827  else throw cet::exception("MARLEYTimeGen")
828  << "Invalid pinching parameter type \"" << pinch_type
829  << "\" specified for the MARLEYTimeGen module.";
830 
831  if ( !p().fit_Emin_(fFitEmin) ) throw cet::exception("MARLEYTimeGen")
832  << "Missing minimum energy for a \"fit\" format spectrum"
833  << " used by the MARLEYTimeGen module.";
834 
835  if ( !p().fit_Emax_(fFitEmax) ) throw cet::exception("MARLEYTimeGen")
836  << "Missing maximum energy for a \"fit\" format spectrum"
837  << " used by the MARLEYTimeGen module.";
838 
839  if (fFitEmax < fFitEmin) throw cet::exception("MARLEYTimeGen")
840  << "Maximum energy is less than the minimum energy for"
841  << " a \"fit\" format spectrum used by the MARLEYTimeGen module.";
842  }
843  else throw cet::exception("MARLEYTimeGen")
844  << "Invalid spectrum file format \"" << p().spectrum_file_format_()
845  << "\" specified for the MARLEYTimeGen module.";
846 
847  // Determine the full file name (including path) of the spectrum file
848  std::string full_spectrum_file_name
849  = fMarleyHelper->find_file(p().spectrum_file_(), "spectrum");
850 
851  marley::Generator& gen = fMarleyHelper->get_generator();
852 
854 
855  // Retrieve the time-dependent neutrino flux from a ROOT file
856  std::unique_ptr<TFile> spectrum_file
857  = std::make_unique<TFile>(full_spectrum_file_name.c_str(), "read");
858  TH2D* temp_h2 = nullptr;
859  std::string namecycle;
860  if ( !p().namecycle_(namecycle) ) {
861  throw cet::exception("MARLEYTimeGen") << "Missing namecycle for"
862  << " a TH2D spectrum file";
863  }
864 
865  spectrum_file->GetObject(namecycle.c_str(), temp_h2);
866  fSpectrumHist.reset(temp_h2);
867 
868  // Disassociate the TH2D from its parent TFile. If we fail to do this,
869  // then ROOT will auto-delete the TH2D when the TFile goes out of scope.
870  fSpectrumHist->SetDirectory(nullptr);
871 
872  // Compute the flux-averaged total cross section using MARLEY. This will be
873  // used to compute neutrino vertex weights for the sim::SupernovaTruth
874  // objects.
875 
876  // Get a 1D projection of the energy spectrum (integrated over time)
877  TH1D* energy_spect = fSpectrumHist->ProjectionY("energy_spect");
878 
879  // Create a new MARLEY neutrino source object using this projection
880  // TODO: replace the hard-coded electron neutrino PDG code here (and in
881  // several other places in this source file) when you're ready to use
882  // MARLEY with multiple neutrino flavors
883  std::unique_ptr<marley::NeutrinoSource> nu_source
884  = marley_root::make_root_neutrino_source(marley_utils::ELECTRON_NEUTRINO,
885  energy_spect);
886 
887  // Factor of hbar_c^2 converts from MeV^(-2) to fm^2
888  fFluxAveragedCrossSection = marley_utils::hbar_c2
889  * flux_averaged_total_xs(*nu_source, gen);
890 
891  // For speed, sample energies first whenever possible (and then sample from
892  // an energy-dependent timing distribution). This avoids unnecessary calls
893  // to MARLEY to change the energy spectrum.
896  {
897  gen.set_source(std::move(nu_source));
898  }
899 
900  } // spectrum_file_format == "th2d"
901 
903 
904  // Clear out the old parameterized spectrum, if one exists
905  fTimeFits.clear();
906 
907  std::ifstream fit_file(full_spectrum_file_name);
908  std::string line;
909 
910  bool found_end = false;
911 
912  // current line number
913  int line_num = 0;
914  // number of lines checked in last call to marley_utils::get_next_line()
915  int lines_checked = 0;
916 
917  double old_time = std::numeric_limits<double>::lowest();
918 
919  while ( line = marley_utils::get_next_line(fit_file, rx_comment_or_empty,
920  false, lines_checked), line_num += lines_checked, !line.empty() )
921  {
922  if (found_end) {
923  MF_LOG_WARNING("MARLEYTimeGen") << "Trailing content after last time"
924  << " bin found on line " << line_num << " of the spectrum file "
925  << full_spectrum_file_name;
926  }
927 
928  double time;
929  double Emean_nue, alpha_nue, luminosity_nue;
930  double Emean_nuebar, alpha_nuebar, luminosity_nuebar;
931  double Emean_nux, alpha_nux, luminosity_nux;
932  std::istringstream iss(line);
933  bool ok_first = static_cast<bool>( iss >> time );
934 
935  if (time <= old_time) throw cet::exception("MARLEYTimeGen")
936  << "Time bin left edges given in the spectrum file must be"
937  << " strictly increasing. Invalid time bin value found on line "
938  << line_num << " of the spectrum file " << full_spectrum_file_name;
939  else old_time = time;
940 
941  bool ok_rest = static_cast<bool>( iss >> Emean_nue >> alpha_nue
942  >> luminosity_nue >> Emean_nuebar >> alpha_nuebar >> luminosity_nuebar
943  >> Emean_nux >> alpha_nux >> luminosity_nux
944  );
945 
946  if (ok_first) {
947  // We haven't reached the final bin, so add another time bin
948  // in the typical way.
949  if (ok_rest) {
950  fTimeFits.emplace_back(time, Emean_nue, alpha_nue, luminosity_nue,
951  Emean_nuebar, alpha_nuebar, luminosity_nuebar, Emean_nux,
952  alpha_nux, luminosity_nux);
953  }
954  else {
955  make_final_timefit(time);
956  found_end = true;
957  }
958  }
959  else throw cet::exception("MARLEYTimeGen") << "Parse error on line "
960  << line_num << " of the spectrum file " << full_spectrum_file_name;
961  }
962 
963  if (!found_end) {
964 
965  size_t num_time_bins = fTimeFits.size();
966  if (num_time_bins < 2) throw cet::exception("MARLEYTimeGen")
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 "
969  << " final bin.";
970 
971  // Guess that the width of the penultimate time bin and the width of
972  // the final time bin are the same
973  double delta_t_bin = fTimeFits.back().Time()
974  - fTimeFits.at(num_time_bins - 2).Time();
975 
976  double last_bin_right_edge = fTimeFits.back().Time() + delta_t_bin;
977 
978  make_final_timefit(last_bin_right_edge);
979 
980  MF_LOG_WARNING("MARLEYTimeGen") << "Missing right"
981  << " edge for the final time bin in the spectrum file "
982  << full_spectrum_file_name << ". Assuming a width of "
983  << delta_t_bin << " s for the final bin.";
984  }
985 
986 
987  // Compute the flux-averaged total cross section for the fitted spectrum.
988  // We will need this to compute neutrino vertex weights.
989  std::vector< std::unique_ptr< marley::NeutrinoSource > > fit_sources;
990  for (const auto& fit : fTimeFits) {
991  fit_sources.emplace_back( source_from_time_fit(fit) );
992  }
993 
994  // TODO: add handling for non-nu_e neutrino types when suitable data become
995  // available in MARLEY
996  auto temp_source = std::make_unique<marley::FunctionNeutrinoSource>(
997  marley_utils::ELECTRON_NEUTRINO, fFitEmin, fFitEmax,
998  [&fit_sources, this](double E_nu) -> double {
999  double flux = 0.;
1000  for (size_t s = 0; s < fit_sources.size(); ++s) {
1001 
1002  const TimeFit& current_fit = this->fTimeFits.at(s);
1003  const auto& current_source = fit_sources.at(s);
1004  const FitParameters& params = current_fit.GetFitParameters(
1005  current_source->get_pid() );
1006 
1007  double lum = params.Luminosity();
1008 
1009  // Skip entries with zero luminosity, since they won't contribute
1010  // anything to the overall integral. Skip negative luminosity ones as
1011  // well, just in case.
1012  if (lum <= 0.) continue;
1013 
1014  flux += lum * current_source->pdf(E_nu);
1015  }
1016  return flux;
1017  }
1018  );
1019 
1020  double flux_integ = 0.;
1021  double tot_xs_integ = 0.;
1022  flux_averaged_total_xs(*temp_source, gen, flux_integ, tot_xs_integ);
1023 
1024  // Factor of hbar_c^2 converts from MeV^(-2) to fm^2
1025  fFluxAveragedCrossSection = marley_utils::hbar_c2
1026  * tot_xs_integ / flux_integ;
1027 
1029 
1030  } // spectrum_file_format == "fit"
1031 
1032  else {
1033  throw cet::exception("MARLEYTimeGen") << "Unrecognized neutrino spectrum"
1034  << " file format \"" << p().spectrum_file_format_() << "\" encountered"
1035  << " in evgen::MarleyTimeGen::reconfigure()";
1036  }
1037 
1038  MF_LOG_INFO("MARLEYTimeGen") << "The flux-averaged total cross section"
1039  << " predicted by MARLEY for the current supernova spectrum is "
1040  << fFluxAveragedCrossSection << " fm^2";
1041 
1042 }
SpectrumFileFormat fSpectrumFileFormat
Format to assume for the neutrino spectrum input file.
pdgs p
Definition: selectors.fcl:22
PinchParamType fPinchType
The pinching parameter convention to use when interpreting the time-dependent fits.
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 ...
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...
MF_LOG_WARNING("SimWire")<< "SimWire is an example module that works for the "<< "MicroBooNE detector. Each experiment should implement "<< "its own version of this module to simulate electronics "<< "response."
double fFitEmax
Maximum neutrino energy to consider when using a &quot;fit&quot;-format spectrum file.
std::unique_ptr< TH2D > fSpectrumHist
ROOT TH2D that contains the time-dependent spectrum to use when sampling neutrino times and energies...
unsigned int fNeutrinosPerEvent
The number of MARLEY neutrino vertices to generate in each art::Event.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
TimeGenSamplingMode fSamplingMode
Represents the sampling mode to use when selecting neutrino times and energies.
double fFitEmin
Minimum neutrino energy to consider when using a &quot;fit&quot;-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...
std::vector< TimeFit > fTimeFits
Vector that contains the fit parameter information for each time bin when using a &quot;fit&quot;-format spectr...
void make_nu_emission_histograms() const
Makes ROOT histograms showing the emitted neutrinos in each time bin when using a &quot;fit&quot;-format spectr...
std::unique_ptr< marley::NeutrinoSource > evgen::MarleyTimeGen::source_from_time_fit ( const TimeFit fit)
protected

Create a MARLEY neutrino source object using a set of fit parameters for a particular time bin.

Definition at line 1186 of file MARLEYTimeGen_module.cc.

1187 {
1188  // Create a "beta-fit" neutrino source using the given fit parameters.
1189 
1190  // The two common fitting schemes (alpha and beta) differ in their
1191  // definitions by \beta = \alpha + 1.
1192  // TODO: add handling for non-nu_e neutrino types
1193  const FitParameters& nue_parameters
1194  = fit.GetFitParameters(marley_utils::ELECTRON_NEUTRINO);
1195 
1196  double beta = nue_parameters.Alpha();
1197  if (fPinchType == PinchParamType::ALPHA) beta += 1.;
1198  else if (fPinchType != PinchParamType::BETA) {
1199  throw cet::exception("MARLEYTimeGen") << "Unreognized pinching parameter"
1200  << " type encountered in evgen::MarleyTimeGen::source_from_time_fit()";
1201  }
1202 
1203  // Create the new source
1204  std::unique_ptr<marley::NeutrinoSource> nu_source
1205  = std::make_unique<marley::BetaFitNeutrinoSource>(
1206  marley_utils::ELECTRON_NEUTRINO, fFitEmin, fFitEmax,
1207  nue_parameters.Emean(), beta);
1208 
1209  return nu_source;
1210 }
PinchParamType fPinchType
The pinching parameter convention to use when interpreting the time-dependent fits.
double fFitEmax
Maximum neutrino energy to consider when using a &quot;fit&quot;-format spectrum file.
double fFitEmin
Minimum neutrino energy to consider when using a &quot;fit&quot;-format spectrum file.

Member Data Documentation

std::unique_ptr<marley::Event> evgen::MarleyTimeGen::fEvent
protected

unique_ptr to the current event created by MARLEY

Definition at line 404 of file MARLEYTimeGen_module.cc.

uint_fast32_t evgen::MarleyTimeGen::fEventNumber
protected

Event number from the art::Event being processed.

Definition at line 501 of file MARLEYTimeGen_module.cc.

TTree* evgen::MarleyTimeGen::fEventTree
protected

The event TTree created by MARLEY.

This tree will be saved to the "hist" output file for validation purposes. The tree contains the same information as the generated simb::MCTruth objects, but in MARLEY's internal format

Definition at line 494 of file MARLEYTimeGen_module.cc.

double evgen::MarleyTimeGen::fFitEmax
protected

Maximum neutrino energy to consider when using a "fit"-format spectrum file.

Definition at line 525 of file MARLEYTimeGen_module.cc.

double evgen::MarleyTimeGen::fFitEmin
protected

Minimum neutrino energy to consider when using a "fit"-format spectrum file.

Definition at line 521 of file MARLEYTimeGen_module.cc.

double evgen::MarleyTimeGen::fFluxAveragedCrossSection
protected

Flux-averaged total cross section (fm2, average is taken over all energies and times for all defined reactions) used by MARLEY to generate neutrino vertices.

Definition at line 513 of file MARLEYTimeGen_module.cc.

std::unique_ptr<evgen::MARLEYHelper> evgen::MarleyTimeGen::fMarleyHelper
protected

Object that provides an interface to the MARLEY event generator.

Definition at line 397 of file MARLEYTimeGen_module.cc.

unsigned int evgen::MarleyTimeGen::fNeutrinosPerEvent
protected

The number of MARLEY neutrino vertices to generate in each art::Event.

Definition at line 517 of file MARLEYTimeGen_module.cc.

PinchParamType evgen::MarleyTimeGen::fPinchType
protected

The pinching parameter convention to use when interpreting the time-dependent fits.

Definition at line 468 of file MARLEYTimeGen_module.cc.

uint_fast32_t evgen::MarleyTimeGen::fRunNumber
protected

Run number from the art::Event being processed.

Definition at line 497 of file MARLEYTimeGen_module.cc.

TimeGenSamplingMode evgen::MarleyTimeGen::fSamplingMode
protected

Represents the sampling mode to use when selecting neutrino times and energies.

Definition at line 437 of file MARLEYTimeGen_module.cc.

SpectrumFileFormat evgen::MarleyTimeGen::fSpectrumFileFormat
protected

Format to assume for the neutrino spectrum input file.

Definition at line 488 of file MARLEYTimeGen_module.cc.

std::unique_ptr<TH2D> evgen::MarleyTimeGen::fSpectrumHist
protected

ROOT TH2D that contains the time-dependent spectrum to use when sampling neutrino times and energies.

This member is only used when reading the spectrum from a ROOT file.

Definition at line 410 of file MARLEYTimeGen_module.cc.

uint_fast32_t evgen::MarleyTimeGen::fSubRunNumber
protected

Subrun number from the art::Event being processed.

Definition at line 499 of file MARLEYTimeGen_module.cc.

std::vector<TimeFit> evgen::MarleyTimeGen::fTimeFits
protected

Vector that contains the fit parameter information for each time bin when using a "fit"-format spectrum file.

This member is unused when the spectrum is read from a ROOT file.

Definition at line 416 of file MARLEYTimeGen_module.cc.

double evgen::MarleyTimeGen::fTNu
protected

Time since the supernova core bounce for the current MARLEY neutrino vertex.

Definition at line 505 of file MARLEYTimeGen_module.cc.

std::unique_ptr<evgen::ActiveVolumeVertexSampler> evgen::MarleyTimeGen::fVertexSampler
protected

Algorithm that allows us to sample vertex locations within the active volume(s) of the detector.

Definition at line 401 of file MARLEYTimeGen_module.cc.

double evgen::MarleyTimeGen::fWeight
protected

Statistical weight for the current MARLEY neutrino vertex.

Definition at line 508 of file MARLEYTimeGen_module.cc.


The documentation for this class was generated from the following file: