Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-15 07:57:14

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 "ActsExamples/Io/EDM4hep/EDM4hepTrackInputConverter.hpp"
0010 
0011 #include "Acts/Plugins/EDM4hep/EDM4hepUtil.hpp"
0012 #include "ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp"
0013 
0014 #include <stdexcept>
0015 
0016 #include <edm4hep/TrackCollection.h>
0017 #include <podio/Frame.h>
0018 
0019 namespace ActsExamples {
0020 
0021 EDM4hepTrackInputConverter::EDM4hepTrackInputConverter(
0022     const Config& config, Acts::Logging::Level level)
0023     : EDM4hepInputConverter("EDM4hepTrackInputConverter", level,
0024                             config.inputFrame),
0025       m_cfg(config) {
0026   m_outputTracks.initialize(m_cfg.outputTracks);
0027 }
0028 
0029 ProcessCode EDM4hepTrackInputConverter::convert(
0030     const AlgorithmContext& ctx, const podio::Frame& frame) const {
0031   const auto& trackCollection =
0032       frame.get<edm4hep::TrackCollection>(m_cfg.inputTracks);
0033 
0034   auto trackContainer = std::make_shared<Acts::VectorTrackContainer>();
0035   auto trackStateContainer = std::make_shared<Acts::VectorMultiTrajectory>();
0036   TrackContainer tracks(trackContainer, trackStateContainer);
0037 
0038   for (const auto& inputTrack : trackCollection) {
0039     auto track = tracks.makeTrack();
0040     Acts::EDM4hepUtil::readTrack(inputTrack, track, m_cfg.Bz);
0041   }
0042 
0043   ConstTrackContainer constTracks{
0044       std::make_shared<Acts::ConstVectorTrackContainer>(
0045           std::move(*trackContainer)),
0046       std::make_shared<Acts::ConstVectorMultiTrajectory>(
0047           std::move(*trackStateContainer))};
0048 
0049   m_outputTracks(ctx, std::move(constTracks));
0050 
0051   return ProcessCode::SUCCESS;
0052 }
0053 
0054 }  // namespace ActsExamples