13#include "GaudiKernel/IToolSvc.h"
14#include "GaudiKernel/FileIncident.h"
15#include "GaudiKernel/ServiceHandle.h"
16#include "GaudiKernel/IEvtSelector.h"
17#include "GaudiKernel/IIncidentSvc.h"
73 ::setenv(
"LCGPATCH_COINMULTISELECT",
"1",1);
84 msg(MSG::INFO) <<
" in initialize() " <<
endmsg;
92 *it = std::move(
file);
96 SmartIF<IIncidentSvc> incsvc{service(
"IncidentSvc")};
99 std::string endfilekey(
"EndTagFile");
100 incsvc->addListener(
this, endfilekey, 0);
101 msg(MSG::DEBUG) <<
"Added listener on "<<endfilekey <<
endmsg;
112 if (!
m_vp1gui->argumentsAreValid()) {
116 return StatusCode::FAILURE;
118 return StatusCode::SUCCESS;
129 msg(MSG::DEBUG) <<
" in execute() " <<
endmsg;
132 return StatusCode::FAILURE;
141 unsigned int trigType = 0;
145 StatusCode status =
evtStore()->retrieve (eventInfo,
"EventInfo");
147 if(status.isSuccess()) {
149 const unsigned long long eventNumber = eventInfo->
eventNumber();
150 const uint32_t runNumber = eventInfo->
runNumber();
151 msg(MSG::DEBUG) <<
" Got run number = " << runNumber
152 <<
", event number = " << eventNumber <<
endmsg;
159 if (
m_noGui||
m_vp1gui->executeNewEvent(runNumber,eventNumber,trigType,time)) {
160 return StatusCode::SUCCESS;
162 msg(MSG::INFO) <<
" Ending application gracefully." <<
endmsg;
163 return StatusCode::FAILURE;
165 return StatusCode::SUCCESS;
168 msg(MSG::DEBUG) <<
" Unable to retrieve EventInfo from StoreGate... using dummy values" <<
endmsg;
171 return StatusCode::SUCCESS;
173 msg(MSG::INFO) <<
" Ending application gracefully." <<
endmsg;
174 return StatusCode::FAILURE;
177 return StatusCode::SUCCESS;
184 msg(MSG::INFO) <<
" in finalize() " <<
endmsg;
187 return StatusCode::FAILURE;
193 return StatusCode::SUCCESS;
199 msg(MSG::INFO) <<
"Handling incident '" << inc.type() <<
"'" <<
endmsg;
202 msg(MSG::INFO) <<
"Aborting due to null VP1Gui pointer." <<
endmsg;
206 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
208 msg(MSG::WARNING) <<
" Unable to cast to file incident" <<
endmsg;
212 msg(MSG::DEBUG) <<
" Casting to file incident successful" <<
endmsg;
216 StatusCode
sc = pEvtSelector.retrieve();
218 if(!
sc.isSuccess() || 0 == pEvtSelector) {
219 msg(MSG::WARNING) <<
"Could not find EventSelector" <<
endmsg;
223 msg(MSG::DEBUG) <<
" Got EventSelector" <<
endmsg;
225 IProperty* propertyServer =
dynamic_cast<IProperty*
>(pEvtSelector.operator->());
226 if (!propertyServer) {
227 msg(MSG::WARNING) <<
"Could not get propertyServer" <<
endmsg;
231 std::vector<std::string> vect;
232 StringArrayProperty inputCollections(
"InputCollections", vect);
234 sc = propertyServer->getProperty(&inputCollections);
235 if(!
sc.isSuccess()) {
236 msg(MSG::INFO) <<
"Could not get InputCollections property" <<
endmsg;
240 msg(MSG::DEBUG) <<
" Got InputCollections property" <<
endmsg;
242 for (
const std::string& s : inputCollections.value()) {
243 if(s != fileInc->fileName())
248 std::string strNewFileName =
m_vp1gui->nextRequestedEventFile();
250 if (strNewFileName.empty())
253 msg(MSG::WARNING) <<
" File requested by VP1 does not exists or is not readable: "<<strNewFileName<<
". Ending." <<
endmsg;
257 vect.push_back(strNewFileName);
258 msg(MSG::INFO) <<
" Setting next event file: " << strNewFileName<<
endmsg;
261 std::vector<std::string> strNewFileNames =
m_vp1gui->userRequestedFiles();
262 for(
unsigned i=0; i<strNewFileNames.size(); ++i) {
263 const std::string& strNewFileName = strNewFileNames[i];
264 if (strNewFileName.empty())
267 msg(MSG::WARNING) <<
" File requested by VP1 does not exists or is not readable: " << strNewFileName <<
endmsg;
270 vect.push_back(strNewFileName);
271 msg(MSG::INFO) <<
" Setting next event file: " << strNewFileName<<
endmsg;
275 StringArrayProperty newInputCollections(
"InputCollections", vect);
277 if(propertyServer->setProperty(newInputCollections)!=StatusCode::SUCCESS)
278 msg(MSG::WARNING) <<
"Could not set new InputCollections property" <<
endmsg;
280 msg(MSG::DEBUG) <<
" InputCollections property set" <<
endmsg;
#define ATH_CHECK
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Gaudi::Property< std::string > m_mfLocalCopyDir
Gaudi::Property< int > m_mfLimit
Gaudi::Property< bool > m_noGui
Gaudi::Property< std::string > m_cruiseInitialMode
virtual StatusCode execute() override
Gaudi::Property< bool > m_mfOn
Gaudi::Property< std::vector< std::string > > m_initialvp1files
Gaudi::Property< unsigned > m_cruiseInitialUpdateSeconds
virtual StatusCode finalize() override
virtual StatusCode initialize() override
VP1Alg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::vector< std::string > > m_mfAvailableLocalInputDirectories
void handle(const Incident &inc) override
Gaudi::Property< std::string > m_mfSourceDir
static bool fileExistsAndReadable(const std::string &)
uint16_t level1TriggerType() const
The Level-1 trigger type.
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
EventInfo_v1 EventInfo
Definition of the latest event info version.