1 #ifndef WEIGHTMANAGER_CXX 2 #define WEIGHTMANAGER_CXX 27 std::vector<std::string> rw_func = p.
get<std::vector<std::string>>(
"weight_functions");
30 for (
auto ifunc=rw_func.begin(); ifunc!=rw_func.end(); ifunc++)
33 std::string func_type = ps_func.
get<std::string>(
"type");
37 throw cet::exception(__FUNCTION__) <<
"Function " << *ifunc <<
" requested in fcl file has not been registered!" << std::endl;
39 throw cet::exception(__FUNCTION__) <<
"Function " << *ifunc <<
" has been requested multiple times in fcl file!" << std::endl;
44 seedservice->
createEngine(engine,
"HepJamesRandom", *ifunc, ps_func,
"random_seed");
46 wcalc->SetName(*ifunc);
53 std::pair<std::string, Weight_t*> pwc(*ifunc,winfo);
71 throw cet::exception(__PRETTY_FUNCTION__) <<
"Have not configured yet!" << std::endl;
79 auto const & weights = it->second->GetWeight(e);
81 if(weights.size() == 0){
82 std::vector<double> empty;
83 std::pair<std::string, std::vector <double> > p(
"empty",empty);
87 std::pair<std::string, std::vector<double> >
88 p(it->first+
"_"+it->second->fWeightCalcType,
size_t Configure(fhicl::ParameterSet const &cfg, art::EngineCreator &ec)
Configuration function.
static WeightCalc * Create(const std::string &classname)
Allows to interface to EventWeight calculators.
seed_t createEngine(art::EngineCreator &module, std::string type, std::string instance="")
Creates an engine with RandomNumberGenerator service.
std::string fWeightCalcType
T get(std::string const &key) const
std::map< std::string, std::vector< double > > fWeight
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.
MCEventWeight Run(art::Event &e, const int inu)
Core function (previous call to Configure is needed)
const std::string & Name() const
Name getter.
cet::coded_exception< error, detail::translate > exception