Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackStateType.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackStateType.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 
11 #include <bitset>
12 #include <cassert>
13 #include <cstddef>
14 #include <cstdint>
15 #include <limits>
16 #include <ostream>
17 
18 namespace Acts {
19 
27  HoleFlag = 3,
31 };
32 
33 class ConstTrackStateType;
34 
38  public:
39  using raw_type = std::uint64_t;
40  static constexpr std::size_t kRawBits =
44  TrackStateType(raw_type& raw) : m_raw{&raw} {}
45 
49  TrackStateType& operator=(const TrackStateType& other) {
50  assert(other.m_raw != nullptr);
51  *m_raw = *other.m_raw;
52  return *this;
53  }
54 
58  TrackStateType& operator=(const ConstTrackStateType& other);
59 
61  operator ConstTrackStateType();
62 
66  bool test(std::size_t pos) const {
67  assert(m_raw != nullptr);
68  std::bitset<kRawBits> bs{*m_raw};
69  return bs.test(pos);
70  }
71 
75  void set(std::size_t pos, bool value = true) {
76  assert(m_raw != nullptr);
77  std::bitset<kRawBits> bs{*m_raw};
78  bs.set(pos, value);
79  *m_raw = bs.to_ullong();
80  }
81 
84  void reset(std::size_t pos) { set(pos, false); }
85 
86  private:
87  raw_type* m_raw{nullptr};
88 };
89 
93  public:
94  using raw_type = std::uint64_t;
95  static constexpr std::size_t kRawBits =
97 
100  ConstTrackStateType(const raw_type& raw) : m_raw{&raw} {}
101 
105  bool test(std::size_t pos) const {
106  assert(m_raw != nullptr);
107  std::bitset<kRawBits> bs{*m_raw};
108  return bs.test(pos);
109  }
110 
111  friend std::ostream& operator<<(std::ostream& os, ConstTrackStateType t) {
112  assert(t.m_raw != nullptr);
113  std::bitset<kRawBits> bs{*t.m_raw};
114  std::bitset<TrackStateFlag::NumTrackStateFlags> trunc;
115  for (size_t i = 0; i < TrackStateFlag::NumTrackStateFlags; i++) {
116  trunc[i] = bs[i];
117  }
118  // MeasurementParameterOutlierHoleMaterialSharedhit
119  os << "MPOHMS=" << trunc;
120  return os;
121  }
122 
123  private:
124  friend class TrackStateType;
125  const raw_type* m_raw{nullptr};
126 };
127 
128 inline TrackStateType& TrackStateType::operator=(
129  const ConstTrackStateType& other) {
130  assert(other.m_raw != nullptr);
131  *m_raw = *other.m_raw;
132  return *this;
133 }
134 inline TrackStateType::operator ConstTrackStateType() {
135  return {*m_raw};
136 }
137 
138 } // namespace Acts