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 14 of file AsgEGammaConfigHelper.cxx.

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

◆ findMask()

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

Definition at line 29 of file AsgEGammaConfigHelper.cxx.

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

◆ Helper()

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

Definition at line 82 of file AsgEGammaConfigHelper.cxx.

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

◆ HelperDouble()

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

Definition at line 105 of file AsgEGammaConfigHelper.cxx.

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

◆ HelperFloat()

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

Definition at line 110 of file AsgEGammaConfigHelper.cxx.

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

◆ HelperInt()

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

Definition at line 115 of file AsgEGammaConfigHelper.cxx.

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

◆ HelperString()

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

Definition at line 122 of file AsgEGammaConfigHelper.cxx.

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

◆ strtof()

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

Definition at line 47 of file AsgEGammaConfigHelper.cxx.

48 {
49  int diff = 0;
50  std::string tmp = input;
51  std::string::size_type first(0);
52  std::string::size_type last(0);
53  first = (input.find('#'));
54 
55  // if we do not find a comment character "#" we are fine
56  if (first == std::string::npos) {
57  std::istringstream buffer(tmp);
58  buffer >> f;
59  return true;
60  } else {
61  // if we have found comment character check if it is inlined between two "#"
62  last = (input.find('#', first + 1));
63  // if nor error
64  if (last == std::string::npos) {
65  static const asg::AsgMessaging msg("Egamma::AsgConfigHelper");
66  msg.msg(MSG::WARNING) << " Improper comment format , inline comment "
67  "should be enclosed between two # "
68  << endmsg;
69  return false;
70  }
71  // else if between two "#" remove this part
72  diff = last - first;
73  tmp = tmp.erase(first, diff + 1);
74  std::istringstream buffer(tmp);
75  buffer >> f;
76  return true;
77  }
78 }
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
max
#define max(a, b)
Definition: cfImp.cxx:41
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
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:47
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