8#include "GaudiKernel/EventContext.h"
13 ISvcLocator* pSvcLocator ) :
14 base_class(name, pSvcLocator),
52 return StatusCode::SUCCESS;
60 return StatusCode::SUCCESS;
66 StatusCode status = StatusCode::SUCCESS;
69 std::set<std::string> uniStreams;
74 uniStreams.insert(iter->first);
79 uniStreams.insert(iter->first);
84 uniStreams.insert(iter->first);
86 std::copy(uniStreams.begin(),uniStreams.end(),std::back_inserter(
m_streamNames));
100 StatusCode status = StatusCode::SUCCESS;
107 status = StatusCode::FAILURE;
110 std::vector<std::string> tmpvec;
112 ATH_MSG_INFO(
"Inserting stream: {} with no Algs", stream);
114 status = StatusCode::SUCCESS;
122 const std::string& name,
const std::string& stream)
125 std::map<std::string, std::vector<std::string> >
::iterator it = streamsModeMap.find(stream);
126 if(it != streamsModeMap.end()){
130 bool algexist =
false;
132 for(
auto vit = (it->second).begin();
133 vit != (it->second).end(); ++vit) {
137 ATH_MSG_ERROR(
"Alg name : {} of stream {} has already been registered!",
139 return StatusCode::FAILURE;
146 if(algexist ==
false){
147 std::vector<std::string> &tmpvec = it->second;
148 tmpvec.push_back(name);
153 std::vector<std::string> tmpvec;
154 tmpvec.push_back(name);
155 streamsModeMap[stream] = std::move(tmpvec);
158 return StatusCode::SUCCESS;
173 const std::string& stream)
184 const std::string& stream)
200const std::vector<std::string>
205 return std::vector<std::string>();
209const std::vector<std::string>
214 return std::vector<std::string>();
218const std::vector<std::string>
223 return std::vector<std::string>();
244 const EventContext& ectx)
const
247 ATH_MSG_DEBUG(
"In DecisionSvc::isEventAccepted( {} )", stream);
252 bool found_accept =
false;
253 bool found_require =
false;
254 bool found_veto =
false;
261 const auto &vecAlgs = itAlgs->second;
266 if ( ! vecAlgs.empty( ) ) {
268 for (
auto it = vecAlgs.begin(); it != vecAlgs.end(); it++) {
270 isE = (
m_algstateSvc->algExecState(*it,ectx).state() == AlgExecState::State::Done);
283 found_require =
true;
285 const auto &vecAlgs = itAlgs->second;
290 if ( ! vecAlgs.empty( ) ) {
291 for (
auto it = vecAlgs.begin(); it != vecAlgs.end(); it++) {
293 isE = (
m_algstateSvc->algExecState(*it,ectx).state() == AlgExecState::State::Done);
308 const auto &vecAlgs = itAlgs->second;
313 if ( ! vecAlgs.empty( ) ) {
314 for (
auto it = vecAlgs.begin(); it != vecAlgs.end(); it++) {
316 isE = (
m_algstateSvc->algExecState(*it,ectx).state() == AlgExecState::State::Done);
326 if(found_accept ==
false && found_require ==
false && found_veto ==
false){
327 ATH_MSG_DEBUG(
"Stream: {} not found registered in DecisionSvc -- accepting event by default ", stream);
336 CHECK( this->interpretAlgMap() );
340 auto teststreams = [](
const auto& m)
342 for (
const auto& p : m)
343 if (!p.second.empty())
return true;
348 if( teststreams(m_stream_accept) || teststreams(m_stream_require) || teststreams(m_stream_veto)) {
349 if (!m_cutflowSvc.empty())
351 if (m_cutflowSvc.retrieve().isFailure())
354 return StatusCode::RECOVERABLE;
360 return DeclareToCutFlowSvc();
368 for(
auto ait = m_streamNames.begin();
369 ait != m_streamNames.end(); ++ait) {
371 const std::vector<std::string> *accFilt=
nullptr;
372 const std::vector<std::string> *reqFilt=
nullptr;
373 const std::vector<std::string> *vetFilt=
nullptr;
374 std::vector< const std::vector<std::string>* > totFilt;
375 if (
auto itr = m_stream_accept.find(streamName); itr != m_stream_accept.end()) {
376 accFilt = &itr->second;
377 totFilt.push_back(accFilt);
379 if (
auto itr = m_stream_require.find(streamName); itr != m_stream_require.end()) {
380 reqFilt = &itr->second;
381 totFilt.push_back(reqFilt);
383 if (
auto itr = m_stream_veto.find(streamName); itr != m_stream_veto.end()) {
384 vetFilt = &itr->second;
385 totFilt.push_back(vetFilt);
390 std::string accstring(
""), reqstring(
""), vetstring(
"");
392 for (
auto it = accFilt->begin(); it != accFilt->end(); ++it) {
393 if(!accstring.empty()) accstring +=
"||";
394 else accstring +=
'(';
399 for (
auto it = reqFilt->begin(); it != reqFilt->end(); ++it) {
400 if(!reqstring.empty()) reqstring +=
"&&";
401 else reqstring +=
'(';
406 for (
auto it = vetFilt->begin(); it != vetFilt->end(); ++it) {
407 if(!vetstring.empty()) vetstring +=
"||";
408 else vetstring +=
'(';
412 std::string logicalKey(
"");
413 if(!accstring.empty()) {
415 logicalKey += accstring;
417 if(!reqstring.empty()) {
419 if (!logicalKey.empty()) logicalKey +=
"&&";
420 logicalKey += reqstring;
422 if(!vetstring.empty()) {
424 if (!logicalKey.empty()) logicalKey +=
"&&";
426 logicalKey += vetstring;
429 if (logicalKey.empty()) logicalKey=
"PassThru";
430 ATH_MSG_DEBUG(
"stream {} uses logic {}", streamName, logicalKey);
433 for(
auto vec = totFilt.begin();
434 vec != totFilt.end(); ++
vec) {
435 ATH_MSG_DEBUG(
"Declaring logic {} for {}", logicalKey, streamName);
436 for (
auto filter = (*vec)->begin();
437 filter != (*vec)->end(); ++filter) {
438 if(!m_cutflowSvc.empty()) {m_cutflowSvc->registerTopFilter( (*filter), logicalKey, 2, streamName,
true ); }
443 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
std::vector< size_t > vec
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode DecisionSvc::start ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
An AttributeList represents a logical row of attributes in a metadata table.
std::map< std::string, std::vector< std::string > > m_stream_accept
Maps of streams – algorithm names' vectors.
virtual StatusCode finalize() override
virtual StatusCode addRequireAlg(const std::string &name, const std::string &stream) override
Add an algorithm to the list of RequireAlgs of a stream.
virtual const std::vector< std::string > getAcceptAlgs(const std::string &stream) const override
Return list of AcceptAlg names.
virtual ~DecisionSvc()
Destructor.
ServiceHandle< StoreGateSvc > m_evtStore
ServiceHandle< ICutFlowSvc > m_cutflowSvc
std::vector< std::string > m_streamNames
virtual StatusCode addAcceptAlg(const std::string &name, const std::string &stream) override
Add an algorithm to the list of AcceptAlgs of a stream.
DecisionSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode addVetoAlg(const std::string &name, const std::string &stream) override
Add an algorithm to the list of VetoAlgs of a stream.
virtual StatusCode initialize() override
Gaudi Service Implementation.
virtual const std::vector< std::string > getVetoAlgs(const std::string &stream) const override
Return list of VetoAlg names.
std::map< std::string, std::vector< std::string > > m_stream_require
std::map< std::string, std::vector< std::string > > m_stream_veto
virtual StatusCode addStream(const std::string &stream) override
Add a stream.
virtual bool isEventAccepted(const std::string &stream) const override
Test whether this event should be output.
virtual const std::vector< std::string > getRequireAlgs(const std::string &stream) const override
Return list of RequireAlg names.
virtual const std::vector< std::string > getStreams() const override
Return list of Streams.
StatusCode fillMap(std::map< std::string, std::vector< std::string > > &streamsModeMap, const std::string &name, const std::string &stream)
ServiceHandle< IAlgExecStateSvc > m_algstateSvc
StatusCode interpretAlgMap()
::StatusCode StatusCode
StatusCode definition for legacy code.