10 #include "boost/property_tree/xml_parser.hpp" 15 Name = pt.get<std::string>(
"<xmlattr>.Name");
16 Id = pt.get<
pid>(
"Pid");
17 for (
const auto &v : pt.get_child(
"")) {
18 if (v.first ==
"QuantumNumber") {
20 std::string type = v.second.get<std::string>(
"<xmlattr>.Type");
23 if (v.second.get<std::string>(
"<xmlattr>.Class") ==
"Spin") {
24 auto value = v.second.get<
double>(
"<xmlattr>.Value");
26 double valueZ = v.second.get<
double>(
"<xmlattr>.Projection");
28 std::make_pair(type +
".Projection", valueZ));
29 }
catch (std::exception &ex) {
32 }
else if (v.second.get<std::string>(
"<xmlattr>.Class") ==
"Int") {
33 auto value = v.second.get<
int>(
"<xmlattr>.Value");
37 "ParticleProperties::ParticleProperties() | " 38 "QuantumNumber is neither of type 'Spin' nor of type " 41 }
else if (v.first ==
"Parameter") {
43 if (v.second.get<std::string>(
"<xmlattr>.Type") !=
"Mass")
45 Mass.
Name = v.second.get<std::string>(
"<xmlattr>.Name");
46 Mass.
Value = v.second.get<
double>(
"Value");
48 auto error = v.second.get_optional<
double>(
"Error");
50 Mass.
Error = std::make_pair(error.get(), error.get());
52 auto errorlow = v.second.get_optional<
double>(
"ErrorLow");
53 auto errorhigh = v.second.get_optional<
double>(
"ErrorHigh");
54 if (errorlow && errorhigh) {
55 Mass.
Error = std::make_pair(errorlow.get(), errorhigh.get());
56 }
else if (errorlow) {
57 throw std::runtime_error(
"ParticleProperties | Error of Parameter " 58 "Mass not properly set (missing ErrorHigh)");
59 }
else if (errorhigh) {
60 throw std::runtime_error(
"ParticleProperties | Error of Parameter " 61 "Mass not properly set (missing ErrorLow)");
65 auto fix = v.second.get_optional<
bool>(
"Fix");
71 auto min = v.second.get_optional<
double>(
"Min");
72 auto max = v.second.get_optional<
double>(
"Max");
75 Mass.
Bounds = std::make_pair(min.get(), max.get());
76 }
else if (min || max) {
77 throw std::runtime_error(
78 "FitParameterFactory() | Parameter bounds not properly set!");
86 auto decayInfo = pt.get_child_optional(
"DecayInfo");
90 DecayInfo.put(
"<xmlattr>.Type",
"Stable");
96 const boost::property_tree::ptree &pt) {
97 auto particleTree = pt.get_child_optional(
"ParticleList");
100 for (
auto const &v : particleTree.get()) {
101 if (v.first !=
"Particle")
104 auto result = list.insert(tmp);
106 if (!result.second) {
107 LOG(INFO) <<
" Particle " << tmp.
getName() <<
" with identical ID " 108 << tmp.
getId() <<
" already exists in list with the name " 109 << result.first->getName() <<
" and ID " 110 << result.first->getId()
111 <<
". Particle properties will be overwritten!";
112 list.erase(result.first);
113 result = list.insert(tmp);
117 std::stringstream ss;
118 ss <<
" Particle " << tmp.
getName() <<
" (id=" << tmp.
getId()
124 }
catch (std::exception &ex) {
129 }
catch (std::exception &ex) {
133 LOG(DEBUG) << ss.str();
140 boost::property_tree::ptree tree;
141 boost::property_tree::xml_parser::read_xml(Stream, tree);
146 boost::property_tree::ptree tree;
147 boost::property_tree::xml_parser::read_xml(FileName, tree);
152 boost::property_tree::ptree tree;
153 boost::property_tree::xml_parser::read_xml(Stream, tree);
158 boost::property_tree::ptree tree;
159 boost::property_tree::xml_parser::read_xml(FileName, tree);
std::string getDecayType() const
ParticleProperties(boost::property_tree::ptree pt)
T getQuantumNumber(std::string type) const
ComPWA::FitParameter< double > Mass
ComPWA::FitParameter< double > getMass() const
ParticleList readParticles(std::stringstream &Stream)
Read list of particles from a stringstream For some reason the boost xml parser needs a non-const ref...
std::set< ParticleProperties > ParticleList
void insertParticles(ParticleList &list, const boost::property_tree::ptree &pt)
Read list of particles from a boost::property_tree.
std::string getName() const
std::map< std::string, double > RealQuantumNumbers
boost::property_tree::ptree DecayInfo
Store decay info in property_tree.
std::map< std::string, int > IntQuantumNumbers