File indexing completed on 2025-05-15 07:57:13
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/EDM4hep/EDM4hepMeasurementInputConverter.hpp"
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp"
0013 #include "Acts/Plugins/Podio/PodioUtil.hpp"
0014 #include "ActsExamples/EventData/Cluster.hpp"
0015 #include "ActsExamples/EventData/Measurement.hpp"
0016 #include "ActsExamples/Framework/WhiteBoard.hpp"
0017 #include "ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp"
0018
0019 #include <stdexcept>
0020
0021 #include <edm4hep/TrackerHitPlane.h>
0022 #include <edm4hep/TrackerHitPlaneCollection.h>
0023 #include <podio/Frame.h>
0024
0025 namespace ActsExamples {
0026
0027 EDM4hepMeasurementInputConverter::EDM4hepMeasurementInputConverter(
0028 const EDM4hepMeasurementInputConverter::Config& config,
0029 Acts::Logging::Level level)
0030 : EDM4hepInputConverter("EDM4hepMeasurementInputConverter", level,
0031 config.inputFrame),
0032 m_cfg(config) {
0033 if (m_cfg.outputMeasurements.empty()) {
0034 throw std::invalid_argument("Missing measurement output collection");
0035 }
0036
0037 if (m_cfg.inputFrame.empty()) {
0038 throw std::invalid_argument("Missing input frame");
0039 }
0040
0041 m_inputFrame.initialize(m_cfg.inputFrame);
0042
0043 m_outputMeasurements.initialize(m_cfg.outputMeasurements);
0044 m_outputMeasurementSimHitsMap.initialize(m_cfg.outputMeasurementSimHitsMap);
0045 m_outputClusters.maybeInitialize(m_cfg.outputClusters);
0046 }
0047
0048 ProcessCode EDM4hepMeasurementInputConverter::convert(
0049 const AlgorithmContext& ctx, const podio::Frame& frame) const {
0050 MeasurementContainer measurements;
0051 ClusterContainer clusters;
0052
0053 IndexMultimap<Index> measurementSimHitsMap;
0054
0055 const auto& trackerHitPlaneCollection =
0056 frame.get<edm4hep::TrackerHitPlaneCollection>("ActsTrackerHitsPlane");
0057 const auto& trackerHitRawCollection =
0058 frame.get<edm4hep::TrackerHit3DCollection>("ActsTrackerHitsRaw");
0059
0060 for (const auto& trackerHitPlane : trackerHitPlaneCollection) {
0061 Cluster cluster;
0062 EDM4hepUtil::readMeasurement(
0063 measurements, trackerHitPlane, &trackerHitRawCollection, &cluster,
0064 [](std::uint64_t cellId) { return Acts::GeometryIdentifier(cellId); });
0065
0066 clusters.push_back(std::move(cluster));
0067 }
0068
0069
0070 m_outputMeasurements(ctx, std::move(measurements));
0071 m_outputMeasurementSimHitsMap(ctx, std::move(measurementSimHitsMap));
0072 if (!m_cfg.outputClusters.empty()) {
0073 m_outputClusters(ctx, std::move(clusters));
0074 }
0075
0076 return ProcessCode::SUCCESS;
0077 }
0078
0079 }