16 #include <framework/gearbox/GearDir.h>
17 #include <framework/logging/Logger.h>
29 class IRGeoBase:
public TObject {
45 std::map<std::string, double>::const_iterator it =
m_params.find(name);
46 if (it !=
m_params.end())
return (*it).second;
47 B2FATAL(
"Requested parameter from IR database not found: " << name);
55 double getParameter(
const std::string& name,
double def)
const
57 std::map<std::string, double>::const_iterator it =
m_params.find(name);
58 if (it !=
m_params.end())
return (*it).second;
68 std::map<std::string, std::string>::const_iterator it =
m_strparams.find(name);
70 B2FATAL(
"Requested parameter from IR database not found: " << name);
77 const std::string&
getParameterStr(
const std::string& name,
const std::string& def)
const
79 std::map<std::string, std::string>::const_iterator it =
m_strparams.find(name);
101 if (
m_params.insert(std::pair<std::string, double>(name, val)).second)
return;
112 void addParameter(
const std::string& name,
const std::string& val)
114 if (
m_strparams.insert(std::pair<std::string, std::string>(name, val)).second)
return;
125 void addParameters(
const GearDir& content,
const std::string& section)
128 for (
const GearDir& slot : content.getNodes(
"sec")) {
129 std::string name = slot.getString(
"@name");
130 std::string unt = slot.getString(
"@unit");
132 if (unt.find(
"rad") != std::string::npos) value = slot.getAngle();
133 else value = slot.getLength();
136 if (content.exists(
"Material"))
addParameter(section +
".Material", content.getString(
"Material"));
137 if (content.exists(
"Intersect"))
addParameter(section +
".Intersect", content.getString(
"Intersect"));
138 if (content.exists(
"Subtract"))
addParameter(section +
".Subtract", content.getString(
"Subtract"));
139 if (content.exists(
"MotherVolume"))
addParameter(section +
".MotherVolume", content.getString(
"MotherVolume"));
140 if (content.exists(
"N"))
addParameter(section +
".N",
double(content.getInt(
"N")));
141 if (content.exists(
"@type"))
addParameter(section +
".type", content.getString(
"@type"));
149 for (std::pair<std::string, double> element :
m_params) {
150 std::cout << element.first <<
" " << element.second << std::endl;
153 for (std::pair<std::string, std::string> element :
m_strparams) {
154 std::cout << element.first <<
" " << element.second << std::endl;
161 std::map<std::string, double>
m_params;