Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:50

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/Csv/CsvDriftCircleReader.hpp"
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Geometry/GeometryIdentifier.hpp"
0013 #include "ActsExamples/EventData/DriftCircle.hpp"
0014 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0015 #include "ActsExamples/Io/Csv/CsvInputOutput.hpp"
0016 #include "ActsExamples/Utilities/Paths.hpp"
0017 #include "ActsFatras/EventData/Barcode.hpp"
0018 #include "ActsFatras/EventData/Hit.hpp"
0019 
0020 #include <array>
0021 #include <stdexcept>
0022 
0023 #include "CsvOutputData.hpp"
0024 
0025 ActsExamples::CsvDriftCircleReader::CsvDriftCircleReader(
0026     const ActsExamples::CsvDriftCircleReader::Config& config,
0027     Acts::Logging::Level level)
0028     : m_cfg(config),
0029       // TODO check that all files (hits,cells,truth) exists
0030       m_eventsRange(
0031           determineEventFilesRange(m_cfg.inputDir, m_cfg.inputStem + ".csv")),
0032       m_logger(Acts::getDefaultLogger("CsvDriftCircleReader", level)) {
0033   if (m_cfg.inputStem.empty()) {
0034     throw std::invalid_argument("Missing input filename stem");
0035   }
0036   if (m_cfg.outputDriftCircles.empty()) {
0037     throw std::invalid_argument("Missing drift circle output collection");
0038   }
0039 
0040   m_outputDriftCircles.initialize(m_cfg.outputDriftCircles);
0041 }
0042 
0043 std::string ActsExamples::CsvDriftCircleReader::CsvDriftCircleReader::name()
0044     const {
0045   return "CsvDriftCircleReader";
0046 }
0047 
0048 std::pair<std::size_t, std::size_t>
0049 ActsExamples::CsvDriftCircleReader::availableEvents() const {
0050   return m_eventsRange;
0051 }
0052 
0053 ActsExamples::ProcessCode ActsExamples::CsvDriftCircleReader::read(
0054     const ActsExamples::AlgorithmContext& ctx) {
0055   auto path = perEventFilepath(m_cfg.inputDir, m_cfg.inputStem + ".csv",
0056                                ctx.eventNumber);
0057 
0058   ActsExamples::NamedTupleCsvReader<MuonDriftCircleData> reader(path);
0059 
0060   DriftCircleContainer DriftCircles;
0061   MuonDriftCircleData data;
0062 
0063   while (reader.read(data)) {
0064     Acts::Vector3 tube_pos{data.tubePositionx * Acts::UnitConstants::mm,
0065                            data.tubePositiony * Acts::UnitConstants::mm,
0066                            data.tubePositionz * Acts::UnitConstants::mm};
0067 
0068     DriftCircles.push_back(DriftCircle(std::move(tube_pos), data.driftRadius,
0069                                        0.0f, data.stationName, data.stationEta,
0070                                        data.stationPhi, data.multilayer,
0071                                        data.tubelayer, data.tube));
0072   }
0073 
0074   // write the ordered data to the EventStore (according to geometry_id).
0075   m_outputDriftCircles(ctx, std::move(DriftCircles));
0076 
0077   return ActsExamples::ProcessCode::SUCCESS;
0078 }