ATLAS Offline Software
Loading...
Searching...
No Matches
hash.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Common file for a few small hashing helpers to store things in
6// std::unordered_*
7
8#ifndef FTAG_HASH_H
9#define FTAG_HASH_H
10
11namespace FlavorTagInference {
12
13 template<typename T>
14 std::size_t getHash(const T& obj) {
15 return std::hash<T>{}(obj);
16 }
17
18 // stolen from https://stackoverflow.com/a/27952689
19 //
20 // it doesn't have to be good, this isn't called much
21 //
22 inline size_t combine( size_t lhs, size_t rhs ) {
23 lhs ^= rhs + 0x517cc1b727220a95 + (lhs << 6) + (lhs >> 2);
24 return lhs;
25 }
26 namespace NNHashing {
27 struct NNKey {
28 std::string path;
30 bool operator==(const NNKey& key) const {
31 return path == key.path && opts == key.opts;
32 }
33 std::size_t hash() const {
34 return combine(getHash(path), getHash(opts));
35 }
36 };
37
38 struct NNHasher {
39 std::size_t operator()(const NNKey& o) const {
40 return o.hash();
41 }
42 };
43 }
44}
45
46#endif
This file contains "getter" functions used for accessing tagger inputs from the EDM.
size_t combine(size_t lhs, size_t rhs)
Definition hash.h:22
std::size_t getHash(const T &obj)
Definition hash.h:14
std::size_t operator()(const NNKey &o) const
Definition hash.h:39
bool operator==(const NNKey &key) const
Definition hash.h:30
std::size_t hash() const
Definition hash.h:33