All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
larsim/larsim/EventWeight/Base/WeightManager.cxx
Go to the documentation of this file.
1 #include "WeightManager.h"
2 
3 
4 namespace evwgh {
5 
6  WeightManager::WeightManager(const std::string name)
7  : _name(name)
8  {
9  _configured = false;
10  }
11 
12  const std::string& WeightManager::Name() const
13  { return _name; }
14 
15 
16  //
17  // CORE FUNCTION
18  //
19  MCEventWeight WeightManager::Run(art::Event & e, const int inu)
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 }
pdgs p
Definition: selectors.fcl:22
std::map< std::string, std::vector< double > > fWeight
Definition: MCEventWeight.h:10
WeightManager(const std::string name="WeightManager")
Default constructor.
std::map< std::string, Weight_t * > fWeightCalcMap
A set of custom weight calculators.
do i e
then echo fcl name
MCEventWeight Run(art::Event &e, const int inu)
Core function (previous call to Configure is needed)
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555
const std::string & Name() const
Name getter.