ATLAS Offline Software
extract_histogram_tag.cxx
Go to the documentation of this file.
1 
3 
4 #include <regex>
5 
6 namespace {
7 
8 // Regular expressions for per-LBN histogram names used over time
9 std::regex const lbRegex_run2("^/?run_\\d+/lb_(\\d+)(/.+)$");
10 std::regex const lbRegex_run3("^(.+)_LB((\\d+)|\\d+_(\\d+))$");
11 
12 }
13 
14 namespace detail {
15 
16 std::pair<std::string, int> extract_histogram_tag(const std::string& histo_name)
17 {
18  std::smatch what;
19  if (std::regex_match(histo_name, what, ::lbRegex_run2)) {
20  try {
21  int tag = std::stoi(what.str(1));
22  return std::make_pair(what[2], tag);
23  } catch(std::exception &ex) {
24  // should not happen but be defensive and just ignore it
25  }
26  }
27  if (std::regex_match(histo_name, what, ::lbRegex_run3)) {
28  std::string const tagStr = what[3].length() > 0 ? what.str(3) : what.str(4);
29  try {
30  int tag = std::stoi(tagStr);
31  return std::make_pair(what[1], tag);
32  } catch(std::exception &ex) {
33  // should not happen but be defensive and just ignore it
34  }
35  }
36  return std::make_pair(histo_name, -1);
37 }
38 
39 } // namespace detail
detail::extract_histogram_tag
std::pair< std::string, int > extract_histogram_tag(const std::string &histo_name)
Extract tag/LB number from per-LBN histogram name.
Definition: extract_histogram_tag.cxx:16
detail
Definition: extract_histogram_tag.cxx:14
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
calibdata.exception
exception
Definition: calibdata.py:496
python.ExitCodes.what
def what(code)
Definition: ExitCodes.py:73
extract_histogram_tag.h
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24