12 #include "art/Framework/Core/EDProducer.h"
13 #include "art/Framework/Core/ModuleMacros.h"
14 #include "art/Framework/Principal/Event.h"
15 #include "art/Framework/Principal/Handle.h"
16 #include "messagefacility/MessageLogger/MessageLogger.h"
17 #include "fhiclcpp/ParameterSet.h"
27 #include "nusimdata/SimulationBase/MCTruth.h"
28 #include "nugen/EventGeneratorBase/GENIE/GENIE2ART.h"
49 void produce(art::Event &
e)
override;
60 , fGenieModuleLabel{
p.get<std::string>(
"genie_module_label",
"generator")}
68 std::string genie_tune_name =
p.get<std::string>(
"TuneName",
69 "${GENIE_XSEC_TUNE}");
74 std::string evgen_list_name =
p.get<std::string>(
"EventGeneratorList",
"");
77 evgb::SetEventGeneratorListAndTune( evgen_list_name, genie_tune_name );
79 auto const n_func = _wgt_manager.Configure(
p, *
this);
81 produces<std::vector<MCEventWeight> >();
87 auto mcwghvec = std::make_unique<std::vector<MCEventWeight>>();
91 std::vector<art::Ptr<simb::MCTruth> > mclist;
94 auto const mcTruthHandle = e.getValidHandle<std::vector<simb::MCTruth>>(
fGenieModuleLabel);
95 art::fill_ptr_vector(mclist, mcTruthHandle);
98 for (
unsigned int inu = 0; inu < mclist.size(); ++inu) {
100 mcwghvec->push_back(mcwgh);
103 e.put(std::move(mcwghvec));
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"
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)
135 for (
int i=1; i<=110; i++) job_summary <<
"=";
136 job_summary << std::endl;
137 mf::LogInfo(
"") << job_summary.str();
void produce(art::Event &e) override
std::string fGenieModuleLabel
EventWeight & operator=(EventWeight const &)=delete
std::map< std::string, Weight_t * > GetWeightCalcMap()
Returns the map between calculator name and Weight_t product.
WeightManager _wgt_manager
EventWeight(fhicl::ParameterSet const &p)
MCEventWeight Run(art::Event &e, const int inu)
Core function (previous call to Configure is needed)