16#ifndef XAOD_STANDALONE
28#ifndef XAOD_STANDALONE
29 declareInterface< ::IMetaDataTool >(
this );
41#ifndef XAOD_STANDALONE
47 return StatusCode::SUCCESS;
69 if (!status.isSuccess()) {
70 if (status.isRecoverable()) {
73 return StatusCode::FAILURE;
84 ATH_MSG_ERROR(
"Could not determine the number of weight variations");
85 return StatusCode::FAILURE;
90#ifndef XAOD_STANDALONE
107 ATH_MSG_ERROR(
"Undefined behaviour: this file has already been processed");
108 return StatusCode::FAILURE;
116 std::string name = incompleteCollName;
118 name.append(
"_weight_");
119 name.append(std::to_string(i));
122 &&
inputMetaStore()->retrieve(inputCollection, name).isSuccess()) {
126 ATH_MSG_DEBUG(
"Successfully merged input incomplete bookkeepers with output");
128 ATH_MSG_INFO(
"No incomplete bookkeepers with name '" << incompleteCollName <<
"' in this file");
140 name.append(
"_weight_");
141 name.append(std::to_string(i));
144 &&
inputMetaStore()->retrieve(inputCollection, name).isSuccess()) {
148 ATH_MSG_DEBUG(
"Successfully copied complete bookkeepers to temp container");
153 return StatusCode::SUCCESS;
156#ifdef XAOD_STANDALONE
162#ifdef XAOD_STANDALONE
165 ATH_MSG_INFO(
"Copying input containers for source '" << source <<
"'");
168 return StatusCode::SUCCESS;
189 name.append(
"_weight_");
190 name.append(std::to_string(i));
192 std::string incompleteName =
"Incomplete" + name;
198 ATH_MSG_ERROR(
"Could not get " << name <<
" CutBookkeepers from output MetaDataStore");
199 return StatusCode::FAILURE;
209 if (!
outputMetaStore()->retrieve(incomplete, incompleteName).isSuccess()) {
210 ATH_MSG_ERROR(
"Could not get " << incompleteName <<
" CutBookkeepers from output MetaDataStore");
211 return StatusCode::FAILURE;
226 ATH_MSG_INFO(
"Successfully copied CutBookkeepers to the output MetaDataStore");
228 return StatusCode::SUCCESS;
244 if (!source.empty()) {
248 return StatusCode::SUCCESS;
251 for (std::size_t i = 0; i < it->second.size(); ++i) {
256 return StatusCode::SUCCESS;
260 for (std::size_t i = 0; i < list.size(); ++i) {
266 return StatusCode::SUCCESS;
271#ifndef XAOD_STANDALONE
276 if (!cache.
empty()) {
283 for (std::size_t i = 0; i < cache.
size(); ++i) {
288 return StatusCode::FAILURE;
292 return StatusCode::SUCCESS;
299 return StatusCode::RECOVERABLE;
303 ATH_MSG_DEBUG(
"Attempting to retrieve MC channel number...");
305 uint32_t mcChannelNumber{uint32_t(-1)};
308 float fltChannelNumber{-1};
310 mcChannelNumber =
static_cast<uint32_t
>(fltChannelNumber);
313 if (mcChannelNumber == uint32_t(-1)) {
314 ATH_MSG_WARNING(
"... MC channel number could not be loaded from FileMetaData");
315#ifdef XAOD_STANDALONE
318 return StatusCode::RECOVERABLE;
323 ATH_MSG_DEBUG(
"Attempting to load weight meta data from xAOD TruthMetaData for channel " << mcChannelNumber);
328 if (mcChannelNumber == 0 && metaDataContainer->
size() == 1) {
329 mcChannelNumber = metaDataContainer->
at(0)->mcChannelNumber();
330 ATH_MSG_WARNING(
"... MC channel number taken from the metadata as " << mcChannelNumber);
333 auto itTruthMetaDataPtr = std::find_if(metaDataContainer->
begin(), metaDataContainer->
end(),
334 [mcChannelNumber] (
const auto& it) { return it->mcChannelNumber() == mcChannelNumber; }
338 if (itTruthMetaDataPtr == metaDataContainer->
end()) {
339#ifdef XAOD_STANDALONE
341 ATH_MSG_DEBUG(
"Could not load weight meta data! Assuming 1 variation.");
342 return StatusCode::SUCCESS;
344 ATH_MSG_DEBUG(
"Could not load weight meta data from TruthMetaData!");
345 return StatusCode::RECOVERABLE;
350 const std::vector<std::string> &truthWeightNames = (*itTruthMetaDataPtr)->weightNames();
358 return StatusCode::SUCCESS;
366#ifdef XAOD_STANDALONE
367 return StatusCode::SUCCESS;
375 return StatusCode::SUCCESS;
379 if (!(
container->payloadContainer()->size() > 0
380 &&
container->payloadContainer()->at(0)->size() > 0)) {
381 return StatusCode::FAILURE;
387 const coral::Attribute& attr
388 =
container->payloadContainer()->at(0)->attributeList(chanNum)[
"HepMCWeightNames"];
390 ATH_MSG_DEBUG(
"Attempting to load weight meta data from /Generation/Parameters");
391 std::map<std::string, int> truthWeightMap;
396 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
bool msgLvl(const MSG::Level lvl) const
This implements the methods for ICutFlowSvc.
const T * at(size_type n) const
Access an element, as an rvalue.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
StatusCode parse(std::tuple< Tup... > &tup, const Gaudi::Parsers::InputData &input)
void updateContainer(xAOD::CutBookkeeperContainer *contToUpdate, const xAOD::CutBookkeeperContainer *otherCont)
Helper function to update a container with information from another one.
TruthMetaDataContainer_v1 TruthMetaDataContainer
Declare the latest version of the truth vertex container.
FileMetaData_v1 FileMetaData
Declare the latest version of the class.
CutBookkeeperContainer_v1 CutBookkeeperContainer
Define the latest version of the CutBookkeeperContainer class.
Helper in-memory structure.
xAOD::CutBookkeeperContainer * at(std::size_t n) const
static void prepareContainers(CutBookkeepersLocalCache &target, size_t size, bool extend=false)