Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RootSimHitReader.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RootSimHitReader.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 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 <cstddef>
20 #include <cstdint>
21 #include <map>
22 #include <memory>
23 #include <mutex>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 class TChain;
29 
30 namespace ActsExamples {
31 struct AlgorithmContext;
32 
36 class RootSimHitReader : public IReader {
37  public:
39  struct Config {
47  bool orderedEvents = true;
48  };
49 
50  RootSimHitReader(const RootSimHitReader &) = delete;
51  RootSimHitReader(const RootSimHitReader &&) = delete;
52 
56 
58  std::string name() const override { return "RootSimHitReader"; }
59 
61  std::pair<size_t, size_t> availableEvents() const override;
62 
66  ProcessCode read(const ActsExamples::AlgorithmContext &context) override;
67 
69  const Config &config() const { return m_cfg; }
70 
71  private:
73  const Acts::Logger &logger() const { return *m_logger; }
74 
77 
79  std::unique_ptr<const Acts::Logger> m_logger;
80 
82  std::mutex m_read_mutex;
83 
85  std::vector<std::tuple<uint32_t, std::size_t, std::size_t>> m_eventMap;
86 
88  TChain *m_inputChain = nullptr;
89 
91  constexpr static std::array<const char *, 12> m_floatKeys = {
92  "tx", "ty", "tz", "tt", "tpx", "tpy",
93  "tpz", "te", "deltapx", "deltapy", "deltapz", "deltae"};
94  constexpr static std::array<const char *, 2> m_uint64Keys = {"geometry_id",
95  "particle_id"};
96  constexpr static std::array<const char *, 6> m_uint32Keys = {
97  "event_id", "volume_id", "boundary_id",
98  "layer_id", "approach_id", "sensitive_id"};
99  constexpr static std::array<const char *, 1> m_int32Keys = {"index"};
100 
101  std::unordered_map<std::string_view, float> m_floatColumns;
102  std::unordered_map<std::string_view, std::uint32_t> m_uint32Columns;
103  std::unordered_map<std::string_view, std::int32_t> m_int32Columns;
104 
105  // For some reason I need to use here `unsigned long long` instead of
106  // `uint64_t` to prevent an internal ROOT type mismatch...
107  std::unordered_map<std::string_view, unsigned long long> m_uint64Columns;
108 };
109 
110 } // namespace ActsExamples