File indexing completed on 2026-08-17 08:36:52
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Utilities/Logger.hpp"
0012 #include "ActsExamples/Framework/DataHandle.hpp"
0013 #include "ActsExamples/Framework/IAlgorithm.hpp"
0014 #include "ActsExamples/Framework/IContextDecorator.hpp"
0015 #include "ActsExamples/Framework/IReader.hpp"
0016 #include "ActsExamples/Framework/IWriter.hpp"
0017 #include "ActsExamples/Framework/SequenceElement.hpp"
0018 #include "ActsExamples/Framework/WhiteBoard.hpp"
0019 #include "ActsExamples/Utilities/tbbWrap.hpp"
0020 #include "ActsPlugins/FpeMonitoring/FpeMonitor.hpp"
0021
0022 #include <cstddef>
0023 #include <memory>
0024 #include <optional>
0025 #include <stdexcept>
0026 #include <string>
0027 #include <utility>
0028 #include <vector>
0029
0030 #include <tbb/enumerable_thread_specific.h>
0031
0032 namespace ActsExamples {
0033
0034 using IterationCallback = void (*)();
0035
0036
0037 class FpeFailure : public std::runtime_error {
0038 using std::runtime_error::runtime_error;
0039 };
0040
0041 class SequenceConfigurationException : public std::runtime_error {
0042 public:
0043 explicit SequenceConfigurationException(const std::string &message)
0044 : std::runtime_error{"Sequence configuration error: " + message} {}
0045 };
0046
0047
0048
0049
0050
0051
0052 class Sequencer {
0053 public:
0054 struct FpeMask {
0055 std::string file;
0056 std::pair<std::size_t, std::size_t> lines;
0057 ActsPlugins::FpeType type{};
0058 std::size_t count = 0;
0059 };
0060
0061 struct Config {
0062
0063 std::size_t skip = 0;
0064
0065
0066 std::optional<std::size_t> events = std::nullopt;
0067
0068 Acts::Logging::Level logLevel = Acts::Logging::INFO;
0069
0070
0071 int numThreads = -1;
0072
0073 std::string outputDir;
0074
0075 std::string outputTimingFile = "timing.csv";
0076
0077
0078 IterationCallback iterationCallback = []() {};
0079
0080 bool trackFpes = true;
0081 std::vector<FpeMask> fpeMasks{};
0082 bool failOnFirstFpe = false;
0083 std::size_t fpeStackTraceLength = 8;
0084 };
0085
0086 explicit Sequencer(const Config &cfg);
0087
0088
0089
0090
0091 void addContextDecorator(std::shared_ptr<IContextDecorator> decorator);
0092
0093
0094
0095
0096 void addReader(std::shared_ptr<IReader> reader);
0097
0098
0099
0100
0101 void addAlgorithm(std::shared_ptr<IAlgorithm> algorithm);
0102
0103
0104
0105
0106 void addElement(const std::shared_ptr<SequenceElement> &element);
0107
0108
0109
0110
0111 void addWriter(std::shared_ptr<IWriter> writer);
0112
0113
0114 void addWhiteboardAlias(const std::string &aliasName,
0115 const std::string &objectName);
0116
0117 ActsPlugins::FpeMonitor::Result fpeResult() const;
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145 int run();
0146
0147
0148 const Config &config() const { return m_cfg; }
0149
0150 private:
0151
0152 std::vector<std::string> listAlgorithmNames() const;
0153
0154
0155
0156 std::pair<std::size_t, std::size_t> determineEventsRange() const;
0157
0158 std::pair<std::string, std::size_t> fpeMaskCount(
0159 const boost::stacktrace::stacktrace &st, ActsPlugins::FpeType type) const;
0160
0161 void fpeReport() const;
0162
0163 struct SequenceElementWithFpeResult {
0164 std::shared_ptr<SequenceElement> sequenceElement;
0165 std::unique_ptr<
0166 tbb::enumerable_thread_specific<ActsPlugins::FpeMonitor::Result>>
0167 fpeResult = std::make_unique<
0168 tbb::enumerable_thread_specific<ActsPlugins::FpeMonitor::Result>>();
0169 };
0170
0171 Config m_cfg;
0172 tbbWrap::task_arena m_taskArena;
0173 std::vector<std::shared_ptr<IContextDecorator>> m_decorators;
0174 std::vector<std::shared_ptr<IReader>> m_readers;
0175 std::vector<std::shared_ptr<IWriter>> m_writers;
0176 std::vector<SequenceElementWithFpeResult> m_sequenceElements;
0177 std::unique_ptr<const Acts::Logger> m_logger;
0178
0179 WhiteBoard::AliasMapType m_whiteboardObjectAliases;
0180
0181 DataHandleBase::StateMapType m_whiteBoardState;
0182
0183 std::atomic<std::size_t> m_nSkippedEvents = 0;
0184 std::atomic<std::size_t> m_nUnmaskedFpe = 0;
0185
0186 const Acts::Logger &logger() const { return *m_logger; }
0187 };
0188
0189 std::ostream &operator<<(std::ostream &os, const Sequencer::FpeMask &m);
0190
0191 }