7#include "GaudiKernel/IIncidentSvc.h"
9#include "eformat/eformat.h"
11#include <boost/property_tree/json_parser.hpp>
14 : base_class(name, svc)
24 return StatusCode::SUCCESS;
35 m_efdfinterface_library = boost::dll::shared_library(full_libname, boost::dll::load_mode::type::search_system_folders | boost::dll::load_mode::type::rtld_global);
36 using cEventHandler = std::unique_ptr<daq::df_ef_interface::EventHandler> (
const boost::property_tree::ptree&);
37 std::function<cEventHandler> cs;
40 }
catch (std::exception & ex) {
41 ATH_MSG_ERROR(
"Cant load function createEventHandler. Are you trying to use incorrect library? - " << ex.what());
46 std::ostringstream oss;
47 boost::property_tree::write_json(oss, configTree,
true);
48 ATH_MSG_INFO(
"EFInterface configuration:\n" << oss.str());
51 }
catch (std::exception & ex) {
52 ATH_MSG_ERROR(
"Cant create EventHandler from DataSource library. Are you trying to use incorrect configuration? - " << ex.what());
60 catch (daq::df_ef_interface::CommunicationError & ex) {
61 ATH_MSG_ERROR(
"CommunicationError while opening EventHandler: " << ex.what());
64 catch (std::exception & ex) {
65 ATH_MSG_ERROR(
"Exception while opening EventHandler: " << ex.what());
69 ATH_MSG_ERROR(
"Unknown exception while opening EventHandler");
80 ATH_MSG_DEBUG(
"EventHandler is not initialized, probably I'm in the mother process.");
87 catch (daq::df_ef_interface::CommunicationError & ex) {
88 ATH_MSG_ERROR(
"CommunicationError while closing EventHandler: " << ex.what());
91 catch (std::exception & ex) {
92 ATH_MSG_ERROR(
"Exception while closing EventHandler: " << ex.what());
96 ATH_MSG_ERROR(
"Unknown exception while closing EventHandler");
100 ATH_MSG_INFO(
"EFInterfaceSvc Stopping. Event processing summary:");
104 return StatusCode::SUCCESS;
112 return StatusCode::SUCCESS;
117 eformat::read::FullEventFragment
ev(rawEventPtr.get());
119 bool accepted = ((
ev.nstream_tag() > 0)?
true:
false);
137 std::future<std::unique_ptr<uint32_t []>> future;
141 ATH_MSG_DEBUG(
"No pending getNext call, creating a new one");
151 if (status == std::future_status::ready) {
152 auto result = future.get();
153 rawEventPtr = std::move(
result);
158 rawEventPtr =
nullptr;
167 catch (daq::df_ef_interface::NoMoreEvents &ex){
171 catch (daq::df_ef_interface::CommunicationError &ex){
172 ATH_MSG_DEBUG(
"CommunicationError received from EFInterface, returning NO_EVENT");
175 catch (std::exception &ex){
176 ATH_MSG_ERROR(
"EFInterface: caught exception: \""<<ex.what()<<
"\" throwing!");
187 boost::property_tree::ptree configTree;
189 configTree.put(
"name",
"DFEFInterfaceSvc");
190 configTree.put(
"stride",
m_stride.value());
194 configTree.put(
"loopOverFiles",
m_loopOverFiles.value() ?
"true" :
"false");
197 boost::property_tree::ptree fileList;
198 for (
const std::string& fname :
m_files.value()) {
199 boost::property_tree::ptree fileNode;
200 fileNode.put(
"", fname);
201 fileList.push_back(std::make_pair(
"file", fileNode));
203 configTree.add_child(
"fileList", fileList);
205 boost::property_tree::ptree runParams;
208 runParams.put(
"beam_type",
m_beamType.value());
210 runParams.put(
"det_mask",
m_detMask.value());
212 runParams.put(
"stream",
m_stream.value());
214 configTree.add_child(
"RunParams", runParams);
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode EFInterfaceSvc::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
static const std::string & type()
Incident type.
Gaudi::Property< std::string > m_outputFileName
@ NO_EVENT
no event available
@ STOP
stop transition (no more events)
Gaudi::Property< int > m_getNextTimeout
std::queue< std::future< std::unique_ptr< uint32_t[]> > > m_getNextFuture
EFInterfaceSvc(const std::string &name, ISvcLocator *svc)
virtual StatusCode stop() override
virtual StatusCode finalize() override
Gaudi::Property< int > m_beamType
uint32_t m_acceptedEvents
Gaudi::Property< std::string > m_stream
Gaudi::Property< std::string > m_detMask
Gaudi::Property< int > m_triggerType
Gaudi::Property< int > m_numEvents
void eventDone(std::unique_ptr< uint32_t[]> rawEventPtr)
virtual Status getNext(std::unique_ptr< uint32_t[]> &rawEventPtr)
Gaudi::Property< std::string > m_interface_library_name
Gaudi::Property< bool > m_loopOverFiles
Gaudi::Property< std::vector< std::string > > m_files
Gaudi::Property< int > m_fileOffset
std::unique_ptr< daq::df_ef_interface::EventHandler > m_eventHandler
Gaudi::Property< int > m_runNumber
Gaudi::Property< std::string > m_T0_project_tag
Gaudi::Property< int > m_beamEnergy
boost::dll::shared_library m_efdfinterface_library
Library with the df_ef_interface implementation.
Gaudi::Property< int > m_lumiblock
virtual void handle(const Incident &incident) override
uint32_t m_processedEvents
Gaudi::Property< int > m_stride
std::mutex m_queueMutex
Mutex for future queue.
uint32_t m_rejectedEvents
Gaudi::Property< int > m_skipEvents
boost::property_tree::ptree prepInterfacePTree()