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
|
// COCOA class implementation file
// Id: Measurement.C
// CAT: Model
// ---------------------------------------------------------------------------
// History: v1.0
// Authors:
// Pedro Arce
#include "Alignment/CocoaModel/interface/MeasurementDistancemeter.h"
#include "Alignment/CocoaModel/interface/LightRay.h"
#include "Alignment/CocoaModel/interface/OpticalObject.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>
#ifdef COCOA_VIS
#include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
#include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
#include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
#endif
#include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void MeasurementDistancemeter::calculateSimulatedValue(ALIbool firstTime) {
if (ALIUtils::debug >= 2)
printStartCalculateSimulatedValue(this); // important for Examples/FakeMeas
//---------- Loop list of OptO that take part in measurement
std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
if (ALIUtils::debug >= 5)
std::cout << "OptOList size= " << OptOList().size() << std::endl;
//----- Check that there are only two measurements that are 'distance_target' and 'distancemeter'
ALIbool right_objects = false;
if (OptOList().size() == 2) {
if ((*vocite)->type() == "distance_target" &&
((*(vocite + 1))->type() == "distancemeter" || (*(vocite + 1))->type() == "distancemeter1dim")) {
right_objects = true;
}
}
if (!right_objects) {
std::cerr << "!!! ERROR in MeasurementDistancemeter: " << name()
<< " There should only be two objects of type 'distance_target' and 'distancemeter' " << std::endl;
std::cerr << " 1st: " << (*vocite)->name() << " 2nd: " << (*vocite + 1)->name() << std::endl;
std::cerr << " 1st " << (*vocite)->type() << " 2nd " << (*vocite + 1)->type() << std::endl;
DumpBadOrderOptOs();
std::exception();
}
#ifdef COCOA_VIS
ALIVisLightPath* vispath = 0;
if (ALIUtils::getFirstTime()) {
GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
}
}
#endif
ALIuint isec = 0; //security variable to check OptOList().size()
for (vocite = OptOList().begin(); vocite != OptOList().end(); ++vocite) {
if (ALIUtils::debug >= 2)
std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;
isec++;
//---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
ALIstring behav = getMeasuringBehaviour(vocite);
//---------- participate in measurement
LightRay lightray; //it is not used in this measurement type
(*vocite)->participateInMeasurement(lightray, *this, behav);
#ifdef COCOA_VIS
if (ALIUtils::getFirstTime()) {
GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
if (ALIUtils::debug >= 5)
std::cout << "ALIVRMLMg addLightPoint " << lightray.point() << (*vocite)->name() << std::endl;
}
if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
vispath->addLightPoint(lightray.point(), *vocite);
}
}
#endif
if (isec > OptOList().size()) {
std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
std::exception();
}
}
if (ALIUtils::debug >= 5)
std::cout << "end calculateSimulatedValue" << std::endl;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@ You input 2 numbers after 'DISTANCEMETER':
//@@
//@@ set the conversion factor from mV to mm
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void MeasurementDistancemeter::setConversionFactor(const std::vector<ALIstring>& wordlist) {
//--------- Check that the format is OK
if (wordlist.size() == 1)
return;
if (wordlist.size() != 4 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) ||
wordlist[2] != ALIstring("+-")) {
std::cerr << "!! Distancemeter Measurement setConversionFactor: WRONG FORMAT " << std::endl
<< "It should be: DISTANCEMETER factor +- error " << std::endl
<< "It is: ";
ALIUtils::dumpVS(wordlist, " ", std::cerr);
std::exception();
}
theFactor = atof(wordlist[1].c_str());
//------ correct by dimension of value of tiltmeter
GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
ALIint dimfac = ALIint(gomgr->GlobalOptions()[ALIstring("distancemeter_meas_value_dimension")]);
if (dimfac == 0) {
theFactor *= 1.;
} else if (dimfac == 1) {
theFactor *= 1.E-3;
} else if (dimfac == 2) {
theFactor *= 1.E-6;
} else {
std::cerr
<< " !!!EXITING: error in global option distancemeter_meas_value_dimension, it can only take values 0,1,2, not "
<< dimfac;
std::exception();
}
theFactorSigma = atof(wordlist[3].c_str());
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@ Value is given in mV: convert to mm
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void MeasurementDistancemeter::correctValueAndSigma() {
ALIdouble val = value()[0];
ALIdouble sig = sigma()[0];
if (ALIUtils::debug >= 4)
std::cout << "MeasurementDistancemeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
//- std::cout << "FACTOR " << theFactor << "correct " << val << " " << thePedestal << std::endl;
val *= theFactor;
//-------- Do not correct the sigma!!!!
//- sig *= theFactor;
if (ALIUtils::debug >= 4)
std::cout << "MeasuremenDistancemeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
setValue(0, val);
setSigma(0, sig);
}
|