16 os <<
"\nFit Fractions:\n";
17 for (
auto const &ff : FFList) {
18 os << ff.Name <<
": " << ff.Value <<
" +- " << ff.Error <<
"\n";
31 const std::vector<std::pair<IntensityComponent, IntensityComponent>>
37 for (
auto Component : Components) {
38 auto NumeratorData =
getIntegralData(Component.first, PhspSample, Result);
39 auto DenominatorData =
42 double FitFractionValue =
43 std::get<1>(NumeratorData) / std::get<1>(DenominatorData);
45 double FitFractionError = 0.;
49 std::vector<double> JacobiColumn;
50 std::vector<std::vector<double>> CovMatrix;
52 std::make_tuple(std::get<1>(NumeratorData),
53 std::get<2>(NumeratorData)),
54 std::make_tuple(std::get<1>(DenominatorData),
55 std::get<2>(DenominatorData)),
59 for (
unsigned int i = 0; i < JacobiColumn.size(); ++i) {
60 for (
unsigned int j = 0; j < JacobiColumn.size(); ++j) {
66 LOG(INFO) <<
"FitFractions::" 67 "calculateFitFractionsWithCovarianceErrorPropagation() | No " 68 "valid fit result. Skip error calculation.";
71 FitFractions.push_back(
72 {std::get<0>(NumeratorData) +
"/" + std::get<0>(DenominatorData),
73 FitFractionValue, FitFractionError});
77 for (
auto &f : FitFractions) {
78 f.Error = std::sqrt(f.Error);
79 LOG(TRACE) <<
"calculateFitFractionsWithCovarianceErrorPropagation(): fit " 81 << f.Name <<
") is " << f.Value <<
" +- " << f.Error;
87 std::tuple<std::vector<double>, std::vector<std::vector<double>>>
89 const std::tuple<
double, std::vector<DerivativeData>> &NominatorDerivatives,
90 const std::tuple<
double, std::vector<DerivativeData>>
91 &DenominatorDerivatives,
93 std::vector<double> Column;
94 std::vector<size_t> ParameterPositions;
96 double N = std::get<0>(NominatorDerivatives);
97 double D = std::get<0>(DenominatorDerivatives);
99 auto dN = std::get<1>(NominatorDerivatives);
100 auto dD = std::get<1>(DenominatorDerivatives);
102 size_t PositionCounter(0);
106 auto FoundNominator =
107 std::find_if(dN.begin(), dN.end(), [&x](
auto const &par) {
108 return par.ParameterName == x.Name;
110 auto FoundDenominator =
111 std::find_if(dD.begin(), dD.end(), [&x](
auto const &par) {
112 return par.ParameterName == x.Name;
114 if (dN.end() != FoundNominator && dD.end() != FoundDenominator) {
116 Column.push_back((FoundNominator->ValueAtParameterPlusEpsilon /
117 FoundDenominator->ValueAtParameterPlusEpsilon -
118 FoundNominator->ValueAtParameterMinusEpsilon /
119 FoundDenominator->ValueAtParameterMinusEpsilon) /
120 FoundNominator->StepSize);
121 }
else if (dN.end() != FoundNominator) {
123 Column.push_back((FoundNominator->ValueAtParameterPlusEpsilon / D -
124 FoundNominator->ValueAtParameterMinusEpsilon / D) /
125 FoundNominator->StepSize);
126 }
else if (dD.end() != FoundDenominator) {
128 Column.push_back((N / FoundDenominator->ValueAtParameterPlusEpsilon -
129 N / FoundDenominator->ValueAtParameterMinusEpsilon) /
130 FoundDenominator->StepSize);
135 ParameterPositions.push_back(PositionCounter);
139 std::vector<std::vector<double>> SubCovarianceMatrix(
140 ParameterPositions.size(),
141 std::vector<double>(ParameterPositions.size()));
142 for (
size_t i = 0; i < ParameterPositions.size(); ++i) {
143 for (
size_t j = 0; j < ParameterPositions.size(); ++j) {
144 SubCovarianceMatrix[i][j] =
149 return std::make_tuple(Column, SubCovarianceMatrix);
152 std::tuple<std::string, double, std::vector<FitFractions::DerivativeData>>
156 std::string Name(IntensComponent.first);
167 *IntensComponent.second, PhspSample, Result)})
170 return std::tuple_cat(std::make_tuple(FoundIntegrals->first),
171 FoundIntegrals->second);
174 std::tuple<double, std::vector<FitFractions::DerivativeData>>
181 std::vector<Parameter> TempParameters = Intens.
getParameters();
182 std::vector<double> TempParameterValues;
183 for (
auto const &x : TempParameters)
184 TempParameterValues.push_back(x.Value);
186 std::vector<DerivativeData> Derivatives;
187 for (
unsigned int i = 0; i < TempParameters.size(); ++i) {
190 [refname = TempParameters[i].Name](
191 auto const &p) {
return p.Name == refname; });
193 if (found->IsFixed) {
196 double TempValue = found->Value;
199 double h = std::sqrt(std::numeric_limits<double>::epsilon());
200 if (TempValue != 0.0)
205 double up(TempValue + h);
206 TempParameterValues[i] = up;
211 double down(TempValue - h);
212 TempParameterValues[i] = down;
220 Derivatives.push_back(GradientData);
223 TempParameterValues[i] = TempValue;
226 return std::make_tuple(Integral, Derivatives);
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
void initializeWithFitResult(ComPWA::Intensity &Intens, ComPWA::FitResult Result)
Data structure which resembles a general fit result.
FitParameterList FinalParameters
virtual std::vector< Parameter > getParameters() const =0
Interface template for a general Function of the form OutputType Function(InputTypes) The concept clo...