LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
SNNueAr40CCGen_module.cc
Go to the documentation of this file.
1 #ifndef EVGEN_SNNUEARCCGEN
11 #define EVGEN_SNNUEARCCGEN
12 
13 // Framework includes
20 #include "fhiclcpp/ParameterSet.h"
21 
22 // art extensions
24 
25 // nutools includes
27 
28 // LArSoft includes
31 
32 #include "CLHEP/Random/RandomEngine.h"
33 
34 // C++ includes
35 #include <map>
36 
37 #include "NueAr40CCGenerator.h"
38 
39 namespace evgen {
40 
44 
45  public:
46 
47  explicit SNNueAr40CCGen(fhicl::ParameterSet const& pset);
48 
49  void beginRun(art::Run& run);
50 
51  void produce(art::Event& event);
52 
53  private:
54 
56 
57  };
58 
59 }
60 
61 namespace evgen {
62 
63  //____________________________________________________________________________
66  (pset.get< fhicl::ParameterSet >("GeneratorAlg")))
67  {
68 
69  produces< std::vector< simb::MCTruth > >();
70  produces< sumdata::RunData, art::InRun >();
71 
72  // Create a default random engine: obtain the random seed
73  // freom NuRandomService, unless overriden in configuration with key "Seed"
75  ->createEngine(*this, pset, "Seed");
76 
77  }
78 
79  //____________________________________________________________________________
81  {
82 
83  // Store information about the geometry we are using in run information
85  std::unique_ptr< sumdata::RunData >
86  runCol(new sumdata::RunData(geo->DetectorName()));
87 
88  run.put(std::move(runCol));
89 
90  return;
91 
92  }
93 
94  //____________________________________________________________________________
96  {
97 
98  std::unique_ptr< std::vector< simb::MCTruth > >
99  truthCol(new std::vector< simb::MCTruth >);
100 
101  // Get an engine from the random number generator
103  CLHEP::HepRandomEngine &engine = randomNumberGenerator->getEngine();
104 
105  std::vector<simb::MCTruth> truths = fGenerator.Generate(engine);
106 
107  for(unsigned int i = 0; i < truths.size(); ++i) {
108  truthCol->emplace_back(truths[i]);
109  }
110 
111  event.put(std::move(truthCol));
112 
113  return;
114 
115  }
116 
117 }
118 
119 namespace evgen {
120 
122 
123 }
124 
125 #endif
126 
void beginRun(art::Run &run)
void produce(art::Event &event)
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:148
Definition: Run.h:30
base_engine_t & getEngine() const
base_engine_t & createEngine(seed_t seed)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
evgen::NueAr40CCGenerator fGenerator
parameter set interface
SNNueAr40CCGen(fhicl::ParameterSet const &pset)
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
std::vector< simb::MCTruth > Generate(CLHEP::HepRandomEngine &engine)
Namespace collecting geometry-related classes utilities.
Event Generation using GENIE, cosmics or single particles.
art framework interface to geometry description
Event finding and building.