Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 08:37:52

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/Logger.hpp"
0012 #include "ActsExamples/Framework/ProcessCode.hpp"
0013 #include "ActsExamples/Framework/SequenceElement.hpp"
0014 
0015 #include <memory>
0016 #include <string>
0017 
0018 namespace ActsExamples {
0019 
0020 /// Event processing algorithm interface.
0021 ///
0022 /// This class provides default implementations for most interface methods and
0023 /// and adds a default logger that can be used directly in subclasses.
0024 /// Algorithm implementations only need to implement the `execute` method.
0025 class IAlgorithm : public SequenceElement {
0026  public:
0027   /// Constructor
0028   ///
0029   /// @name The algorithm name
0030   /// @level The logging level for this algorithm
0031   /// @deprecated Use the constructor with a logger instead
0032   [[deprecated("Use the constructor with a logger instead")]]
0033   explicit IAlgorithm(const std::string& name, Acts::Logging::Level level);
0034 
0035   /// Constructor
0036   ///
0037   /// @name The algorithm name
0038   /// @logger The logger for this algorithm
0039   explicit IAlgorithm(const std::string& name,
0040                       std::unique_ptr<const Acts::Logger> logger = nullptr);
0041 
0042   /// The algorithm name.
0043   std::string name() const override;
0044 
0045   /// Execute the algorithm for one event.
0046   ///
0047   /// This function must be implemented by subclasses.
0048   virtual ProcessCode execute(const AlgorithmContext& context) const = 0;
0049 
0050   /// Internal execute method forwards to the algorithm execute method as const
0051   /// @param context The algorithm context
0052   ProcessCode internalExecute(const AlgorithmContext& context) final;
0053 
0054   /// Initialize the algorithm
0055   ProcessCode initialize() override { return ProcessCode::SUCCESS; }
0056   /// Finalize the algorithm
0057   ProcessCode finalize() override { return ProcessCode::SUCCESS; }
0058 
0059   std::string_view typeName() const override { return "Algorithm"; }
0060 
0061  protected:
0062   const Acts::Logger& logger() const { return *m_logger; }
0063 
0064  private:
0065   std::string m_name;
0066   std::unique_ptr<const Acts::Logger> m_logger;
0067 };
0068 
0069 }  // namespace ActsExamples