ATLAS Offline Software
Functions
AsgConfigHelper Namespace Reference

Functions

std::string findConfigFile (const std::string &input, const std::map< std::string, std::string > &configmap)
 
unsigned int findMask (const std::string &input, const std::map< std::string, unsigned int > &maskmap)
 
std::vector< double > HelperDouble (const std::string &input, TEnv &env)
 
std::vector< float > HelperFloat (const std::string &input, TEnv &env)
 
std::vector< int > HelperInt (const std::string &input, TEnv &env)
 
std::vector< std::string > HelperString (const std::string &input, TEnv &env)
 
template<typename T >
bool strtof (const std::string &input, T &f)
 
template<typename T >
std::vector< T > Helper (const std::string &input, TEnv &env)
 

Function Documentation

◆ findConfigFile()

std::string AsgConfigHelper::findConfigFile ( const std::string &  input,
const std::map< std::string, std::string > &  configmap 
)

Definition at line 15 of file AsgEGammaConfigHelper.cxx.

17 {
18  auto confFile_itr = configmap.find(input);
19  if (confFile_itr == configmap.end()) {
20  static const asg::AsgMessaging msg("Egamma::AsgConfigHelper");
21  msg.msg(MSG::WARNING) << "Key " << input
22  << " not found in map, no config file returned"
23  << endmsg;
24  return "";
25  }
26  return confFile_itr->second;
27 }

◆ findMask()

unsigned int AsgConfigHelper::findMask ( const std::string &  input,
const std::map< std::string, unsigned int > &  maskmap 
)

Definition at line 30 of file AsgEGammaConfigHelper.cxx.

32 {
33  auto mask_itr = maskmap.find(input);
34  if (mask_itr == maskmap.end()) {
35  static const asg::AsgMessaging msg("Egamma::AsgConfigHelper");
36  msg.msg(MSG::WARNING)
37  << "Key " << input
38  << " not found in map, egammaPID::EgPidUndefined mask returned"
39  << endmsg;
40  // mask has the choice to default to all 1 or all 0 bits, choose the former
42  }
43  return static_cast<unsigned int>(mask_itr->second);
44 }

◆ Helper()

template<typename T >
std::vector<T> AsgConfigHelper::Helper ( const std::string &  input,
TEnv &  env 
)

Definition at line 83 of file AsgEGammaConfigHelper.cxx.

84 {
85  std::vector<T> CutVector;
86  std::string env_input(env.GetValue(input.c_str(), ""));
87  if (!env_input.empty()) {
88  std::string::size_type end;
89  do {
90  end = env_input.find(';');
91  T myValue{}; //default init
92  if (AsgConfigHelper::strtof(env_input.substr(0, end), myValue)) {
93  CutVector.push_back(myValue);
94  }
95  if (end != std::string::npos) {
96  env_input = env_input.substr(end + 1);
97  }
98  } while (end != std::string::npos);
99  }
100  return CutVector;
101 }

◆ HelperDouble()

std::vector< double > AsgConfigHelper::HelperDouble ( const std::string &  input,
TEnv &  env 
)

Definition at line 106 of file AsgEGammaConfigHelper.cxx.

107 {
108  return AsgConfigHelper::Helper<double>(input, env);
109 }

◆ HelperFloat()

std::vector< float > AsgConfigHelper::HelperFloat ( const std::string &  input,
TEnv &  env 
)

Definition at line 111 of file AsgEGammaConfigHelper.cxx.

112 {
113  return AsgConfigHelper::Helper<float>(input, env);
114 }

◆ HelperInt()

std::vector< int > AsgConfigHelper::HelperInt ( const std::string &  input,
TEnv &  env 
)

Definition at line 116 of file AsgEGammaConfigHelper.cxx.

117 {
118  return AsgConfigHelper::Helper<int>(input, env);
119 }

◆ HelperString()

std::vector< std::string > AsgConfigHelper::HelperString ( const std::string &  input,
TEnv &  env 
)

Definition at line 123 of file AsgEGammaConfigHelper.cxx.

124 {
125  return AsgConfigHelper::Helper<std::string>(input, env);
126 }

◆ strtof()

template<typename T >
bool AsgConfigHelper::strtof ( const std::string &  input,
T &  f 
)

Definition at line 48 of file AsgEGammaConfigHelper.cxx.

49 {
50  int diff = 0;
51  std::string tmp = input;
52  std::string::size_type first(0);
53  std::string::size_type last(0);
54  first = (input.find('#'));
55 
56  // if we do not find a comment character "#" we are fine
57  if (first == std::string::npos) {
58  std::istringstream buffer(tmp);
59  buffer >> f;
60  return true;
61  } else {
62  // if we have found comment character check if it is inlined between two "#"
63  last = (input.find('#', first + 1));
64  // if nor error
65  if (last == std::string::npos) {
66  static const asg::AsgMessaging msg("Egamma::AsgConfigHelper");
67  msg.msg(MSG::WARNING) << " Improper comment format , inline comment "
68  "should be enclosed between two # "
69  << endmsg;
70  return false;
71  }
72  // else if between two "#" remove this part
73  diff = last - first;
74  tmp = tmp.erase(first, diff + 1);
75  std::istringstream buffer(tmp);
76  buffer >> f;
77  return true;
78  }
79 }
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:11
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
hist_file_dump.f
f
Definition: hist_file_dump.py:140
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
AsgConfigHelper::strtof
bool strtof(const std::string &input, T &f)
Definition: AsgEGammaConfigHelper.cxx:48
DeMoScan.first
bool first
Definition: DeMoScan.py:534
python.DataFormatRates.env
env
Definition: DataFormatRates.py:32
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35