MARLEYHelper.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////
2 /// \file MARLEYHelper.h
3 /// \brief LArSoft interface to the MARLEY (Model of Argon Reaction Low Energy
4 /// Yields) supernova neutrino event generator
5 ///
6 /// \author Steven Gardiner <sjgardiner@ucdavis.edu>
7 //////////////////////////////////////////////////////////////////////////////
8 
9 #ifndef LARSIM_ALGORITHMS_MARLEYGENERATOR_H
10 #define LARSIM_ALGORITHMS_MARLEYGENERATOR_H
11 
12 // standard library includes
13 #include <array>
14 #include <memory>
15 #include <sstream>
16 #include <string>
17 #include <vector>
18 
19 // framework includes
20 #include "fhiclcpp/ParameterSet.h"
21 
22 // art extensions
23 namespace rndm { class NuRandomService; }
24 
25 // LArSoft includes
28 
29 // ROOT includes
30 #include "TLorentzVector.h"
31 
32 // MARLEY includes
33 #include "marley/Generator.hh"
34 #include "marley/JSON.hh"
35 
36 namespace marley {
37  class Event;
38  class Particle;
39 }
40 
41 namespace evgen {
42 
43  class MARLEYHelper {
44 
45  public:
46 
47  MARLEYHelper( const fhicl::ParameterSet& pset,
48  rndm::NuRandomService& rand_service,
49  const std::string& generator_name );
50 
51  void reconfigure( const fhicl::ParameterSet& pset );
52 
53  // If a non-null marley::Event* is supplied, the marley::Event
54  // object corresponding to the generated MCTruth object is loaded
55  // into the target of the pointer.
56  simb::MCTruth create_MCTruth( const TLorentzVector& vtx_pos,
57  marley::Event* marley_event = nullptr );
58 
59  marley::Generator& get_generator() { return *fMarleyGenerator; }
60  const marley::Generator& get_generator() const
61  { return *fMarleyGenerator; }
62 
63  std::string find_file( const std::string& fileName,
64  const std::string& fileType );
65 
66  protected:
67 
68  void add_marley_particles( simb::MCTruth& truth,
69  const std::vector<marley::Particle*>& particles,
70  const TLorentzVector& vtx_pos, bool track );
71 
72  void load_full_paths_into_json( marley::JSON& json,
73  const std::string& array_name, bool missing_ok = false );
74 
75  std::unique_ptr< marley::Generator > fMarleyGenerator;
76 
77  // name to use for this instance of MARLEYHelper
79 
80  // string stream used to capture logger output from MARLEY
81  // and redirect it to the LArSoft logger
82  std::stringstream fMarleyLogStream;
83 
84  // Loads ROOT dictionaries for the MARLEY Event and Particle classes.
85  // This allows a module to write the generated events to a TTree.
86  void load_marley_dictionaries();
87 
88  }; // class evgen::MARLEYHelper
89 
90 } // namespace evgen
91 
92 #endif // LARSIM_ALGORITHMS_MARLEYGENERATOR_H
std::unique_ptr< marley::Generator > fMarleyGenerator
Definition: MARLEYHelper.h:75
std::string string
Definition: nybbler.cc:12
Particle class.
std::stringstream fMarleyLogStream
Definition: MARLEYHelper.h:82
std::string fHelperName
Definition: MARLEYHelper.h:78
fileName
Definition: dumpTree.py:9
virtual void reconfigure(fhicl::ParameterSet const &pset)
Definition: types.h:32
const marley::Generator & get_generator() const
Definition: MARLEYHelper.h:60
Event generator information.
Definition: MCTruth.h:32
marley::Generator & get_generator()
Definition: MARLEYHelper.h:59
Event Generation using GENIE, cosmics or single particles.