LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MARLEYHelper.h
Go to the documentation of this file.
1 
9 #ifndef LARSIM_ALGORITHMS_MARLEYGENERATOR_H
10 #define LARSIM_ALGORITHMS_MARLEYGENERATOR_H
11 
12 // standard library includes
13 #include <memory>
14 #include <sstream>
15 #include <string>
16 #include <vector>
17 
18 // framework includes
19 namespace fhicl {
20  class ParameterSet;
21 }
22 
23 // art extensions
24 namespace rndm {
25  class NuRandomService;
26 }
27 
28 // LArSoft includes
30 
31 // ROOT includes
32 #include "TLorentzVector.h"
33 
34 // MARLEY includes
35 #include "marley/Generator.hh"
36 
37 namespace marley {
38  class Event;
39  class JSON;
40  class Particle;
41 }
42 
43 namespace evgen {
44 
45  class MARLEYHelper {
46 
47  public:
49  rndm::NuRandomService& rand_service,
50  const std::string& generator_name);
51 
52  void reconfigure(const fhicl::ParameterSet& pset);
53 
54  // If a non-null marley::Event* is supplied, the marley::Event
55  // object corresponding to the generated MCTruth object is loaded
56  // into the target of the pointer.
57  simb::MCTruth create_MCTruth(const TLorentzVector& vtx_pos,
58  marley::Event* marley_event = nullptr);
59 
60  marley::Generator& get_generator() { return *fMarleyGenerator; }
61  const marley::Generator& get_generator() const { return *fMarleyGenerator; }
62 
63  std::string find_file(const std::string& fileName, const std::string& fileType);
64 
65  protected:
66  void add_marley_particles(simb::MCTruth& truth,
67  const std::vector<marley::Particle*>& particles,
68  const TLorentzVector& vtx_pos,
69  bool track);
70 
71  void load_full_paths_into_json(marley::JSON& json,
72  const std::string& array_name,
73  bool missing_ok = false);
74 
75  std::unique_ptr<marley::Generator> fMarleyGenerator;
76 
77  // name to use for this instance of MARLEYHelper
78  std::string fHelperName;
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::stringstream fMarleyLogStream
Definition: MARLEYHelper.h:82
std::unique_ptr< marley::Generator > fMarleyGenerator
Definition: MARLEYHelper.h:75
std::string fHelperName
Definition: MARLEYHelper.h:78
parameter set interface
const marley::Generator & get_generator() const
Definition: MARLEYHelper.h:61
Event generator information.
Definition: MCTruth.h:32
Float_t track
Definition: plot.C:35
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
marley::Generator & get_generator()
Definition: MARLEYHelper.h:60
Event Generation using GENIE, cosmics or single particles.