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"
40 bool leftString(std::string& s,
char sc) {
41 if (
const auto pos =
s.find(
sc); pos != std::string::npos) {
52 : base_class( name, pSvcLocator )
59 {
"EventStreamInfo_p3", 167728019 },
60 {
"ByteStreamMetadataContainer_p1", 1076128893 },
61 {
"IOVMetaDataContainer_p1", 1316383046 },
62 {
"xAOD::EventFormat_v1", 243004407 },
63 {
"xAOD::CutBookkeeperContainer_v1", 1234982351 },
64 {
"xAOD::CutBookkeeperAuxContainer_v1", 1147935274 },
65 {
"xAOD::TriggerMenuContainer_v1", 1107011239 },
66 {
"DataVector<xAOD::TriggerMenu_v1>", 1107011239 },
67 {
"xAOD::TriggerMenuAuxContainer_v1", 1212409402 },
68 {
"xAOD::TriggerMenuJsonContainer_v1", 1221262614 },
69 {
"DataVector<xAOD::TriggerMenuJson_v1>", 1221262614 },
70 {
"xAOD::TriggerMenuJsonAuxContainer_v1", 373045213 },
71 {
"xAOD::LumiBlockRangeContainer_v1", 1115934851 },
72 {
"DataVector<xAOD::LumiBlockRange_v1>", 1115934851 },
73 {
"xAOD::LumiBlockRangeAuxContainer_v1", 1251061086 },
74 {
"xAOD::FileMetaData_v1", 178309087 },
75 {
"xAOD::FileMetaDataAuxInfo_v1", 73252552 },
76 {
"xAOD::RingSetConfContainer_v1", 1157997427 },
77 {
"DataVector<xAOD::RingSetConf_v1>", 1157997427 },
78 {
"xAOD::RingSetConfAuxContainer_v1", 1307745126 },
79 {
"xAOD::TruthMetaDataContainer_v1", 1188015687 },
80 {
"DataVector<xAOD::TruthMetaData_v1>", 1188015687 },
81 {
"xAOD::TruthMetaDataAuxContainer_v1", 1094306618 } } {}
112 m_incSvc->addListener(
this,
"FirstInputFile", 80,
true);
113 m_incSvc->addListener(
this,
"BeginInputFile", 80,
true);
114 m_incSvc->addListener(
this,
"EndInputFile", 10,
true);
115 m_incSvc->addListener(
this,
"BeginInputMemFile", 80,
true);
116 m_incSvc->addListener(
this,
"EndInputMemFile", 10,
true);
124 if (!joSvc.retrieve().isSuccess()) {
127 if (joSvc->has(
"EventSelector.InputCollections")) {
130 if (!evtsel.retrieve().isSuccess()) {
138 return(StatusCode::SUCCESS);
143 if (!
m_incSvc.release().isSuccess()) {
165 return(StatusCode::SUCCESS);
172 Incident metaDataStopIncident(name(),
"MetaDataStop");
173 m_incSvc->fireIncident(metaDataStopIncident);
174 return(StatusCode::SUCCESS);
180 return(StatusCode::SUCCESS);
183 return(StatusCode::SUCCESS);
188 const CLID clid = dhe.getPrimaryClassID();
193 return(StatusCode::SUCCESS);
198 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
199 if (fileInc ==
nullptr) {
200 ATH_MSG_ERROR(
"Unable to get FileName from EndInputFile incident");
201 return StatusCode::FAILURE;
203 const std::string guid = fileInc->fileGuid();
204 const std::string fileName = fileInc->fileName();
207 if (!fileName.starts_with(
"BSF:")) {
217 StatusCode
rc{StatusCode::SUCCESS};
219 ATH_MSG_DEBUG(
" calling beginInputFile on {} for GUID \"{}\"",
221 if (tool->beginInputFile(guid).isFailure()) {
222 ATH_MSG_ERROR(
"Unable to call beginInputFile for {}", tool->name());
223 rc = StatusCode::FAILURE;
231 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
232 if (fileInc ==
nullptr) {
233 ATH_MSG_ERROR(
"Unable to get FileName from EndInputFile incident");
234 return StatusCode::FAILURE;
236 const std::string guid = fileInc->fileGuid();
237 ATH_MSG_DEBUG(
"retireMetadataSource: {}", fileInc->fileName());
244 return StatusCode::SUCCESS;
250 return StatusCode::SUCCESS;
253 StatusCode
rc{StatusCode::SUCCESS};
256 if (tool->metaDataStop().isFailure()) {
257 ATH_MSG_ERROR(
"Unable to call metaDataStop for {}", tool->name());
258 rc = StatusCode::FAILURE;
273 if( outputName.empty() ) {
278 StatusCode
rc{StatusCode::SUCCESS};
282 if (tool->metaDataStop().isFailure()) {
283 ATH_MSG_ERROR(
"Unable to call metaDataStop for {}", tool->name());
284 rc = StatusCode::FAILURE;
294 if (
m_addrCrtr.name() !=
"AthenaPoolSharedIOCnvSvc") {
296 return StatusCode::FAILURE;
309 return StatusCode::SUCCESS;
314 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
315 if (fileInc ==
nullptr) {
316 ATH_MSG_ERROR(
"Unable to get FileName from EndInputFile incident");
319 const std::string fileName = fileInc->fileName();
322 if (inc.type() ==
"FirstInputFile") {
324 using namespace std::placeholders;
326 if (
m_fileMgr->regAction(std::move(boa), Io::OPEN).isFailure()) {
327 ATH_MSG_FATAL(
"Cannot register ROOT file open action with FileMgr.");
332 }
else if (inc.type() ==
"BeginInputFile" || inc.type() ==
"BeginInputMemFile") {
334 ATH_MSG_ERROR(
"Could not process new metadata source {}", fileName);
336 }
else if (inc.type() ==
"EndInputFile" || inc.type() ==
"EndInputMemFile") {
338 ATH_MSG_ERROR(
"Could not retire metadata source {}", fileName);
350 FileIncident inc(
"transitionMetaDataFile",
"EndInputFile",
"dummyMetaInputFileName",
"");
356 Incident metaDataStopIncident(name(),
"MetaDataStop");
357 m_incSvc->fireIncident(metaDataStopIncident);
368 return(StatusCode::SUCCESS);
377 ATH_MSG_INFO(
"Attached MetaDataTool: {}", tool->name());
380 return(StatusCode::SUCCESS);
384 return(StatusCode::SUCCESS);
391 if( pos==std::string::npos )
return "";
392 size_t epos = key.find(
']', pos);
394 std::string stream = key.substr( spos, epos - spos );
396 key = key.substr(0, pos) + key.substr(epos+1);
410 std::string fileName = tokenStr.substr(tokenStr.find(
"[FILE=") + 6);
411 leftString(fileName,
']');
412 std::string className = tokenStr.substr(tokenStr.find(
"[PNAME=") + 7);
413 leftString(className,
']');
414 std::string contName = tokenStr.substr(tokenStr.find(
"[CONT=") + 6);
415 leftString(contName,
']');
416 std::size_t pos1 = contName.find(
'(');
417 std::string keyName = contName.substr(pos1 + 1, contName.size() - pos1 - 2);
418 std::size_t pos2 = keyName.find(
'/');
419 if (pos2 != std::string::npos) keyName = keyName.substr(pos2 + 1);
420 std::string numName = tokenStr.substr(tokenStr.find(
"[NUM=") + 5);
421 leftString(numName,
']');
422 unsigned long num = 0;
423 std::istringstream iss(numName);
429 if( clid == 178309087 ) {
430 std::string newName = std::format(
"{}{}{}{}", keyName,
m_streamInKeyMark, fileName,
"]");
433 keyName = std::move(newName);
435 if( clid == 73252552 ) {
436 std::string newName = std::format(
"{}{}{}]{}",
443 keyName = std::move(newName);
445 const std::string par[3] = {
"SHM" , keyName , std::move(className) };
446 const unsigned long ipar[2] = { num , 0 };
447 IOpaqueAddress* opqAddr =
nullptr;
450 ATH_MSG_DEBUG(
"Resetting duplicate proxy for: {}#{} from file: {}",
451 clid, keyName, fileName);
455 ATH_MSG_FATAL(
"addProxyToInputMetaDataStore: Cannot create address for {}", tokenStr);
456 return(StatusCode::FAILURE);
459 ATH_MSG_FATAL(
"addProxyToInputMetaDataStore: Cannot create proxy for {}", tokenStr);
460 return(StatusCode::FAILURE);
463 ATH_MSG_FATAL(
"addProxyToInputMetaDataStore: Cannot access data for {}", tokenStr);
464 return(StatusCode::FAILURE);
468 ATH_MSG_WARNING(
"addProxyToInputMetaDataStore: Cannot symlink to AuxStore for {}", tokenStr);
470 return(StatusCode::SUCCESS);
474 ATH_MSG_DEBUG(
"initInputMetaDataStore: file name {}", fileName);
478 ATH_MSG_DEBUG(
"MetaDataSvc called without MetaDataContainer set.");
479 return(StatusCode::SUCCESS);
481 if (fileName.starts_with(
"BSF:")) {
483 }
else if (fileName.compare(0, 3,
"SHM")==0) {
486 const std::string par[2] = {
490 const std::string parOld[2] = {
495 ATH_MSG_DEBUG(
"initInputMetaDataStore: MetaData Store already contains DataHeader, key = {}", name());
497 const unsigned long ipar[2] = { 0 , 0 };
498 IOpaqueAddress* opqAddr =
nullptr;
502 ATH_MSG_WARNING(
"initInputMetaDataStore: Cannot create proxy for DataHeader, key = {}", name());
506 std::list<SG::TransientAddress*> tList;
509 CLID clid = tad->clID();
510 ATH_MSG_VERBOSE(
"initInputMetaDataStore: add proxy for clid = {}, key = {}",
513 ATH_MSG_DEBUG(
"initInputMetaDataStore: MetaData Store already contains clid = {}, key = {}",
517 ATH_MSG_ERROR(
"initInputMetaDataStore: Cannot create proxy for clid = {}, key = {}",
519 return StatusCode::FAILURE;
523 for (
CLID tclid : tad->transientID()) {
527 clid, tad->name(), tclid);
536 return(StatusCode::SUCCESS);
542 const EventContext& ctx = Gaudi::Hive::currentContext();
550 ATH_MSG_DEBUG(
"Not translating metadata item ID #{}", itemID);
554 std::string itemName;
556 if (
m_classIDSvc->getTypeNameOfID(itemID, itemName).isSuccess()) {
557 const std::string contName = std::format(
"MetaCont<{}>", itemName);
560 if (
m_classIDSvc->getIDOfTypeName(contName, contID).isSuccess())
568 const std::string& typeName = System::typeinfoName(typeInfo);
572 if (
m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
575 ATH_MSG_DEBUG(
"MetaDataSvc will handle {} ClassID: {}", typeName, itemID);
580 const std::string& typeName = System::typeinfoName(typeInfo);
584 if (
m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
586 ATH_MSG_DEBUG(
"MetaDataSvc will no longer handle {} ClassID: {}",
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
uint32_t CLID
The Class ID type.
This file contains the class definition for the OutputStreamSequencerSvc class.
Base class for all conversion services.
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.
std::list< SG::TransientAddress * > tadList
virtual StatusCode shmProxy(const std::string &tokenStr) 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.
static constexpr CLID ID()