10 #ifndef WEIGHTMANAGER_H
11 #define WEIGHTMANAGER_H
13 #include "art/Framework/Principal/fwd.h"
14 #include "art/Framework/Services/Registry/ServiceHandle.h"
15 #include "nurandom/RandomUtils/NuRandomService.h"
17 #include "fhiclcpp/ParameterSet.h"
39 const std::string&
Name()
const;
50 template <
typename Module>
84 template <
typename Module>
88 ::art::ServiceHandle<rndm::NuRandomService> seedservice;
91 auto const rw_func = p.get<std::vector<std::string>>(
"weight_functions");
94 auto const module_label = p.get<std::string>(
"module_label");
95 for (
auto const& func : rw_func) {
96 auto const ps_func = p.get<fhicl::ParameterSet>(func);
97 std::string func_type = ps_func.get<std::string>(
"type");
100 if (wcalc ==
nullptr)
101 throw cet::exception(__FUNCTION__) <<
"Function " << func <<
" requested in fcl file has not been registered!" << std::endl;
103 throw cet::exception(__FUNCTION__) <<
"Function " << func <<
" has been requested multiple times in fcl file!" << std::endl;
106 CLHEP::HepRandomEngine& engine = seedservice->createEngine(module,
"HepJamesRandom", func, ps_func,
"random_seed");
107 wcalc->SetName(func);
108 wcalc->Configure(p, engine);
112 winfo->
fNmultisims=ps_func.get<
int>(
"number_of_multisims", 0);
static WeightCalc * Create(const std::string &classname)
std::map< std::string, Weight_t * > GetWeightCalcMap()
Returns the map between calculator name and Weight_t product.
std::string fWeightCalcType
size_t Configure(fhicl::ParameterSet const &cfg, Module &module)
Configuration function.
bool _configured
Readiness flag.
WeightManager(const std::string name="WeightManager")
Default constructor.
std::map< std::string, Weight_t * > fWeightCalcMap
A set of custom weight calculators.
~WeightManager()
Default destructor.
MCEventWeight Run(art::Event &e, const int inu)
Core function (previous call to Configure is needed)
const std::string & Name() const
Name getter.
Tools and modules for checking out the basics of the Monte Carlo.