ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
xAODMaker::EventFormatMetaDataTool Class Reference

Tool taking care of copying the event format object from file to file. More...

#include <EventFormatMetaDataTool.h>

Inheritance diagram for xAODMaker::EventFormatMetaDataTool:
Collaboration diagram for xAODMaker::EventFormatMetaDataTool:

Public Member Functions

 EventFormatMetaDataTool (const std::string &type, const std::string &name, const IInterface *parent)
 Regular AlgTool constructor. More...
 
virtual StatusCode initialize () override
 Function initialising the tool. More...
 
virtual StatusCode beginInputFile (const SG::SourceID &) override
 Function collecting the metadata from a new input file. More...
 
virtual StatusCode endInputFile (const SG::SourceID &) override
 Function collecting the metadata from a new input file. More...
 
virtual StatusCode metaDataStop (const SG::SourceID &)
 Wait for metadata write operations to finish, then returns SUCCESS. More...
 
virtual StatusCode beginInputFile ()
 Function called when a new input file is opened. More...
 
virtual StatusCode endInputFile ()
 Function called when the currently open input file got completely processed. More...
 
virtual StatusCode metaDataStop () override
 Wait for metadata write operations to finish, then return SUCCESS. More...
 

Private Member Functions

StatusCode collectMetaData ()
 Function collecting the event format metadata from the input file. More...
 

Private Attributes

ServiceHandle< ::StoreGateSvcm_inputMetaStore
 Connection to the input metadata store. More...
 
ServiceHandle< IAthMetaDataSvcm_outputMetaStore
 Connection to the output metadata store. More...
 
Gaudi::Property< std::vector< std::string > > m_keys
 (optional) list of keys to copy, all if empty, default: empty More...
 
std::mutex m_outputMutex
 MetaDataStop need to wait for ongoing writes. More...
 

Detailed Description

Tool taking care of copying the event format object from file to file.

This tool does the heavy lifting when fast-merging DxAOD files to make sure that the xAOD::EventFormat metadata object is propagated correctly from the input files to the output.

Author
Jack Cranshaw crans.nosp@m.haw@.nosp@m.anl.g.nosp@m.ov
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 35 of file EventFormatMetaDataTool.h.

Constructor & Destructor Documentation

◆ EventFormatMetaDataTool()

xAODMaker::EventFormatMetaDataTool::EventFormatMetaDataTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Regular AlgTool constructor.

Definition at line 20 of file EventFormatMetaDataTool.cxx.

22  :
23  base_class(type, name, parent) { }

Member Function Documentation

◆ beginInputFile() [1/2]

StatusCode xAODMaker::EventFormatMetaDataTool::beginInputFile ( )
virtual

Function called when a new input file is opened.

Definition at line 47 of file EventFormatMetaDataTool.cxx.

47  {
48  // lock the tool, so metaDataStop will wait for write to finish
49  std::lock_guard< std::mutex > guard(m_outputMutex);
50 
51  // Create object to hold information from the new file
52  auto format = std::make_unique< xAOD::EventFormat >();
53 
55 
56  return StatusCode::SUCCESS;
57  }

◆ beginInputFile() [2/2]

virtual StatusCode xAODMaker::EventFormatMetaDataTool::beginInputFile ( const SG::SourceID )
inlineoverridevirtual

Function collecting the metadata from a new input file.

Definition at line 46 of file EventFormatMetaDataTool.h.

46 {return beginInputFile();}

◆ collectMetaData()

StatusCode xAODMaker::EventFormatMetaDataTool::collectMetaData ( )
private

Function collecting the event format metadata from the input file.

Definition at line 68 of file EventFormatMetaDataTool.cxx.

68  {
69 
70  std::vector< std::string > keys = m_keys;
71  if (keys.empty()) {
73  } else {
74  // remove keys not in the InputMetaDataStore
75  keys.erase(
76  std::remove_if(
77  keys.begin(), keys.end(),
78  [this](std::string& key) {
79  return !m_inputMetaStore->contains<xAOD::EventFormat>(key);
80  }),
81  keys.end());
82  }
83 
84  // If the input file doesn't have any event format metadata,
85  // then finish right away:
86  if (keys.empty()) return StatusCode::SUCCESS;
87 
88  // Retrieve the input container:
89  for (const std::string& key : keys) {
90  std::list<SG::ObjectWithVersion<xAOD::EventFormat> > allVersions;
91  if (!m_inputMetaStore->retrieveAllVersions(allVersions, key)
92  .isSuccess()) {
93  ATH_MSG_DEBUG("Failed to retrieve \""
94  << key << "\" from InputMetaDataStore");
95  continue; // try next key
96  }
97 
98  // get output object
99  auto output = m_outputMetaStore->tryRetrieve<xAOD::EventFormat>(key);
100  if (!output) {
101  auto ef = std::make_unique<xAOD::EventFormat>();
102  output = ef.get();
103  if (!m_outputMetaStore->record(std::move(ef), key).isSuccess()) {
104  ATH_MSG_DEBUG("Failed to create output object \""
105  << key << "\" in MetaDataSvc");
106  continue;
107  }
108  }
109 
110  ATH_MSG_VERBOSE("Merging all versions of " << key);
111  for (auto& version : allVersions) {
112  const auto* input = version.dataObject.cptr();
113  // Merge the new object into the output one:
114  for (const auto& pair : *input) {
115  if (!output->exists(pair.second.hash())) {
116  output->add(pair.second);
117  }
118  }
119  }
120  }
121 
122  // Return gracefully:
123  return StatusCode::SUCCESS;
124  }

◆ endInputFile() [1/2]

virtual StatusCode xAODMaker::EventFormatMetaDataTool::endInputFile ( )
inlinevirtual

Function called when the currently open input file got completely processed.

Definition at line 59 of file EventFormatMetaDataTool.h.

59 {return StatusCode::SUCCESS;}

◆ endInputFile() [2/2]

virtual StatusCode xAODMaker::EventFormatMetaDataTool::endInputFile ( const SG::SourceID )
inlineoverridevirtual

Function collecting the metadata from a new input file.

Definition at line 49 of file EventFormatMetaDataTool.h.

49 {return endInputFile();}

◆ initialize()

StatusCode xAODMaker::EventFormatMetaDataTool::initialize ( )
overridevirtual

Function initialising the tool.

Definition at line 26 of file EventFormatMetaDataTool.cxx.

26  {
27  // Greet the user:
28  ATH_MSG_VERBOSE("Initialising");
31  if (!m_keys.empty()) {
32  ATH_MSG_VERBOSE("Asked to copy EventFormat with keys:");
33  for (const std::string& key : m_keys) {
34  ATH_MSG_VERBOSE(" - " << key);
35  }
36  }
37 
38  // Connect to the metadata stores:
39  ATH_CHECK(m_inputMetaStore.retrieve());
40  ATH_CHECK(m_outputMetaStore.retrieve());
41 
42  // Return gracefully:
43  return StatusCode::SUCCESS;
44  }

◆ metaDataStop() [1/2]

StatusCode xAODMaker::EventFormatMetaDataTool::metaDataStop ( )
overridevirtual

Wait for metadata write operations to finish, then return SUCCESS.

Definition at line 60 of file EventFormatMetaDataTool.cxx.

60  {
61  // wait for threads currently writing to finish
62  std::lock_guard< std::mutex > guard(m_outputMutex);
63 
64  return StatusCode::SUCCESS;
65  }

◆ metaDataStop() [2/2]

virtual StatusCode xAODMaker::EventFormatMetaDataTool::metaDataStop ( const SG::SourceID )
inlinevirtual

Wait for metadata write operations to finish, then returns SUCCESS.

Definition at line 52 of file EventFormatMetaDataTool.h.

52 {return metaDataStop();}

Member Data Documentation

◆ m_inputMetaStore

ServiceHandle< ::StoreGateSvc > xAODMaker::EventFormatMetaDataTool::m_inputMetaStore
private
Initial value:
{this, "InputMetaStore",
"StoreGateSvc/InputMetaDataStore", name()}

Connection to the input metadata store.

Definition at line 69 of file EventFormatMetaDataTool.h.

◆ m_keys

Gaudi::Property<std::vector<std::string> > xAODMaker::EventFormatMetaDataTool::m_keys
private
Initial value:
{ this, "Keys", {},
"(optional) list of keys to copy, all if empty. default: empty"}

(optional) list of keys to copy, all if empty, default: empty

Definition at line 77 of file EventFormatMetaDataTool.h.

◆ m_outputMetaStore

ServiceHandle< IAthMetaDataSvc > xAODMaker::EventFormatMetaDataTool::m_outputMetaStore
private
Initial value:
{this, "MetaDataSvc",
"MetaDataSvc", name()}

Connection to the output metadata store.

Definition at line 73 of file EventFormatMetaDataTool.h.

◆ m_outputMutex

std::mutex xAODMaker::EventFormatMetaDataTool::m_outputMutex
private

MetaDataStop need to wait for ongoing writes.

Definition at line 81 of file EventFormatMetaDataTool.h.


The documentation for this class was generated from the following files:
vtune_athena.format
format
Definition: vtune_athena.py:14
xAODMaker::EventFormatMetaDataTool::m_keys
Gaudi::Property< std::vector< std::string > > m_keys
(optional) list of keys to copy, all if empty, default: empty
Definition: EventFormatMetaDataTool.h:77
xAODMaker::EventFormatMetaDataTool::m_outputMutex
std::mutex m_outputMutex
MetaDataStop need to wait for ongoing writes.
Definition: EventFormatMetaDataTool.h:81
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAODMaker::EventFormatMetaDataTool::m_outputMetaStore
ServiceHandle< IAthMetaDataSvc > m_outputMetaStore
Connection to the output metadata store.
Definition: EventFormatMetaDataTool.h:73
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
xAODMaker::EventFormatMetaDataTool::metaDataStop
virtual StatusCode metaDataStop() override
Wait for metadata write operations to finish, then return SUCCESS.
Definition: EventFormatMetaDataTool.cxx:60
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAODMaker::EventFormatMetaDataTool::m_inputMetaStore
ServiceHandle< ::StoreGateSvc > m_inputMetaStore
Connection to the input metadata store.
Definition: EventFormatMetaDataTool.h:69
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
merge.output
output
Definition: merge.py:16
xAODMaker::EventFormatMetaDataTool::endInputFile
virtual StatusCode endInputFile()
Function called when the currently open input file got completely processed.
Definition: EventFormatMetaDataTool.h:59
xAOD::EventFormat_v1
Event format metadata for xAOD files.
Definition: EventFormat_v1.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAODMaker::EventFormatMetaDataTool::collectMetaData
StatusCode collectMetaData()
Function collecting the event format metadata from the input file.
Definition: EventFormatMetaDataTool.cxx:68
xAODMaker::EventFormatMetaDataTool::beginInputFile
virtual StatusCode beginInputFile()
Function called when a new input file is opened.
Definition: EventFormatMetaDataTool.cxx:47
get_generator_info.version
version
Definition: get_generator_info.py:33
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
LheEventFiller_Common.ef
ef
Definition: SFGen_i/share/common/LheEventFiller_Common.py:7
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37