Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:49

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 #include "HelloWhiteBoardAlgorithm.hpp"
0010 
0011 #include "ActsExamples/Framework/WhiteBoard.hpp"
0012 
0013 #include "HelloData.hpp"
0014 
0015 ActsExamples::HelloWhiteBoardAlgorithm::HelloWhiteBoardAlgorithm(
0016     const Config& cfg, Acts::Logging::Level level)
0017     : ActsExamples::IAlgorithm("HelloWhiteBoard", level), m_cfg(cfg) {
0018   // non-optional config settings must be checked on construction.
0019   if (m_cfg.input.empty()) {
0020     throw std::invalid_argument("Missing input collection");
0021   }
0022   m_readHandle.initialize(m_cfg.input);
0023   if (m_cfg.output.empty()) {
0024     throw std::invalid_argument("Missing output collection");
0025   }
0026   m_writeHandle.initialize(m_cfg.output);
0027 }
0028 
0029 ActsExamples::ProcessCode ActsExamples::HelloWhiteBoardAlgorithm::execute(
0030     const ActsExamples::AlgorithmContext& ctx) const {
0031   // event-store is append-only and always returns a const reference.
0032   ACTS_INFO("Reading HelloDataCollection " << m_cfg.input);
0033   const auto& in = m_readHandle(ctx);
0034   ACTS_VERBOSE("Read HelloDataCollection with size " << in.size());
0035 
0036   // create a copy
0037   HelloDataCollection copy(in);
0038 
0039   // transfer the copy to the event store. this always transfers ownership
0040   // via r-value reference/ move construction.
0041   ACTS_INFO("Writing HelloDataCollection " << m_cfg.output);
0042   m_writeHandle(ctx, std::move(copy));
0043 
0044   return ActsExamples::ProcessCode::SUCCESS;
0045 }