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