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");
169 const char* JiveXMLFileName_cString = JiveXMLFileName.c_str();
170 PyObject* pJiveXMLFileName = PyUnicode_FromString(JiveXMLFileName_cString);
171 PyObject* pArgs_zip = PyTuple_Pack(2, pDirectory, pJiveXMLFileName);
175 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventUtils.zipXMLFile");
179 if (anyNullPtr(pJiveXMLFileName,
zipXMLFile, pArgs_zip)){
180 throw std::runtime_error(
"OnlineEventDisplaysSvc::endEvent: Py_DECREF on nullptr argument");
182 Py_DECREF(pJiveXMLFileName);
184 Py_DECREF(pArgs_zip);
186 if (anyNullPtr(pModule, pArgs, pCheckPair, pMaxEvents, pDirectory)){
187 throw std::runtime_error(
"OnlineEventDisplaysSvc::endEvent: Py_DECREF on nullptr argument");
191 Py_DECREF(pCheckPair);
192 Py_DECREF(pMaxEvents);
193 Py_DECREF(pDirectory);
209 const char* char_dir =
directory.c_str();
211 if (
access(char_dir, F_OK) == 0) {
212 struct stat directoryStat;
213 if (
stat(char_dir, &directoryStat) == 0 && S_ISDIR(directoryStat.st_mode) &&
214 access(char_dir, W_OK) == 0) {
216 if (directoryStat.st_gid != zpgid) {
218 chown(char_dir, -1, zpgid);
225 auto rc =
mkdir(char_dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
229 rc = chown(char_dir, -1, zpgid);
234 }
catch (
const std::system_error&
err) {
243 struct group* grp_result;
245 (void)getgrnam_r(
"zp", &grp, buf,
sizeof(buf), &grp_result);
246 if (grp_result !=
nullptr) {
249 ATH_MSG_DEBUG(
"If running on private machine, zp group might not exist. Just set to the likely value 1307.");
260 ATH_MSG_DEBUG(
"You have requested to only output JiveXML and ESD files when a trigger in the following streams was fired: ");
267 incSvc->addListener(
this,
"BeginEvent");
268 incSvc->addListener(
this,
"StoreCleared");
272 return StatusCode::SUCCESS;
278 return StatusCode::SUCCESS;
282 ATH_MSG_DEBUG(
"Received incident " << incident.type() <<
" from " << incident.source() );
283 if ( incident.type() == IncidentType::BeginEvent && incident.source() ==
"BeginIncFiringAlg" ){
286 if ( incident.type() ==
"StoreCleared" && incident.source() ==
"StoreGateSvc" ){