28 return key.find(
"__STREAM[") != std::string::npos;
43 const auto *parentAlg =
dynamic_cast< const INamedInterface*
>(parent());
52 incidentSvc->addListener(
this,
"EndInputFile", 40);
53 incidentSvc->addListener(
this,
"PostFork", 40);
56 ATH_MSG_DEBUG(
"Creating new xAOD::FileMetaData object to fill");
57 m_info = std::make_unique< xAOD::FileMetaData >();
58 m_aux = std::make_unique< xAOD::FileMetaDataAuxInfo >();
66 return StatusCode::SUCCESS;
72 if (inc.type() ==
"EndInputFile") {
77 ATH_MSG_DEBUG(
"Failed to fill FileMetaData with non-event info");
78 }
else if (inc.type() ==
"PostFork") {
82 if (!
m_info->setValue(
"runNumbers", std::vector<uint32_t>{}) ||
83 !
m_info->setValue(
"lumiBlocks", std::vector<uint32_t>{}))
84 ATH_MSG_WARNING(
"Error clearing event information from before the fork");
92 return StatusCode::SUCCESS;
97 return StatusCode::SUCCESS;
102 return StatusCode::SUCCESS;
110 ATH_MSG_DEBUG(
"Not writing empty or incomplete FileMetaData object");
121 if (!output->setValue(
"runNumbers", std::vector<uint32_t>{}) ||
122 !output->setValue(
"lumiBlocks", std::vector<uint32_t>{})) {
129 return StatusCode::SUCCESS;
136 auto info = std::make_unique<xAOD::FileMetaData>();
137 auto aux = std::make_unique<xAOD::FileMetaDataAuxInfo>();
138 info->setStore(aux.get());
146 float orig_mcProcID = -1;
147 std::vector<uint32_t> orig_runNumbers, orig_lumiBlocks;
150 if (!output->value(
"runNumbers", orig_runNumbers))
152 if (!output->value(
"lumiBlocks", orig_lumiBlocks))
157 ATH_MSG_DEBUG(
"FileMetaData payload replaced in store with content created for this stream");
161 ATH_MSG_DEBUG(
"Event information was not filled, restoring what we had");
165 orig_runNumbers.clear();
166 orig_lumiBlocks.clear();
168 if (!output->setValue(
"runNumbers", orig_runNumbers))
170 if (!output->setValue(
"lumiBlocks", orig_lumiBlocks))
178 return StatusCode::SUCCESS;
183 return StatusCode::SUCCESS;
193 ATH_MSG_DEBUG(
"Failed to fill FileMetaData with non-event info");
198 return StatusCode::SUCCESS;
204 <<
", not adding it to the FileMetaData");
205 return StatusCode::SUCCESS;
210 StatusCode
sc = StatusCode::FAILURE;
218 if (eventInfo &&
sc.isSuccess()) {
235 }
catch (std::exception&) {
243 <<
", runNumbers, or lumiBlockNumbers");
249 return StatusCode::SUCCESS;
261 return StatusCode::SUCCESS;
265 ATH_MSG_DEBUG(
"Deferring non-event fill due to eventless-input");
266 return StatusCode::SUCCESS;
288 std::string beamEnergy =
m_tagInfoMgr->findTag(
"beam_energy");
291 std::stof(beamEnergy));
292 }
catch (std::invalid_argument& e) {
293 ATH_MSG_DEBUG(
"beam energy \"" << beamEnergy <<
"\" tag could not be converted to float");
294 }
catch (std::out_of_range& e) {
295 ATH_MSG_DEBUG(
"converted beam energy value (\"" << beamEnergy <<
"\") outside float range");
298 std::string dataYear =
m_tagInfoMgr->findTag(
"data_year");
299 if (!dataYear.empty()) {
302 static_cast<uint32_t
>(std::stoul(dataYear)));
303 }
catch (std::invalid_argument& e) {
304 ATH_MSG_DEBUG(
"data year \"" << dataYear <<
"\" tag could not be converted to unsigned long");
305 }
catch (std::out_of_range& e) {
306 ATH_MSG_DEBUG(
"converted data year value (\"" << dataYear <<
"\") outside unsigned long range");
312 StatusCode
sc = StatusCode::FAILURE;
318 const coral::AttributeList * attrList =
nullptr;
319 if (simInfo &&
sc.isSuccess()) {
321 for (
const auto& itr : *payload) {
322 attrList = &(itr.second);
327 bool simFlavourSet{};
328 bool isDataOverlaySet{};
331 std::string key =
"SimulationFlavour";
332 if (attrList->exists(key)) {
333 std::string value = (*attrList)[key].data< std::string >();
336 if (value ==
"default")
340 simFlavourSet =
true;
345 std::string key =
"IsDataOverlay";
346 if (attrList->exists(key)) {
347 std::string attr = (*attrList)[key].data< std::string >();
349 isDataOverlaySet =
true;
354 if (!simFlavourSet || !isDataOverlaySet) {
359 <<
". Trying to get them from input metadata store." );
365 if (!simFlavourSet) {
366 std::string orig_simFlavour =
"none";
369 "Could not get xAOD::FileMetaData::simFlavour "
370 "from input metadata "
380 if (!isDataOverlaySet) {
381 bool orig_isDataOverlay =
false;
385 "xAOD::FileMetaData::isDataOverlay from input "
390 << orig_isDataOverlay);
408 }
catch (std::exception&) {
417 return StatusCode::SUCCESS;
425 if (
m_info->setValue(key, value)) {
428 ATH_MSG_DEBUG(
"error setting " << key <<
" to " << std::boolalpha << value
429 << std::noboolalpha);
431 }
catch (std::exception&) {
442 if (
m_info->setValue(key, value)) {
447 }
catch (std::exception&) {
458 if (
m_info->setValue(key, value)) {
463 }
catch (std::exception&) {
472 const std::string& value) {
473 if (value.empty())
return;
475 if (
m_info->setValue(key, value)) {
480 }
catch (std::exception&) {
487 const std::string&
type, uint32_t value) {
489 std::vector<uint32_t> list;
497 auto it = std::lower_bound(list.begin(), list.end(), value);
498 if (it == list.end() || (*it) != value) {
499 list.insert(it, value);
505 }
catch (std::exception& e) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
This class is a collection of AttributeLists where each one is associated with a channel number.
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t runNumber() const
The current event's run number.
uint32_t mcChannelNumber() const
The MC generator's channel number.
::StatusCode StatusCode
StatusCode definition for legacy code.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
EventInfo_v1 EventInfo
Definition of the latest event info version.
FileMetaData_v1 FileMetaData
Declare the latest version of the class.