9 #include <alignment/PedeResult.h>
27 int PedeResult::getParameterIndex(
int parameterLabel)
29 auto index = labelIndices.find(parameterLabel);
30 if (index != labelIndices.end())
35 void PedeResult::readEigenFile(
string filename)
41 ifstream file(filename);
46 int eigenPairIndex = -1;
48 for (
auto& pData : data) {
49 pData.eigenweights.clear();
50 pData.eigenweights.reserve(20);
53 while (getline(file, line)) {
57 string tmp1, tmp2, tmp3;
60 ss >> tmp1 >> eigenPairNumber >> tmp2 >> tmp3 >> eigenvalue;
61 cout << tmp1 <<
" " << tmp2 <<
" " << tmp3 <<
" " << eigenPairNumber <<
" " << eigenvalue << endl;
62 if (tmp1 ==
"Eigenvector")
68 vector<pair<int, double>> elements;
69 while (getline(file, line) && line.length() > 2) {
76 triplet >> lab1 >> w1 >> lab2 >> w2 >> lab3 >> w3;
77 if (lab1) elements.push_back({lab1, w1});
78 if (lab2) elements.push_back({lab2, w2});
79 if (lab3) elements.push_back({lab3, w3});
82 for (
auto& pData : data) {
83 pData.eigenweights.push_back(0.);
85 for (
auto el : elements) {
86 int index = getParameterIndex(el.first);
88 data[index].eigenweights[eigenPairIndex] = el.second;
90 eigenNumbers.push_back(eigenvalue);
95 void PedeResult::read(
string filename)
98 ifstream res(filename);
102 noDeterminedParams = 0;
104 labelIndices.clear();
107 while (getline(res, line)) {
111 double presigma = 0.;
116 ss >> label >> param >> presigma >> differ >> error;
117 data.push_back(
parameterData(index, label, param, error, presigma));
118 labelIndices.insert(make_pair(label, index));
119 if (isParameterDetermined(index))
120 ++noDeterminedParams;
126 PedeResult::PedeResult(
const string& filename): data(), eigenNumbers(), valid(false), labelIndices()
134 return data[parameterIndex].label;
139 return data[parameterIndex].correction;
144 return data[parameterIndex].error;
149 return data[parameterIndex].presigma;
154 return data[parameterIndex].presigma < 0;
159 return !
isParameterFixed(parameterIndex) &&
data[parameterIndex].correction != 0. &&
data[parameterIndex].error != 0.;
171 if (eigenPairIndex >= element.eigenweights.size())
174 return data[parameterIndex].eigenweights[eigenPairIndex];
178 for (
auto pdata :
data) {
179 std::cout << pdata.index <<
" : " << pdata.label <<
" corr: " << pdata.correction <<
" err: " << pdata.error <<
" presigma: " <<
180 pdata.presigma << endl;
double getParameterCorrection(unsigned int parameterIndex)
Get determined correction of parameter at index.
bool isParameterDetermined(unsigned int parameterIndex)
Is parameter at given index determined?
double getEigenNumber(unsigned int eigenPairIndex)
Get eigennumber at given index.
void read(std::string filename="millepede.res")
Reads the result file and inits the object.
bool outOfBounds(int iparam)
Is index out of valid range?
bool isParameterFixed(unsigned int parameterIndex)
Is parameter at given index fixed?
unsigned int getParameterLabel(unsigned int parameterIndex)
Get label of parameter at index.
double getParameterPresigma(unsigned int parameterIndex)
Get presigma of parameter at index.
std::vector< double > eigenNumbers
Vector of loaded eigennumbers.
double getParameterError(unsigned int parameterIndex)
Get correction error of parameter at index.
double getEigenVectorElement(unsigned int eigenPairIndex, unsigned int parameterIndex)
Get eigenvector at given index.
std::vector< parameterData > data
Vector with all the parameter data.
void dump()
Dump the content to std::cout.
Abstract base class for different kinds of events.
Struct to hold data for a parameter.