All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SNNueAr40CCGen_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 /// \file SNNueAr40CCGen_module.cc
3 /// \brief Supernova Nue-Ar CC interaction generator
4 ///
5 /// Module that produces MC particles from supernova electron neutrinos
6 /// interacting via charge current with Ar40
7 ///
8 /// \author gleb.sinev@duke.edu
9 ////////////////////////////////////////////////////////////////////////////////
10 
11 // Framework includes
12 #include "art/Framework/Core/EDProducer.h"
13 #include "art/Framework/Principal/Event.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Services/Registry/ServiceHandle.h"
17 #include "fhiclcpp/ParameterSet.h"
18 
19 // nurandom includes
20 #include "nurandom/RandomUtils/NuRandomService.h"
21 
22 // nusimdata includes
23 #include "nusimdata/SimulationBase/MCTruth.h"
24 
25 // LArSoft includes
29 
30 // C++ includes
31 
32 namespace evgen {
33 
34  /// Module producing electrons and gammas from supernova neutrino
35  /// interactions with liquid argon (based on SingleGen)
36  class SNNueAr40CCGen : public art::EDProducer {
37  public:
38  explicit SNNueAr40CCGen(fhicl::ParameterSet const& pset);
39 
40  private:
41  void beginRun(art::Run& run) override;
42  void produce(art::Event& event) override;
43 
44  CLHEP::HepRandomEngine& fEngine;
46  };
47 
48  //____________________________________________________________________________
49  SNNueAr40CCGen::SNNueAr40CCGen(fhicl::ParameterSet const& pset)
50  : EDProducer{pset}
51  // Create a default random engine: obtain the random seed
52  // freom NuRandomService, unless overriden in configuration with key "Seed"
53  , fEngine(art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*this, pset, "Seed"))
54  , fGenerator{pset.get< fhicl::ParameterSet >("GeneratorAlg")}
55  {
56  produces< std::vector< simb::MCTruth > >();
57  produces< sumdata::RunData, art::InRun >();
58  }
59 
60  //____________________________________________________________________________
61  void SNNueAr40CCGen::beginRun(art::Run& run)
62  {
63  // Store information about the geometry we are using in run information
64  art::ServiceHandle<geo::Geometry const> geo;
65  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
66  }
67 
68  //____________________________________________________________________________
69  void SNNueAr40CCGen::produce(art::Event& event)
70  {
71  event.put(std::make_unique<std::vector<simb::MCTruth>>(fGenerator.Generate(fEngine)));
72  }
73 
74 }
75 
76 DEFINE_ART_MODULE(evgen::SNNueAr40CCGen)
void beginRun(art::Run &run) override
evgen::NueAr40CCGenerator fGenerator
fEngine(art::ServiceHandle< rndm::NuRandomService >() ->createEngine(*this, pset,"Seed"))
SNNueAr40CCGen(fhicl::ParameterSet const &pset)
void produce(art::Event &event) override
std::vector< simb::MCTruth > Generate(CLHEP::HepRandomEngine &engine)
art framework interface to geometry description
CLHEP::HepRandomEngine & fEngine