LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
SAMMetadataTranslators.h
Go to the documentation of this file.
1 #ifndef art_Utilities_SAMMetadataTranslators_h
2 #define art_Utilities_SAMMetadataTranslators_h
3 
4 #include "cetlib/container_algorithms.h"
5 
6 #include <map>
7 #include <string>
8 
9 namespace art {
10 
11  using new_t = std::string;
12  using old_t = std::string;
13 
14  inline std::map<new_t, old_t>
16  {
17  return {{"file_type", "fileType"},
18  {"data_tier", "dataTier"},
19  {"data_stream", "streamName"},
20  {"run_type", "runType"}};
21  }
22 
23  // Translator
24  struct NewToOld {
25  std::string
26  operator()(std::string const& name) const
27  {
28  auto const& transMap = newToOldName();
29  auto it = transMap.find(name);
30  return it != transMap.cend() ? it->second : name;
31  }
32  };
33 
34  //==============================================================================
35 
36  inline std::map<new_t, old_t>
38  {
39  auto const newToOld = newToOldName();
40  std::map<old_t, new_t> oldToNew;
41  cet::transform_all(
42  newToOld, std::inserter(oldToNew, oldToNew.begin()), [](auto const& pr) {
43  return std::make_pair(pr.second, pr.first);
44  });
45  return oldToNew;
46  }
47 
48  // Translator
49  struct OldToNew {
50  std::string
51  operator()(std::string const& name) const
52  {
53  auto const& transMap = oldToNewName();
54  auto it = transMap.find(name);
55  return it != transMap.cend() ? it->second : name;
56  }
57  };
58 }
59 
60 #endif /* art_Utilities_SAMMetadataTranslators_h */
61 
62 // Local variables:
63 // mode: c++
64 // End:
std::string operator()(std::string const &name) const
std::map< new_t, old_t > newToOldName()
std::string old_t
std::string new_t
std::string operator()(std::string const &name) const
std::map< new_t, old_t > oldToNewName()
HLT enums.