29 ATH_MSG_ERROR(
"Configured CutFlowSvc does not use the CutFlowSvc implementation");
30 return StatusCode::FAILURE;
35 return StatusCode::SUCCESS;
42 return StatusCode::SUCCESS;
47 if (!eventCollection || eventCollection->
empty()) {
48 ATH_MSG_ERROR(
"Cannot declare generator weights from an empty GEN_EVENT");
49 return StatusCode::FAILURE;
54 ATH_MSG_ERROR(
"Cannot declare generator weights from a null event");
55 return StatusCode::FAILURE;
58 const std::size_t weightCount =
event->weights().size();
59 if (weightCount == 0) {
60 ATH_MSG_ERROR(
"Cannot declare an empty generator-weight vector");
61 return StatusCode::FAILURE;
65 const auto runInfo =
event->run_info();
67 const std::size_t rawNameCount =
runInfo->weight_names().size();
68 if (rawNameCount != weightCount) {
69 ATH_MSG_ERROR(
"Generator weight names and values have different sizes: "
70 << rawNameCount <<
" and " << weightCount);
71 return StatusCode::FAILURE;
73 if (weightNames.size() != rawNameCount) {
75 return StatusCode::FAILURE;
82 if (!weightNames.empty()) {
89 <<
" generator weight slot" << (weightCount == 1 ?
"" :
"s")
90 <<
" from the first event");
91 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
This implements the methods for ICutFlowSvc.
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
virtual StatusCode initialize() override
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const McEventCollection * events_const(const EventContext &ctx) const
Access the current event's McEventCollection (const).
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
ServiceHandle< IHepMCWeightSvc > m_hepMCWeightSvc
ServiceHandle< ICutFlowSvc > m_cutFlowSvc
CutFlowSvc * m_cutFlowSvcImpl
GenWeightDeclaration(const std::string &name, ISvcLocator *svcLoc)
std::map< std::string, std::size_t > WeightMap
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
std::map< std::string, std::size_t > weights_map(const HepMC3::GenEvent *e)
HepMC3::GenEvent GenEvent