The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
Sequencer.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13#include <Gaudi/Property.h>
14#include <Gaudi/Sequence.h>
15#include <mutex>
16
17namespace Gaudi {
29 public:
30 using Gaudi::Sequence::Sequence;
31
39 StatusCode initialize() override;
40
42 StatusCode reinitialize() override;
43
45 StatusCode start() override;
46
48 StatusCode execute( const EventContext& ctx ) const override;
49
51 StatusCode stop() override;
52
54 StatusCode finalize() override;
55
57 bool branchFilterPassed( const EventContext& ctx ) const;
58
60 void setBranchFilterPassed( const EventContext& ctx, bool state ) const;
61
63 StatusCode append( Gaudi::Algorithm* pAlgorithm );
64
67
78 StatusCode createAndAppend( const std::string& type, // The concrete algorithm class of the algorithm
79 const std::string& name, // The name to be given to the algorithm
80 Gaudi::Algorithm*& pAlgorithm // Set to point to the newly created algorithm object
81 );
82
92 StatusCode createAndAppendToBranch( const std::string& type, // The concrete algorithm class of the algorithm
93 const std::string& name, // The name to be given to the algorithm
94 Gaudi::Algorithm*& pAlgorithm // Set to point to the newly created algorithm
95 // object
96 );
97
99 StatusCode remove( Gaudi::Algorithm* pAlgorithm );
100 StatusCode remove( const std::string& name );
102 StatusCode removeFromBranch( const std::string& name );
103
111 const std::vector<Gaudi::Algorithm*>& branchAlgorithms() const;
112 std::vector<Gaudi::Algorithm*>& branchAlgorithms();
113
116
119
120 protected:
124 StatusCode append( Gaudi::Algorithm* pAlgorithm, std::vector<Gaudi::Algorithm*>& theAlgs );
125
135 StatusCode createAndAppend( const std::string& type, // The concrete algorithm class of the algorithm
136 const std::string& name, // The name to be given to the algorithm
137 Gaudi::Algorithm*& pAlgorithm, // Set to point to the newly created algorithm object
138 std::vector<Gaudi::Algorithm*>& theAlgs );
139
143 StatusCode decodeNames( Gaudi::Property<std::vector<std::string>>& theNames,
144 std::vector<Gaudi::Algorithm*>& theAlgs, std::vector<bool>& theLogic );
145
149 StatusCode execute( const EventContext& ctx, const std::vector<Gaudi::Algorithm*>& theAlgs,
150 const std::vector<bool>& theLogic, Gaudi::Algorithm*& lastAlgorithm,
151 std::size_t first = 0 ) const;
152
156 StatusCode executeMember( Gaudi::Algorithm* theAlgorithm, const EventContext& context ) const;
157
161
162 StatusCode remove( const std::string& algname, std::vector<Gaudi::Algorithm*>& theAlgs );
163
164 // NO COPY / ASSIGNMENT ALLOWED
165 Sequencer( const Sequencer& a ) = delete;
166 Sequencer& operator=( const Sequencer& rhs ) = delete;
167
168 public:
170 std::ostream& toControlFlowExpression( std::ostream& os ) const override;
171
172 private:
174 "Members",
175 {},
176 [this]( auto& ) {
177 if ( this->isInitialized() )
178 this->decodeMemberNames().ignore();
179 },
180 "member names",
181 "vector<Algorithm>" };
183 "BranchMembers",
184 {},
185 [this]( auto& ) {
186 if ( this->isInitialized() )
187 this->decodeBranchMemberNames().ignore();
188 },
189 "branch member names",
190 "vector<Algorithm>" };
191
192 Gaudi::Property<bool> m_shortCircuit{ this, "ShortCircuit", true, "stop processing as soon as possible" };
193 Gaudi::Property<bool> m_sequential{ this, "Sequential", false, "execute members one at a time" };
194 Gaudi::Property<bool> m_modeOR{ this, "ModeOR", false, "use OR logic instead of AND" };
195 Gaudi::Property<bool> m_ignoreFilter{ this, "IgnoreFilterPassed", false, "always continue" };
196 Gaudi::Property<bool> m_invert{ this, "Invert", false, "invert the logic result of the sequencer" };
197
199 this, "VetoObjects", {}, "skip execute if one or more of these TES objects exist" };
201 this, "RequireObjects", {}, "execute only if one or more of these TES objects exist" };
202
203 std::vector<bool> m_isInverted; // Member logic inverted list
204 std::vector<Gaudi::Algorithm*> m_branchAlgs; // Branch algorithms
205 std::vector<bool> m_isBranchInverted; // Branch Member logic inverted list
206
207 mutable std::mutex m_branchFilterMutex;
208 mutable std::map<EventContext::ContextID_t, bool> m_branchFilterPassed; // Branch filter passed flag
209 };
210} // namespace Gaudi
#define GAUDI_API
Definition Kernel.h:49
This class represents an entry point to all the event specific data.
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:87
const std::string & name() const override
The identifying name of the algorithm object.
const std::string & type() const override
The type of the algorithm object.
Definition Algorithm.h:162
bool isInitialized() const override
Has the Algorithm already been initialized?
Definition Algorithm.h:401
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
Gaudi::Property< bool > m_modeOR
Definition Sequencer.h:194
std::ostream & toControlFlowExpression(std::ostream &os) const override
Produce string representation of the control flow expression.
Gaudi::Property< bool > m_sequential
Definition Sequencer.h:193
void setBranchFilterPassed(const EventContext &ctx, bool state) const
Set the branch filter passed flag for the last event.
Gaudi::Property< std::vector< std::string > > m_branchNames
Definition Sequencer.h:182
StatusCode execute(const EventContext &ctx) const override
The actions to be performed by the sequencer on an event.
Definition Sequencer.cpp:71
StatusCode remove(Gaudi::Algorithm *pAlgorithm)
Remove the specified algorithm from the sequencer.
StatusCode decodeBranchMemberNames()
Decode branch member name list.
Gaudi::Property< std::vector< std::string > > m_names
Definition Sequencer.h:173
Gaudi::Property< bool > m_shortCircuit
Definition Sequencer.h:192
StatusCode finalize() override
Sequencer finalization.
StatusCode createAndAppendToBranch(const std::string &type, const std::string &name, Gaudi::Algorithm *&pAlgorithm)
Create a algorithm and append it to the sequencer branch.
StatusCode start() override
Sequencer finalization.
StatusCode decodeNames(Gaudi::Property< std::vector< std::string > > &theNames, std::vector< Gaudi::Algorithm * > &theAlgs, std::vector< bool > &theLogic)
Decode algorithm names, creating or appending algorithms as appropriate.
std::vector< bool > m_isBranchInverted
Definition Sequencer.h:205
StatusCode createAndAppend(const std::string &type, const std::string &name, Gaudi::Algorithm *&pAlgorithm)
Create a algorithm and append it to the sequencer.
StatusCode reinitialize() override
Sequencer Reinitialization.
Definition Sequencer.cpp:58
Sequencer & operator=(const Sequencer &rhs)=delete
Gaudi::Property< bool > m_invert
Definition Sequencer.h:196
std::mutex m_branchFilterMutex
Definition Sequencer.h:207
Sequencer(const Sequencer &a)=delete
const std::vector< Gaudi::Algorithm * > & branchAlgorithms() const
List of branch algorithms.
std::map< EventContext::ContextID_t, bool > m_branchFilterPassed
Definition Sequencer.h:208
StatusCode executeMember(Gaudi::Algorithm *theAlgorithm, const EventContext &context) const
Execute member algorithm.
StatusCode initialize() override
Initialization of a sequencer.
Definition Sequencer.cpp:28
std::vector< bool > m_isInverted
Definition Sequencer.h:203
Gaudi::Property< std::vector< std::string > > m_requireObjs
Definition Sequencer.h:200
std::vector< Gaudi::Algorithm * > m_branchAlgs
Definition Sequencer.h:204
StatusCode append(Gaudi::Algorithm *pAlgorithm)
Append an algorithm to the sequencer.
bool branchFilterPassed(const EventContext &ctx) const
Was the branch filter passed for the last event?
StatusCode stop() override
Sequencer stop.
StatusCode decodeMemberNames()
Decode Member Name list.
StatusCode removeFromBranch(Gaudi::Algorithm *pAlgorithm)
Gaudi::Property< bool > m_ignoreFilter
Definition Sequencer.h:195
StatusCode appendToBranch(Gaudi::Algorithm *pAlgorithm)
Append an algorithm to the sequencer branch.
Gaudi::Property< std::vector< std::string > > m_vetoObjs
Definition Sequencer.h:198
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1