Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasurementMapSelector.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MeasurementMapSelector.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 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 
9 #pragma once
10 
18 
19 #include <string>
20 #include <vector>
21 
22 namespace ActsExamples {
23 
28 class MeasurementMapSelector final : public IAlgorithm {
30 
31  public:
32  struct Config {
35 
38 
41 
43  std::vector<Acts::GeometryIdentifier> geometrySelection;
44  };
45 
51  : IAlgorithm("MeasurementMapSelector", lvl), m_cfg(cfg) {
55  }
56 
57  virtual ~MeasurementMapSelector() = default;
58 
64  const ActsExamples::AlgorithmContext& ctx) const final {
65  const auto& inputSourceLinks = m_inputSourceLinks(ctx);
66  const auto& inputMap = m_inputMap(ctx);
67 
68  Map outputMap;
69 
70  for (const auto geoId : m_cfg.geometrySelection) {
71  auto range = selectLowestNonZeroGeometryObject(inputSourceLinks, geoId);
72  for (const auto& sl : range) {
73  const auto [begin, end] = inputMap.equal_range(sl.index());
74  outputMap.insert(begin, end);
75  }
76  }
77 
78  m_outputMap(ctx, std::move(outputMap));
79 
80  return ProcessCode::SUCCESS;
81  }
82 
83  const Config& config() const { return m_cfg; }
84 
85  private:
86  // configuration
88 
90  this, "InputSourceLinks"};
91  ReadDataHandle<Map> m_inputMap{this, "InputMeasurementParticleMap"};
92  WriteDataHandle<Map> m_outputMap{this, "OutputMeasurementParticleMap"};
93 };
94 
95 } // namespace ActsExamples