1 #ifndef _SBN_WEIGHTMANAGER_H_
2 #define _SBN_WEIGHTMANAGER_H_
12 #include "art/Framework/Principal/fwd.h"
13 #include "art/Framework/Services/Registry/ServiceHandle.h"
14 #include "nurandom/RandomUtils/NuRandomService.h"
16 #include "fhiclcpp/ParameterSet.h"
39 template <
typename Module>
65 template <
typename Module>
67 ::art::ServiceHandle<rndm::NuRandomService> seedservice;
70 auto const rw_func = p.get<std::vector<std::string> >(
"weight_functions");
71 auto const module_label = p.get<std::string>(
"module_label");
74 for (
auto const& func : rw_func) {
75 auto const ps_func = p.get<fhicl::ParameterSet>(func);
76 std::string func_type = ps_func.get<std::string>(
"type");
80 throw cet::exception(__FUNCTION__) <<
"Function " << func <<
" requested in fcl file has not been registered!" << std::endl;
83 throw cet::exception(__FUNCTION__) <<
"Function " << func <<
" has been requested multiple times in fcl file!" << std::endl;
86 CLHEP::HepRandomEngine& engine = seedservice->createEngine(module,
"HepJamesRandom", func, ps_func,
"random_seed");
89 wcalc->SetType(func_type);
90 wcalc->Configure(p, engine);
101 #endif // _SBN_WEIGHTMANAGER_H_
std::map< std::string, std::vector< float > > EventWeightMap
Container for event-level weights.
size_t Configure(fhicl::ParameterSet const &cfg, Module &module)
std::map< std::string, WeightCalc * > fWeightCalcMap
A set of custom weight calculators.
std::map< std::string, WeightCalc * > GetWeightCalcMap()
static WeightCalc * Create(const std::string &classname)
EventWeightMap Run(art::Event &e, const int inu)
Tools and modules for checking out the basics of the Monte Carlo.