EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HelloWhiteBoardAlgorithm.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HelloWhiteBoardAlgorithm.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 
13 #include "HelloData.hpp"
14 
16  const Config& cfg, Acts::Logging::Level level)
17  : ActsExamples::BareAlgorithm("HelloWhiteBoard", level), m_cfg(cfg) {
18  // non-optional config settings must be checked on construction.
19  if (m_cfg.input.empty()) {
20  throw std::invalid_argument("Missing input collection");
21  }
22  if (m_cfg.output.empty()) {
23  throw std::invalid_argument("Missing output collection");
24  }
25 }
26 
28  const ActsExamples::AlgorithmContext& ctx) const {
29  // event-store is append-only and always returns a const reference.
30  ACTS_INFO("Reading HelloDataCollection " << m_cfg.input);
31  const auto& in = ctx.eventStore.get<HelloDataCollection>(m_cfg.input);
32  ACTS_VERBOSE("Read HelloDataCollection with size " << in.size());
33 
34  // create a copy
35  HelloDataCollection copy(in);
36 
37  // transfer the copy to the event store. this always transfers ownership
38  // via r-value reference/ move construction.
39  ACTS_INFO("Writing HelloDataCollection " << m_cfg.output);
40  ctx.eventStore.add(m_cfg.output, std::move(copy));
41 
43 }