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;
237 std::string beamEnergy =
m_tagInfoMgr->findTag(
"beam_energy");
240 std::stof(beamEnergy));
241 }
catch (std::invalid_argument& e) {
242 ATH_MSG_DEBUG(
"beam energy \"" << beamEnergy <<
"\" tag could not be converted to float");
243 }
catch (std::out_of_range& e) {
244 ATH_MSG_DEBUG(
"converted beam energy value (\"" << beamEnergy <<
"\") outside float range");
247 std::string dataYear =
m_tagInfoMgr->findTag(
"data_year");
248 if (!dataYear.empty()) {
251 static_cast<uint32_t
>(std::stoul(dataYear)));
252 }
catch (std::invalid_argument& e) {
253 ATH_MSG_DEBUG(
"data year \"" << dataYear <<
"\" tag could not be converted to unsigned long");
254 }
catch (std::out_of_range& e) {
255 ATH_MSG_DEBUG(
"converted data year value (\"" << dataYear <<
"\") outside unsigned long range");
261 StatusCode
sc = StatusCode::FAILURE;
267 const coral::AttributeList * attrList =
nullptr;
268 if (simInfo &&
sc.isSuccess()) {
270 for (
const auto& itr : *payload) {
271 attrList = &(itr.second);
276 bool simFlavourSet{};
277 bool isDataOverlaySet{};
280 std::string key =
"SimulationFlavour";
281 if (attrList->exists(key)) {
282 std::string value = (*attrList)[key].data< std::string >();
285 if (value ==
"default")
289 simFlavourSet =
true;
294 std::string key =
"IsDataOverlay";
295 if (attrList->exists(key)) {
296 std::string attr = (*attrList)[key].data< std::string >();
298 isDataOverlaySet =
true;
303 if (!simFlavourSet || !isDataOverlaySet) {
308 <<
". Trying to get them from input metadata store." );
314 if (!simFlavourSet) {
315 std::string orig_simFlavour =
"none";
318 "Could not get xAOD::FileMetaData::simFlavour "
319 "from input metadata "
329 if (!isDataOverlaySet) {
330 bool orig_isDataOverlay =
false;
334 "xAOD::FileMetaData::isDataOverlay from input "
339 << orig_isDataOverlay);
356 }
catch (std::exception&) {
365 return StatusCode::SUCCESS;
373 if (
m_info->setValue(key, value))
376 ATH_MSG_DEBUG(
"error setting " << key <<
" to " << std::boolalpha << value
377 << std::noboolalpha);
378 }
catch (std::exception&) {
389 if (
m_info->setValue(key, value))
393 }
catch (std::exception&) {
404 if (
m_info->setValue(key, value))
408 }
catch (std::exception&) {
417 const std::string& value) {
418 if (value.empty())
return;
420 if (
m_info->setValue(key, value))
424 }
catch (std::exception&) {
431 const std::string&
type, uint32_t value) {
433 std::vector<uint32_t> list;
441 auto it = std::lower_bound(list.begin(), list.end(), value);
442 if (it == list.end() || (*it) != value) {
443 list.insert(it, value);
449 }
catch (std::exception& e) {
#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...
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.