14 #include <boost/archive/xml_iarchive.hpp> 15 #include <boost/archive/xml_oarchive.hpp> 16 #include <boost/serialization/nvp.hpp> 17 #include <boost/serialization/vector.hpp> 22 ss << std::setprecision(10);
24 ss << std::setprecision(5);
28 ss <<
" +- " << p.
Error.first;
30 ss <<
" [" << p.
Error.first <<
", " << p.
Error.second <<
"]";
36 auto OldPrecision(os.precision());
40 os <<
"\n--------------FIT RESULT INFOS----------------\n";
44 os <<
"duration of fit (in seconds): " << Result.
FitDuration.count() <<
"\n";
49 size_t ParErrorWidth = 30;
53 if (x.Error.first != x.Error.second) {
60 FitParametersFormatter.
addColumn(
"Name", 30);
61 FitParametersFormatter.
addColumn(
"Initial Value", 15);
62 FitParametersFormatter.
addColumn(
"Final Value", ParErrorWidth);
64 FitParametersFormatter.
header();
66 os << std::setprecision(10);
67 size_t parameterId = 0;
72 return p.Name == x.Name;
77 if (p.Name.find(
"phase") != std::string::npos)
81 FitParametersFormatter << parameterId << p.Name;
89 FitParametersFormatter << res->Value;
92 <<
"FitResult operator<<(): could not find initial parameter. " 93 "FitResult corrupted, skipping initial value";
94 FitParametersFormatter <<
" ";
103 FitParametersFormatter.
footer();
105 os << std::setprecision(5);
109 bool CovarianceValid(
true);
111 if (x.size() != NRows) {
112 CovarianceValid =
false;
114 <<
"FitResult operator<<(): Covariance is not a square matrix!";
118 if (CovarianceValid) {
127 CovarianceFormatter.
addColumn(p.Name, 17);
132 CovarianceFormatter.
header();
137 CovarianceFormatter << p.Name;
139 CovarianceFormatter << val;
143 CovarianceFormatter.
footer();
146 os << std::setprecision(OldPrecision);
152 std::ofstream ofs(filename);
153 boost::archive::xml_oarchive oa(ofs);
154 oa << boost::serialization::make_nvp(
"FitResult", *
this);
159 std::ifstream ifs(filename);
161 boost::archive::xml_iarchive ia(ifs);
162 ia >> boost::serialization::make_nvp(
"FitResult", Result);
169 std::vector<double> ParameterValues;
170 for (
auto p : Params) {
173 [&p](
auto const &x) {
return p.Name == x.Name; });
175 LOG(ERROR) <<
"initializeWithFitResult(): Could not find parameter " 177 <<
" in fit result! Intensity is not fully initialized!" 178 <<
"\nPlease make sure the supplied fit result " 179 "is compatible with this Intensity.";
181 ParameterValues.push_back(found->Value);
virtual void updateParametersFrom(const std::vector< double > &)=0
It is important to input the vector in the same length and order as defined in the getParameters() me...
std::vector< std::vector< double > > CovarianceMatrix
std::ostream & operator<<(std::ostream &os, const Event &ev)
void initializeWithFitResult(ComPWA::Intensity &Intens, ComPWA::FitResult Result)
double shiftAngle(double value)
std::chrono::seconds FitDuration
double InitialEstimatorValue
double FinalEstimatorValue
Data structure which resembles a general fit result.
FitParameterList FinalParameters
FitParameterList InitialParameters
void write(std::string filename) const
FitResult load(std::string filename)
std::string makeFitParameterString(ComPWA::FitParameter< double > p)
virtual std::vector< Parameter > getParameters() const =0
Interface template for a general Function of the form OutputType Function(InputTypes) The concept clo...