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
sbn::evwgh::SBNEventWeight Class Reference
Inheritance diagram for sbn::evwgh::SBNEventWeight:

Public Member Functions

 SBNEventWeight (fhicl::ParameterSet const &p)
 
 SBNEventWeight (SBNEventWeight const &)=delete
 
 SBNEventWeight (SBNEventWeight &&)=delete
 
SBNEventWeightoperator= (SBNEventWeight const &)=delete
 
SBNEventWeightoperator= (SBNEventWeight &&)=delete
 

Private Member Functions

void produce (art::Event &e) override
 
void beginRun (art::Run &run) override
 

Private Attributes

WeightManager fWeightManager
 
std::string fGenieModuleLabel
 
bool fAllowMissingTruth
 

Detailed Description

Definition at line 37 of file SBNEventWeight_module.cc.

Constructor & Destructor Documentation

sbn::evwgh::SBNEventWeight::SBNEventWeight ( fhicl::ParameterSet const &  p)
explicit

Definition at line 57 of file SBNEventWeight_module.cc.

58  : EDProducer{p},
59  fGenieModuleLabel(p.get<std::string>("generator_module_label", "generator")),
60  fAllowMissingTruth(p.get<bool>("AllowMissingTruth"))
61 {
62  const size_t n_func = fWeightManager.Configure(p, *this);
63  if (n_func > 0) {
64  produces<std::vector<sbn::evwgh::EventWeightMap> >();
65  produces<art::Assns<simb::MCTruth, sbn::evwgh::EventWeightMap> >();
66  produces<std::vector<sbn::evwgh::EventWeightParameterSet>, art::InRun>();
67  }
68 }
pdgs p
Definition: selectors.fcl:22
size_t Configure(fhicl::ParameterSet const &cfg, Module &module)
sbn::evwgh::SBNEventWeight::SBNEventWeight ( SBNEventWeight const &  )
delete
sbn::evwgh::SBNEventWeight::SBNEventWeight ( SBNEventWeight &&  )
delete

Member Function Documentation

void sbn::evwgh::SBNEventWeight::beginRun ( art::Run &  run)
overrideprivate

Definition at line 101 of file SBNEventWeight_module.cc.

101  {
102  auto p = std::make_unique<std::vector<EventWeightParameterSet> >();
103 
104  for (auto const& it : fWeightManager.GetWeightCalcMap()) {
105  p->push_back(it.second->fParameterSet);
106  }
107 
108  run.put(std::move(p));
109 }
pdgs p
Definition: selectors.fcl:22
std::map< std::string, WeightCalc * > GetWeightCalcMap()
SBNEventWeight& sbn::evwgh::SBNEventWeight::operator= ( SBNEventWeight const &  )
delete
SBNEventWeight& sbn::evwgh::SBNEventWeight::operator= ( SBNEventWeight &&  )
delete
void sbn::evwgh::SBNEventWeight::produce ( art::Event &  e)
overrideprivate

Definition at line 71 of file SBNEventWeight_module.cc.

71  {
72  auto mcwghvec = std::make_unique<std::vector<EventWeightMap> >();
73  auto wghassns = std::make_unique<art::Assns<simb::MCTruth, sbn::evwgh::EventWeightMap> >();
74 
75  art::PtrMaker<sbn::evwgh::EventWeightMap> makeWeightPtr(e);
76 
77  // Get the MC generator information
78  std::vector<art::Ptr<simb::MCTruth> > mclist;
79  art::Handle<std::vector<simb::MCTruth>> mcTruthHandle;
80  if(!fGenieModuleLabel.empty()) e.getByLabel(fGenieModuleLabel, mcTruthHandle);
81  // Prooceed even with missing handle if we want to require the MCTruth to be
82  // found, so that an exception will be thrown explaining the problem.
83  if(mcTruthHandle.isValid() || !fAllowMissingTruth){
84  art::fill_ptr_vector(mclist, mcTruthHandle);
85 
86  // Loop over all truth objects (e.g. neutrinos) in this event
87  for (size_t i=0; i<mclist.size(); i++) {
88  const EventWeightMap mcwgh = fWeightManager.Run(e, i);
89  mcwghvec->push_back(std::move(mcwgh));
90 
91  art::Ptr<sbn::evwgh::EventWeightMap> wghPtr = makeWeightPtr(mcwghvec->size() - 1);
92  wghassns->addSingle(mclist.at(i), wghPtr);
93  }
94  }
95 
96  e.put(std::move(mcwghvec));
97  e.put(std::move(wghassns));
98 }
std::map< std::string, std::vector< float > > EventWeightMap
Container for event-level weights.
do i e
EventWeightMap Run(art::Event &e, const int inu)

Member Data Documentation

bool sbn::evwgh::SBNEventWeight::fAllowMissingTruth
private

Definition at line 53 of file SBNEventWeight_module.cc.

std::string sbn::evwgh::SBNEventWeight::fGenieModuleLabel
private

Definition at line 52 of file SBNEventWeight_module.cc.

WeightManager sbn::evwgh::SBNEventWeight::fWeightManager
private

Definition at line 51 of file SBNEventWeight_module.cc.


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