10 #include "cetlib_except/exception.h" 20 #include "TInterpreter.h" 24 #include "marley/Event.hh" 25 #include "marley/Particle.hh" 26 #include "marley/RootJSONConfig.hh" 31 constexpr
double MeV_to_GeV = 1
e-3;
37 const std::string& helper_name)
38 : fHelperName(helper_name)
54 auto seed =
static_cast<uint_fast64_t
>(lar_seed);
70 uint_fast64_t marley_cast_seed =
static_cast<uint_fast64_t
>(marley_seed);
85 const std::vector<marley::Particle*>& particles,
86 const TLorentzVector& vtx_pos,
91 for (
const marley::Particle* p : particles) {
96 int pdg = p->pdg_code();
97 double mass = p->mass() * MeV_to_GeV;
98 double px = p->px() * MeV_to_GeV;
99 double py = p->py() * MeV_to_GeV;
100 double pz = p->pz() * MeV_to_GeV;
101 double E = p->total_energy() * MeV_to_GeV;
102 TLorentzVector mom(px, py, pz, E);
105 if (track) status = 1;
121 marley::Event* marley_event)
134 const marley::Particle& nu =
event.projectile();
135 const marley::Particle& lep =
event.ejectile();
136 double qx = nu.px() - lep.px();
137 double qy = nu.py() - lep.py();
138 double qz = nu.pz() - lep.pz();
139 double Enu = nu.total_energy();
140 double Elep = lep.total_energy();
141 double Q2 = qx * qx + qy * qy + qz * qz - std::pow(Enu - Elep, 2);
145 double bjorken_x = Q2 / (2 *
event.target().mass() * (Enu - Elep));
146 double inelasticity_y = 1. - Elep / Enu;
152 const marley::Particle& res =
event.residue();
153 double hadronic_mass_W = res.mass() +
event.Ex();
159 marley_utils::get_nucleus_pid(18, 40),
160 marley_utils::NEUTRON,
162 hadronic_mass_W * MeV_to_GeV,
165 Q2 * std::pow(MeV_to_GeV, 2));
167 if (marley_event) *marley_event =
event;
185 cet::search_path searchPath(
"FW_SEARCH_PATH");
187 std::string fullName;
188 searchPath.find_file(fileName, fullName);
190 if (fullName.empty())
192 <<
"Cannot find MARLEY " << fileType <<
" data file '" << fileName <<
'\'';
199 const std::string& key,
202 if (json.has_key(key)) {
204 marley::JSON&
value = json.at(key);
206 if (value.is_array()) {
209 for (
auto& element : value.array_range()) {
210 element =
find_file(element.to_string(), key);
215 value =
find_file(value.to_string(), key);
217 else if (!missing_ok)
219 <<
"Missing \"" << key <<
"\" key in the MARLEY parameters.";
229 marley::JSON& json = mpsw.
get_json();
238 if (json.has_key(
"source")) {
239 marley::JSON& source_object = json.at(
"source");
246 " the JSON configuration\n" 247 << json.dump_string() <<
'\n';
248 marley::RootJSONConfig config(json);
251 fMarleyGenerator = std::make_unique<marley::Generator>(config.create_generator());
257 static bool already_loaded_marley_dict =
false;
259 if (already_loaded_marley_dict)
return;
270 if (gROOT->GetVersionInt() >= 60000) {
272 <<
"ROOT 6 or greater" 273 <<
" detected. Loading class information\nfrom headers" 274 <<
" \"marley/Particle.hh\" and \"marley/Event.hh\"";
275 TInterpreter::EErrorCode* ec =
new TInterpreter::EErrorCode();
276 gInterpreter->ProcessLine(
"#include \"marley/Particle.hh\"", ec);
279 <<
"Error loading MARLEY header Particle.hh. For MARLEY headers stored" 280 <<
" in /path/to/include/marley/, please add /path/to/include" 281 <<
" to your ROOT_INCLUDE_PATH environment variable and" 283 gInterpreter->ProcessLine(
"#include \"marley/Event.hh\"");
287 <<
" MARLEY header Event.hh. For MARLEY headers stored in" 288 <<
" /path/to/include/marley/, please add /path/to/include" 289 <<
" to your ROOT_INCLUDE_PATH environment variable and" 296 already_loaded_marley_dict =
true;
LArSoft interface to the MARLEY (Model of Argon Reaction Low Energy Yields) supernova neutrino event ...
void load_marley_dictionaries()
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void add_marley_particles(simb::MCTruth &truth, const std::vector< marley::Particle * > &particles, const TLorentzVector &vtx_pos, bool track)
void SetOrigin(simb::Origin_t origin)
MARLEYHelper(const fhicl::ParameterSet &pset, rndm::NuRandomService &rand_service, const std::string &generator_name)
simb::MCTruth create_MCTruth(const TLorentzVector &vtx_pos, marley::Event *marley_event=nullptr)
Concrete fhicl::ParameterSetWalker that converts a fhicl::ParameterSet into a marley::JSON object...
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
seed_t registerEngine(SeedMaster_t::Seeder_t seeder, std::string const instance="", std::optional< seed_t > const seed=std::nullopt)
Registers an existing engine with rndm::NuRandomService.
const marley::JSON & get_json() const
std::stringstream fMarleyLogStream
std::unique_ptr< marley::Generator > fMarleyGenerator
std::string find_file(const std::string &fileName, const std::string &fileType)
void reconfigure(const fhicl::ParameterSet &pset)
Identifier for a engine, made of module name and optional instance name.
void walk(ParameterSetWalker &psw) const
#define MF_LOG_INFO(category)
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
void Add(simb::MCParticle const &part)
n.b.: this group is similar but not quite, entirely unlike GENIE ScatteringType convention ...
void load_full_paths_into_json(marley::JSON &json, const std::string &array_name, bool missing_ok=false)
Event generator information.
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
cet::coded_exception< error, detail::translate > exception
Event finding and building.
art::detail::EngineCreator::seed_t seed_t