Public Member Functions | Private Member Functions | Private Attributes | List of all members
evwgh::EventWeight Class Reference
Inheritance diagram for evwgh::EventWeight:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 EventWeight (fhicl::ParameterSet const &p)
 
 EventWeight (EventWeight const &)=delete
 
 EventWeight (EventWeight &&)=delete
 
EventWeightoperator= (EventWeight const &)=delete
 
EventWeightoperator= (EventWeight &&)=delete
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

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

Private Attributes

WeightManager _wgt_manager
 
std::string fGenieModuleLabel
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 33 of file EventWeight_module.cc.

Constructor & Destructor Documentation

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

Definition at line 59 of file EventWeight_module.cc.

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

Member Function Documentation

void evwgh::EventWeight::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 107 of file EventWeight_module.cc.

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

Implements art::EDProducer.

Definition at line 85 of file EventWeight_module.cc.

86  {
87  // Implementation of required member function here.
88  auto mcwghvec = std::make_unique<std::vector<MCEventWeight>>();
89 
90  // Get the MC generator information out of the event
91  // these are all handles to mc information.
92  std::vector<art::Ptr<simb::MCTruth> > mclist;
93 
94  // Actually go and get the stuff
95  auto const mcTruthHandle = e.getValidHandle<std::vector<simb::MCTruth>>(fGenieModuleLabel);
96  art::fill_ptr_vector(mclist, mcTruthHandle);
97 
98  // Loop over all neutrinos in this event
99  for (unsigned int inu = 0; inu < mclist.size(); ++inu) {
100  auto const mcwgh = _wgt_manager.Run(e, inu);
101  mcwghvec->push_back(mcwgh);
102  }
103 
104  e.put(std::move(mcwghvec));
105  }
std::string fGenieModuleLabel
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
WeightManager _wgt_manager
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
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 55 of file EventWeight_module.cc.

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

Definition at line 56 of file EventWeight_module.cc.


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