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

Classes

struct  Config
 Collection of configuration parameters for the module. More...
 
struct  KeysToIgnore
 

Public Types

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

Public Member Functions

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

Private Attributes

std::unique_ptr
< evgen::MARLEYHelper
fMarleyHelper
 
std::unique_ptr
< evgen::ActiveVolumeVertexSampler
fVertexSampler
 
std::unique_ptr< marley::Event > fEvent
 
TTree * fEventTree
 
uint_fast32_t fRunNumber
 
uint_fast32_t fSubRunNumber
 
uint_fast32_t fEventNumber
 

Detailed Description

Definition at line 40 of file MARLEYGen_module.cc.

Member Typedef Documentation

using evgen::MarleyGen::Comment = fhicl::Comment

Definition at line 45 of file MARLEYGen_module.cc.

using evgen::MarleyGen::Name = fhicl::Name

Definition at line 44 of file MARLEYGen_module.cc.

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

Definition at line 73 of file MARLEYGen_module.cc.

Constructor & Destructor Documentation

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

Definition at line 105 of file MARLEYGen_module.cc.

106  : EDProducer{ p.get_PSet() },
107  fEvent(new marley::Event), fRunNumber(0), fSubRunNumber(0), fEventNumber(0)
108 {
109  // Configure the module (including MARLEY itself) using the FHiCL parameters
110  this->reconfigure( p );
111 
112  // Create a ROOT TTree using the TFileService that will store the MARLEY
113  // event objects (useful for debugging purposes)
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());
118 
119  // Add branches that give the art::Event run, subrun, and event numbers for
120  // easy match-ups between the MARLEY and art TTrees. All three are recorded
121  // as 32-bit unsigned integers.
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");
125 
126  produces< std::vector<simb::MCTruth> >();
128 }
virtual void reconfigure(const Parameters &p)
pdgs p
Definition: selectors.fcl:22
produces< sumdata::RunData, art::InRun >()
uint_fast32_t fRunNumber
uint_fast32_t fSubRunNumber
uint_fast32_t fEventNumber
art::ServiceHandle< art::TFileService > tfs
std::unique_ptr< marley::Event > fEvent

Member Function Documentation

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

Definition at line 131 of file MARLEYGen_module.cc.

132 {
133  art::ServiceHandle<geo::Geometry const> geo;
134  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
135 }
void evgen::MarleyGen::produce ( art::Event &  e)
overridevirtual

Definition at line 138 of file MARLEYGen_module.cc.

139 {
140  // Get the run, subrun, and event numbers from the current art::Event
141  fRunNumber = e.run();
142  fSubRunNumber = e.subRun();
143  fEventNumber = e.event();
144 
145  std::unique_ptr< std::vector<simb::MCTruth> >
146  truthcol(new std::vector<simb::MCTruth>);
147 
148  // Get the primary vertex location for this event
149  art::ServiceHandle<geo::Geometry const> geo;
150  TLorentzVector vertex_pos = fVertexSampler->sample_vertex_pos(*geo);
151 
152  // Create the MCTruth object, and retrieve the marley::Event object
153  // that was generated as it was created
154  simb::MCTruth truth = fMarleyHelper->create_MCTruth(vertex_pos,
155  fEvent.get());
156 
157  // Write the marley::Event object to the event tree
158  fEventTree->Fill();
159 
160  truthcol->push_back(truth);
161 
162  e.put(std::move(truthcol));
163 }
std::unique_ptr< evgen::MARLEYHelper > fMarleyHelper
uint_fast32_t fRunNumber
uint_fast32_t fSubRunNumber
std::unique_ptr< evgen::ActiveVolumeVertexSampler > fVertexSampler
do i e
uint_fast32_t fEventNumber
std::unique_ptr< marley::Event > fEvent
void evgen::MarleyGen::reconfigure ( const Parameters p)
virtual

Definition at line 166 of file MARLEYGen_module.cc.

167 {
168  const auto& seed_service = art::ServiceHandle<rndm::NuRandomService>();
169  const auto& geom_service = art::ServiceHandle<geo::Geometry const>();
170 
171  // Create a new evgen::ActiveVolumeVertexSampler object based on the current
172  // configuration
173  fVertexSampler = std::make_unique<evgen::ActiveVolumeVertexSampler>(
174  p().vertex_, *seed_service, *geom_service, "MARLEY_Vertex_Sampler");
175 
176  // Create a new marley::Generator object based on the current configuration
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" );
181 }
pdgs p
Definition: selectors.fcl:22
std::unique_ptr< evgen::MARLEYHelper > fMarleyHelper
std::unique_ptr< evgen::ActiveVolumeVertexSampler > fVertexSampler

Member Data Documentation

std::unique_ptr<marley::Event> evgen::MarleyGen::fEvent
private

Definition at line 93 of file MARLEYGen_module.cc.

uint_fast32_t evgen::MarleyGen::fEventNumber
private

Definition at line 101 of file MARLEYGen_module.cc.

TTree* evgen::MarleyGen::fEventTree
private

Definition at line 96 of file MARLEYGen_module.cc.

std::unique_ptr<evgen::MARLEYHelper> evgen::MarleyGen::fMarleyHelper
private

Definition at line 86 of file MARLEYGen_module.cc.

uint_fast32_t evgen::MarleyGen::fRunNumber
private

Definition at line 99 of file MARLEYGen_module.cc.

uint_fast32_t evgen::MarleyGen::fSubRunNumber
private

Definition at line 100 of file MARLEYGen_module.cc.

std::unique_ptr<evgen::ActiveVolumeVertexSampler> evgen::MarleyGen::fVertexSampler
private

Definition at line 90 of file MARLEYGen_module.cc.


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