Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:33

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDISEQUENCER_H
0012 #define GAUDISEQUENCER_H 1
0013 
0014 // Include files
0015 // from Gaudi
0016 #include "GaudiAlg/GaudiAlg.h"
0017 #include "GaudiAlg/GaudiCommon.h"
0018 #include <Gaudi/Sequence.h>
0019 
0020 // Forward declarations
0021 class ISequencerTimerTool;
0022 
0023 /** @class GaudiSequencer GaudiSequencer.h
0024  *  Sequencer for executing several algorithms, stopping when one is faulty.
0025  *
0026  *  Default behaviour (ModeOR=False) is to execute all algorithms until one returns
0027  *  filterPassed() = False. If ShortCircuit is set to False, then all algorithms
0028  *  will be executed.
0029  *
0030  *  In OR mode, the logic is opposite. All algorithms until one returns
0031  *  filterPassed() = True. To then exit one must conter-intuitively set
0032  *  ShortCircuit to False. If the default value ShortCircuit=True is left
0033  *  then all algorithms will be executed.
0034  *
0035  *  @author Olivier Callot
0036  *  @date   2004-05-13
0037  */
0038 class GAUDI_API GaudiSequencer : public GaudiCommon<Gaudi::Sequence> {
0039 public:
0040   /// Standard constructor
0041   using GaudiCommon::GaudiCommon;
0042 
0043   StatusCode initialize() override;
0044   StatusCode execute( const EventContext& ctx ) const override;
0045   StatusCode sysExecute( const EventContext& ctx ) override;
0046 
0047   /// Produce string represention of the control flow expression.
0048   std::ostream& toControlFlowExpression( std::ostream& os ) const override;
0049 
0050 private:
0051   class AlgorithmEntry final {
0052   public:
0053     /// Standard constructor
0054     AlgorithmEntry( Gaudi::Algorithm* alg ) : m_algorithm( alg ) {}
0055 
0056     void setReverse( bool flag ) { m_reverse = flag; }
0057 
0058     Gaudi::Algorithm* algorithm() const { return m_algorithm; }
0059     bool              reverse() const { return m_reverse; }
0060     void              setTimer( int nb ) { m_timer = nb; }
0061     int               timer() const { return m_timer; }
0062 
0063   private:
0064     Gaudi::Algorithm* m_algorithm = nullptr; ///< Algorithm pointer
0065     bool              m_reverse   = false;   ///< Indicates that the flag has to be inverted
0066     int               m_timer     = 0;       ///< Timer number for this algorithm
0067   };
0068 
0069   /** Decode a vector of string. */
0070   StatusCode decodeNames();
0071 
0072   /** for asynchronous changes in the list of algorithms */
0073   void membershipHandler();
0074 
0075   Gaudi::Property<std::vector<std::string>> m_vetoObjs{
0076       this, "VetoObjects", {}, "skip execute if one or more of these TES objects exist" };
0077   Gaudi::Property<std::vector<std::string>> m_requireObjs{
0078       this, "RequireObjects", {}, "execute only if one or more of these TES objects exist" };
0079 
0080   Gaudi::Property<std::vector<std::string>> m_names = {
0081       this, "Members", {}, &GaudiSequencer::membershipHandler, "list of algorithms" };
0082   Gaudi::Property<bool> m_sequential   = { this, "Sequential", false, "execute members one at a time" };
0083   Gaudi::Property<bool> m_modeOR       = { this, "ModeOR", false, "use OR logic instead of AND" };
0084   Gaudi::Property<bool> m_ignoreFilter = { this, "IgnoreFilterPassed", false, "always continue" };
0085   Gaudi::Property<bool> m_measureTime  = { this, "MeasureTime", false, "measure time" };
0086   Gaudi::Property<bool> m_returnOK     = { this, "ReturnOK", false, "forces the sequencer to return a good status" };
0087   Gaudi::Property<bool> m_shortCircuit = { this, "ShortCircuit", true, "stop processing as soon as possible" };
0088   Gaudi::Property<bool> m_invert       = { this, "Invert", false, "invert the logic result of the sequencer" };
0089 
0090   std::vector<AlgorithmEntry> m_entries;             ///< List of algorithms to process.
0091   ISequencerTimerTool*        m_timerTool = nullptr; ///< Pointer to the timer tool
0092   int                         m_timer;               ///< Timer number for the sequencer
0093 };
0094 #endif // GAUDISEQUENCER_H