ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Barcode.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Barcode.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2020 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 <cstdint>
12 
14 
15 namespace ActsFatras {
16 
94 class Barcode : public Acts::MultiIndex<uint64_t, 12, 12, 16, 8, 16> {
96 
97  public:
98  using Base::Base;
99  using Base::Value;
100 
102  constexpr Value vertexPrimary() const { return level(0); }
104  constexpr Value vertexSecondary() const { return level(1); }
106  constexpr Value particle() const { return level(2); }
108  constexpr Value generation() const { return level(3); }
110  constexpr Value subParticle() const { return level(4); }
111 
113  constexpr Barcode& setVertexPrimary(Value id) { return set(0, id), *this; }
115  constexpr Barcode& setVertexSecondary(Value id) { return set(1, id), *this; }
117  constexpr Barcode& setParticle(Value id) { return set(2, id), *this; }
119  constexpr Barcode& setGeneration(Value id) { return set(3, id), *this; }
121  constexpr Barcode& setSubParticle(Value id) { return set(4, id), *this; }
122 
126  Barcode makeDescendant(Value sub = 0u) const {
127  return Barcode(*this).setGeneration(generation() + 1).setSubParticle(sub);
128  }
129 };
130 
131 } // namespace ActsFatras
132 
133 // specialize std::hash so Barcode can be used e.g. in an unordered_map
134 namespace std {
135 template <>
136 struct hash<ActsFatras::Barcode> {
137  auto operator()(ActsFatras::Barcode barcode) const noexcept {
138  return std::hash<ActsFatras::Barcode::Value>()(barcode.value());
139  }
140 };
141 } // namespace std