13 #include "GaudiKernel/IIncidentSvc.h"
14 #include "GaudiKernel/FileIncident.h"
15 #include "GaudiKernel/ConcurrencyFlags.h"
21 : base_class(
name, pSvcLocator),
22 m_metaDataSvc(
"MetaDataSvc",
name),
23 m_fileSequenceNumber(-1)
36 if (!incsvc.retrieve().isSuccess()) {
38 return(StatusCode::FAILURE);
42 incsvc->addListener(
this, IncidentType::BeginProcessing, 100);
48 return StatusCode::FAILURE;
62 return(StatusCode::SUCCESS);
70 return(StatusCode::SUCCESS);
75 return Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1;
86 auto slot = Gaudi::Hive::currentContext().slot();
87 bool has_context = ( slot != EventContext::INVALID_CONTEXT_ID );
89 if( !has_context ) slot = 0;
92 << (!has_context?
" NO event context":
"") );
96 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
97 if (fileInc !=
nullptr) {
98 rangeID = fileInc->fileName();
99 ATH_MSG_DEBUG(
"Requested (through incident) Next Event Range filename extension: " << rangeID);
102 if( rangeID ==
"dummy" ) {
108 bool disconnect {
true };
110 throw GaudiException(
"Cannot transition MetaData",
name(), StatusCode::FAILURE);
118 std::lock_guard lockg(
m_mutex );
120 if( rangeID.empty() ) {
121 std::ostringstream
n;
124 ATH_MSG_DEBUG(
"Default next event range filename extension: " << rangeID);
140 bool disconnect {
false };
142 if( !
m_metaDataSvc->transitionMetaDataFile(
"" , disconnect ).isSuccess() ) {
143 throw GaudiException(
"Cannot transition MetaData",
name(), StatusCode::FAILURE);
147 else if( inc.type() == IncidentType::BeginProcessing ) {
150 std::lock_guard lockg(
m_mutex );
167 std::lock_guard lockg(
m_mutex );
169 std::string fileNameCore = orgFileName, fileNameExt;
170 std::size_t sepPos = orgFileName.find(
'[');
171 if (sepPos != std::string::npos) {
172 fileNameCore = orgFileName.substr(0, sepPos);
173 fileNameExt = orgFileName.substr(sepPos);
175 std::ostringstream
n;
176 n << fileNameCore <<
"." << rangeID << fileNameExt;
189 if( !
inUse() )
return "";
190 auto slot = Gaudi::Hive::currentContext().slot();
191 if( slot == EventContext::INVALID_CONTEXT_ID ) slot = 0;
192 std::lock_guard lockg(
m_mutex );
200 auto slot = Gaudi::Hive::currentContext().slot();
201 if( slot == EventContext::INVALID_CONTEXT_ID ) slot = 0;
202 std::lock_guard lockg(
m_mutex );
204 throw std::runtime_error(
"OutputStreamSequencer::setRangeID(): slot out of range");
214 std::lock_guard lockg(
m_mutex );
224 std::lock_guard lockg(
m_mutex );