PSC configuration object.
More...
#include <Config.h>
|
| | Config (const boost::property_tree::ptree &config) |
| void | prepareWorker (const boost::property_tree::ptree &args) |
| std::string | dumpOptions () const |
| | Returns a string with all options which are held in the options cache.
|
| std::string | getOption (const std::string &key, bool quiet=false) const |
| | Gets an option in a "safer" way.
|
| std::string | toPython (const std::string &dictName) const |
| | Incredibly simple minded way to access this object from python.
|
| std::string | getLogLevelAsNumStr () const |
| | Get a string representing the actual number value of the first LOGLEVEL in this configuration.
|
| bool | didUserSetLogLevel () const |
| | Returns whether the user specified an explicit log level.
|
|
| std::map< std::string, std::string > | optmap |
| | Map with name/value pairs of parameters.
|
| std::vector< uint32_t > | enabled_robs |
| | Lists of statically enabled ROBs and sub-detectors.
|
| std::vector< uint32_t > | enabled_SubDets |
|
| const boost::property_tree::ptree & | m_config |
PSC configuration object.
Definition at line 31 of file Config.h.
◆ Config()
| Config::Config |
( |
const boost::property_tree::ptree & | config | ) |
|
Definition at line 107 of file Config.cxx.
109{
111
114
115 const ptree::value_type& hltimpl = getHltConfigImpl(config);
116 if(hltimpl.first == "HLTImplementationJobOptions")
117 {
118 ERS_DEBUG(1, "Job Options configuration");
120 }
121 else if(hltimpl.first == "HLTImplementationDB")
122 {
123 ERS_DEBUG(1, "DB configuration");
125 }
126 else if(hltimpl.first == "HLTImplementationDBPython")
127 {
128 ERS_DEBUG(1, "DBPY configuration");
129 ERS_PSC_WARNING(
"HLT configured with HLTImplementationDBPython object. This"
130 " is for offline purposes only. Do not use this for online running!");
132 }
133 else
134 {
135 string msg =
"Unknown HLTImplementation type: " + hltimpl.first;
136 throw psc::ConfigurationIssue(ERS_HERE,
msg.c_str());
137 }
138
141}
#define ERS_PSC_WARNING(message)
void fill_enabled_dets(const boost::property_tree::ptree &ros2robs)
void fillopt_db(const boost::property_tree::ptree &hlt)
void setup_optmap_defaults()
const boost::property_tree::ptree & m_config
void fill_enabled_robs(const boost::property_tree::ptree &ros2robs)
void fillopt_jo(const boost::property_tree::ptree &hlt)
void fillopt_dbpy(const boost::property_tree::ptree &hlt)
◆ didUserSetLogLevel()
| bool Config::didUserSetLogLevel |
( |
| ) |
const |
Returns whether the user specified an explicit log level.
Definition at line 245 of file Config.cxx.
246{
247
248
249 return getOption(
"LOGLEVEL").substr(0,4) !=
"INFO";
250}
std::string getOption(const std::string &key, bool quiet=false) const
Gets an option in a "safer" way.
◆ dumpOptions()
| std::string Config::dumpOptions |
( |
| ) |
const |
Returns a string with all options which are held in the options cache.
Definition at line 155 of file Config.cxx.
156{
157 std::ostringstream
ost;
158 ost <<
" --- Dump of all options held by Config --- total size = " <<
optmap.size() <<
"\n";
160 for(std::map<std::string, std::string>::const_iterator
162 ost <<
" # = " << std::setw(3) <<
pos
163 <<
" Option : " <<
"'" <<
it->first
164 <<
"' = '" <<
it->second <<
"'\n";
165 }
166
167
168 ost <<
" --- Number of enabled ROB IDs read from OKS = " <<
enabled_robs.size() <<
"\n";
169 ost <<
"List of enabled ROBs: [";
172 eformat::SubDetector previous_subDet(eformat::OTHER);
174 {
175 if(!first)
ost <<
", ";
176 if (eformat::helper::SourceIdentifier(rob).subdetector_id() != previous_subDet) {
177 previous_subDet = eformat::helper::SourceIdentifier(rob).subdetector_id();
179 }
180 if(index%10==0)
ost<<
"\n" ;
181 ost <<
" 0x" << std::setw(6) << std::hex << rob << std::dec;
184 }
186
187
188 ost <<
" --- Number of enabled Sub Detector configured = "
190 ost <<
"List of enabled Sub-Detectors: [\n";
194 {
195 if(!first)
198 ost << std::setw(4) <<
index <<
": 0x" << std::setw(2) << std::hex <<
det << std::dec
199 << " (" << std::setw(26) << eformat::helper::SourceIdentifier((eformat::SubDetector)det,0).human_detector() << " )";
201 }
203
205}
std::vector< uint32_t > enabled_SubDets
std::vector< uint32_t > enabled_robs
Lists of statically enabled ROBs and sub-detectors.
std::map< std::string, std::string > optmap
Map with name/value pairs of parameters.
◆ fill_enabled_dets()
| void Config::fill_enabled_dets |
( |
const boost::property_tree::ptree & | ros2robs | ) |
|
|
private |
Definition at line 381 of file Config.cxx.
382{
383 std::set<eformat::SubDetector> set_enabled_subDets;
384 for(const auto& ros : r2r)
385 for(
const auto& rob:
ros.second)
386 set_enabled_subDets.insert(eformat::helper::SourceIdentifier(rob.second.get_value<uint32_t>()).subdetector_id());
387
389 for(
const auto& it_det: set_enabled_subDets)
enabled_SubDets.push_back(it_det);
390}
◆ fill_enabled_robs()
| void Config::fill_enabled_robs |
( |
const boost::property_tree::ptree & | ros2robs | ) |
|
|
private |
Definition at line 369 of file Config.cxx.
370{
371 std::set<uint32_t> set_enabled_robs;
372 for(const auto& ros : r2r)
373 for(
const auto& rob:
ros.second)
374 set_enabled_robs.insert(rob.second.get_value<uint32_t>());
375
377 for(
const auto& it_rob: set_enabled_robs)
enabled_robs.push_back(it_rob);
378}
◆ fillopt_athenaHLT()
| void Config::fillopt_athenaHLT |
( |
| ) |
|
|
private |
Definition at line 339 of file Config.cxx.
340{
341 const auto& ath_hlt =
m_config.get_child_optional(athlt_path);
342 if(ath_hlt)
343 {
344 const auto& llnode = ath_hlt->get_child_optional("logLevels");
345 optmap[
"LOGLEVEL"] = plevelToStr(llnode,
',');
346
347 const auto& psnode = ath_hlt->get_child_optional("pythonSetupFile");
348 if(psnode)
349 optmap[
"PYTHONSETUPFILE"] = psnode->data();
350 }
351}
◆ fillopt_common()
| void Config::fillopt_common |
( |
const boost::property_tree::ptree & | hlt | ) |
|
|
private |
Definition at line 312 of file Config.cxx.
313{
314 boost::optional<const ptree&> circbuf =
m_config.get_child_optional(
315 "Configuration.HLTMPPUApplication.MuonCalibrationConfig.CircBuffer");
316 if(circbuf)
317 {
318 optmap[
"MUONCALBUFFERNAME"] = circbuf->get_child(
"CircName").data();
319 optmap[
"MUONCALBUFFERSIZE"] = circbuf->get_child(
"CircSize").data();
320 }
321
322 const ptree& com =
hlt.get_child(
"HLTCommonParameters.HLTCommonParameters");
323 optmap[
"MESSAGESVCTYPE"] = com.get_child(
"messageSvcType").data();
324 optmap[
"JOBOPTIONSSVCTYPE"] = com.get_child(
"jobOptionsSvcType").data();
325
326 optmap[
"DF_PARTITION_NAME"] =
m_config.get_child(
"Configuration.Partition.UID").data();
327
328 const ptree& hltmppu =
m_config.get_child(
"Configuration.HLTMPPUApplication");
329 optmap[
"DF_APPLICATIONNAME"] = hltmppu.get_child(
"UID").data();
330 optmap[
"HARDTIMEOUT"] = hltmppu.get_child(
"HardTimeout").data();
331 optmap[
"SOFTTIMEOUTFRACTION"] = hltmppu.get_child(
"softTimeoutFraction").data();
332 optmap[
"NEVENTSLOTS"] = hltmppu.get_child(
"numberOfEventSlots").data();
333 optmap[
"NTHREADS"] = hltmppu.get_child(
"numberOfAthenaMTThreads").data();
334 optmap[
"NPROCS"] = hltmppu.get_child(
"numForks").data();
335 optmap[
"MAXEVENTSIZEMB"] = hltmppu.get_child(
"maximumHltResultMb").data();
336}
boost::property_tree::ptree ptree
◆ fillopt_db()
| void Config::fillopt_db |
( |
const boost::property_tree::ptree & | hlt | ) |
|
|
private |
Definition at line 282 of file Config.cxx.
283{
285 std::ostringstream
s;
286 s <<
"server=" <<
db.get_child(
"Alias").data()
287 <<
";smkey=" <<
db.get_child(
"SuperMasterKey").data()
288 <<
";lvl1key=" <<
m_config.get_child(l1_path +
".Lvl1PrescaleKey").data()
289 <<
";hltkey=" <<
hlt.get_child(
"hltPrescaleKey").data();
290
291 optmap[
"JOBOPTIONSPATH"] =
s.str();
292 optmap[
"JOBOPTIONSTYPE"] =
"DB";
293
295}
void fillopt_common(const boost::property_tree::ptree &hlt)
◆ fillopt_dbpy()
| void Config::fillopt_dbpy |
( |
const boost::property_tree::ptree & | hlt | ) |
|
|
private |
Definition at line 298 of file Config.cxx.
299{
302}
void fillopt_py(const boost::property_tree::ptree &hlt)
◆ fillopt_jo()
| void Config::fillopt_jo |
( |
const boost::property_tree::ptree & | hlt | ) |
|
|
private |
Definition at line 263 of file Config.cxx.
264{
265 optmap[
"JOBOPTIONSPATH"] =
hlt.get_child(
"jobOptionsPath").data();
266 optmap[
"PYTHONSETUPFILE"] =
hlt.get_child(
"pythonSetupFile").data();
267
268
269 if (boost::algorithm::to_lower_copy(
optmap[
"JOBOPTIONSPATH"]).ends_with(
".json")) {
270 optmap[
"JOBOPTIONSTYPE"] =
"FILE";
271 }
272 else {
273 optmap[
"JOBOPTIONSTYPE"] =
"NONE";
274 }
275 optmap[
"LOGLEVEL"] = plevelToStr(
hlt.get_child_optional(
"logLevels"),
',');
276
279}
◆ fillopt_py()
| void Config::fillopt_py |
( |
const boost::property_tree::ptree & | hlt | ) |
|
|
private |
Definition at line 305 of file Config.cxx.
306{
307 optmap[
"PRECOMMAND"] = plevelToStr(
hlt.get_child_optional(
"preCommands"));
308 optmap[
"POSTCOMMAND"] = plevelToStr(
hlt.get_child_optional(
"postCommands"));
309}
◆ getLogLevelAsNumStr()
| std::string Config::getLogLevelAsNumStr |
( |
| ) |
const |
Get a string representing the actual number value of the first LOGLEVEL in this configuration.
Definition at line 240 of file Config.cxx.
241{
242 return log_level_as_num_str(
getOption(
"LOGLEVEL"));
243}
◆ getOption()
| std::string Config::getOption |
( |
const std::string & | key, |
|
|
bool | quiet = false ) const |
Gets an option in a "safer" way.
- Parameters
-
| quiet | Print warning if option is not available |
Definition at line 208 of file Config.cxx.
209{
210 std::map<std::string, std::string>::const_iterator
it =
optmap.find(key);
215 }
216 return "";
217 }
219}
std::string dumpOptions() const
Returns a string with all options which are held in the options cache.
◆ prepareWorker()
| void Config::prepareWorker |
( |
const boost::property_tree::ptree & | args | ) |
|
Definition at line 144 of file Config.cxx.
145{
148
149 optmap[
"DF_APPLICATIONNAME"] =
args.get_child(
"appName").data();
150 optmap[
"DF_WORKER_ID"] =
args.get_child(
"workerId").data();
151 optmap[
"DF_NUMBER_OF_WORKERS"] =
args.get_child(
"numberOfWorkers").data();
152}
◆ setPInfo()
| void Config::setPInfo |
( |
| ) |
|
|
private |
Definition at line 354 of file Config.cxx.
355{
356 char cstr_host[HOST_NAME_MAX];
357 gethostname(cstr_host, sizeof(cstr_host));
358 optmap[
"DF_MACHINE_NAME"] = string(cstr_host);
359
360 ostringstream oss;
361 oss << "0x" << std::hex << gethostid() ;
362 optmap[
"DF_HOST_ID"] = oss.str();
363
366}
◆ setup_optmap_defaults()
| void Config::setup_optmap_defaults |
( |
| ) |
|
|
private |
Definition at line 253 of file Config.cxx.
254{
255 optmap[
"LOGLEVEL"] =
"INFO";
256 optmap[
"PRECOMMAND"] =
"";
257 optmap[
"POSTCOMMAND"] =
"";
258 optmap[
"MUONCALBUFFERNAME"] =
"";
259 optmap[
"MUONCALBUFFERSIZE"] =
"";
260}
◆ toPython()
| std::string Config::toPython |
( |
const std::string & | dictName | ) |
const |
Incredibly simple minded way to access this object from python.
Create a python dictionary with key/value pairs.
Definition at line 222 of file Config.cxx.
223{
224 ostringstream oss;
225 oss << dictName << " = {";
227 std::map<std::string, std::string>::const_iterator
it =
optmap.begin();
229 if (!first) {
230 oss << ",";
231 }
232 oss <<
"'" <<
it->first <<
"':'" <<
it->second <<
"'";
234 }
235 oss << "}" << std::endl;
236 return oss.str();
237}
◆ updatePids()
| void Config::updatePids |
( |
| ) |
|
|
private |
Definition at line 393 of file Config.cxx.
394{
395 optmap[
"DF_PID"] = std::to_string(getpid());
396 optmap[
"DF_PPID"] = std::to_string(getppid());
397}
◆ updateSeed()
| void Config::updateSeed |
( |
| ) |
|
|
private |
Definition at line 400 of file Config.cxx.
401{
402
403
404
405
406
407
408
409
410
411
412 unsigned int extract_mask = 0;
413 for(
unsigned i = 0;
i <
sizeof(
int)/2; ++
i)
414 extract_mask |= UCHAR_MAX << (i*CHAR_BIT);
415
416 ostringstream oss;
417
418 oss << "0x" << std::hex << (gethostid() & extract_mask)
419 << (getpid() & extract_mask);
420
421 optmap[
"DF_RANDOM_SEED"] = oss.str();
422}
◆ enabled_robs
| std::vector<uint32_t> psc::Config::enabled_robs |
Lists of statically enabled ROBs and sub-detectors.
Definition at line 76 of file Config.h.
◆ enabled_SubDets
| std::vector<uint32_t> psc::Config::enabled_SubDets |
◆ m_config
| const boost::property_tree::ptree& psc::Config::m_config |
|
private |
◆ optmap
| std::map<std::string, std::string> psc::Config::optmap |
Map with name/value pairs of parameters.
Definition at line 71 of file Config.h.
The documentation for this class was generated from the following files: