WeightManager.cxx
Go to the documentation of this file.
1 #include "WeightManager.h"
2 
3 
4 namespace evwgh {
5 
7  : _name(name)
8  {
9  _configured = false;
10  }
11 
13  { return _name; }
14 
15 
16  //
17  // CORE FUNCTION
18  //
20  {
21 
22  if (!_configured)
23  throw cet::exception(__PRETTY_FUNCTION__) << "Have not configured yet!" << std::endl;
24 
25  //
26  // Loop over all functions ang calculate weights
27  //
28  MCEventWeight mcwgh;
29  for (auto it = fWeightCalcMap.begin() ;it != fWeightCalcMap.end(); it++) {
30 
31  auto const & weights = it->second->GetWeight(e);
32 
33  if(weights.size() == 0){
34  std::vector<double> empty;
35  std::pair<std::string, std::vector <double> > p("empty",empty);
36  mcwgh.fWeight.insert(p);
37  }
38  else{
39  std::pair<std::string, std::vector<double> >
40  p(it->first+"_"+it->second->fWeightCalcType,
41  weights[inu]);
42  mcwgh.fWeight.insert(p);
43  }
44  }
45 
46  return mcwgh;
47  }
48 
49 
50 
52 
53  return;
54  }
55 
56 }
static QCString name
Definition: declinfo.cpp:673
std::string _name
Name.
Definition: WeightManager.h:81
std::string string
Definition: nybbler.cc:12
Allows to interface to EventWeight calculators.
const double e
p
Definition: test.py:223
std::map< std::string, std::vector< double > > fWeight
Definition: MCEventWeight.h:10
bool _configured
Readiness flag.
Definition: WeightManager.h:80
WeightManager(const std::string name="WeightManager")
Default constructor.
std::map< std::string, Weight_t * > fWeightCalcMap
A set of custom weight calculators.
Definition: WeightManager.h:79
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:97
QTextStream & endl(QTextStream &s)