14#include <framework/gearbox/GearDir.h>
15#include <framework/logging/Logger.h>
43 std::map<std::string, double>::const_iterator it =
m_params.find(name);
44 if (it !=
m_params.end())
return (*it).second;
45 B2FATAL(
"Requested parameter from IR database not found: " << name);
55 std::map<std::string, double>::const_iterator it =
m_params.find(name);
56 if (it !=
m_params.end())
return (*it).second;
66 std::map<std::string, std::string>::const_iterator it =
m_strparams.find(name);
68 B2FATAL(
"Requested parameter from IR database not found: " << name);
76 const std::string&
getParameterStr(
const std::string& name,
const std::string& def)
const
78 std::map<std::string, std::string>::const_iterator it =
m_strparams.find(name);
100 if (
m_params.insert(std::pair<std::string, double>(name, val)).second)
return;
113 if (
m_strparams.insert(std::pair<std::string, std::string>(name, val)).second)
return;
127 for (
const GearDir& slot : content.getNodes(
"sec")) {
128 std::string name = slot.getString(
"@name");
129 std::string unt = slot.getString(
"@unit");
131 if (unt.find(
"rad") != std::string::npos) value = slot.getAngle();
132 else value = slot.getLength();
135 if (content.exists(
"Material"))
addParameter(section +
".Material", content.getString(
"Material"));
136 if (content.exists(
"HeadMaterial"))
addParameter(section +
".HeadMaterial", content.getString(
"HeadMaterial"));
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;
GearDir is the basic class used for accessing the parameter store.
Base class for IR geometry parameters.
ClassDef(IRGeoBase, 1)
ClassDef.
void addParameters(const GearDir &content, const std::string §ion)
Add parameters from Gearbox.
const std::string & getParameterStr(const std::string &name) const
Get string parameter.
double getParameter(const std::string &name, double def) const
Get parameter value with giving default value in case parameter doesn't exist in DB.
const std::map< std::string, std::string > & getParametersStr() const
Get map of all string parameters.
void addParameter(const std::string &name, const std::string &val)
Add string parameter to map of parameters.
void addParameter(const std::string &name, double val)
Add parameter to map of parameters.
std::map< std::string, double > m_params
map of numeric parameters
const std::map< std::string, double > & getParameters() const
Get map of all parameters.
IRGeoBase()
Default constructor.
double getParameter(const std::string &name) const
Get parameter value.
std::map< std::string, std::string > m_strparams
map of string parameters
const std::string & getParameterStr(const std::string &name, const std::string &def) const
Get string parameter with giving default value in case of non-existence.
void print() const
Print all parameters.
Abstract base class for different kinds of events.