ATLAS Offline Software
HashTools.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef TRIGTOOLS_TRIG_VSI_HASHTOOLS
5 #define TRIGTOOLS_TRIG_VSI_HASHTOOLS
6 
11 #include <cstdint>
12 
13 namespace TrigVSI {
14 
15  // The Function to make new hash from some existed hashes
16  // from: Boost.ContainerHash https://github.com/boostorg/container_hash/blob/develop/include/boost/container_hash/hash.hpp
17  inline void HashCombineImpl(size_t& h, size_t k) noexcept
18  {
19  constexpr std::uint64_t m = 0xc6a4a7935bd1e995;
20  constexpr int r = 47;
21  k *= m;
22  k ^= k >> r;
23  k *= m;
24  h ^= k;
25  h *= m;
26  // Completely arbitrary number, to prevent 0's
27  // from hashing to 0.
28  h += 0xe6546b64;
29  }
30 
31  // Combines hashes to make new hash
32  template <class Type>
33  inline void HashCombine(std::size_t& h, const Type& value) noexcept
34  {
35  HashCombineImpl(h, std::hash<Type>{}(value));
36  }
37 
38  // hash func for std::pair
39  template<typename T1, typename T2>
40  struct PairHash
41  {
42  size_t operator() (const std::pair<T1,T2>& p) const noexcept
43  {
44  size_t seed = 0;
45  HashCombine(seed, p.first);
46  HashCombine(seed, p.second);
47  return seed;
48  }
49  };
50 
51 } // end of namespace bracket TrigVSI
52 
53 #endif
beamspotman.r
def r
Definition: beamspotman.py:676
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrigVSI::HashCombineImpl
void HashCombineImpl(size_t &h, size_t k) noexcept
Definition: HashTools.h:17
athena.value
value
Definition: athena.py:122
TrigVSI::PairHash::operator()
size_t operator()(const std::pair< T1, T2 > &p) const noexcept
Definition: HashTools.h:42
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
TrigVSI::HashCombine
void HashCombine(std::size_t &h, const Type &value) noexcept
Definition: HashTools.h:33
xAODType
Definition: ObjectType.h:13
TrigVSI::PairHash
Definition: HashTools.h:41
h
TrigVSI
Definition: TrigVrtSecInclusive.cxx:27
fitman.k
k
Definition: fitman.py:528