6 #include "Gaudi/Property.h"
7 #include "GaudiKernel/IIncidentSvc.h"
8 #include "GaudiKernel/Incident.h"
9 #include "GaudiKernel/MsgStream.h"
13 #include <sys/types.h>
23 template<
typename ...Ptr>
25 anyNullPtr(Ptr&&...
p){
26 return ((
p==
nullptr) or ...);
31 ISvcLocator* pSvcLocator ) :
32 base_class(
name, pSvcLocator){}
40 std::vector<std::string>
streams;
48 ATH_MSG_DEBUG(
"A trigger in stream " <<
tag.type() <<
"_" <<
tag.name() <<
" was fired in this event.");
49 std::string stream_fullname =
tag.type() +
"_" +
tag.name();
52 ATH_MSG_WARNING(
"You have not requested any specific streams, going to allow all streams");
53 streams.emplace_back(stream_fullname);
59 streams.emplace_back(stream_fullname);
61 bool isPublic =
false;
68 PyObject* pProjectTag = PyUnicode_FromString(
tag.c_str());
72 ATH_MSG_WARNING(
"Failed to create Python Unicode object from project tag");
75 PyObject* pHelper = PyImport_ImportModule(
"EventDisplaysOnline.EventDisplaysOnlineHelpers");
79 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventDisplaysOnlineHelpers module");
85 ATH_MSG_WARNING(
"Could not find or call EventCanBeSeenByPublic function in EventDisplaysOnline.EventDisplaysOnlineHelpers module");
94 isPublic = PyObject_IsTrue(
result);
101 Py_DECREF(pProjectTag);
104 streams.emplace_back(
"Public");
110 ATH_MSG_DEBUG(
"streams where a trigger fired and in your desired streams list: " <<
stream);
136 PyObject* pDirectory = PyUnicode_FromString(cString);
137 PyObject* pArgs = PyTuple_Pack(4, pDirectory, pMaxEvents, pCheckPair,pBeamSplash);
138 PyObject* pModule = PyImport_ImportModule(
const_cast< char*
>(
"EventDisplaysOnline.EventUtils"));
139 if(!pCheckPair || !pBeamSplash || !pMaxEvents || !pDirectory || !pArgs){
144 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventUtils module");
146 ATH_MSG_DEBUG(
"Successfully imported EventDisplaysOnline.EventUtils module");
151 ATH_MSG_WARNING(
"Could not find or call cleanDirectory function in EventDisplaysOnline.EventUtils module");
153 ATH_MSG_DEBUG(
"Found cleanDirectory function in EventDisplaysOnline.EventUtils module");
157 if (PyErr_Occurred()) {
162 throw std::runtime_error(
"OnlineEventDisplaysSvc::endEvent: Py_DECREF on nullptr argument");
167 if (anyNullPtr(pModule, pArgs, pCheckPair, pMaxEvents, pDirectory)){
168 throw std::runtime_error(
"OnlineEventDisplaysSvc::endEvent: Py_DECREF on nullptr argument");
172 Py_DECREF(pCheckPair);
173 Py_DECREF(pMaxEvents);
174 Py_DECREF(pDirectory);
190 const char* char_dir =
directory.c_str();
192 if (
access(char_dir, F_OK) == 0) {
193 struct stat directoryStat;
194 if (
stat(char_dir, &directoryStat) == 0 && S_ISDIR(directoryStat.st_mode) &&
195 access(char_dir, W_OK) == 0) {
197 if (directoryStat.st_gid != zpgid) {
199 chown(char_dir, -1, zpgid);
206 auto rc =
mkdir(char_dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
210 rc = chown(char_dir, -1, zpgid);
215 }
catch (
const std::system_error&
err) {
224 struct group* grp_result;
226 (void)getgrnam_r(
"zp", &grp, buf,
sizeof(buf), &grp_result);
227 if (grp_result !=
nullptr) {
230 ATH_MSG_DEBUG(
"If running on private machine, zp group might not exist. Just set to the likely value 1307.");
241 ATH_MSG_DEBUG(
"You have requested to only output JiveXML and ESD files when a trigger in the following streams was fired: ");
248 incSvc->addListener(
this,
"BeginEvent");
249 incSvc->addListener(
this,
"StoreCleared");
253 return StatusCode::SUCCESS;
259 return StatusCode::SUCCESS;
263 ATH_MSG_DEBUG(
"Received incident " << incident.type() <<
" from " << incident.source() );
264 if ( incident.type() == IncidentType::BeginEvent && incident.source() ==
"BeginIncFiringAlg" ){
267 if ( incident.type() ==
"StoreCleared" && incident.source() ==
"StoreGateSvc" ){