28 const auto icat = s_hashStore.hashCat.find(category);
29 if (icat != s_hashStore.hashCat.end()) {
30 const HashMap& cat = icat->second;
37 s_hashStore.hashCat.emplace(category, std::make_unique<HashMap>());
48 for (
int i = (
int)
s.size()-1; i >= 0; --i )
49 hash ^= (
hash >> 5) + s[i] + ( hash << 7 );
51 for (
int i = 0;
i < (
int)
s.size(); ++
i )
52 hash ^= ( hash >> 5) +
s[
i] + (
hash << 7 );
56 HashMap& cat = s_hashStore.hashCat.at(category);
61 cat.name2hash.emplace(s, hash);
67 if ( s != itr->second ) {
68 throw std::domain_error(
"Hash collision in category " + category +
69 " for elements " + itr->second +
" and " + s);
78 const auto& icat = s_hashStore.hashCat.find(category);
79 if (icat == s_hashStore.hashCat.end()) {
80 return "UNKNOWN CATEGORY";
83 const HashMap& cat = icat->second;
86 return "UNKNOWN HASH ID";
93 std::ofstream
fout(fileName);
95 for (
const auto [category, hashes] : s_hashStore.hashCat) {
97 for (
const auto [hash, nameptr] :
hashes.hash2name) {
98 std::string
name(nameptr);
106 std::ifstream
fin(fileName);
107 if (!
fin.is_open()) {
114 while(std::getline(fin, line)) {
116 std::getline(fin, category);
121 std::getline(fin, name);
124 std::cerr <<
"Inconsistency in file2hashes(" <<
fileName <<
") function,"
125 " item " <<
name <<
" has hash " <<
hash <<
" not " <<
check << std::endl;
const_iterator find(const key_type &key) const
Look up an element in the map.
const_iterator end() const
Iterator at the end of the map.
std::pair< const_iterator, bool > emplace(key_type key, const mapped_type &val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
const_iterator find(const key_type key) const
Look up an element in the map.
const_iterator end() const
Iterator at the end of the map.
static const std::string hash2string(HLTHash, const std::string &category="TE")
hash function translating identifiers into names (via internal dictionary)
static void hashes2file(const std::string &fileName="hashes2string.txt")
debugging output of internal dictionary
static const std::string s_newCategory
In-file identifier.
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
static void file2hashes(const std::string &fileName="hashes2string.txt")
debugging output of internal dictionary
Forward iterator to traverse the main components of the trigger configuration.
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.
Two concurrent maps to store name->hash and hash->name mappings.
Hash2NameMap_t hash2name
hash to name map
Name2HashMap_t name2hash
name to hash map