File indexing completed on 2026-05-20 07:35:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/Csv/CsvTrackParameterReader.hpp"
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/Surfaces/PerigeeSurface.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "ActsExamples/EventData/Track.hpp"
0016 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0017 #include "ActsExamples/Io/Csv/CsvInputOutput.hpp"
0018 #include "ActsExamples/Utilities/Paths.hpp"
0019
0020 #include <stdexcept>
0021 #include <string>
0022
0023 #include "CsvOutputData.hpp"
0024
0025 namespace ActsExamples {
0026
0027 CsvTrackParameterReader::CsvTrackParameterReader(const Config& config,
0028 Acts::Logging::Level level)
0029 : m_cfg(config),
0030 m_eventsRange(
0031 determineEventFilesRange(m_cfg.inputDir, m_cfg.inputStem + ".csv")),
0032 m_logger(Acts::getDefaultLogger("CsvTrackParameterReader", level)) {
0033 if (m_cfg.inputStem.empty()) {
0034 throw std::invalid_argument("Missing input filename stem");
0035 }
0036 if (m_cfg.outputTrackParameters.empty()) {
0037 throw std::invalid_argument("Missing output collection");
0038 }
0039
0040 m_outputTrackParameters.initialize(m_cfg.outputTrackParameters);
0041 }
0042
0043 std::string CsvTrackParameterReader::CsvTrackParameterReader::name() const {
0044 return "CsvTrackParameterReader";
0045 }
0046
0047 std::pair<std::size_t, std::size_t> CsvTrackParameterReader::availableEvents()
0048 const {
0049 return m_eventsRange;
0050 }
0051
0052 ProcessCode CsvTrackParameterReader::read(const AlgorithmContext& ctx) {
0053 TrackParametersContainer trackParameters;
0054
0055 auto surface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
0056 Acts::Vector3(m_cfg.beamspot[0], m_cfg.beamspot[1], m_cfg.beamspot[2]));
0057
0058 auto path = perEventFilepath(m_cfg.inputDir, m_cfg.inputStem + ".csv",
0059 ctx.eventNumber);
0060 BoostDescribeCsvReader<TrackParameterData> reader(path);
0061 TrackParameterData d{};
0062
0063 while (reader.read(d)) {
0064 Acts::BoundVector params = Acts::BoundVector::Zero();
0065 params[Acts::eBoundLoc0] = d.d0;
0066 params[Acts::eBoundLoc1] = d.z0;
0067 params[Acts::eBoundPhi] = d.phi;
0068 params[Acts::eBoundTheta] = d.theta;
0069 params[Acts::eBoundQOverP] = d.qop;
0070
0071 Acts::BoundMatrix cov = Acts::BoundMatrix::Zero();
0072 cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = d.var_d0;
0073 cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = d.var_z0;
0074 cov(Acts::eBoundPhi, Acts::eBoundPhi) = d.var_phi;
0075 cov(Acts::eBoundTheta, Acts::eBoundTheta) = d.var_theta;
0076 cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = d.var_qop;
0077 cov(Acts::eBoundTime, Acts::eBoundTime) = 1;
0078
0079 cov(Acts::eBoundLoc0, Acts::eBoundLoc1) = d.cov_d0z0;
0080 cov(Acts::eBoundLoc0, Acts::eBoundPhi) = d.cov_d0phi;
0081 cov(Acts::eBoundLoc0, Acts::eBoundTheta) = d.cov_d0theta;
0082 cov(Acts::eBoundLoc0, Acts::eBoundQOverP) = d.cov_d0qop;
0083
0084 cov(Acts::eBoundLoc1, Acts::eBoundLoc0) = d.cov_z0d0;
0085 cov(Acts::eBoundLoc1, Acts::eBoundPhi) = d.cov_z0phi;
0086 cov(Acts::eBoundLoc1, Acts::eBoundTheta) = d.cov_z0theta;
0087 cov(Acts::eBoundLoc1, Acts::eBoundQOverP) = d.cov_z0qop;
0088
0089 cov(Acts::eBoundPhi, Acts::eBoundLoc0) = d.cov_phid0;
0090 cov(Acts::eBoundPhi, Acts::eBoundLoc1) = d.cov_phiz0;
0091 cov(Acts::eBoundPhi, Acts::eBoundTheta) = d.cov_phitheta;
0092 cov(Acts::eBoundPhi, Acts::eBoundQOverP) = d.cov_phiqop;
0093
0094 cov(Acts::eBoundTheta, Acts::eBoundLoc0) = d.cov_thetad0;
0095 cov(Acts::eBoundTheta, Acts::eBoundLoc1) = d.cov_thetaz0;
0096 cov(Acts::eBoundTheta, Acts::eBoundPhi) = d.cov_thetaphi;
0097 cov(Acts::eBoundTheta, Acts::eBoundQOverP) = d.cov_thetaqop;
0098
0099 cov(Acts::eBoundQOverP, Acts::eBoundLoc0) = d.cov_qopd0;
0100 cov(Acts::eBoundQOverP, Acts::eBoundLoc1) = d.cov_qopz0;
0101 cov(Acts::eBoundQOverP, Acts::eBoundPhi) = d.cov_qopphi;
0102 cov(Acts::eBoundQOverP, Acts::eBoundTheta) = d.cov_qoptheta;
0103
0104
0105 trackParameters.emplace_back(surface, params, cov,
0106 Acts::ParticleHypothesis::pion());
0107 }
0108
0109 m_outputTrackParameters(ctx, std::move(trackParameters));
0110
0111 return ProcessCode::SUCCESS;
0112 }
0113
0114 }