1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
// COCOA class implementation file
//Id: FittedEntriesSet.cc
//CAT: Model
//
// History: v1.0
// Pedro Arce
#include <fstream>
#include <map>
#include "Alignment/CocoaFit/interface/FittedEntriesSet.h"
#include "Alignment/CocoaModel/interface/Model.h"
#include "Alignment/CocoaModel/interface/Measurement.h"
#include "Alignment/CocoaModel/interface/OpticalObject.h"
#include "Alignment/CocoaModel/interface/Entry.h"
#ifdef MAT_MESCHACH
#include "Alignment/CocoaFit/interface/MatrixMeschach.h"
#endif
//
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
FittedEntriesSet::FittedEntriesSet(MatrixMeschach* AtWAMatrix) {
//- theTime = Model::MeasurementsTime();
theDate = Measurement::getCurrentDate();
theTime = Measurement::getCurrentTime();
theMinEntryQuality = 2;
theEntriesErrorMatrix = AtWAMatrix;
Fill();
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
FittedEntriesSet::FittedEntriesSet(const std::vector<ALIstring>& wl) {
//- theTime = Model::MeasurementsTime();
theDate = wl[0];
theTime = "99:99";
theMinEntryQuality = 2;
theEntriesErrorMatrix = (MatrixMeschach*)nullptr;
FillEntriesFromFile(wl);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
FittedEntriesSet::FittedEntriesSet(const std::vector<FittedEntriesSet*>& vSets) {
theDate = "99/99/99";
theTime = "99:99";
theMinEntryQuality = 2;
theEntriesErrorMatrix = (MatrixMeschach*)nullptr;
FillEntriesAveragingSets(vSets);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
void FittedEntriesSet::Fill() {
FillEntries();
FillCorrelations();
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
void FittedEntriesSet::FillEntries() {
//---------- Store Fitted Entries
//----- Iterate over entry list
std::vector<Entry*>::const_iterator vecite;
for (vecite = Model::EntryList().begin(); vecite != Model::EntryList().end(); ++vecite) {
//--- Only for good quality parameters (='unk')
if ((*vecite)->quality() >= theMinEntryQuality) {
// ALIdouble dimv = (*vecite)->ValueDimensionFactor();
// ALIdouble dims = (*vecite)->SigmaDimensionFactor();
ALIint ipos = (*vecite)->fitPos();
FittedEntry* fe = new FittedEntry((*vecite), ipos, sqrt(theEntriesErrorMatrix->Mat()->me[ipos][ipos]));
//- std::cout << fe << "IN fit FE " << fe->theValue<< " " << fe->Sigma()<< " " << sqrt(theEntriesErrorMatrix->Mat()->me[NoEnt][NoEnt]) / dims<< std::endl;
theFittedEntries.push_back(fe);
}
}
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
void FittedEntriesSet::FillCorrelations() {
//------ Count the number of entries that will be in the set
ALIuint nent = 0;
std::vector<Entry*>::const_iterator vecite;
for (vecite = Model::EntryList().begin(); vecite != Model::EntryList().end(); ++vecite) {
if ((*vecite)->quality() > theMinEntryQuality) {
nent++;
}
}
CreateCorrelationMatrix(nent);
//---------- Store correlations
ALIuint ii;
for (ii = 0; ii < nent; ii++) {
for (ALIuint jj = ii + 1; jj < nent; jj++) {
ALIdouble corr = theEntriesErrorMatrix->Mat()->me[ii][jj];
if (corr != 0) {
corr /= (sqrt(theEntriesErrorMatrix->Mat()->me[ii][ii]) / sqrt(theEntriesErrorMatrix->Mat()->me[jj][jj]));
theCorrelationMatrix[ii][jj] = corr;
}
}
}
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
void FittedEntriesSet::CreateCorrelationMatrix(const ALIuint nent) {
std::vector<ALIdouble> vd(nent, 0.);
std::vector<std::vector<ALIdouble> > vvd(nent, vd);
theCorrelationMatrix = vvd;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
void FittedEntriesSet::FillEntriesFromFile(const std::vector<ALIstring>& wl) {
ALIuint siz = wl.size();
for (ALIuint ii = 1; ii < siz; ii += 3) {
FittedEntry* fe = new FittedEntry(wl[ii], ALIUtils::getFloat(wl[ii + 1]), ALIUtils::getFloat(wl[ii + 2]));
theFittedEntries.push_back(fe);
}
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
void FittedEntriesSet::FillEntriesAveragingSets(const std::vector<FittedEntriesSet*>& vSets) {
std::vector<FittedEntry*> vFEntry;
ALIuint nEntry = vSets[0]->FittedEntries().size();
// ALIuint setssiz = vSets.size();
for (ALIuint ii = 0; ii < nEntry; ii++) { // loop to FittedEntry's
if (ALIUtils::debug >= 5)
std::cout << "FillEntriesAveragingSets entry " << ii << std::endl;
vFEntry.clear();
for (ALIuint jj = 0; jj < vSets.size(); jj++) { // look for FittedEntry ii in each Sets
if (ALIUtils::debug >= 5)
std::cout << "FillEntriesAveragingSets set " << jj << std::endl;
//----- Check all have the same number of entries
if (vSets[jj]->FittedEntries().size() != nEntry) {
std::cerr << "!!! FATAL ERROR FittedEntriesSet::FillEntriesAveragingSets set number " << jj
<< " has different number of entries = " << vSets[jj]->FittedEntries().size()
<< " than first set = " << nEntry << std::endl;
exit(1);
}
vFEntry.push_back(vSets[jj]->FittedEntries()[ii]);
}
FittedEntry* fe = new FittedEntry(vFEntry);
if (ALIUtils::debug >= 5)
std::cout << "FillEntriesAveragingSets new fentry " << fe->getValue() << " " << fe->getSigma() << std::endl;
theFittedEntries.push_back(fe);
}
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
void FittedEntriesSet::SetOptOEntries() {
if (ALIUtils::debug >= 5)
std::cout << " FittedEntriesSet::SetOptOEntries " << theFittedEntries.size() << std::endl;
std::vector<FittedEntry*>::const_iterator ite;
for (ite = theFittedEntries.begin(); ite != theFittedEntries.end(); ++ite) {
FittedEntry* fe = (*ite);
OpticalObject* opto = Model::getOptOByName(fe->getOptOName());
Entry* entry = Model::getEntryByName(fe->getOptOName(), fe->getEntryName());
entry->setValue(fe->getValue());
entry->setSigma(fe->getSigma());
if (ALIUtils::debug >= 5)
std::cout << " FittedEntriesSet::SetOptOEntries() " << opto->name() << " " << entry->name() << std::endl;
opto->setGlobalCoordinates();
opto->setOriginalEntryValues();
}
}
|