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);
87 ATH_MSG_INFO(
"Checking if we have access to the Extrapolator tool...");
90 ATH_MSG_WARNING(
"No extrapolator found. Will not be able to extrapolate tracks.");
92 ATH_MSG_INFO(
"Extrapolator found. Will be able to extrapolate tracks.");
95 ATH_MSG_INFO(
"VP1 has been started with no input data files; so we don't need to retrieve the Extrapolator tool.");
104 *it = std::move(
file);
108 SmartIF<IIncidentSvc> incsvc{service(
"IncidentSvc")};
111 std::string endfilekey(
"EndTagFile");
112 incsvc->addListener(
this, endfilekey, 0);
113 msg(MSG::DEBUG) <<
"Added listener on "<<endfilekey <<
endmsg;
124 if (!
m_vp1gui->argumentsAreValid()) {
128 return StatusCode::FAILURE;
130 return StatusCode::SUCCESS;
141 msg(MSG::DEBUG) <<
" in execute() " <<
endmsg;
144 return StatusCode::FAILURE;
153 unsigned int trigType = 0;
157 StatusCode status =
evtStore()->retrieve (eventInfo,
"EventInfo");
159 if(status.isSuccess()) {
161 const unsigned long long eventNumber = eventInfo->
eventNumber();
162 const uint32_t runNumber = eventInfo->
runNumber();
163 msg(MSG::DEBUG) <<
" Got run number = " << runNumber
164 <<
", event number = " << eventNumber <<
endmsg;
171 if (
m_noGui||
m_vp1gui->executeNewEvent(runNumber,eventNumber,trigType,time)) {
172 return StatusCode::SUCCESS;
174 msg(MSG::INFO) <<
" Ending application gracefully." <<
endmsg;
175 return StatusCode::FAILURE;
177 return StatusCode::SUCCESS;
180 msg(MSG::DEBUG) <<
" Unable to retrieve EventInfo from StoreGate... using dummy values" <<
endmsg;
183 return StatusCode::SUCCESS;
185 msg(MSG::INFO) <<
" Ending application gracefully." <<
endmsg;
186 return StatusCode::FAILURE;
189 return StatusCode::SUCCESS;
196 msg(MSG::INFO) <<
" in finalize() " <<
endmsg;
199 return StatusCode::FAILURE;
205 return StatusCode::SUCCESS;
211 msg(MSG::INFO) <<
"Handling incident '" << inc.type() <<
"'" <<
endmsg;
214 msg(MSG::INFO) <<
"Aborting due to null VP1Gui pointer." <<
endmsg;
218 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
220 msg(MSG::WARNING) <<
" Unable to cast to file incident" <<
endmsg;
224 msg(MSG::DEBUG) <<
" Casting to file incident successful" <<
endmsg;
228 StatusCode
sc = pEvtSelector.retrieve();
230 if(!
sc.isSuccess() || 0 == pEvtSelector) {
231 msg(MSG::WARNING) <<
"Could not find EventSelector" <<
endmsg;
235 msg(MSG::DEBUG) <<
" Got EventSelector" <<
endmsg;
237 IProperty* propertyServer =
dynamic_cast<IProperty*
>(pEvtSelector.operator->());
238 if (!propertyServer) {
239 msg(MSG::WARNING) <<
"Could not get propertyServer" <<
endmsg;
243 std::vector<std::string> vect;
244 StringArrayProperty inputCollections(
"InputCollections", vect);
246 sc = propertyServer->getProperty(&inputCollections);
247 if(!
sc.isSuccess()) {
248 msg(MSG::INFO) <<
"Could not get InputCollections property" <<
endmsg;
252 msg(MSG::DEBUG) <<
" Got InputCollections property" <<
endmsg;
254 for (
const std::string& s : inputCollections.value()) {
255 if(s != fileInc->fileName())
260 std::string strNewFileName =
m_vp1gui->nextRequestedEventFile();
262 if (strNewFileName.empty())
265 msg(MSG::WARNING) <<
" File requested by VP1 does not exists or is not readable: "<<strNewFileName<<
". Ending." <<
endmsg;
269 vect.push_back(strNewFileName);
270 msg(MSG::INFO) <<
" Setting next event file: " << strNewFileName<<
endmsg;
273 std::vector<std::string> strNewFileNames =
m_vp1gui->userRequestedFiles();
274 for(
unsigned i=0; i<strNewFileNames.size(); ++i) {
275 const std::string& strNewFileName = strNewFileNames[i];
276 if (strNewFileName.empty())
279 msg(MSG::WARNING) <<
" File requested by VP1 does not exists or is not readable: " << strNewFileName <<
endmsg;
282 vect.push_back(strNewFileName);
283 msg(MSG::INFO) <<
" Setting next event file: " << strNewFileName<<
endmsg;
287 StringArrayProperty newInputCollections(
"InputCollections", vect);
289 if(propertyServer->setProperty(newInputCollections)!=StatusCode::SUCCESS)
290 msg(MSG::WARNING) <<
"Could not set new InputCollections property" <<
endmsg;
292 msg(MSG::DEBUG) <<
" InputCollections property set" <<
endmsg;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
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
ToolHandle< Trk::IExtrapolator > m_extrapolator
Gaudi::Property< bool > m_mfOn
Gaudi::Property< bool > m_vp1Conf_emptyInput
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
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
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.