MARLEY (Model of Argon Reaction Low Energy Yields)  v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
JSONConfig.hh
1 //
5 // This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6 //
7 // MARLEY is free software: you can redistribute it and/or modify it under the
8 // terms of version 3 of the GNU General Public License as published by the
9 // Free Software Foundation.
10 //
11 // For the full text of the license please see COPYING or
12 // visit http://opensource.org/licenses/GPL-3.0
13 //
14 // Please respect the MCnet academic usage guidelines. See GUIDELINES
15 // or visit https://www.montecarlonet.org/GUIDELINES for details.
16 
17 #pragma once
18 
19 // standard library includes
20 #include <string>
21 
22 // MARLEY includes
23 #include "marley/Generator.hh"
24 #include "marley/InterpolationGrid.hh"
25 #include "marley/JSON.hh"
26 
27 namespace marley {
28 
29  class JSONConfig {
30 
31  public:
32 
33  using InterpMethod = marley::InterpolationGrid<double>
34  ::InterpolationMethod;
35 
36  explicit JSONConfig(const marley::JSON& object);
37  explicit JSONConfig(const std::string& json_filename);
38 
39  marley::Generator create_generator() const;
40 
41  void prepare_direction( marley::Generator& gen ) const;
42  void prepare_neutrino_source( marley::Generator& gen ) const;
43  void prepare_reactions( marley::Generator& gen ) const;
44  void prepare_structure( marley::Generator& gen ) const;
45  void prepare_target( marley::Generator& gen ) const;
46 
47  void update_logger_settings() const;
48 
49  InterpMethod get_interpolation_method(const std::string& rule) const;
50  int neutrino_pdg(const std::string& nu) const;
51 
52  inline virtual bool process_extra_source_types(
53  const std::string& /*type*/, const marley::JSON& /*source_spec*/,
54  int /*pdg_code*/, std::unique_ptr<marley::NeutrinoSource>& /*source*/)
55  const;
56 
57  inline const marley::JSON& get_json() const;
58  inline void set_json(const marley::JSON& json);
59 
60  static void handle_json_error(const std::string& name,
61  const marley::JSON& json);
62 
63  protected:
64 
67  std::string source_get(const char* name, const marley::JSON& source_spec,
68  const char* description, const char* default_str) const;
69 
72  };
73 
74  inline const marley::JSON& marley::JSONConfig::get_json() const
75  { return json_; }
76 
77  inline void marley::JSONConfig::set_json(const marley::JSON& json)
78  { json_ = json; }
79 
80  inline bool marley::JSONConfig::process_extra_source_types(
81  const std::string& /*type*/, const marley::JSON& /*source_spec*/,
82  int /*pdg_code*/, std::unique_ptr<marley::NeutrinoSource>& /*source*/)
83  const
84  { return false; }
85 
86 }
The MARLEY Event generator.
Definition: Generator.hh:42
Definition: JSONConfig.hh:29
marley::JSON json_
JSON object describing this configuration.
Definition: JSONConfig.hh:71
std::string source_get(const char *name, const marley::JSON &source_spec, const char *description, const char *default_str) const
Helper function for loading strings from the JSON configuration.
Definition: JSONConfig.cc:822
Definition: JSON.hh:62