All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
evwgh::EventWeight Class Reference
Inheritance diagram for evwgh::EventWeight:

Public Member Functions

 EventWeight (fhicl::ParameterSet const &p)
 
 EventWeight (EventWeight const &)=delete
 
 EventWeight (EventWeight &&)=delete
 
EventWeightoperator= (EventWeight const &)=delete
 
EventWeightoperator= (EventWeight &&)=delete
 

Private Member Functions

void produce (art::Event &e) override
 
void endJob () override
 

Private Attributes

WeightManager _wgt_manager
 
std::string fGenieModuleLabel
 

Detailed Description

Definition at line 32 of file EventWeight_module.cc.

Constructor & Destructor Documentation

evwgh::EventWeight::EventWeight ( fhicl::ParameterSet const &  p)
explicit

Definition at line 58 of file EventWeight_module.cc.

59  : EDProducer{p}
60  , fGenieModuleLabel{p.get<std::string>("genie_module_label", "generator")}
61  {
62  // Configure the appropriate GENIE tune if needed (important for v3+ only)
63  // NOTE: In all normal use cases, relying on the ${GENIE_XSEC_TUNE}
64  // environment variable set by the genie_xsec package should be sufficient.
65  // Only include the "TuneName" FHiCL parameter for EventWeight if you
66  // really know what you're doing! The same goes for the
67  // "EventGeneratorList" parameter.
68  std::string genie_tune_name = p.get<std::string>("TuneName",
69  "${GENIE_XSEC_TUNE}");
70 
71  // The default empty string used here will cause the subsequent call to
72  // evgb::SetEventGeneratorListAndTune() to leave GENIE's current event
73  // generator list name (probably "Default") alone
74  std::string evgen_list_name = p.get<std::string>("EventGeneratorList", "");
75 
76  // Tell GENIE about the event generator list and tune
77  evgb::SetEventGeneratorListAndTune( evgen_list_name, genie_tune_name );
78 
79  auto const n_func = _wgt_manager.Configure(p, *this);
80  if ( n_func > 0 )
81  produces<std::vector<MCEventWeight> >();
82  }
pdgs p
Definition: selectors.fcl:22
std::string fGenieModuleLabel
WeightManager _wgt_manager
size_t Configure(fhicl::ParameterSet const &cfg, Module &module)
Configuration function.
evwgh::EventWeight::EventWeight ( EventWeight const &  )
delete
evwgh::EventWeight::EventWeight ( EventWeight &&  )
delete

Member Function Documentation

void evwgh::EventWeight::endJob ( )
overrideprivate

Definition at line 106 of file EventWeight_module.cc.

107  {
108  // Get the map from sting to Weight_t from the manager
109  std::map<std::string, Weight_t*> weightCalcMap = _wgt_manager.GetWeightCalcMap();
110 
111  std::stringstream job_summary;
112  job_summary << std::setprecision(2);
113  for (int i=1; i <= 110 ;i++) job_summary << "=";
114  job_summary << std::endl;
115  job_summary << std::setw(20) << "WeightCalc"
116  << std::setw(15) << "Type"
117  << std::setw(15) << "#RW neutrinos"
118  << std::setw(15) << "#Multisims"
119  << std::setw(15) << "Min"
120  << std::setw(15) << "Max"
121  << std::setw(15) << "Avg"
122  << std::endl;
123  for (int i=1; i <= 110; i++) job_summary << "=";
124  job_summary << std::endl;
125  for (auto it = weightCalcMap.begin(); it!=weightCalcMap.end(); it++) {
126  job_summary << std::setw(20) << it->first
127  << std::setw(15) << (it->second->fWeightCalcType)
128  << std::setw(15) << (it->second->fNcalls)
129  << std::setw(15) << (it->second->fNmultisims)
130  << std::setw(15) << (it->second->fMinWeight)
131  << std::setw(15) << (it->second->fMaxWeight)
132  << std::setw(15) << (it->second->fAvgWeight)
133  << std::endl;
134  }
135  for (int i=1; i<=110; i++) job_summary << "=";
136  job_summary << std::endl;
137  mf::LogInfo("") << job_summary.str();
138  }
std::map< std::string, Weight_t * > GetWeightCalcMap()
Returns the map between calculator name and Weight_t product.
WeightManager _wgt_manager
EventWeight& evwgh::EventWeight::operator= ( EventWeight const &  )
delete
EventWeight& evwgh::EventWeight::operator= ( EventWeight &&  )
delete
void evwgh::EventWeight::produce ( art::Event &  e)
overrideprivate

Definition at line 84 of file EventWeight_module.cc.

85  {
86  // Implementation of required member function here.
87  auto mcwghvec = std::make_unique<std::vector<MCEventWeight>>();
88 
89  // Get the MC generator information out of the event
90  // these are all handles to mc information.
91  std::vector<art::Ptr<simb::MCTruth> > mclist;
92 
93  // Actually go and get the stuff
94  auto const mcTruthHandle = e.getValidHandle<std::vector<simb::MCTruth>>(fGenieModuleLabel);
95  art::fill_ptr_vector(mclist, mcTruthHandle);
96 
97  // Loop over all neutrinos in this event
98  for (unsigned int inu = 0; inu < mclist.size(); ++inu) {
99  auto const mcwgh = _wgt_manager.Run(e, inu);
100  mcwghvec->push_back(mcwgh);
101  }
102 
103  e.put(std::move(mcwghvec));
104  }
std::string fGenieModuleLabel
WeightManager _wgt_manager
do i e
MCEventWeight Run(art::Event &e, const int inu)
Core function (previous call to Configure is needed)

Member Data Documentation

WeightManager evwgh::EventWeight::_wgt_manager
private

Definition at line 54 of file EventWeight_module.cc.

std::string evwgh::EventWeight::fGenieModuleLabel
private

Definition at line 55 of file EventWeight_module.cc.


The documentation for this class was generated from the following file: