ATLAS Offline Software
Loading...
Searching...
No Matches
xAODMaker::FileMetaDataCreatorTool Class Reference

Tool creating xAOD::FileMetaData information. More...

#include <FileMetaDataCreatorTool.h>

Inheritance diagram for xAODMaker::FileMetaDataCreatorTool:
Collaboration diagram for xAODMaker::FileMetaDataCreatorTool:

Public Member Functions

AlgTool Methods

Called by AthenaOutputStream::initialize() (via ToolSvc retrieve()).

StatusCode initialize () override
StatusCode finalize () override
 Called at the end of AthenaOutputStream::finalize() (via release()).
Methods inherited by IAthenaOutputTool

Called at the end of AthenaOutputStream::initialize().

StatusCode postInitialize () override
StatusCode preExecute () override
 Called at the beginning of AthenaOutputStream::execute().
StatusCode preStream () override
 Called before actually streaming objects.
StatusCode postExecute () override
 Fill the FileMetaData with event information.
StatusCode preFinalize () override
 Write the FileMetaData object to the MetaDataStore via the MetaDataSvc.

IIncidentListener methods

Gaudi::Property< std::string > m_key
 output key for produced xAOD::FileMetaData in MetaDataStore
Gaudi::Property< std::string > m_tagInfoKey
 Read tag information.
Gaudi::Property< std::string > m_simInfoKey
 Read simulation parameters.
Gaudi::Property< std::string > m_eventInfoKey
 Key for xAOD::EventInfo to update MC channel number.
Gaudi::Property< std::string > m_dataHeaderKey
 Key for DataHeader in StoreGateSvc.
ServiceHandle< StoreGateSvc > m_eventStore {"StoreGateSvc", name()}
 DataHeader is produced by another OutputTool, so need StoreGateSvc.
ServiceHandle< IAthMetaDataSvc > m_metaDataSvc {"MetaDataSvc", name()}
 Use MetaDataSvc store interface to support output in EventService.
ServiceHandle< StoreGateSvc > m_inputMetaDataStore
 Access to the input metadata store.
ServiceHandle< StoreGateSvc > m_metaDataStore
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
 Access to TagInfoMgr for tags.
std::unique_ptr< xAOD::FileMetaData > m_info
 The object created for this output stream.
std::unique_ptr< xAOD::FileMetaDataAuxInfo > m_aux
 The auxiliary containing the created object.
bool m_filledNonEvent {false}
 FileMetaData has been filled with non-event info.
bool m_filledEvent {false}
 FileMetaData has been filled with event information.
bool m_hasInputFile {false}
 Input file incident check.
std::mutex m_toolMutex
 creation of FileMetaData should happen on a single thread
void handle (const Incident &) override
 Calls updateFromNonEvent on EndInputFile Clears event information inherited from the parent process on PostFork.
StatusCode updateFromNonEvent ()
 Update from Simulation Parameters and TagInfo.
void set (const xAOD::FileMetaData::MetaDataType, bool)
 helper method to update FileMetaDataProperty with some checks
void set (const xAOD::FileMetaData::MetaDataType, uint32_t)
void set (const xAOD::FileMetaData::MetaDataType, float)
void set (const xAOD::FileMetaData::MetaDataType, const std::string &)
void addUniqueValue (const std::string &type, uint32_t value)
 helper function to add values to lists

Detailed Description

Tool creating xAOD::FileMetaData information.

This Athena-only tool can be used to create xAOD::FileMetaData information out of the non-ROOT-readable metadata available in the input. The FileMetaDataTool may have copied a xAOD::FileMetaData object to the MetaDataStore. If such a xAOD::FileMetaData object is found it is updated to reflect the current data type and MC channel number.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Frank Berghaus fberg.nosp@m.haus.nosp@m.@anl..nosp@m.gov

Definition at line 44 of file FileMetaDataCreatorTool.h.

Member Function Documentation

◆ addUniqueValue()

void xAODMaker::FileMetaDataCreatorTool::addUniqueValue ( const std::string & type,
uint32_t value )
private

helper function to add values to lists

Definition at line 486 of file FileMetaDataCreatorTool.cxx.

487 {
488 try {
489 std::vector<uint32_t> list;
490 if (m_info->value(type, list)) {
491 ATH_MSG_DEBUG("retrieved existing list of " << type);
492 } else {
493 ATH_MSG_DEBUG("adding new list for " << type);
494 }
495 // we want a sorted list of unique values (without using std::set)
496 std::sort(list.begin(), list.end());
497 auto it = std::lower_bound(list.begin(), list.end(), value);
498 if (it == list.end() || (*it) != value) {
499 list.insert(it, value);
500 ATH_MSG_DEBUG("added " << value << " to list of " << type);
501 }
502 if (!m_info->setValue(type, list)) {
503 ATH_MSG_WARNING("error updating list for " + type);
504 }
505 } catch (std::exception& e) {
506 // Processing generated events not data
507 ATH_MSG_WARNING(e.what());
508 }
509}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
std::unique_ptr< xAOD::FileMetaData > m_info
The object created for this output stream.
list(name, path='/')
Definition histSizes.py:38
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ finalize()

StatusCode xAODMaker::FileMetaDataCreatorTool::finalize ( )
override

Called at the end of AthenaOutputStream::finalize() (via release()).

Definition at line 182 of file FileMetaDataCreatorTool.cxx.

182 {
183 return StatusCode::SUCCESS;
184 }

◆ handle()

void xAODMaker::FileMetaDataCreatorTool::handle ( const Incident & inc)
override

Calls updateFromNonEvent on EndInputFile Clears event information inherited from the parent process on PostFork.

Definition at line 70 of file FileMetaDataCreatorTool.cxx.

70 {
71 // gracefully ignore unexpected incident types
72 if (inc.type() == "EndInputFile") {
73 // Lock the tool while we work on the FileMetaData
74 std::lock_guard lock(m_toolMutex);
75 m_hasInputFile = true;
76 if (!updateFromNonEvent().isSuccess())
77 ATH_MSG_DEBUG("Failed to fill FileMetaData with non-event info");
78 } else if (inc.type() == "PostFork") {
79 // Drop event info inherited from the parent process
80 std::lock_guard lock(m_toolMutex);
81 if (m_info && m_filledEvent) {
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");
85 m_filledEvent = false;
86 }
87 }
88 }
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
bool m_filledEvent
FileMetaData has been filled with event information.
StatusCode updateFromNonEvent()
Update from Simulation Parameters and TagInfo.
std::mutex m_toolMutex
creation of FileMetaData should happen on a single thread
bool m_hasInputFile
Input file incident check.

◆ initialize()

StatusCode xAODMaker::FileMetaDataCreatorTool::initialize ( )
override

Definition at line 34 of file FileMetaDataCreatorTool.cxx.

34 {
35 ATH_CHECK(m_eventStore.retrieve());
36 ATH_CHECK(m_metaDataSvc.retrieve());
38 ATH_CHECK(m_metaDataStore.retrieve());
39 ATH_CHECK(m_tagInfoMgr.retrieve());
40
41 // If DataHeader key not specified, try determining it
42 if (m_dataHeaderKey.empty()) {
43 const auto *parentAlg = dynamic_cast< const INamedInterface* >(parent());
44 if (parentAlg)
45 m_dataHeaderKey = parentAlg->name();
46 }
47
48 // Listen for the begin of an input file. Act after MetaDataSvc (prio 80) and
49 // TagInfoMgr (prio 50). That means the FileMetaDataTool be called first
50 ServiceHandle< IIncidentSvc > incidentSvc("IncidentSvc", name());
51 ATH_CHECK(incidentSvc.retrieve());
52 incidentSvc->addListener(this, "EndInputFile", 40);
53 incidentSvc->addListener(this, "PostFork", 40);
54
55 // Create a fresh object to fill
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 >();
59 m_info->setStore(m_aux.get());
60
61 // FileMetaData has no content
62 m_filledNonEvent = false;
63 m_filledEvent = false;
64
65 // Return gracefully:
66 return StatusCode::SUCCESS;
67 }
#define ATH_CHECK
Evaluate an expression and check for errors.
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Access to TagInfoMgr for tags.
ServiceHandle< IAthMetaDataSvc > m_metaDataSvc
Use MetaDataSvc store interface to support output in EventService.
ServiceHandle< StoreGateSvc > m_metaDataStore
ServiceHandle< StoreGateSvc > m_eventStore
DataHeader is produced by another OutputTool, so need StoreGateSvc.
ServiceHandle< StoreGateSvc > m_inputMetaDataStore
Access to the input metadata store.
bool m_filledNonEvent
FileMetaData has been filled with non-event info.
Gaudi::Property< std::string > m_dataHeaderKey
Key for DataHeader in StoreGateSvc.
std::unique_ptr< xAOD::FileMetaDataAuxInfo > m_aux
The auxiliary containing the created object.

◆ postExecute()

StatusCode xAODMaker::FileMetaDataCreatorTool::postExecute ( )
override

Fill the FileMetaData with event information.

Use information from xAOD::EventInfo to fill xAOD::FileMetaData::mcProcID and DataHeader to set xAOD::FileMetaData::dataType

Definition at line 187 of file FileMetaDataCreatorTool.cxx.

187 {
188 // Lock the tool while working with FileMetaData
189 std::lock_guard lock(m_toolMutex);
190
191 // Fill information from TagInfo and Simulation Parameters
192 if (!updateFromNonEvent().isSuccess())
193 ATH_MSG_DEBUG("Failed to fill FileMetaData with non-event info");
194
195 // Sanity check
196 if (!(m_info && m_aux)) {
197 ATH_MSG_DEBUG("No xAOD::FileMetaData object to fill");
198 return StatusCode::SUCCESS;
199 }
200
201 // Skip events not written by this stream (no DataHeader)
202 if (!m_eventStore->contains<DataHeader>(m_dataHeaderKey)) {
203 ATH_MSG_DEBUG("Event was not written to " << m_dataHeaderKey.value()
204 << ", not adding it to the FileMetaData");
205 return StatusCode::SUCCESS;
206 }
207
208 { // MC channel, run and/or lumi block numbers
209 const xAOD::EventInfo* eventInfo = nullptr;
210 StatusCode sc = StatusCode::FAILURE;
211
212 if (m_eventStore->contains< xAOD::EventInfo >(m_eventInfoKey)) {
213 sc = m_eventStore->retrieve(eventInfo, m_eventInfoKey);
214 } else if (m_eventStore->contains< xAOD::EventInfo >("Mc" + m_eventInfoKey)) {
215 sc = m_eventStore->retrieve(eventInfo, "Mc" + m_eventInfoKey);
216 }
217
218 if (eventInfo && sc.isSuccess()) {
219 addUniqueValue("runNumbers", eventInfo->runNumber());
220 addUniqueValue("lumiBlocks", eventInfo->lumiBlock());
221 // Return if object has already been filled
222 if (m_filledEvent) return StatusCode::SUCCESS;
223
224 try {
225 ATH_MSG_DEBUG("Retrieved " << m_eventInfoKey);
226
228 const float id = static_cast< float >(eventInfo->mcChannelNumber());
229
230 if (m_info->setValue(type, id)) {
231 ATH_MSG_DEBUG("setting " << type << " to " << id);
232 } else {
233 ATH_MSG_DEBUG("error setting " << type << " to " << id);
234 }
235 } catch (std::exception&) {
236 // Processing data not generated events
237 ATH_MSG_DEBUG("Failed to set " << xAOD::FileMetaData::mcProcID);
238 }
239 } else {
241 "Failed to retrieve " << m_eventInfoKey << " => cannot set "
243 << ", runNumbers, or lumiBlockNumbers");
244 }
245 }
246
247 m_filledEvent = true;
248
249 return StatusCode::SUCCESS;
250 }
static Double_t sc
void addUniqueValue(const std::string &type, uint32_t value)
helper function to add values to lists
Gaudi::Property< std::string > m_eventInfoKey
Key for xAOD::EventInfo to update MC 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.
MetaDataType
Pre-defined metadata value types.
@ mcProcID
Same as mc_channel_number [float].
::StatusCode StatusCode
StatusCode definition for legacy code.
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ postInitialize()

StatusCode xAODMaker::FileMetaDataCreatorTool::postInitialize ( )
override

Definition at line 91 of file FileMetaDataCreatorTool.cxx.

91 {
92 return StatusCode::SUCCESS;
93 }

◆ preExecute()

StatusCode xAODMaker::FileMetaDataCreatorTool::preExecute ( )
override

Called at the beginning of AthenaOutputStream::execute().

Definition at line 96 of file FileMetaDataCreatorTool.cxx.

96 {
97 return StatusCode::SUCCESS;
98 }

◆ preFinalize()

StatusCode xAODMaker::FileMetaDataCreatorTool::preFinalize ( )
override

Write the FileMetaData object to the MetaDataStore via the MetaDataSvc.

Definition at line 106 of file FileMetaDataCreatorTool.cxx.

106 {
107 std::lock_guard lock(m_toolMutex);
108
109 if (!m_filledNonEvent) {
110 ATH_MSG_DEBUG("Not writing empty or incomplete FileMetaData object");
111 // Input FileMetaData is still written (e.g. pre-fork parent), so drop its event info
112 if (!m_filledEvent) {
113 for (const std::string& key : m_metaDataSvc->getPerStreamKeysFor(m_key)) {
114 if (isFromSharedWriterWorker(key)) {
115 continue;
116 }
117 auto* output = m_metaDataSvc->tryRetrieve<xAOD::FileMetaData>(key);
118 if (!output) {
119 continue;
120 }
121 if (!output->setValue("runNumbers", std::vector<uint32_t>{}) ||
122 !output->setValue("lumiBlocks", std::vector<uint32_t>{})) {
123 ATH_MSG_WARNING("Could not clear the event information of " << key);
124 } else {
125 ATH_MSG_DEBUG("Cleared the event information of " << key);
126 }
127 }
128 }
129 return StatusCode::SUCCESS;
130 }
131
132 // Set metadata with content created for given stream
133 for (const std::string& key : m_metaDataSvc->getPerStreamKeysFor(m_key)) {
134 // Remove any existing objects with this key
135 if (!m_metaDataSvc->contains<xAOD::FileMetaData>(key)) {
136 auto info = std::make_unique<xAOD::FileMetaData>();
137 auto aux = std::make_unique<xAOD::FileMetaDataAuxInfo>();
138 info->setStore(aux.get());
139 ATH_CHECK(m_metaDataSvc->record(std::move(info), key));
140 ATH_CHECK(m_metaDataSvc->record(std::move(aux), key + "Aux."));
141 }
142
143 auto* output = m_metaDataSvc->tryRetrieve<xAOD::FileMetaData>(key);
144 if (output) {
145 // save event info that we've already had
146 float orig_mcProcID = -1;
147 std::vector<uint32_t> orig_runNumbers, orig_lumiBlocks;
148 if (!output->value(xAOD::FileMetaData::mcProcID, orig_mcProcID))
149 ATH_MSG_DEBUG("Could not get mcProcID");
150 if (!output->value("runNumbers", orig_runNumbers))
151 ATH_MSG_DEBUG("Could not get runNumbers");
152 if (!output->value("lumiBlocks", orig_lumiBlocks))
153 ATH_MSG_DEBUG("Could not get lumiBlocks");
154
155 // Replace content in store with content created for this stream
156 *output = *m_info;
157 ATH_MSG_DEBUG("FileMetaData payload replaced in store with content created for this stream");
158 if (!m_filledEvent) {
159 // No events were written to this stream by this process: restore the original
160 // mcProcID, keep run/lumi info only if it came from a SharedWriter worker
161 ATH_MSG_DEBUG("Event information was not filled, restoring what we had");
162 if (!output->setValue(xAOD::FileMetaData::mcProcID, orig_mcProcID))
163 ATH_MSG_DEBUG("Could not set " << xAOD::FileMetaData::mcProcID << " to " << orig_mcProcID);
164 if (!isFromSharedWriterWorker(key)) {
165 orig_runNumbers.clear();
166 orig_lumiBlocks.clear();
167 }
168 if (!output->setValue("runNumbers", orig_runNumbers))
169 ATH_MSG_DEBUG("Could not set runNumbers");
170 if (!output->setValue("lumiBlocks", orig_lumiBlocks))
171 ATH_MSG_DEBUG("Could not set lumiBlocks");
172 }
173 } else {
174 ATH_MSG_DEBUG("cannot copy FileMetaData payload to output");
175 }
176 }
177
178 return StatusCode::SUCCESS;
179}
static bool isFromSharedWriterWorker(const std::string &key)
Check if the object under this key was received by the SharedWriter from a worker Keep in sync with M...
Gaudi::Property< std::string > m_key
output key for produced xAOD::FileMetaData in MetaDataStore
output
Definition merge.py:16
FileMetaData_v1 FileMetaData
Declare the latest version of the class.

◆ preStream()

StatusCode xAODMaker::FileMetaDataCreatorTool::preStream ( )
override

Called before actually streaming objects.

Definition at line 101 of file FileMetaDataCreatorTool.cxx.

101 {
102 return StatusCode::SUCCESS;
103 }

◆ set() [1/4]

void xAODMaker::FileMetaDataCreatorTool::set ( const xAOD::FileMetaData::MetaDataType key,
bool value )
private

helper method to update FileMetaDataProperty with some checks

Definition at line 421 of file FileMetaDataCreatorTool.cxx.

423 {
424 try {
425 if (m_info->setValue(key, value)) {
426 ATH_MSG_DEBUG("setting " << key << " to " << value);
427 } else {
428 ATH_MSG_DEBUG("error setting " << key << " to " << std::boolalpha << value
429 << std::noboolalpha);
430 }
431 } catch (std::exception&) {
432 // Processing data not generated events
433 ATH_MSG_DEBUG("Failed to set " << key);
434 }
435 }

◆ set() [2/4]

void xAODMaker::FileMetaDataCreatorTool::set ( const xAOD::FileMetaData::MetaDataType key,
const std::string & value )
private

Definition at line 470 of file FileMetaDataCreatorTool.cxx.

472 {
473 if (value.empty()) return;
474 try {
475 if (m_info->setValue(key, value)) {
476 ATH_MSG_DEBUG("setting " << key << " to " << value);
477 } else {
478 ATH_MSG_DEBUG("error setting " << key << " to " << value);
479 }
480 } catch (std::exception&) {
481 // Processing data not generated events
482 ATH_MSG_DEBUG("Failed to set " << key);
483 }
484 }

◆ set() [3/4]

void xAODMaker::FileMetaDataCreatorTool::set ( const xAOD::FileMetaData::MetaDataType key,
float value )
private

Definition at line 454 of file FileMetaDataCreatorTool.cxx.

456 {
457 try {
458 if (m_info->setValue(key, value)) {
459 ATH_MSG_DEBUG("setting " << key << " to " << value);
460 } else {
461 ATH_MSG_DEBUG("error setting " << key << " to " << value);
462 }
463 } catch (std::exception&) {
464 // Processing data not generated events
465 ATH_MSG_DEBUG("Failed to set " << key);
466 }
467 }

◆ set() [4/4]

void xAODMaker::FileMetaDataCreatorTool::set ( const xAOD::FileMetaData::MetaDataType key,
uint32_t value )
private

Definition at line 438 of file FileMetaDataCreatorTool.cxx.

440 {
441 try {
442 if (m_info->setValue(key, value)) {
443 ATH_MSG_DEBUG("setting " << key << " to " << value);
444 } else {
445 ATH_MSG_DEBUG("error setting " << key << " to " << value);
446 }
447 } catch (std::exception&) {
448 // Processing data not generated events
449 ATH_MSG_DEBUG("Failed to set " << key);
450 }
451 }

◆ updateFromNonEvent()

StatusCode xAODMaker::FileMetaDataCreatorTool::updateFromNonEvent ( )
private

Update from Simulation Parameters and TagInfo.

Definition at line 253 of file FileMetaDataCreatorTool.cxx.

253 {
254
255 // Have we already done this?
256 if (m_filledNonEvent) return StatusCode::SUCCESS;
257
258 // Sanity check
259 if (!(m_info && m_aux)) {
260 ATH_MSG_DEBUG("No xAOD::FileMetaData object to fill");
261 return StatusCode::SUCCESS;
262 }
263
264 if (m_hasInputFile && m_tagInfoMgr->getInputTags().empty()) {
265 ATH_MSG_DEBUG("Deferring non-event fill due to eventless-input");
266 return StatusCode::SUCCESS;
267 }
268
270 m_tagInfoMgr->findTag("AtlasRelease"));
271
273 m_tagInfoMgr->findTag("AODFixVersion"));
274
275 set(xAOD::FileMetaData::amiTag, m_tagInfoMgr->findTag("AMITag"));
276
278
280 m_tagInfoMgr->findTag("IOVDbGlobalTag"));
281
282 set(xAOD::FileMetaData::beamType, m_tagInfoMgr->findTag("beam_type"));
283
284 set(xAOD::FileMetaData::mcCampaign, m_tagInfoMgr->findTag("mc_campaign"));
285
286 set(xAOD::FileMetaData::generatorsInfo, m_tagInfoMgr->findTag("generators"));
287
288 std::string beamEnergy = m_tagInfoMgr->findTag("beam_energy");
289 try {
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");
296 }
297
298 std::string dataYear = m_tagInfoMgr->findTag("data_year");
299 if (!dataYear.empty()) {
300 try {
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");
307 }
308 }
309
310 // Read simulation parameters
311 const IOVMetaDataContainer * simInfo = nullptr;
312 StatusCode sc = StatusCode::FAILURE;
313 if (m_inputMetaDataStore->contains< IOVMetaDataContainer >(m_simInfoKey)) {
314 sc = m_inputMetaDataStore->retrieve(simInfo, m_simInfoKey);
315 } else if (m_metaDataStore->contains< IOVMetaDataContainer >(m_simInfoKey)) {
316 sc = m_metaDataStore->retrieve(simInfo, m_simInfoKey);
317 }
318 const coral::AttributeList * attrList = nullptr;
319 if (simInfo && sc.isSuccess()) {
320 for (const CondAttrListCollection* payload : *simInfo->payloadContainer()) {
321 for (const auto& itr : *payload) {
322 attrList = &(itr.second);
323 }
324 }
325 }
326
327 bool simFlavourSet{};
328 bool isDataOverlaySet{};
329 if (attrList) {
330 { // set simulation flavor
331 std::string key = "SimulationFlavour";
332 if (attrList->exists(key)) {
333 std::string value = (*attrList)[key].data< std::string >();
334
335 // remap simulation flavor "default" to "FullSim"
336 if (value == "default")
337 value = "FullSim";
338
340 simFlavourSet = true;
341 }
342 }
343
344 { // set whether this is overlay
345 std::string key = "IsDataOverlay";
346 if (attrList->exists(key)) {
347 std::string attr = (*attrList)[key].data< std::string >();
348 set(xAOD::FileMetaData::isDataOverlay, attr == "True");
349 isDataOverlaySet = true;
350 }
351 }
352 }
353
354 if (!simFlavourSet || !isDataOverlaySet) {
356 "Failed to set "
359 << ". Trying to get them from input metadata store." );
360
361 for (const std::string& key : m_metaDataSvc->getPerStreamKeysFor(m_key)) {
362 const xAOD::FileMetaData* input = nullptr;
363 input = m_inputMetaDataStore->tryConstRetrieve< xAOD::FileMetaData >(key);
364 if (input) {
365 if (!simFlavourSet) {
366 std::string orig_simFlavour = "none";
367 if (!input->value(xAOD::FileMetaData::simFlavour, orig_simFlavour)) {
369 "Could not get xAOD::FileMetaData::simFlavour "
370 "from input metadata "
371 "store");
372 } else {
373 ATH_MSG_DEBUG("Retrieved from input metadata store: "
375 << orig_simFlavour);
376 set(xAOD::FileMetaData::simFlavour, orig_simFlavour);
377 }
378 }
379
380 if (!isDataOverlaySet) {
381 bool orig_isDataOverlay = false;
382 if (!input->value(xAOD::FileMetaData::isDataOverlay, orig_isDataOverlay)) {
384 "Could not get "
385 "xAOD::FileMetaData::isDataOverlay from input "
386 "metadata store");
387 } else {
388 ATH_MSG_DEBUG("Retrieved from input metadata store: "
390 << orig_isDataOverlay);
391 set(xAOD::FileMetaData::isDataOverlay, orig_isDataOverlay);
392 }
393 }
394 }
395 }
396 }
397
398 if (m_filledNonEvent) return StatusCode::SUCCESS;
399
400 { // get dataType
402 try {
403 if (m_info->setValue(type, m_dataHeaderKey.value())) {
404 ATH_MSG_DEBUG("set " << type << " to " << m_dataHeaderKey.value());
405 } else {
406 ATH_MSG_DEBUG("error setting " << type << " to " << m_dataHeaderKey.value());
407 }
408 } catch (std::exception&) {
409 // This is unexpected
410 ATH_MSG_DEBUG("Failed to set " << xAOD::FileMetaData::dataType);
411 }
412 }
413
414 // FileMetaData object has been filled with non event info
415 m_filledNonEvent = true;
416
417 return StatusCode::SUCCESS;
418 }
const IOVPayloadContainer * payloadContainer() const
Access to payload container.
void set(const xAOD::FileMetaData::MetaDataType, bool)
helper method to update FileMetaDataProperty with some checks
Gaudi::Property< std::string > m_simInfoKey
Read simulation parameters.
@ beamEnergy
Beam energy [float].
@ conditionsTag
Conditions version used for simulation/reconstruction [string].
@ dataType
Data type that's in the file [string].
@ generatorsInfo
Generators information [string].
@ AODFixVersion
Version of AODFix that was used on the file last [string].
@ mcCampaign
MC campaign [string].
@ amiTag
AMI tag used to process the file the last time [string].
@ dataYear
Data year [uint32_t].
@ beamType
Beam type [string].
@ simFlavour
Fast or Full sim [string].
@ productionRelease
Release that was used to make the file [string].
@ isDataOverlay
Used data overlay for backgrounds [bool].
@ geometryVersion
Geometry version [string].
setEventNumber uint32_t

Member Data Documentation

◆ m_aux

std::unique_ptr< xAOD::FileMetaDataAuxInfo > xAODMaker::FileMetaDataCreatorTool::m_aux
private

The auxiliary containing the created object.

Definition at line 161 of file FileMetaDataCreatorTool.h.

◆ m_dataHeaderKey

Gaudi::Property< std::string > xAODMaker::FileMetaDataCreatorTool::m_dataHeaderKey
private
Initial value:
{
this,
"StreamName",
"",
"Key to read data header from event store"
}

Key for DataHeader in StoreGateSvc.

Definition at line 121 of file FileMetaDataCreatorTool.h.

121 {
122 this,
123 "StreamName",
124 "",
125 "Key to read data header from event store"
126 };

◆ m_eventInfoKey

Gaudi::Property< std::string > xAODMaker::FileMetaDataCreatorTool::m_eventInfoKey
private
Initial value:
{
this,
"EventInfoKey",
"EventInfo",
"Key to read xAOD::EventInfo from EventStore"
}

Key for xAOD::EventInfo to update MC channel number.

Definition at line 113 of file FileMetaDataCreatorTool.h.

113 {
114 this,
115 "EventInfoKey",
116 "EventInfo",
117 "Key to read xAOD::EventInfo from EventStore"
118 };

◆ m_eventStore

ServiceHandle< StoreGateSvc > xAODMaker::FileMetaDataCreatorTool::m_eventStore {"StoreGateSvc", name()}
private

DataHeader is produced by another OutputTool, so need StoreGateSvc.

Definition at line 129 of file FileMetaDataCreatorTool.h.

129{"StoreGateSvc", name()};

◆ m_filledEvent

bool xAODMaker::FileMetaDataCreatorTool::m_filledEvent {false}
private

FileMetaData has been filled with event information.

Definition at line 167 of file FileMetaDataCreatorTool.h.

167{false};

◆ m_filledNonEvent

bool xAODMaker::FileMetaDataCreatorTool::m_filledNonEvent {false}
private

FileMetaData has been filled with non-event info.

Definition at line 164 of file FileMetaDataCreatorTool.h.

164{false};

◆ m_hasInputFile

bool xAODMaker::FileMetaDataCreatorTool::m_hasInputFile {false}
private

Input file incident check.

Definition at line 170 of file FileMetaDataCreatorTool.h.

170{false};

◆ m_info

std::unique_ptr< xAOD::FileMetaData > xAODMaker::FileMetaDataCreatorTool::m_info
private

The object created for this output stream.

Definition at line 158 of file FileMetaDataCreatorTool.h.

◆ m_inputMetaDataStore

ServiceHandle< StoreGateSvc > xAODMaker::FileMetaDataCreatorTool::m_inputMetaDataStore
private
Initial value:
{
"InputMetaDataStore", name()}

Access to the input metadata store.

Definition at line 135 of file FileMetaDataCreatorTool.h.

135 {
136 "InputMetaDataStore", name()};

◆ m_key

Gaudi::Property< std::string > xAODMaker::FileMetaDataCreatorTool::m_key
private
Initial value:
{
this,
"OutputKey",
"FileMetaData",
"Key used to write FileMetaData into MetaDataStore"
}

output key for produced xAOD::FileMetaData in MetaDataStore

Definition at line 89 of file FileMetaDataCreatorTool.h.

89 {
90 this,
91 "OutputKey",
92 "FileMetaData",
93 "Key used to write FileMetaData into MetaDataStore"
94 };

◆ m_metaDataStore

ServiceHandle< StoreGateSvc > xAODMaker::FileMetaDataCreatorTool::m_metaDataStore
private
Initial value:
{
"MetaDataStore", name()}

Definition at line 138 of file FileMetaDataCreatorTool.h.

138 {
139 "MetaDataStore", name()};

◆ m_metaDataSvc

ServiceHandle< IAthMetaDataSvc > xAODMaker::FileMetaDataCreatorTool::m_metaDataSvc {"MetaDataSvc", name()}
private

Use MetaDataSvc store interface to support output in EventService.

Definition at line 132 of file FileMetaDataCreatorTool.h.

132{"MetaDataSvc", name()};

◆ m_simInfoKey

Gaudi::Property< std::string > xAODMaker::FileMetaDataCreatorTool::m_simInfoKey
private
Initial value:
{
this,
"SimInfoKey",
"/Simulation/Parameters",
"Key to look up simulation parameters from InputMetaDataStore"
}

Read simulation parameters.

Definition at line 105 of file FileMetaDataCreatorTool.h.

105 {
106 this,
107 "SimInfoKey",
108 "/Simulation/Parameters",
109 "Key to look up simulation parameters from InputMetaDataStore"
110 };

◆ m_tagInfoKey

Gaudi::Property< std::string > xAODMaker::FileMetaDataCreatorTool::m_tagInfoKey
private
Initial value:
{
this,
"TagInfoKey",
"/TagInfo",
"Key to look up tags from InputMetaDataStore"
}

Read tag information.

Definition at line 97 of file FileMetaDataCreatorTool.h.

97 {
98 this,
99 "TagInfoKey",
100 "/TagInfo",
101 "Key to look up tags from InputMetaDataStore"
102 };

◆ m_tagInfoMgr

ServiceHandle< ITagInfoMgr > xAODMaker::FileMetaDataCreatorTool::m_tagInfoMgr
private
Initial value:
{
"TagInfoMgr", name()}

Access to TagInfoMgr for tags.

Definition at line 142 of file FileMetaDataCreatorTool.h.

142 {
143 "TagInfoMgr", name()};

◆ m_toolMutex

std::mutex xAODMaker::FileMetaDataCreatorTool::m_toolMutex
private

creation of FileMetaData should happen on a single thread

Definition at line 173 of file FileMetaDataCreatorTool.h.


The documentation for this class was generated from the following files: