16 #include "GaudiKernel/IAlgorithm.h"
17 #include "GaudiKernel/SmartIF.h"
18 #include "GaudiKernel/Incident.h"
19 #include "GaudiKernel/DataObject.h"
20 #include "GaudiKernel/IIncidentSvc.h"
21 #include "GaudiKernel/IDataManagerSvc.h"
22 #include "GaudiKernel/IDataProviderSvc.h"
23 #include "GaudiKernel/IConversionSvc.h"
24 #include "GaudiKernel/GaudiException.h"
25 #include "GaudiKernel/AppReturnCode.h"
26 #include "GaudiKernel/MsgStream.h"
27 #include "GaudiKernel/EventIDBase.h"
28 #include "GaudiKernel/ThreadLocalContext.h"
29 #include "GaudiKernel/FileIncident.h"
33 #include "EventInfo/EventInfo.h"
39 #include "tbb/tick_count.h"
40 #include "yampl/SocketFactory.h"
54 leftString(std::string &
s,
char sc){
55 bool truncated{
false};
57 if (
n!=std::string::npos){
65 leftString(std::string &
s,
int n){
66 bool truncated{
false};
67 if (
static_cast<size_t>(
n) <
s.size()){
76 , ISvcLocator* svcLoc)
77 : MinimalEventLoopMgr(nam, svcLoc)
78 , m_incidentSvc (
"IncidentSvc", nam )
79 , m_eventStore(
"StoreGateSvc", nam )
80 , m_evtSelector{
nullptr}
81 , m_evtContext{
nullptr}
82 , m_histoDataMgrSvc(
"HistogramDataSvc", nam )
83 , m_histoPersSvc (
"HistogramPersistencySvc", nam )
84 , m_evtIdModSvc(
"", nam)
93 , m_doEvtHeartbeat(
false)
94 , m_conditionsCleaner(
"Athena::ConditionsCleanerSvc", nam )
95 , m_outSeqSvc(
"OutputStreamSequencerSvc", nam)
98 "Name of Event Selector to use. If empty string (default) "
99 "take value from ApplicationMgr");
101 "Histogram persistency technology to use: ROOT, HBOOK, NONE. "
102 "By default (empty string) get property value from "
105 "histogram write/update interval");
107 "Controls behaviour of event loop depending on return code of"
108 " Algorithms. 0: all non-SUCCESSes terminate job. "
109 "1: RECOVERABLE skips to next event, FAILURE terminates job "
110 "(DEFAULT). 2: RECOVERABLE and FAILURE skip to next events");
112 "Print event heartbeat printouts every m_eventPrintoutInterval events");
114 m_clearStorePolicy =
"EndEvent",
115 "Configure the policy wrt handling of when the "
116 "'clear-the-event-store' event shall happen: at EndEvent "
117 "(default as it is makes things easier for memory management"
118 ") or at BeginEvent (easier e.g. for interactive use)");
119 declareProperty(
"PreSelectTools",m_tools,
"AlgTools for event pre-selection")->
123 "Name of the scheduler to be used");
126 "Name of the Whiteboard to be used");
131 "ServiceHandle for EvtIdModifierSvc");
134 "Event interval at which to increment lumiBlock# when "
135 "creating events without an EventSelector. Zero means "
136 "don't increment it");
138 "timestamp interval between events when creating Events "
139 "without an EventSelector");
140 declareProperty(
"RequireInputAttributeList", m_requireInputAttributeList =
false,
141 "Require valid input attribute list to be present");
142 declareProperty(
"UseSecondaryEventNumber", m_useSecondaryEventNumber =
false,
143 "In case of DoubleEventSelector use event number from secondary input");
145 declareProperty(
"ESTestPilotMessages", m_testPilotMessages,
"List of messages from fake pilot for test mode");
147 m_scheduledStop =
false;
160 if(!
sc.isSuccess()) {
161 error() <<
"Failed to initialize base class MinimalEventLoopMgr" <<
endmsg;
172 return StatusCode::FAILURE;
177 fatal() <<
"Error retrieving SchedulerSvc interface ISchedulerSvc." <<
endmsg;
178 return StatusCode::FAILURE;
183 fatal() <<
"Error retrieving AlgResourcePool" <<
endmsg;
184 return StatusCode::FAILURE;
187 m_aess = serviceLocator()->service(
"AlgExecStateSvc");
189 fatal() <<
"Error retrieving AlgExecStateSvc" <<
endmsg;
190 return StatusCode::FAILURE;
199 SmartIF<IProperty> prpMgr(serviceLocator());
200 if(!prpMgr.isValid()) {
201 fatal() <<
"IProperty interface not found in ApplicationMgr." <<
endmsg;
202 return StatusCode::FAILURE;
208 if(histPersName.empty()) {
209 ATH_CHECK(setProperty(prpMgr->getProperty(
"HistogramPersistency")));
212 if(histPersName !=
"NONE") {
217 IService *is{
nullptr};
218 sc = serviceLocator()->service(
"RootHistSvc", is);
220 if (
sc.isFailure()) {
221 error() <<
"could not locate actual Histogram persistency service" <<
endmsg;
226 error() <<
"Could not dcast HistPersSvc to a Service" <<
endmsg;
229 const Gaudi::Details::PropertyBase &prop =
s->getProperty(
"OutputFile");
232 const StringProperty &sprop =
dynamic_cast<const StringProperty&
>(prop);
236 verbose() <<
"could not dcast OutputFile property to a StringProperty."
237 <<
" Need to fix Gaudi."
240 val = prop.toString();
244 &&
val !=
"UndefinedROOTOutputFileName") {
252 debug() <<
"Histograms saving not required." <<
endmsg;
260 debug() <<
"EventID modifier Service not set. No run number, ... overrides "
265 debug() <<
"Could not find EventID modifier Service. No run number, ... "
277 sc = setProperty(prpMgr->getProperty(
"EvtSel"));
279 if (
sc.isFailure()) {
280 warning() <<
"Unable to set EvtSel property" <<
endmsg;
285 IEvtSelector* theEvtSel{
nullptr};
286 sc = serviceLocator()->service(
selName, theEvtSel);
293 fatal() <<
"Can not create the event selector Context." <<
endmsg;
294 return StatusCode::FAILURE;
296 if (msgLevel(MSG::INFO)) {
297 INamedInterface* named (
dynamic_cast< INamedInterface*
>(theEvtSel));
299 info() <<
"Setup EventSelector service " << named->name( ) <<
endmsg;
303 else if (
sc.isFailure()) {
304 fatal() <<
"No valid event selector called " <<
selName <<
endmsg;
305 return StatusCode::FAILURE;
315 return StatusCode::FAILURE;
326 info() <<
"Using secondary event number." <<
endmsg;
330 info() <<
"runnung in standalone TEST MODE" <<
endmsg;
353 if ( policyName !=
"BeginEvent" &&
354 policyName !=
"EndEvent" ) {
356 fatal() <<
"Unknown policy [" << policyName
357 <<
"] for the 'ClearStore-policy !\n"
358 <<
" Valid values are: BeginEvent, EndEvent"
360 throw GaudiException(
"Can not setup 'ClearStore'-policy",
362 StatusCode::FAILURE);
384 unsigned int toolCtr = 0;
385 for ( ; firstTool != lastTool; ++firstTool )
408 error() <<
"Error in Service base class Finalize"
415 error() <<
"Error in writing Histograms"
441 unsigned int toolCtr = 0;
442 info() <<
"Summary of AthenaEvtLoopPreSelectTool invocation: (invoked/success/failure)" <<
endmsg;
443 info() <<
"-----------------------------------------------------" <<
endmsg;
445 for ( ; firstTool != lastTool; ++firstTool ) {
446 info() << std::setw(2) << std::setiosflags(std::ios_base::right)
447 << toolCtr+1 <<
".) " << std::resetiosflags(std::ios_base::right)
448 << std::setw(48) << std::setfill(
'.')
449 << std::setiosflags(std::ios_base::left)
450 << (*firstTool)->name() << std::resetiosflags(std::ios_base::left)
453 << std::setw(6) << std::setiosflags(std::ios_base::right)
465 return (
sc.isFailure() || sc2.isFailure() ) ? StatusCode::FAILURE :
478 std::vector<DataObject*>
objects;
480 DataObject*
obj =
reg->object();
481 if ( !
obj ||
obj->clID() == CLID_StatisticsFile )
return false;
486 if ( !
sc.isSuccess() ) {
487 error() <<
"Error while traversing Histogram data store" <<
endmsg;
495 (writeInterval != 0 &&
m_nevt%writeInterval == 0) ) {
499 IOpaqueAddress* pAddr =
nullptr;
501 if ( iret.isFailure() )
return iret;
502 i->registry()->setAddress( pAddr );
506 IRegistry*
reg =
i->registry();
508 return iret.isFailure() ? iret : isc;
510 if ( !
sc.isSuccess() ) {
511 error() <<
"Error while saving Histograms." <<
endmsg;
515 if (
force || (writeInterval != 0 &&
m_nevt%writeInterval == 0) ) {
531 return StatusCode::SUCCESS;
539 return StatusCode::SUCCESS;
551 always() <<
"A stopRun was requested by an incidentListener. "
552 <<
"Do not process this event."
555 return (StatusCode::SUCCESS);
561 Gaudi::Hive::setCurrentContext ( ctx );
564 if (declEvtRootSc == 0 ) {
566 return StatusCode::SUCCESS;
567 }
else if ( declEvtRootSc == -1) {
568 error() <<
"declareEventRootAddress for context " << ctx <<
" failed"
570 return StatusCode::FAILURE;
574 unsigned int conditionsRun = ctx.eventID().run_number();
577 if (
eventStore()->contains<AthenaAttributeList>(
"Input") &&
579 if (attr->exists(
"ConditionsRun")) {
580 conditionsRun = (*attr)[
"ConditionsRun"].data<
unsigned int>();
585 Gaudi::Hive::setCurrentContext ( ctx );
588 if (
eventStore()->record(std::make_unique<EventContext> (ctx),
589 "EventContext").isFailure())
591 error() <<
"Error recording event context object" <<
endmsg;
592 return (StatusCode::FAILURE);
613 bool toolsPassed=
true;
618 unsigned int toolCtr=0;
622 while(toolsPassed && theTool!=lastTool )
624 toolsPassed = (*theTool)->passEvent(ctx.eventID());
636 info() <<
" ===>>> start processing event #" << evtNumber <<
", run #" <<
m_currentRun
637 <<
" on slot " << ctx.slot() <<
", " <<
m_proc
638 <<
" events processed so far <<<===" <<
endmsg;
640 info() <<
" ===>>> start processing event #" << evtNumber <<
", run #" <<
m_currentRun
641 <<
" on slot " << ctx.slot() <<
", "
643 <<
" events processed so far <<<===" <<
endmsg;
656 debug() <<
"Adding event " << ctx.evt()
657 <<
", slot " << ctx.slot()
658 <<
" to the scheduler" <<
endmsg;
665 if (!addEventStatus.isSuccess()){
666 fatal() <<
"An event processing slot should be now free in the scheduler, but it appears not to be the case." <<
endmsg;
676 Gaudi::Hive::setCurrentContext( EventContext() );
678 return StatusCode::SUCCESS;
688 if (
sc.isSuccess()) {
699 SmartIF<IProperty> appmgr(serviceLocator());
700 if(Gaudi::setAppReturnCode(appmgr, Gaudi::ReturnCode::ScheduledStop).isFailure()) {
701 error() <<
"Could not set return code of the application ("
702 << Gaudi::ReturnCode::ScheduledStop <<
")" <<
endmsg;
705 return StatusCode::SUCCESS;
726 for (
size_t islot = 0; islot < nslot; islot++) {
730 Gaudi::Hive::setCurrentContext( EventContext() );
737 if(maxevt==0)
return StatusCode::SUCCESS;
739 yampl::ISocketFactory* socketFactory =
new yampl::SocketFactory();
749 info() <<
"Starting loop on events" <<
endmsg;
755 auto secsFromStart = [&start_time]()->
double{
759 std::unique_ptr<RangeStruct>
range;
765 bool loop_ended =
range->eventRangeID.empty();
772 bool no_more_events =
false;
776 debug() <<
" -> createdEvts: " << createdEvts <<
endmsg;
786 if ( !ctx.valid() ) {
787 sc = StatusCode::FAILURE;
793 if (
sc.isFailure()) {
794 error() <<
"Terminating event processing loop due to errors" <<
endmsg;
806 if(
range->eventRangeID.empty()) {
807 no_more_events =
true;
828 sc = StatusCode::FAILURE;
835 sc = StatusCode::SUCCESS;
844 info() <<
"---> Loop Finished (seconds): " << secsFromStart() <<
endmsg;
848 delete socketFactory;
861 error() <<
"Seek failed; unsupported by event selector"
863 return StatusCode::FAILURE;
868 fatal() <<
"Can not create the event selector Context."
870 return StatusCode::FAILURE;
876 if (
sc.isSuccess()) {
901 error() <<
"Collection size unsupported by event selector"
908 fatal() <<
"Can not create the event selector Context."
923 if(inc.type()!=
"BeforeFork")
927 warning() <<
"Skipping BeforeFork handler. Either no event selector is provided or begin run has already passed" <<
endmsg;
933 error() <<
"Failed to initialize Algorithms" <<
endmsg;
939 IOpaqueAddress* addr = 0;
941 if(!
sc.isSuccess()) {
942 info() <<
"No more events in event selection " <<
endmsg;
946 if (
sc.isFailure()) {
947 error() <<
"Could not create an IOpaqueAddress" <<
endmsg;
953 if(!
sc.isSuccess()) {
954 error() <<
"Error declaring Event object" <<
endmsg;
959 if(
eventStore()->loadEventProxies().isFailure()) {
960 warning() <<
"Error loading Event proxies" <<
endmsg;
966 if(!
sc.isSuccess()) {
967 error() <<
"Unable to retrieve Event root object" <<
endmsg;
978 if(!
sc.isSuccess()) {
979 error() <<
"Clear of Event data store failed" <<
endmsg;
993 if ( IEventSeek::interfaceID().versionMatch(riid) ) {
994 *ppvInterface =
dynamic_cast<IEventSeek*
>(
this);
996 else if ( IEventProcessor::interfaceID().versionMatch(riid) ) {
997 *ppvInterface =
dynamic_cast<IEventProcessor*
>(
this);
1003 return MinimalEventLoopMgr::queryInterface(riid, ppvInterface);
1006 return StatusCode::SUCCESS;
1015 if ( !
sc.isSuccess() ) {
1020 if( !
sc.isSuccess() ) {
1022 if (
sc.isSuccess() ) {
1024 if ( !
sc.isSuccess() ) {
1025 warning() <<
"Error creating IOpaqueAddress." <<
endmsg;
1046 std::unique_ptr<const EventInfo> pEvent;
1054 IOpaqueAddress* addr = 0;
1058 error() <<
"Seek failed; unsupported by event selector" <<
endmsg;
1063 if(
sc.isFailure()) {
1070 if ( !
sc.isSuccess() ) {
1072 info() <<
"No more events in event selection " <<
endmsg;
1077 error() <<
"Could not create an IOpaqueAddress" <<
endmsg;
1086 if( !
sc.isSuccess() ) {
1088 warning() <<
"Error declaring Event object" <<
endmsg;
1091 }
if ((
sc=
eventStore()->loadEventProxies()).isFailure()) {
1092 error() <<
"Error loading Event proxies" <<
endmsg;
1095 bool consume_modifier_stream =
false;
1098 if ( pAttrList !=
nullptr && pAttrList->size() > 6 ) {
1100 unsigned int runNumber = (*pAttrList)[
"RunNumber"].data<
unsigned int>();
1101 unsigned long long eventNumber = (*pAttrList)[
"EventNumber"].data<
unsigned long long>();
1102 unsigned int eventTime = (*pAttrList)[
"EventTime"].data<
unsigned int>();
1103 unsigned int eventTimeNS = (*pAttrList)[
"EventTimeNanoSec"].data<
unsigned int>();
1104 unsigned int lumiBlock = (*pAttrList)[
"LumiBlockN"].data<
unsigned int>();
1105 unsigned int bunchId = (*pAttrList)[
"BunchId"].data<
unsigned int>();
1107 consume_modifier_stream =
true;
1110 unsigned long long eventNumberSecondary{};
1111 if ( !(pAttrList->exists(
"hasSecondaryInput") && (*pAttrList)[
"hasSecondaryInput"].data<
bool>()) ) {
1112 fatal() <<
"Secondary EventNumber requested, but secondary input does not exist!" <<
endmsg;
1115 if ( pAttrList->exists(
"EventNumber_secondary") ) {
1116 eventNumberSecondary = (*pAttrList)[
"EventNumber_secondary"].data<
unsigned long long>();
1122 if (pEventSecondary) {
1123 eventNumberSecondary = pEventSecondary->
event_ID()->event_number();
1126 fatal() <<
"Secondary EventNumber requested, but it does not exist!" <<
endmsg;
1130 if (eventNumberSecondary != 0) {
1132 info() <<
" ===>>> using secondary event #" << eventNumberSecondary <<
" instead of #" <<
eventNumber <<
"<<<===" <<
endmsg;
1139 pEvent = std::make_unique<EventInfo>(
1146 fatal() <<
"Valid input attribute list required but not present!";
1150 const EventInfo* pEventObserver{pEvent.get()};
1151 if (!pEventObserver) {
1154 if( !pEventObserver ) {
1159 if( !
sc.isSuccess() ) {
1160 error() <<
"Unable to retrieve Event root object" <<
endmsg;
1163 consume_modifier_stream =
true;
1165 pEvent = std::make_unique<EventInfo>(
1168 pEventObserver = pEvent.get();
1170 if( !
sc.isSuccess() ) {
1171 error() <<
"Error declaring event data object" <<
endmsg;
1175 consume_modifier_stream =
false;
1183 consume_modifier_stream);
1189 unsigned int runNmb{1}, evtNmb{
m_nevt + 1};
1196 auto eid = std::make_unique<EventID> (runNmb,evtNmb,
m_timeStamp);
1198 eid->set_lumi_block( runNmb );
1202 pEvent = std::make_unique<EventInfo>(eid.release(),
new EventType());
1206 debug() <<
"selecting store: " << ctx.slot() <<
endmsg;
1210 debug() <<
"recording EventInfo " << *pEvent->
event_ID() <<
" in "
1213 if( !
sc.isSuccess() ) {
1214 error() <<
"Error declaring event data object" <<
endmsg;
1224 bool consume_modifier_stream) {
1230 m_evtIdModSvc->modify_evtid(new_eID, ctx.evt(), consume_modifier_stream);
1232 unsigned int oldrunnr = eID.run_number();
1233 unsigned int oldLB = eID.lumi_block();
1234 unsigned int oldTS = eID.time_stamp();
1235 unsigned int oldTSno = eID.time_stamp_ns_offset();
1236 debug() <<
"modifyEventContext: use evtIdModSvc runnr=" << oldrunnr
1237 <<
" -> " << new_eID.run_number() <<
endmsg;
1238 debug() <<
"modifyEventContext: use evtIdModSvc LB=" << oldLB <<
" -> "
1239 << new_eID.lumi_block() <<
endmsg;
1240 debug() <<
"modifyEventContext: use evtIdModSvc TimeStamp=" << oldTS
1241 <<
" -> " << new_eID.time_stamp() <<
endmsg;
1242 debug() <<
"modifyEventContext: use evtIdModSvc TimeStamp ns Offset="
1243 << oldTSno <<
" -> " << new_eID.time_stamp_ns_offset() <<
endmsg;
1245 ctx.setEventID(new_eID);
1247 ctx.eventID().run_number());
1251 ctx.setEventID(eID);
1260 if (
sc.isFailure()) {
1261 fatal() <<
"Slot " << ctx.slot()
1262 <<
" could not be selected for the WhiteBoard" <<
endmsg;
1263 return EventContext{};
1267 debug() <<
"created EventContext, num: " << ctx.evt() <<
" in slot: "
1276 Gaudi::setAppReturnCode(
m_appMgrProperty, Gaudi::ReturnCode::Success,
true).ignore();
1294 std::vector<EventContext*> finishedEvtContexts;
1296 EventContext* finishedEvtContext(
nullptr);
1299 debug() <<
"drainScheduler: [" << finishedEvts <<
"] Waiting for a context" <<
endmsg;
1303 if (
sc.isSuccess()){
1304 debug() <<
"drainScheduler: scheduler not empty: Context "
1305 << finishedEvtContext <<
endmsg;
1306 finishedEvtContexts.push_back(finishedEvtContext);
1309 debug() <<
"drainScheduler: scheduler empty" <<
endmsg;
1314 while (
m_schedulerSvc->tryPopFinishedEvent(finishedEvtContext).isSuccess()){
1315 finishedEvtContexts.push_back(finishedEvtContext);
1320 for (
auto& thisFinishedEvtContext : finishedEvtContexts){
1321 if (!thisFinishedEvtContext) {
1322 fatal() <<
"Detected nullptr ctxt while clearing WB!"<<
endmsg;
1327 if (
m_aess->eventStatus(*thisFinishedEvtContext) != EventStatus::Success) {
1328 fatal() <<
"Failed event detected on " << thisFinishedEvtContext
1329 <<
" w/ fail mode: "
1330 <<
m_aess->eventStatus(*thisFinishedEvtContext) <<
endmsg;
1331 delete thisFinishedEvtContext;
1339 if (
m_whiteboard->selectStore(thisFinishedEvtContext->slot()).isSuccess()) {
1340 n_run = thisFinishedEvtContext->eventID().run_number();
1341 n_evt = thisFinishedEvtContext->eventID().event_number();
1343 error() <<
"DrainSched: unable to select store "
1344 << thisFinishedEvtContext->slot() <<
endmsg;
1345 delete thisFinishedEvtContext;
1354 Gaudi::Hive::setCurrentContext( *thisFinishedEvtContext );
1356 m_incidentSvc->fireIncident(Incident(
name(), IncidentType::EndProcessing, *thisFinishedEvtContext ));
1362 std::string outputFileReport = rangeReport->second + std::string(
",ID:")
1363 + rangeReport->first + std::string(
",CPU:N/A,WALL:N/A");
1366 void* message2pilot =
malloc(outputFileReport.size());
1367 memcpy(message2pilot,outputFileReport.data(),outputFileReport.size());
1368 m_socket->send(message2pilot,outputFileReport.size());
1370 info() <<
"Reported the output " << outputFileReport <<
endmsg;
1374 debug() <<
"Clearing slot " << thisFinishedEvtContext->slot()
1375 <<
" (event " << thisFinishedEvtContext->evt()
1376 <<
") of the whiteboard" <<
endmsg;
1379 if (!
sc.isSuccess()) {
1380 error() <<
"Whiteboard slot " << thisFinishedEvtContext->slot()
1381 <<
" could not be properly cleared";
1383 delete thisFinishedEvtContext;
1394 info() <<
" ===>>> done processing event #" << n_evt <<
", run #" << n_run
1395 <<
" on slot " << thisFinishedEvtContext->slot() <<
", "
1396 <<
m_proc <<
" events processed so far <<<===" <<
endmsg;
1398 info() <<
" ===>>> done processing event #" << n_evt <<
", run #" << n_run
1399 <<
" on slot " << thisFinishedEvtContext->slot() <<
", "
1401 <<
" events processed so far <<<===" <<
endmsg;
1402 std::ofstream
outfile(
"eventLoopHeartBeat.txt");
1404 error() <<
" unable to open: eventLoopHeartBeat.txt" <<
endmsg;
1406 delete thisFinishedEvtContext;
1409 outfile <<
" done processing event #" << n_evt <<
", run #" << n_run
1410 <<
" " <<
m_nev <<
" events read so far <<<===" << std::endl;
1415 debug() <<
"drainScheduler thisFinishedEvtContext: " << thisFinishedEvtContext
1418 delete thisFinishedEvtContext;
1421 return (
fail ? -1 : 1 );
1429 if( !
sc.isSuccess() ) {
1430 warning() <<
"Clear of Event data store failed" <<
endmsg;
1438 static const std::string strReady(
"Ready for events");
1439 static const std::string strStopProcessing(
"No more events");
1443 static std::atomic<size_t> line_n = 0;
1444 info() <<
"in TEST MODE, Range #" << line_n+1 <<
endmsg;
1448 void* ready_message =
malloc(strReady.size());
1449 memcpy(ready_message,strReady.data(),strReady.size());
1450 socket->send(ready_message,strReady.size());
1451 void* eventRangeMessage;
1452 std::string strPeerId;
1453 ssize_t eventRangeSize = socket->recv(eventRangeMessage,strPeerId);
1454 range = std::string((
const char*)eventRangeMessage,eventRangeSize);
1455 leftString(
range,
'\n');
1458 std::unique_ptr<RangeStruct>
result = std::make_unique<RangeStruct>();
1459 if(
range.compare(strStopProcessing)==0) {
1460 info() <<
"No more events from the server" <<
endmsg;
1474 std::map<std::string,std::string> eventRangeMap;
1476 size_t endpos =
range.find(
',');
1477 while(endpos!=std::string::npos) {
1479 std::string
keyValue(
range.substr(startpos,endpos-startpos));
1480 size_t colonPos =
keyValue.find(
':');
1481 std::string strKey =
keyValue.substr(0,colonPos);
1482 std::string strVal =
keyValue.substr(colonPos+1);
1485 eventRangeMap[strKey]=strVal;
1488 startpos = endpos+1;
1489 endpos =
range.find(
',',startpos);
1494 size_t colonPos =
keyValue.find(
':');
1495 std::string strKey =
keyValue.substr(0,colonPos);
1496 std::string strVal =
keyValue.substr(colonPos+1);
1499 eventRangeMap[strKey]=strVal;
1509 if(eventRangeMap.find(
"eventRangeID")==eventRangeMap.end()
1510 || eventRangeMap.find(
"startEvent")==eventRangeMap.end()
1511 || eventRangeMap.find(
"lastEvent")==eventRangeMap.end()
1512 || eventRangeMap.find(
"PFN")==eventRangeMap.end()) {
1514 errorStr =
"ERR_ATHENAMP_PARSE \"" +
range +
"\": Wrong format";
1521 if(eventRangeMap[
"eventRangeID"].
empty()
1522 || eventRangeMap[
"PFN"].
empty()
1525 errorStr =
"ERR_ATHENAMP_PARSE \"" +
range +
"\": Wrong values of range fields";
1529 if(
m_pfn != eventRangeMap[
"PFN"]) {
1530 IProperty* propertyServer =
dynamic_cast<IProperty*
>(
m_evtSelector);
1531 if(!propertyServer) {
1532 errorStr =
"ERR_ATHENAMP_PARSE \"" +
range +
"\": Unable to dyn-cast the event selector to IProperty";
1535 std::string strInpuCol(
"InputCollections");
1536 std::vector<std::string> vectInpCol{eventRangeMap[
"PFN"],};
1537 StringArrayProperty inputFileList(strInpuCol, vectInpCol);
1538 if(propertyServer->setProperty(inputFileList).isFailure()) {
1539 errorStr =
"ERR_ATHENAMP_PARSE \"" +
range +
"\": Unable to set input file name property to the Event Selector";
1542 m_pfn = eventRangeMap[
"PFN"];
1551 debug() <<
"*** Decoded Event Range ***" <<
endmsg;
1552 for (
const auto& fieldvalue : eventRangeMap) {
1553 debug() << fieldvalue.first <<
":" << fieldvalue.second <<
endmsg;
1556 result->eventRangeID = eventRangeMap[
"eventRangeID"];
1557 result->pfn = eventRangeMap[
"PFN"];
1563 info() <<
"Ignoring this event range" <<
endmsg;
1567 socket->send(errorMessage,
errorStr.size());
1582 if(
str.empty())
return;
1586 while(
str[
i]==
' ')
i--;
1587 if(
i)
str.resize(
i+1);
1596 if(
str.rfind(
'\'')==
str.size()-1) {
1602 if(
str.rfind(
'\"')==
str.size()-1) {