LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
WeightManager.cxx
Go to the documentation of this file.
1 #include "WeightManager.h"
2 
3 namespace evwgh {
4 
5  WeightManager::WeightManager(const std::string name) : _name(name)
6  {
7  _configured = false;
8  }
9 
10  const std::string& WeightManager::Name() const
11  {
12  return _name;
13  }
14 
15  //
16  // CORE FUNCTION
17  //
19  {
20 
21  if (!_configured)
22  throw cet::exception(__PRETTY_FUNCTION__) << "Have not configured yet!" << std::endl;
23 
24  //
25  // Loop over all functions ang calculate weights
26  //
27  MCEventWeight mcwgh;
28  for (auto it = fWeightCalcMap.begin(); it != fWeightCalcMap.end(); it++) {
29 
30  auto const& weights = it->second->GetWeight(e);
31 
32  if (weights.size() == 0) {
33  std::vector<double> empty;
34  std::pair<std::string, std::vector<double>> p("empty", empty);
35  mcwgh.fWeight.insert(p);
36  }
37  else {
38  std::pair<std::string, std::vector<double>> p(it->first + "_" + it->second->fWeightCalcType,
39  weights[inu]);
40  mcwgh.fWeight.insert(p);
41  }
42  }
43 
44  return mcwgh;
45  }
46 
48  {
49  return;
50  }
51 
52 }
std::string _name
Name.
Definition: WeightManager.h:73
Allows to interface to EventWeight calculators.
std::map< std::string, std::vector< double > > fWeight
Definition: MCEventWeight.h:9
bool _configured
Readiness flag.
Definition: WeightManager.h:72
WeightManager(const std::string name="WeightManager")
std::map< std::string, Weight_t * > fWeightCalcMap
A set of custom weight calculators.
Definition: WeightManager.h:71
Float_t e
Definition: plot.C:35
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
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109