37 const auto *parentAlg =
dynamic_cast< const INamedInterface*
>(parent());
46 incidentSvc->addListener(
this,
"EndInputFile", 40);
49 ATH_MSG_DEBUG(
"Creating new xAOD::FileMetaData object to fill");
50 m_info = std::make_unique< xAOD::FileMetaData >();
51 m_aux = std::make_unique< xAOD::FileMetaDataAuxInfo >();
59 return StatusCode::SUCCESS;
65 if (inc.type() ==
"EndInputFile") {
70 ATH_MSG_DEBUG(
"Failed to fill FileMetaData with non-event info");
76 return StatusCode::SUCCESS;
81 return StatusCode::SUCCESS;
86 return StatusCode::SUCCESS;
94 ATH_MSG_DEBUG(
"Not writing empty or incomplete FileMetaData object");
95 return StatusCode::SUCCESS;
102 auto info = std::make_unique<xAOD::FileMetaData>();
103 auto aux = std::make_unique<xAOD::FileMetaDataAuxInfo>();
104 info->setStore(aux.get());
112 float orig_mcProcID = -1;
113 std::vector<uint32_t> orig_runNumbers, orig_lumiBlocks;
116 if (!output->value(
"runNumbers", orig_runNumbers))
118 if (!output->value(
"lumiBlocks", orig_lumiBlocks))
123 ATH_MSG_DEBUG(
"FileMetaData payload replaced in store with content created for this stream");
126 ATH_MSG_DEBUG(
"Event information was not filled, restoring what we had");
129 if (!output->setValue(
"runNumbers", orig_runNumbers))
131 if (!output->setValue(
"lumiBlocks", orig_lumiBlocks))
139 return StatusCode::SUCCESS;
144 return StatusCode::SUCCESS;
154 ATH_MSG_DEBUG(
"Failed to fill FileMetaData with non-event info");
159 return StatusCode::SUCCESS;
164 StatusCode
sc = StatusCode::FAILURE;
171 if (eventInfo &&
sc.isSuccess()) {
187 }
catch (std::exception&) {
195 <<
", runNumbers, or lumiBlockNumbers");
201 return StatusCode::SUCCESS;
213 return StatusCode::SUCCESS;
217 ATH_MSG_DEBUG(
"Deferring non-event fill due to eventless-input");
218 return StatusCode::SUCCESS;
240 std::string beamEnergy =
m_tagInfoMgr->findTag(
"beam_energy");
243 std::stof(beamEnergy));
244 }
catch (std::invalid_argument& e) {
245 ATH_MSG_DEBUG(
"beam energy \"" << beamEnergy <<
"\" tag could not be converted to float");
246 }
catch (std::out_of_range& e) {
247 ATH_MSG_DEBUG(
"converted beam energy value (\"" << beamEnergy <<
"\") outside float range");
250 std::string dataYear =
m_tagInfoMgr->findTag(
"data_year");
251 if (!dataYear.empty()) {
254 static_cast<uint32_t
>(std::stoul(dataYear)));
255 }
catch (std::invalid_argument& e) {
256 ATH_MSG_DEBUG(
"data year \"" << dataYear <<
"\" tag could not be converted to unsigned long");
257 }
catch (std::out_of_range& e) {
258 ATH_MSG_DEBUG(
"converted data year value (\"" << dataYear <<
"\") outside unsigned long range");
264 StatusCode
sc = StatusCode::FAILURE;
270 const coral::AttributeList * attrList =
nullptr;
271 if (simInfo &&
sc.isSuccess()) {
273 for (
const auto& itr : *payload) {
274 attrList = &(itr.second);
279 bool simFlavourSet{};
280 bool isDataOverlaySet{};
283 std::string key =
"SimulationFlavour";
284 if (attrList->exists(key)) {
285 std::string value = (*attrList)[key].data< std::string >();
288 if (value ==
"default")
292 simFlavourSet =
true;
297 std::string key =
"IsDataOverlay";
298 if (attrList->exists(key)) {
299 std::string attr = (*attrList)[key].data< std::string >();
301 isDataOverlaySet =
true;
306 if (!simFlavourSet || !isDataOverlaySet) {
311 <<
". Trying to get them from input metadata store." );
317 if (!simFlavourSet) {
318 std::string orig_simFlavour =
"none";
321 "Could not get xAOD::FileMetaData::simFlavour "
322 "from input metadata "
332 if (!isDataOverlaySet) {
333 bool orig_isDataOverlay =
false;
337 "xAOD::FileMetaData::isDataOverlay from input "
342 << orig_isDataOverlay);
359 }
catch (std::exception&) {
368 return StatusCode::SUCCESS;
376 if (
m_info->setValue(key, value))
379 ATH_MSG_DEBUG(
"error setting " << key <<
" to " << std::boolalpha << value
380 << std::noboolalpha);
381 }
catch (std::exception&) {
392 if (
m_info->setValue(key, value))
396 }
catch (std::exception&) {
407 if (
m_info->setValue(key, value))
411 }
catch (std::exception&) {
420 const std::string& value) {
421 if (value.empty())
return;
423 if (
m_info->setValue(key, value))
427 }
catch (std::exception&) {
434 const std::string&
type, uint32_t value) {
436 std::vector<uint32_t> list;
444 auto it = std::lower_bound(list.begin(), list.end(), value);
445 if (it == list.end() || (*it) != value) {
446 list.insert(it, value);
452 }
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.