File indexing completed on 2024-11-15 09:38:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #pragma once
0012
0013 #include <Gaudi/Property.h>
0014 #include <Gaudi/Sequence.h>
0015 #include <mutex>
0016
0017 namespace Gaudi {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 class GAUDI_API Sequencer : public Gaudi::Sequence {
0029 public:
0030 using Gaudi::Sequence::Sequence;
0031
0032
0033
0034
0035
0036
0037
0038
0039 StatusCode initialize() override;
0040
0041
0042 StatusCode reinitialize() override;
0043
0044
0045 StatusCode start() override;
0046
0047
0048 StatusCode execute( const EventContext& ctx ) const override;
0049
0050
0051 StatusCode stop() override;
0052
0053
0054 StatusCode finalize() override;
0055
0056
0057 bool branchFilterPassed( const EventContext& ctx ) const;
0058
0059
0060 void setBranchFilterPassed( const EventContext& ctx, bool state ) const;
0061
0062
0063 StatusCode append( Gaudi::Algorithm* pAlgorithm );
0064
0065
0066 StatusCode appendToBranch( Gaudi::Algorithm* pAlgorithm );
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 StatusCode createAndAppend( const std::string& type,
0079 const std::string& name,
0080 Gaudi::Algorithm*& pAlgorithm
0081 );
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 StatusCode createAndAppendToBranch( const std::string& type,
0093 const std::string& name,
0094 Gaudi::Algorithm*& pAlgorithm
0095
0096 );
0097
0098
0099 StatusCode remove( Gaudi::Algorithm* pAlgorithm );
0100 StatusCode remove( const std::string& name );
0101 StatusCode removeFromBranch( Gaudi::Algorithm* pAlgorithm );
0102 StatusCode removeFromBranch( const std::string& name );
0103
0104
0105
0106
0107
0108
0109
0110
0111 const std::vector<Gaudi::Algorithm*>& branchAlgorithms() const;
0112 std::vector<Gaudi::Algorithm*>& branchAlgorithms();
0113
0114
0115 StatusCode decodeMemberNames();
0116
0117
0118 StatusCode decodeBranchMemberNames();
0119
0120 protected:
0121
0122
0123
0124 StatusCode append( Gaudi::Algorithm* pAlgorithm, std::vector<Gaudi::Algorithm*>& theAlgs );
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 StatusCode createAndAppend( const std::string& type,
0136 const std::string& name,
0137 Gaudi::Algorithm*& pAlgorithm,
0138 std::vector<Gaudi::Algorithm*>& theAlgs );
0139
0140
0141
0142
0143 StatusCode decodeNames( Gaudi::Property<std::vector<std::string>>& theNames,
0144 std::vector<Gaudi::Algorithm*>& theAlgs, std::vector<bool>& theLogic );
0145
0146
0147
0148
0149 StatusCode execute( const EventContext& ctx, const std::vector<Gaudi::Algorithm*>& theAlgs,
0150 const std::vector<bool>& theLogic, Gaudi::Algorithm*& lastAlgorithm,
0151 std::size_t first = 0 ) const;
0152
0153
0154
0155
0156 StatusCode executeMember( Gaudi::Algorithm* theAlgorithm, const EventContext& context ) const;
0157
0158
0159
0160
0161
0162 StatusCode remove( const std::string& algname, std::vector<Gaudi::Algorithm*>& theAlgs );
0163
0164
0165 Sequencer( const Sequencer& a ) = delete;
0166 Sequencer& operator=( const Sequencer& rhs ) = delete;
0167
0168 public:
0169
0170 std::ostream& toControlFlowExpression( std::ostream& os ) const override;
0171
0172 private:
0173 Gaudi::Property<std::vector<std::string>> m_names{ this,
0174 "Members",
0175 {},
0176 [this]( auto& ) {
0177 if ( this->isInitialized() )
0178 this->decodeMemberNames().ignore();
0179 },
0180 "member names",
0181 "vector<Algorithm>" };
0182 Gaudi::Property<std::vector<std::string>> m_branchNames{ this,
0183 "BranchMembers",
0184 {},
0185 [this]( auto& ) {
0186 if ( this->isInitialized() )
0187 this->decodeBranchMemberNames().ignore();
0188 },
0189 "branch member names",
0190 "vector<Algorithm>" };
0191
0192 Gaudi::Property<bool> m_shortCircuit{ this, "ShortCircuit", true, "stop processing as soon as possible" };
0193 Gaudi::Property<bool> m_sequential{ this, "Sequential", false, "execute members one at a time" };
0194 Gaudi::Property<bool> m_modeOR{ this, "ModeOR", false, "use OR logic instead of AND" };
0195 Gaudi::Property<bool> m_ignoreFilter{ this, "IgnoreFilterPassed", false, "always continue" };
0196 Gaudi::Property<bool> m_invert{ this, "Invert", false, "invert the logic result of the sequencer" };
0197
0198 Gaudi::Property<std::vector<std::string>> m_vetoObjs{
0199 this, "VetoObjects", {}, "skip execute if one or more of these TES objects exist" };
0200 Gaudi::Property<std::vector<std::string>> m_requireObjs{
0201 this, "RequireObjects", {}, "execute only if one or more of these TES objects exist" };
0202
0203 std::vector<bool> m_isInverted;
0204 std::vector<Gaudi::Algorithm*> m_branchAlgs;
0205 std::vector<bool> m_isBranchInverted;
0206
0207 mutable std::mutex m_branchFilterMutex;
0208 mutable std::map<EventContext::ContextID_t, bool> m_branchFilterPassed;
0209 };
0210 }