6 #include "Gaudi/Property.h"
7 #include "GaudiKernel/IIncidentSvc.h"
8 #include "GaudiKernel/Incident.h"
9 #include "GaudiKernel/MsgStream.h"
15 ISvcLocator* pSvcLocator ) :
24 std::vector<std::string>
streams;
32 ATH_MSG_DEBUG(
"A trigger in stream " <<
tag.type() <<
"_" <<
tag.name() <<
" was fired in this event.");
33 std::string stream_fullname =
tag.type() +
"_" +
tag.name();
36 ATH_MSG_WARNING(
"You have not requested any specific streams, going to allow all streams");
37 streams.emplace_back(stream_fullname);
43 streams.emplace_back(stream_fullname);
45 bool isPublic =
false;
52 PyObject* pProjectTag = PyUnicode_FromString(
tag.c_str());
56 ATH_MSG_WARNING(
"Failed to create Python Unicode object from project tag");
59 PyObject* pHelper = PyImport_ImportModule(
"EventDisplaysOnline.EventDisplaysOnlineHelpers");
63 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventDisplaysOnlineHelpers module");
69 ATH_MSG_WARNING(
"Could not find or call EventCanBeSeenByPublic function in EventDisplaysOnline.EventDisplaysOnlineHelpers module");
78 isPublic = PyObject_IsTrue(
result);
85 Py_DECREF(pProjectTag);
94 ATH_MSG_DEBUG(
"streams where a trigger fired and in your desired streams list: " <<
stream);
121 PyObject* pDirectory = PyUnicode_FromString(cString);
122 PyObject* pArgs = PyTuple_Pack(4, pDirectory, pMaxEvents, pCheckPair,pBeamSplash);
123 PyObject* pModule = PyImport_ImportModule(
const_cast< char*
>(
"EventDisplaysOnline.EventUtils"));
124 if(!pCheckPair || !pBeamSplash || !pMaxEvents || !pDirectory || !pArgs){
129 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventUtils module");
131 ATH_MSG_DEBUG(
"Successfully imported EventDisplaysOnline.EventUtils module");
136 ATH_MSG_WARNING(
"Could not find or call cleanDirectory function in EventDisplaysOnline.EventUtils module");
138 ATH_MSG_DEBUG(
"Found cleanDirectory function in EventDisplaysOnline.EventUtils module");
142 if (PyErr_Occurred()) {
151 const char* JiveXMLFileName_cString = JiveXMLFileName.c_str();
152 PyObject* pJiveXMLFileName = PyUnicode_FromString(JiveXMLFileName_cString);
153 PyObject* pArgs_zip = PyTuple_Pack(2, pDirectory, pJiveXMLFileName);
157 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventUtils.zipXMLFile");
162 Py_DECREF(pJiveXMLFileName);
164 Py_DECREF(pArgs_zip);
168 Py_DECREF(pCheckPair);
169 Py_DECREF(pMaxEvents);
170 Py_DECREF(pDirectory);
186 const char* char_dir =
directory.c_str();
188 if (
access(char_dir, F_OK) == 0) {
189 struct stat directoryStat;
190 if (
stat(char_dir, &directoryStat) == 0 && S_ISDIR(directoryStat.st_mode) &&
191 access(char_dir, W_OK) == 0) {
193 if (directoryStat.st_gid != zpgid) {
195 chown(char_dir, -1, zpgid);
202 mkdir(char_dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
203 chown(char_dir, -1, zpgid);
205 }
catch (
const std::system_error&
err) {
206 std::cerr <<
"Failed to create output directory " <<
directory
207 <<
err.what() << std::endl;
214 struct group* zp_group = getgrnam(
"zp");
215 if (zp_group !=
nullptr) {
216 zpgid = zp_group->gr_gid;
218 ATH_MSG_DEBUG(
"If running on private machine, zp group might not exist. Just set to the likely value 1307.");
227 IIncidentSvc* incSvc =
nullptr;
228 ATH_CHECK( service(
"IncidentSvc",incSvc) );
229 ATH_MSG_DEBUG(
"You have requested to only output JiveXML and ESD files when a trigger in the following streams was fired: ");
236 incSvc->addListener(
this,
"BeginEvent");
237 incSvc->addListener(
this,
"StoreCleared");
241 return StatusCode::SUCCESS;
247 return StatusCode::SUCCESS;
251 ATH_MSG_DEBUG(
"Received incident " << incident.type() <<
" from " << incident.source() );
252 if ( incident.type() == IncidentType::BeginEvent && incident.source() ==
"BeginIncFiringAlg" ){
255 if ( incident.type() ==
"StoreCleared" && incident.source() ==
"StoreGateSvc" ){
266 return AthService::queryInterface(riid, ppvInterface);
269 return StatusCode::SUCCESS;