Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EDM4hepMultiTrajectoryWriter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EDM4hepMultiTrajectoryWriter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 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 
14 
15 #include <stdexcept>
16 
17 #include <edm4hep/TrackCollection.h>
18 #include <podio/Frame.h>
19 
20 namespace ActsExamples {
21 
26  "EDM4hepMultiTrajectoryWriter", level),
27  m_cfg(config),
28  m_writer(config.outputPath) {
29  if (m_cfg.inputTrajectories.empty()) {
30  throw std::invalid_argument("Missing input trajectories collection");
31  }
32 
33  if (m_cfg.inputMeasurementParticlesMap.empty()) {
34  throw std::invalid_argument{"Missing input hit to particle map"};
35  }
36 
38 }
39 
41  m_writer.finish();
42 
43  return ProcessCode::SUCCESS;
44 }
45 
47  const AlgorithmContext& context,
48  const TrajectoriesContainer& trajectories) {
49  podio::Frame frame{};
50 
51  const auto& hitParticlesMap = m_inputMeasurementParticlesMap(context);
52 
53  edm4hep::TrackCollection trackCollection;
54 
55  for (const auto& from : trajectories) {
56  for (const auto& trackTip : from.tips()) {
57  auto to = trackCollection.create();
59  trackTip, m_cfg.particleHypothesis,
60  hitParticlesMap);
61  }
62  }
63 
64  frame.put(std::move(trackCollection), "ActsTracks");
65 
66  m_writer.writeFrame(frame, "events");
67 
68  return ProcessCode::SUCCESS;
69 }
70 
71 } // namespace ActsExamples