Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EDM4hepTrackWriter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EDM4hepTrackWriter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 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 
13 
14 #include <stdexcept>
15 
16 #include <edm4hep/TrackCollection.h>
17 #include <podio/Frame.h>
18 
19 namespace ActsExamples {
20 
23  : WriterT<ConstTrackContainer>(config.inputTracks, "EDM4hepTrackWriter",
24  level),
25  m_cfg(config),
26  m_writer(config.outputPath) {
27  if (m_cfg.inputTracks.empty()) {
28  throw std::invalid_argument("Missing input trajectories collection");
29  }
30 }
31 
33  m_writer.finish();
34 
35  return ProcessCode::SUCCESS;
36 }
37 
39  const ConstTrackContainer& tracks) {
40  podio::Frame frame{};
41 
42  edm4hep::TrackCollection trackCollection;
43 
44  for (const auto& from : tracks) {
45  auto to = trackCollection.create();
47  }
48 
49  frame.put(std::move(trackCollection), m_cfg.outputTracks);
50 
51  m_writer.writeFrame(frame, "events");
52 
53  return ProcessCode::SUCCESS;
54 }
55 
56 } // namespace ActsExamples