14 #include "art/Framework/Core/EDProducer.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Principal/Run.h"
18 #include "art/Framework/Services/Registry/ServiceHandle.h"
19 #include "art_root_io/TFileService.h"
20 #include "fhiclcpp/types/Table.h"
23 #include "nurandom/RandomUtils/NuRandomService.h"
28 #include "nusimdata/SimulationBase/MCTruth.h"
52 return {
"marley_parameters" };
59 fhicl::Table<evgen::ActiveVolumeVertexSampler::Config>
vertex_ {
61 Comment(
"Configuration for selecting the vertex location(s)")
73 using Parameters = art::EDProducer::Table<Config, KeysToIgnore>;
78 virtual void produce(art::Event&
e)
override;
79 virtual void beginRun(art::Run& run)
override;
93 std::unique_ptr<marley::Event>
fEvent;
106 : EDProducer{ p.get_PSet() },
107 fEvent(
new marley::Event), fRunNumber(0), fSubRunNumber(0), fEventNumber(0)
114 art::ServiceHandle<art::TFileService const>
tfs;
115 fEventTree = tfs->make<TTree>(
"MARLEY_event_tree",
116 "Neutrino events generated by MARLEY");
117 fEventTree->Branch(
"event",
"marley::Event", fEvent.get());
122 fEventTree->Branch(
"run_number", &fRunNumber,
"run_number/i");
123 fEventTree->Branch(
"subrun_number", &fSubRunNumber,
"subrun_number/i");
124 fEventTree->Branch(
"event_number", &fEventNumber,
"event_number/i");
126 produces< std::vector<simb::MCTruth> >();
133 art::ServiceHandle<geo::Geometry const> geo;
134 run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
141 fRunNumber = e.run();
142 fSubRunNumber = e.subRun();
143 fEventNumber = e.event();
145 std::unique_ptr< std::vector<simb::MCTruth> >
146 truthcol(
new std::vector<simb::MCTruth>);
149 art::ServiceHandle<geo::Geometry const> geo;
150 TLorentzVector vertex_pos = fVertexSampler->sample_vertex_pos(*geo);
154 simb::MCTruth truth = fMarleyHelper->create_MCTruth(vertex_pos,
160 truthcol->push_back(truth);
162 e.put(std::move(truthcol));
168 const auto& seed_service = art::ServiceHandle<rndm::NuRandomService>();
169 const auto& geom_service = art::ServiceHandle<geo::Geometry const>();
173 fVertexSampler = std::make_unique<evgen::ActiveVolumeVertexSampler>(
174 p().vertex_, *seed_service, *geom_service,
"MARLEY_Vertex_Sampler");
177 fhicl::ParameterSet marley_pset = p.get_PSet().get< fhicl::ParameterSet >(
178 "marley_parameters" );
179 fMarleyHelper = std::make_unique<MARLEYHelper>( marley_pset,
180 *seed_service,
"MARLEY" );
virtual void reconfigure(const Parameters &p)
fhicl::Atom< std::string > module_type_
LArSoft interface to the MARLEY (Model of Argon Reaction Low Energy Yields) supernova neutrino event ...
virtual void beginRun(art::Run &run) override
produces< sumdata::RunData, art::InRun >()
std::unique_ptr< evgen::MARLEYHelper > fMarleyHelper
fhicl::Table< evgen::ActiveVolumeVertexSampler::Config > vertex_
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 fSubRunNumber
std::unique_ptr< evgen::ActiveVolumeVertexSampler > fVertexSampler
Collection of configuration parameters for the module.
BEGIN_PROLOG vertical distance to the surface Name
virtual void produce(art::Event &e) override
uint_fast32_t fEventNumber
art::ServiceHandle< art::TFileService > tfs
MarleyGen(const Parameters &p)
std::unique_ptr< marley::Event > fEvent
art framework interface to geometry description
std::set< std::string > operator()()
art::EDProducer::Table< Config, KeysToIgnore > Parameters