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;
106 ATH_MSG_WARNING(
"Stream name : " << stream <<
" already been registered!");
107 status = StatusCode::FAILURE;
110 std::vector<std::string> tmpvec;
112 ATH_MSG_INFO(
"Inserting stream: "<< stream <<
" with no Algs");
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) {
138 <<
" of stream " << stream
139 <<
" has already been registered!");
140 return StatusCode::FAILURE;
147 if(algexist ==
false){
148 std::vector<std::string> &tmpvec = it->second;
149 tmpvec.push_back(name);
154 std::vector<std::string> tmpvec;
155 tmpvec.push_back(name);
156 streamsModeMap[stream] = std::move(tmpvec);
159 return StatusCode::SUCCESS;
174 const std::string& stream)
185 const std::string& stream)
201const std::vector<std::string>
206 return std::vector<std::string>();
210const std::vector<std::string>
215 return std::vector<std::string>();
219const std::vector<std::string>
224 return std::vector<std::string>();
245 const EventContext& ectx)
const
248 ATH_MSG_DEBUG(
"In DecisionSvc::isEventAccepted( " << stream <<
" )");
253 bool found_accept =
false;
254 bool found_require =
false;
255 bool found_veto =
false;
262 const auto &vecAlgs = itAlgs->second;
267 if ( ! vecAlgs.empty( ) ) {
269 for (
auto it = vecAlgs.begin(); it != vecAlgs.end(); it++) {
271 isE = (
m_algstateSvc->algExecState(*it,ectx).state() == AlgExecState::State::Done);
284 found_require =
true;
286 const auto &vecAlgs = itAlgs->second;
291 if ( ! vecAlgs.empty( ) ) {
292 for (
auto it = vecAlgs.begin(); it != vecAlgs.end(); it++) {
294 isE = (
m_algstateSvc->algExecState(*it,ectx).state() == AlgExecState::State::Done);
309 const auto &vecAlgs = itAlgs->second;
314 if ( ! vecAlgs.empty( ) ) {
315 for (
auto it = vecAlgs.begin(); it != vecAlgs.end(); it++) {
317 isE = (
m_algstateSvc->algExecState(*it,ectx).state() == AlgExecState::State::Done);
327 if(found_accept ==
false && found_require ==
false && found_veto ==
false){
328 ATH_MSG_DEBUG(
"Stream: " << stream <<
" not found registered in DecisionSvc -- accepting event by default ");
337 CHECK( this->interpretAlgMap() );
341 auto teststreams = [](
const auto& m)
343 for (
const auto& p : m)
344 if (!p.second.empty())
return true;
349 if( teststreams(m_stream_accept) || teststreams(m_stream_require) || teststreams(m_stream_veto)) {
350 if (!m_cutflowSvc.empty())
352 if (m_cutflowSvc.retrieve().isFailure())
355 return StatusCode::RECOVERABLE;
361 return DeclareToCutFlowSvc();
369 for(
auto ait = m_streamNames.begin();
370 ait != m_streamNames.end(); ++ait) {
372 const std::vector<std::string> *accFilt=
nullptr;
373 const std::vector<std::string> *reqFilt=
nullptr;
374 const std::vector<std::string> *vetFilt=
nullptr;
375 std::vector< const std::vector<std::string>* > totFilt;
376 if (
auto itr = m_stream_accept.find(streamName); itr != m_stream_accept.end()) {
377 accFilt = &itr->second;
378 totFilt.push_back(accFilt);
380 if (
auto itr = m_stream_require.find(streamName); itr != m_stream_require.end()) {
381 reqFilt = &itr->second;
382 totFilt.push_back(reqFilt);
384 if (
auto itr = m_stream_veto.find(streamName); itr != m_stream_veto.end()) {
385 vetFilt = &itr->second;
386 totFilt.push_back(vetFilt);
391 std::string accstring(
""), reqstring(
""), vetstring(
"");
393 for (
auto it = accFilt->begin(); it != accFilt->end(); ++it) {
394 if(!accstring.empty()) accstring +=
"||";
395 else accstring +=
'(';
400 for (
auto it = reqFilt->begin(); it != reqFilt->end(); ++it) {
401 if(!reqstring.empty()) reqstring +=
"&&";
402 else reqstring +=
'(';
407 for (
auto it = vetFilt->begin(); it != vetFilt->end(); ++it) {
408 if(!vetstring.empty()) vetstring +=
"||";
409 else vetstring +=
'(';
413 std::string logicalKey(
"");
414 if(!accstring.empty()) {
416 logicalKey += accstring;
418 if(!reqstring.empty()) {
420 if (!logicalKey.empty()) logicalKey +=
"&&";
421 logicalKey += reqstring;
423 if(!vetstring.empty()) {
425 if (!logicalKey.empty()) logicalKey +=
"&&";
427 logicalKey += vetstring;
430 if (logicalKey.empty()) logicalKey=
"PassThru";
431 ATH_MSG_DEBUG(
"stream " << streamName <<
" uses logic " << logicalKey);
434 for(
auto vec = totFilt.begin();
435 vec != totFilt.end(); ++
vec) {
436 ATH_MSG_DEBUG(
"Declaring logic " << logicalKey <<
" for " << streamName);
437 for (
auto filter = (*vec)->begin();
438 filter != (*vec)->end(); ++filter) {
439 if(!m_cutflowSvc.empty()) {m_cutflowSvc->registerTopFilter( (*filter), logicalKey, 2, streamName,
true ); }
444 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(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()