21 std::istringstream istrm(hexOrDecString);
24 istrm.exceptions(std::ios_base::badbit|std::ios_base::failbit);
26 if (not hexOrDecString.empty()){
28 bool numberIsHex = (hexOrDecString.find(
'x') not_eq std::string::npos) or (hexOrDecString.find(
'X') not_eq std::string::npos);
34 }
catch (
const std::ios_base::failure&){
37 std::cerr<<
"stringToInt failed to convert a string to an integer in InDetCabling/SCT_CablingUtilities"<<std::endl;
38 throw(std::ios_base::failure(
"stringToInt failure in SCT_CablingUtilities"));
45 bool inRange(
const int value,
const int lowerBound,
const int upperBound,
const std::string & valueName){
46 bool bad= ( (value > upperBound) or (value<lowerBound) );
48 std::string name = valueName.empty()?
"The value":valueName;
49 std::cerr<<name<<
" = "<<value<<
" is out of the allowable range."<<std::endl;
55 int calculateLink(
const int MURorder,
const int ModID,
const int theSide,
const bool isSwapped =
false){
56 return isSwapped?(MURorder*12 + (5 - ModID) * 2 + (theSide)):(MURorder*12 + ModID * 2 + theSide);
63 std::string
getenv(
const std::string & variableName){
65 const char * pChar=std::getenv(variableName.c_str());
std::string getenv(const std::string &variableName)
get an environment variable
int calculateLink(const int MURorder, const int ModID, const int theSide, const bool isSwapped=false)
calculate link, normal and swapped (from Kondo)
int stringToInt(const std::string &hexOrDecString)
Convert a string (decimal or hex) to an int; -1 indicates an error.
bool inRange(const int value, const int lowerBound, const int upperBound, const std::string &valueName)
Check range and give error if out of range.