ATLAS Offline Software
Loading...
Searching...
No Matches
MetaDataSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "MetaDataSvc.h"
11
12#include "Gaudi/Interfaces/IOptionsSvc.h"
13#include "GaudiKernel/IAlgTool.h"
14#include "GaudiKernel/IEvtSelector.h"
15#include "GaudiKernel/IIncidentSvc.h"
16#include "GaudiKernel/IIoComponentMgr.h"
17#include "GaudiKernel/IOpaqueAddress.h"
18#include "GaudiKernel/FileIncident.h"
19#include "GaudiKernel/System.h"
20
26
28
29#include <vector>
30#include <sstream>
31
32#include "boost/bind/bind.hpp"
33
34
35namespace {
43 bool leftString(std::string& s, char sc) {
44 if (const auto pos = s.find(sc); pos != std::string::npos) {
45 s.resize(pos);
46 return true;
47 }
48 return false;
49 }
50}
51
52
53//________________________________________________________________________________
54MetaDataSvc::MetaDataSvc( const std::string& name, ISvcLocator* pSvcLocator )
55 : base_class( name, pSvcLocator )
56 , m_inputDataStore( "StoreGateSvc/InputMetaDataStore", name )
57 , m_outputDataStore( "StoreGateSvc/MetaDataStore", name )
58 , m_fileMgr( "FileMgr", name )
59 , m_incSvc( "IncidentSvc", name )
60 , m_outSeqSvc( "OutputStreamSequencerSvc", name )
61 , m_persToClid{ { "DataHeader_p5", 222376821 },
62 { "EventStreamInfo_p3", 167728019 },
63 { "ByteStreamMetadataContainer_p1", 1076128893 },
64 { "IOVMetaDataContainer_p1", 1316383046 },
65 { "xAOD::EventFormat_v1", 243004407 },
66 { "xAOD::CutBookkeeperContainer_v1", 1234982351 },
67 { "xAOD::CutBookkeeperAuxContainer_v1", 1147935274 },
68 { "xAOD::TriggerMenuContainer_v1", 1107011239 },
69 { "DataVector<xAOD::TriggerMenu_v1>", 1107011239 },
70 { "xAOD::TriggerMenuAuxContainer_v1", 1212409402 },
71 { "xAOD::TriggerMenuJsonContainer_v1", 1221262614 },
72 { "DataVector<xAOD::TriggerMenuJson_v1>", 1221262614 },
73 { "xAOD::TriggerMenuJsonAuxContainer_v1", 373045213 },
74 { "xAOD::LumiBlockRangeContainer_v1", 1115934851 },
75 { "DataVector<xAOD::LumiBlockRange_v1>", 1115934851 },
76 { "xAOD::LumiBlockRangeAuxContainer_v1", 1251061086 },
77 { "xAOD::FileMetaData_v1", 178309087 },
78 { "xAOD::FileMetaDataAuxInfo_v1", 73252552 },
79 { "xAOD::RingSetConfContainer_v1", 1157997427 },
80 { "DataVector<xAOD::RingSetConf_v1>", 1157997427 },
81 { "xAOD::RingSetConfAuxContainer_v1", 1307745126 },
82 { "xAOD::TruthMetaDataContainer_v1", 1188015687 },
83 { "DataVector<xAOD::TruthMetaData_v1>", 1188015687 },
84 { "xAOD::TruthMetaDataAuxContainer_v1", 1094306618 } } {}
85
86//________________________________________________________________________________
88
89//__________________________________________________________________________
91 ATH_MSG_INFO("Initializing " << name());
92
93 // Retrieve InputMetaDataStore
94 ATH_CHECK( m_inputDataStore.retrieve() );
95 // Retrieve OutputMetaDataStore
96 ATH_CHECK( m_outputDataStore.retrieve() );
97 // Retrieve AddressCreator
98 ATH_CHECK( m_addrCrtr.retrieve() );
99
100 AthCnvSvc* cnvSvc = dynamic_cast<AthCnvSvc*>(m_addrCrtr.operator->());
101 if (cnvSvc) {
102 m_storageType = cnvSvc->repSvcType();
103 } else {
104 ATH_MSG_WARNING("Cannot get ConversionSvc Interface.");
105 }
106 // Get FileMgr
107 ATH_CHECK( m_fileMgr.retrieve() );
108
109 // Set to be listener for end of event
110 ATH_CHECK( m_incSvc.retrieve() );
111
112 ATH_CHECK( m_metaDataTools.retrieve() );
113 ATH_MSG_INFO("Found " << m_metaDataTools);
114
115 m_incSvc->addListener(this, "FirstInputFile", 80, true);
116 m_incSvc->addListener(this, "BeginInputFile", 80, true);
117 m_incSvc->addListener(this, "EndInputFile", 10, true);
118 m_incSvc->addListener(this, "BeginInputMemFile", 80, true);
119 m_incSvc->addListener(this, "EndInputMemFile", 10, true);
120
121 // Register this service for 'I/O' events
122 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", this->name());
123 ATH_CHECK( iomgr.retrieve() );
124 ATH_CHECK( iomgr->io_register(this) );
125
126 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc", name());
127 if (!joSvc.retrieve().isSuccess()) {
128 ATH_MSG_WARNING("Cannot get JobOptionsSvc.");
129 } else {
130 if (joSvc->has("EventSelector.InputCollections")) {
131 // Get EventSelector to force in-time initialization and FirstInputFile incident
132 ServiceHandle<IEvtSelector> evtsel("EventSelector", this->name());
133 if (!evtsel.retrieve().isSuccess()) {
134 ATH_MSG_WARNING("Cannot get EventSelector.");
135 }
136 }
137 }
138 // retrieve the output sequences service (EventService) if available
139 m_outSeqSvc.retrieve().ignore();
140
141 return(StatusCode::SUCCESS);
142}
143//__________________________________________________________________________
145 // Release IncidentService
146 if (!m_incSvc.release().isSuccess()) {
147 ATH_MSG_WARNING("Cannot release IncidentService.");
148 }
149 // Release FileMgr
150 if (!m_fileMgr.release().isSuccess()) {
151 ATH_MSG_WARNING("Cannot release FileMgr.");
152 }
153 // Release AddressCreator
154 if (!m_addrCrtr.release().isSuccess()) {
155 ATH_MSG_WARNING("Cannot release AddressCreator.");
156 }
157 // Release OutputMetaDataStore
158 if (!m_outputDataStore.release().isSuccess()) {
159 ATH_MSG_WARNING("Cannot release OutputMetaDataStore.");
160 }
161 // Release InputMetaDataStore
162 if (!m_inputDataStore.release().isSuccess()) {
163 ATH_MSG_WARNING("Cannot release InputMetaDataStore.");
164 }
166 ATH_MSG_WARNING("EndInputFile was not received before finalize");
167 }
168 return(StatusCode::SUCCESS);
169}
170
171//__________________________________________________________________________
172StatusCode MetaDataSvc::stop() {
173 ATH_MSG_DEBUG("MetaDataSvc::stop()");
174 // Fire metaDataStopIncident
175 Incident metaDataStopIncident(name(), "MetaDataStop");
176 m_incSvc->fireIncident(metaDataStopIncident);
177 return(StatusCode::SUCCESS);
178}
179
180//________________________________________________________________________________
182 if (storeID != StoreID::METADATA_STORE) { // should this (also) run in the INPUT_METADATA_STORE?
183 return(StatusCode::SUCCESS);
184 }
185 // Put Additional MetaData objects into Input MetaData Store using VersionedKey
186 std::list<SG::ObjectWithVersion<DataHeader> > allVersions;
187 StatusCode sc = m_inputDataStore->retrieveAllVersions(allVersions, name());
188 if (!sc.isSuccess()) {
189 ATH_MSG_WARNING("Could not retrieve all versions for DataHeader, will not read Metadata");
190 } else {
191 int verNumber = -1;
192 for (SG::ObjectWithVersion<DataHeader>& obj : allVersions) {
193 ++verNumber;
194 const DataHeader* dataHeader = obj.dataObject.cptr();
195 if (dataHeader == nullptr) {
196 ATH_MSG_ERROR("Could not get DataHeader, will not read Metadata");
197 return(StatusCode::FAILURE);
198 }
199 for (const DataHeaderElement& dhe : *dataHeader) {
200 const CLID clid = dhe.getPrimaryClassID();
201 if (clid != ClassID_traits<DataHeader>::ID()) {
202 SG::VersionedKey myVersObjKey(dhe.getKey(), verNumber);
203 std::string key = dhe.getKey();
204 if (verNumber != 0) {
205 key = myVersObjKey;
206 }
207 tads.push_back(dhe.getAddress(m_storageType, key));
208 }
209 }
210 }
211 }
212 return(StatusCode::SUCCESS);
213}
214//________________________________________________________________________________
215StatusCode MetaDataSvc::newMetadataSource(const Incident& inc)
216{
217 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
218 if (fileInc == nullptr) {
219 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
220 return StatusCode::FAILURE;
221 }
222 const std::string guid = fileInc->fileGuid();
223 const std::string fileName = fileInc->fileName();
224 m_allowMetaDataStop = false;
226 if (!fileName.starts_with( "BSF:")) {
227 // the input file is _not_ bytestream
229 if (!m_inputDataStore->clearStore().isSuccess()) {
230 ATH_MSG_WARNING("Unable to clear input MetaData Proxies");
231 }
233 }
235 }
236 StatusCode rc{StatusCode::SUCCESS};
237 for (auto& tool : m_metaDataTools) {
238 ATH_MSG_DEBUG(" calling beginInputFile on " << tool->name() << " for GUID \"" << guid << "\"");
239 if (tool->beginInputFile(guid).isFailure()) {
240 ATH_MSG_ERROR("Unable to call beginInputFile for " << tool->name());
241 rc = StatusCode::FAILURE;
242 }
243 }
244 return rc;
245}
246
247StatusCode MetaDataSvc::retireMetadataSource(const Incident& inc)
248{
249 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
250 if (fileInc == nullptr) {
251 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
252 return StatusCode::FAILURE;
253 }
254 const std::string guid = fileInc->fileGuid();
255 ATH_MSG_DEBUG("retireMetadataSource: " << fileInc->fileName());
256 for (auto& tool : m_metaDataTools) {
257 ATH_MSG_DEBUG(" calling endInputFile on " << tool->name() << " for GUID \"" << guid << "\"");
258 ATH_CHECK(tool->endInputFile(guid));
259 }
260 m_allowMetaDataStop = true;
261 return StatusCode::SUCCESS;
262}
263
265{
266 if (m_outputPrepared) {
267 return StatusCode::SUCCESS;
268 }
269
270 StatusCode rc{StatusCode::SUCCESS};
271 for (auto& tool : m_metaDataTools) {
272 ATH_MSG_DEBUG(" calling metaDataStop for " << tool->name());
273 if (tool->metaDataStop().isFailure()) {
274 ATH_MSG_ERROR("Unable to call metaDataStop for " << tool->name());
275 rc = StatusCode::FAILURE;
276 }
277 }
278 if (!m_metaDataTools.release().isSuccess()) {
279 ATH_MSG_WARNING("Cannot release " << m_metaDataTools);
280 }
281
282 m_outputPrepared = true;
283 return rc;
284}
285
286// like prepareOutput() but for parallel streams
287StatusCode MetaDataSvc::prepareOutput(const std::string& outputName)
288{
289 // default to the serial implementation if no output name given
290 if( outputName.empty() ) {
291 return prepareOutput();
292 }
293 ATH_MSG_DEBUG( "prepareOutput('" << outputName << "')" );
294
295 StatusCode rc{StatusCode::SUCCESS};
296 for (auto& tool : m_metaDataTools) {
297 ATH_MSG_DEBUG(" calling metaDataStop for " << tool->name());
298 // planning to replace the call below with (*it)->prepareOutput(outputName)
299 if (tool->metaDataStop().isFailure()) {
300 ATH_MSG_ERROR("Unable to call metaDataStop for " << tool->name());
301 rc = StatusCode::FAILURE;
302 }
303 }
304 // MN: not releasing tools here - revisit when clear what happens on new file open
305 return rc;
306}
307
308
309StatusCode MetaDataSvc::shmProxy(const std::string& filename)
310{
312 ATH_CHECK(m_inputDataStore->clearStore(true));
314 }
316 ATH_CHECK(m_outputDataStore->clearStore(true));
318 }
320 return StatusCode::SUCCESS;
321}
322
323//__________________________________________________________________________
324void MetaDataSvc::handle(const Incident& inc) {
325 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
326 if (fileInc == nullptr) {
327 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
328 return;
329 }
330 const std::string fileName = fileInc->fileName();
331 ATH_MSG_DEBUG("handle() " << inc.type() << " for " << fileName);
332
333 if (inc.type() == "FirstInputFile") {
334 // Register open/close callback actions
335 using namespace boost::placeholders;
336 Io::bfcn_action_t boa = boost::bind(&MetaDataSvc::rootOpenAction, this, _1,_2);
337 if (m_fileMgr->regAction(std::move(boa), Io::OPEN).isFailure()) {
338 ATH_MSG_FATAL("Cannot register ROOT file open action with FileMgr.");
339 }
340 if (!initInputMetaDataStore(fileName).isSuccess()) {
341 ATH_MSG_WARNING("Unable to initialize InputMetaDataStore");
342 }
343 } else if (inc.type() == "BeginInputFile" || inc.type() == "BeginInputMemFile") {
344 if(newMetadataSource(inc).isFailure()) {
345 ATH_MSG_ERROR("Could not process new metadata source " << fileName);
346 }
347 } else if (inc.type() == "EndInputFile" || inc.type() == "EndInputMemFile") {
348 if(retireMetadataSource(inc).isFailure()) {
349 ATH_MSG_ERROR("Could not retire metadata source " << fileName);
350 }
351 }
352}
353
354//__________________________________________________________________________
355// This method is currently called only from OutputStreamSequencerSvc
356StatusCode MetaDataSvc::transitionMetaDataFile(const std::string& outputConn, bool disconnect)
357{
358 ATH_MSG_DEBUG("transitionMetaDataFile: " << outputConn );
359
360 // this is normally called through EndInputFile inc, simulate it for EvSvc
361 FileIncident inc("transitionMetaDataFile", "EndInputFile", "dummyMetaInputFileName", "");
363
364 // Reset flag to allow calling prepareOutput again at next transition
365 m_outputPrepared = false;
366
367 Incident metaDataStopIncident(name(), "MetaDataStop");
368 m_incSvc->fireIncident(metaDataStopIncident);
369
370 if( disconnect ) {
371 AthCnvSvc* cnvSvc = dynamic_cast<AthCnvSvc*>(m_addrCrtr.operator->());
372 if (cnvSvc) {
373 if (!cnvSvc->disconnectOutput(outputConn).isSuccess()) {
374 ATH_MSG_WARNING("Cannot get disconnect Output Files");
375 }
376 }
377 }
378
379 return(StatusCode::SUCCESS);
380}
381
382//__________________________________________________________________________
384 ATH_MSG_INFO("I/O reinitialization...");
385 ATH_MSG_DEBUG("Dumping InputMetaDataStore: " << m_inputDataStore->dump());
386 ATH_MSG_DEBUG("Dumping OutputMetaDataStore: " << m_outputDataStore->dump());
387 for (const auto& tool : m_metaDataTools) {
388 ATH_MSG_INFO("Attached MetaDataTool: " << tool->name());
389 }
390 m_outputPrepared = false;
391 return(StatusCode::SUCCESS);
392}
393//__________________________________________________________________________
394StatusCode MetaDataSvc::rootOpenAction(FILEMGR_CALLBACK_ARGS) {
395 return(StatusCode::SUCCESS);
396}
397//__________________________________________________________________________
398// check if the metadata object key contains Stream name (added by SharedWriter in MetaDataSvc)
399// remove stream part from the key (i.e. modify the parameter) and return it
400std::string MetaDataSvc::removeStreamFromKey(std::string& key) {
401 size_t pos = key.find(m_streamInKeyMark);
402 if( pos==std::string::npos ) return "";
403 size_t epos = key.find(']', pos);
404 size_t spos = pos + m_streamInKeyMark.size();
405 std::string stream = key.substr( spos, epos - spos );
406 //cppcheck-suppress uselessCallsSubstr
407 key = key.substr(0, pos) + key.substr(epos+1);
408 return stream;
409}
410
411//__________________________________________________________________________
412[[nodiscard]] std::set<std::string> MetaDataSvc::getPerStreamKeysFor(const std::string& key) const {
413 if (!m_streamKeys.contains(key)) {
414 return {key};
415 }
416 return m_streamKeys.at(key);
417}
418
419//__________________________________________________________________________
420StatusCode MetaDataSvc::addProxyToInputMetaDataStore(const std::string& tokenStr) {
421 std::string fileName = tokenStr.substr(tokenStr.find("[FILE=") + 6);
422 leftString(fileName, ']');
423 std::string className = tokenStr.substr(tokenStr.find("[PNAME=") + 7);
424 leftString(className, ']');
425 std::string contName = tokenStr.substr(tokenStr.find("[CONT=") + 6);
426 leftString(contName,']');
427 std::size_t pos1 = contName.find('(');
428 std::string keyName = contName.substr(pos1 + 1, contName.size() - pos1 - 2);
429 std::size_t pos2 = keyName.find('/');
430 if (pos2 != std::string::npos) keyName = keyName.substr(pos2 + 1);
431 std::string numName = tokenStr.substr(tokenStr.find("[NUM=") + 5);
432 leftString(numName,']');
433 unsigned long num = 0;
434 std::istringstream iss(numName);
435 iss >> num;
436 CLID clid = m_persToClid[className];
437
438 // make stream-unique keys for infile metadata objects
439 // AthenaOutputStream will use this to distribute objects to the right stream (and restore the original key)
440 if( clid == 178309087 ) { // FileMetaData
441 std::string newName = std::format("{}{}{}{}", keyName, m_streamInKeyMark, fileName, "]");
442 ATH_MSG_DEBUG("Recording " << keyName << " as " << newName);
443 m_streamKeys[keyName].insert(newName);
444 keyName = std::move(newName);
445 }
446 if( clid == 73252552 ) { // FileMetaDataAuxInfo
447 std::string newName = std::format("{}{}{}]{}",
448 keyName.substr(0, keyName.find(RootAuxDynIO::AUX_POSTFIX)),
450 fileName,
452 ATH_MSG_DEBUG("Recording " << keyName << " as " << newName);
453 m_streamKeys[keyName].insert(newName);
454 keyName = std::move(newName);
455 }
456 const std::string par[3] = { "SHM" , keyName , std::move(className) };
457 const unsigned long ipar[2] = { num , 0 };
458 IOpaqueAddress* opqAddr = nullptr;
459 SG::DataProxy* dp = m_inputDataStore->proxy(clid, keyName);
460 if (dp != nullptr) {
461 ATH_MSG_DEBUG("Resetting duplicate proxy for: " << clid << "#" << keyName << " from file: " << fileName);
462 dp->reset();
463 }
464 if (!m_addrCrtr->createAddress(m_storageType, clid, par, ipar, opqAddr).isSuccess()) {
465 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create address for " << tokenStr);
466 return(StatusCode::FAILURE);
467 }
468 if (m_inputDataStore->recordAddress(keyName, opqAddr).isFailure()) {
469 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create proxy for " << tokenStr);
470 return(StatusCode::FAILURE);
471 }
472 if (m_inputDataStore->accessData(clid, keyName) == nullptr) {
473 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot access data for " << tokenStr);
474 return(StatusCode::FAILURE);
475 }
476 if (keyName.find(RootAuxDynIO::AUX_POSTFIX) != std::string::npos
477 && m_inputDataStore->symLink(clid, keyName, 187169987).isFailure()) {
478 ATH_MSG_WARNING("addProxyToInputMetaDataStore: Cannot symlink to AuxStore for " << tokenStr);
479 }
480 return(StatusCode::SUCCESS);
481}
482//__________________________________________________________________________
483StatusCode MetaDataSvc::initInputMetaDataStore(const std::string& fileName) {
484 ATH_MSG_DEBUG("initInputMetaDataStore: file name " << fileName);
486 // Load proxies for InputMetaDataStore
487 if (m_metaDataCont.value().empty()) {
488 ATH_MSG_DEBUG("MetaDataSvc called without MetaDataContainer set.");
489 return(StatusCode::SUCCESS);
490 }
491 if (fileName.starts_with( "BSF:")) {
492 ATH_MSG_DEBUG("MetaDataSvc called for non ROOT file.");
493 } else if (fileName.compare(0, 3, "SHM")==0) {
494 ATH_MSG_DEBUG("MetaDataSvc called for shared memory.");
495 } else {
496 const std::string par[2] = {
497 fileName,
498 std::format("{}(DataHeader)", m_metaDataCont.value())
499 };
500 const std::string parOld[2] = {
501 fileName,
502 std::format("{}{}", m_metaDataCont.value(), "DataHeader")
503 };
504 for (int verNumber = 0; verNumber < 100; verNumber++) {
505 SG::VersionedKey myVersKey(name(), verNumber);
506 if (m_inputDataStore->contains<DataHeader>(myVersKey)) {
507 ATH_MSG_DEBUG("initInputMetaDataStore: MetaData Store already contains DataHeader, key = " << myVersKey);
508 } else {
509 const unsigned long ipar[2] = { (unsigned long)verNumber , 0 };
510 IOpaqueAddress* opqAddr = nullptr;
511 if (!m_addrCrtr->createAddress(m_storageType, ClassID_traits<DataHeader>::ID(), par, ipar, opqAddr).isSuccess()) {
512 if (!m_addrCrtr->createAddress(m_storageType, ClassID_traits<DataHeader>::ID(), parOld, ipar, opqAddr).isSuccess()) {
513 break;
514 }
515 }
516 if (m_inputDataStore->recordAddress(myVersKey, opqAddr).isFailure()) {
517 ATH_MSG_WARNING("initInputMetaDataStore: Cannot create proxy for DataHeader, key = " << myVersKey);
518 }
519 }
520 }
521 std::list<SG::TransientAddress*> tList;
523 for (SG::TransientAddress* tad : tList) {
524 CLID clid = tad->clID();
525 ATH_MSG_VERBOSE("initInputMetaDataStore: add proxy for clid = " << clid << ", key = " << tad->name());
526 if (m_inputDataStore->contains(tad->clID(), tad->name())) {
527 ATH_MSG_DEBUG("initInputMetaDataStore: MetaData Store already contains clid = " << clid << ", key = " << tad->name());
528 } else {
529 if (!m_inputDataStore->recordAddress(tad->name(), tad->address())) {
530 ATH_MSG_ERROR("initInputMetaDataStore: Cannot create proxy for clid = " << clid << ", key = " << tad->name());
531 return StatusCode::FAILURE;
532 }
533 }
534
535 for (CLID tclid : tad->transientID()) {
536 if (tclid != clid) {
537 if (m_inputDataStore->symLink (clid, tad->name(), tclid).isFailure()) {
538 ATH_MSG_WARNING("Cannot make autosymlink from " <<
539 clid << "/" << tad->name() << " to " << tclid);
540 }
541 }
542 }
543 delete tad;
544 }
545 tList.clear();
546 }
547 ATH_MSG_DEBUG("Loaded input meta data store proxies");
548 return(StatusCode::SUCCESS);
549}
550
551
552const std::string MetaDataSvc::currentRangeID() const
553{
554 return m_outSeqSvc.isValid()? m_outSeqSvc->currentRangeID() : "";
555}
556
557
559{
560 if (!m_handledClasses.contains(itemID)) {
561 ATH_MSG_DEBUG("Not translating metadata item ID #" << itemID);
562 return itemID;
563 }
564
565 std::string itemName;
566 CLID contID = 0;
567 if (m_classIDSvc->getTypeNameOfID(itemID, itemName).isSuccess()) {
568 const std::string contName = std::format("MetaCont<{}>", itemName);
569 ATH_MSG_DEBUG("Transforming " << contName << " to " << itemName
570 << " for output");
571 if (m_classIDSvc->getIDOfTypeName(contName, contID).isSuccess())
572 return contID;
573 }
574
575 return itemID;
576}
577
578void MetaDataSvc::recordHook(const std::type_info& typeInfo) {
579 const std::string& typeName = System::typeinfoName(typeInfo);
580 ATH_MSG_VERBOSE("Handling record event of type " << typeName);
581
582 CLID itemID = 0;
583 if (m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
584 auto result = m_handledClasses.insert(itemID);
585 if (result.second)
586 ATH_MSG_DEBUG("MetaDataSvc will handle " << typeName
587 << " ClassID: " << itemID);
588 }
589}
590
591void MetaDataSvc::removeHook(const std::type_info& typeInfo) {
592 const std::string& typeName = System::typeinfoName(typeInfo);
593 ATH_MSG_VERBOSE("Handling removal event of type " << typeName);
594
595 CLID itemID = 0;
596 if (m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
597 if (0 < m_handledClasses.erase(itemID))
598 ATH_MSG_DEBUG("MetaDataSvc will no longer handle " << typeName
599 << " ClassID: " << itemID);
600 }
601}
602
604 ATH_MSG_DEBUG("Locking metadata tools");
605 for(auto& tool : m_metaDataTools ) {
606 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
607 if( lockable ) lockable->lock_shared();
608 }
609}
610
612 ATH_MSG_DEBUG("Unlocking metadata tools");
613 for(auto& tool : m_metaDataTools ) {
614 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
615 if( lockable ) lockable->unlock_shared();
616 }
617}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This file contains the class definition for the DataHeader and DataHeaderElement classes.
uint32_t CLID
The Class ID type.
static Double_t sc
static Double_t rc
This file contains the class definition for the MetaDataSvc class.
This file contains the class definition for the OutputStreamSequencerSvc class.
defines a StoreGateSvc key with a version number
Base class for all conversion services.
Definition AthCnvSvc.h:66
virtual long repSvcType() const override
Retrieve the class type of the data store the converter uses.
virtual StatusCode disconnectOutput(const std::string &output)
Disconnect output files from the service.
This class provides a persistent form for the TransientAddress.
Definition DataHeader.h:37
This class provides the layout for summary information stored for data written to POOL.
Definition DataHeader.h:123
std::list< SG::TransientAddress * > tadList
Provide an interface for locking and unlocking a tool externally.
virtual void lock_shared() const =0
Lock the tool.
virtual void unlock_shared() const =0
Unlock the tool.
ServiceHandle< OutputStreamSequencerSvc > m_outSeqSvc
virtual StatusCode prepareOutput()
Makes the metadata store ready for output.
long m_storageType
std::map< std::string, std::set< std::string > > m_streamKeys
static constexpr std::string_view m_streamInKeyMark
marker string for embedding stream name in MetaData object keys for SharedWriter server
virtual StatusCode newMetadataSource(const Incident &)
Fills the input metadata store with the content of the new input file.
virtual StatusCode initialize() override
initialize the metadata service at the beginning of the job
void recordHook(const std::type_info &) override
MetaDataSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
void lockTools() const
bool m_beginInputFileSeen
PublicToolHandleArray< IMetaDataTool > m_metaDataTools
MetaDataTools, vector with the MetaData tools.
virtual void handle(const Incident &incident) override
react to file incidents.
ServiceHandle< StoreGateSvc > m_outputDataStore
virtual StatusCode io_reinit() override
Implements IIoComponent interface sets m_outputPrepared to false and prints some information.
StatusCode transitionMetaDataFile(const std::string &outputConn, bool disconnect)
Transition output metadata file - fire MeteDataStop incident to transition OutputStream and disconnec...
CLID remapMetaContCLID(const CLID &item_id) const
StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS)
ServiceHandle< StoreGateSvc > m_inputDataStore
virtual ~MetaDataSvc()
Destructor.
virtual StatusCode retireMetadataSource(const Incident &)
Allows metadata tools to act before an input file is closed.
std::set< CLID > m_handledClasses
bool m_allowMetaDataStop
ServiceHandle< IAddressCreator > m_addrCrtr
virtual StatusCode finalize() override
finalize the metadata service at the end of the job
StatusCode initInputMetaDataStore(const std::string &fileName)
Initialize input metadata store - can be called directly or via BeginInputFile incident.
std::map< std::string_view, CLID > m_persToClid
virtual StatusCode stop() override
stop the metadata service
ServiceHandle< IIncidentSvc > m_incSvc
std::string removeStreamFromKey(std::string &key)
check if the metadata object key contains Stream name (added by SharedWriter in MetaDataSvc) remove s...
virtual const std::string currentRangeID() const override final
StatusCode addProxyToInputMetaDataStore(const std::string &tokenStr)
ServiceHandle< IFileMgr > m_fileMgr
void removeHook(const std::type_info &) override
bool m_clearedOutputDataStore
StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
loads addresses of versioned metadata object.
bool m_outputPrepared
void unlockTools() const
Gaudi::Property< std::string > m_metaDataCont
MetaDataContainer, POOL container name for MetaData.
bool m_clearedInputDataStore
ServiceHandle< IClassIDSvc > m_classIDSvc
virtual std::set< std::string > getPerStreamKeysFor(const std::string &key) const override final
Get all per-stream Key variants created for in-file metadata object with original key If no stream-sp...
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
a StoreGateSvc key with a version number.
@ METADATA_STORE
Definition StoreID.h:29
virtual StatusCode shmProxy(const std::string &filename) override
Loads file metadata from memory shared between streams in SharedWriter This function clears the input...
constexpr char AUX_POSTFIX[]
Common post-fix for the names of auxiliary containers in StoreGate.