92 auto slot = Gaudi::Hive::currentContext().slot();
93 bool has_context = ( slot != EventContext::INVALID_CONTEXT_ID );
95 if( !has_context ) slot = 0;
98 << (!has_context?
" NO event context":
"") );
102 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
103 if (fileInc !=
nullptr) {
104 rangeID = fileInc->fileName();
106 if (inc.type() == IncidentType::BeginInputFile) {
110 "Requested (through incident) Next Event Range filename extension: "
114 if( rangeID ==
"dummy" ) {
120 bool disconnect {
true };
121 std::lock_guard lockg(
m_mutex );
123 throw GaudiException(
"Cannot transition MetaData", name(), StatusCode::FAILURE);
131 std::lock_guard lockg(
m_mutex );
133 if( rangeID.empty() ) {
134 std::ostringstream n;
137 ATH_MSG_DEBUG(
"Default next event range filename extension: " << rangeID);
139 else if (rangeID ==
"INFILE") {
144 m_rangeIDinSlot.resize( std::max(slot+1, Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents()) );
156 bool disconnect {
false };
158 if( !
m_metaDataSvc->transitionMetaDataFile(
"" , disconnect ).isSuccess() ) {
159 throw GaudiException(
"Cannot transition MetaData", name(), StatusCode::FAILURE);
163 else if( inc.type() == IncidentType::BeginProcessing ) {
165 std::lock_guard lockg(
m_mutex );
169 m_rangeIDinSlot.resize( std::max(slot+1, Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents()) );
183 std::lock_guard lockg(
m_mutex );
186 std::string fileNameCore = orgFileName, fileNameExt;
187 std::size_t sepPos = orgFileName.find(
'[');
188 if (sepPos != std::string::npos) {
189 fileNameCore = orgFileName.substr(0, sepPos);
190 fileNameExt = orgFileName.substr(sepPos);
192 std::ostringstream n;
193 n << fileNameCore <<
"." << rangeID << fileNameExt;
196 std::string_view origFileNameView = orgFileName;
197 std::size_t open = origFileNameView.find(
'[');
198 std::size_t close = origFileNameView.find(
']');
201 if (open == std::string_view::npos || close == std::string_view::npos) {
206 std::vector<std::string_view> elems{};
207 std::size_t pos = open + 1;
208 for (std::size_t comma = origFileNameView.find(
',', pos);
210 comma = origFileNameView.find(
',', pos)) {
211 std::string_view item = origFileNameView.substr(pos, comma - pos);
212 ATH_MSG_DEBUG(
"(start) pos = " << pos <<
", (end) comma = " << comma <<
", item = " << item);
213 elems.push_back(item);
216 std::string_view last_item = origFileNameView.substr(pos, close - pos);
217 ATH_MSG_DEBUG(
"(start) pos = " << pos <<
", (end) close = " << close <<
", item = " << last_item);
218 elems.push_back(last_item);
220 std::size_t rangeIdx{};
221 auto rangeIdxParseRes = std::from_chars(
222 rangeID.data(), rangeID.data() + rangeID.size(), rangeIdx);
223 if (rangeIdxParseRes.ec != std::errc()) {
225 "Error parsing rangeID to integer. Replacing [] list with "
228 std::format(
"{}{}{}", origFileNameView.substr(0, open), rangeID,
229 origFileNameView.substr(close + 1));
230 }
else if (rangeIdx >= elems.size()) {
232 "Number of elements in [] list <= rangeID. Replacing [] list with "
235 std::format(
"{}{}{}", origFileNameView.substr(0, open), rangeID,
236 origFileNameView.substr(close + 1));
239 "{}{}{}", origFileNameView.substr(0, open), elems.at(rangeIdx),
240 origFileNameView.substr(close + 1));