ATLAS Offline Software
Functions
PixelConditionsAlgorithms Namespace Reference

Functions

std::vector< std::pair< int, int > > parseDeadMapString (const std::string &s)
 

Function Documentation

◆ parseDeadMapString()

std::vector< std::pair< int, int > > PixelConditionsAlgorithms::parseDeadMapString ( const std::string &  s)

Definition at line 19 of file StringUtilities.cxx.

19  {
20  std::vector<std::pair<int, int>> result;
21  //the Trigger_athenaHLT_v1Cosmic CI test returns a pair of empty braces, "{}"; trap this
22  //in fact the minimal useful string would be {"d":d}, where d is a digit
23  if (s.size()<7) return result;
24  //a valid string is json, enclosed in braces.
25  const bool is_valid = (s.front() == '{') and (s.back() == '}');
26  if (not is_valid) return result;
27  auto is_digit=[](const char c)->bool{
28  return (c>='0') and (c<='9');
29  };
30  auto is_quote=[](const char c)->bool{
31  return (c=='"');
32  };
33  const auto *pc=s.data();
34  const auto *const pcEnd=pc+s.size();
35  int hash{};
36  int status{};
37  static constexpr std::errc success{};
38 
39  //database strings look like : {"12":0,"19":0,"53":0,"64":256}
40  for (;pc<pcEnd;++pc){
41  //fast-forward to the first quote
42  pc=std::find_if(pc,pcEnd,is_quote);
43  //the following converts everything up to the first non-digit character
44  //the ptr is pointing to the first non-digit character (which should be a quote)
45  const auto &[ptr, errCode] = std::from_chars(++pc, pcEnd, hash);
46  if (errCode!= success){
47  throw std::runtime_error("Bad hash conversion from database string in PixelConditionsAlgorithms::parseDeadMapString:" +s+".");
48  }
49  //fast-forward to the next digit
50  pc=std::find_if(ptr,pcEnd,is_digit);
51  const auto &[ptr2, errCode2] = std::from_chars(pc, pcEnd, status);
52  if (errCode2!= success){
53  throw std::runtime_error("Bad status conversion from database string in PixelConditionsAlgorithms::parseDeadMapString:"+s+".");
54  }
55  pc=ptr2;
56  result.emplace_back(hash, status);
57  }
58 
59  //
60  return result;
61  }
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
merge.status
status
Definition: merge.py:17
python.compressB64.c
def c
Definition: compressB64.py:93
python.SystemOfUnits.pc
float pc
Definition: SystemOfUnits.py:99