File indexing completed on 2024-04-06 11:56:02
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Alignment/CocoaModel/interface/MeasurementTiltmeter.h"
0010 #include "Alignment/CocoaModel/interface/LightRay.h"
0011 #include "Alignment/CocoaModel/interface/OpticalObject.h"
0012 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0013 #include <iostream>
0014 #include <iomanip>
0015 #include <cstdlib>
0016
0017
0018
0019
0020 void MeasurementTiltmeter::calculateSimulatedValue(ALIbool firstTime) {
0021 if (ALIUtils::debug >= 2)
0022 printStartCalculateSimulatedValue(this);
0023
0024
0025 std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
0026 if (OptOList().size() != 1 || (*vocite)->type() == "distancemeter") {
0027 std::cerr << "!!! ERROR in MeasurementTiltmeter: " << name()
0028 << " There should only be one object of type 'tiltmeter' " << std::endl;
0029 DumpBadOrderOptOs();
0030 exit(1);
0031 }
0032
0033
0034 ALIstring behav = getMeasuringBehaviour(vocite);
0035
0036
0037 LightRay ll;
0038 (*vocite)->participateInMeasurement(ll, *this, behav);
0039
0040 if (ALIUtils::debug >= 5)
0041 std::cout << "end calculateSimulatedValue" << std::endl;
0042 }
0043
0044
0045
0046
0047
0048
0049 void MeasurementTiltmeter::setConversionFactor(const std::vector<ALIstring>& wordlist) {
0050
0051 if (wordlist.size() == 1)
0052 return;
0053 if (wordlist.size() != 7 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) ||
0054 !ALIUtils::IsNumber(wordlist[4]) || !ALIUtils::IsNumber(wordlist[6]) || wordlist[2] != ALIstring("+-") ||
0055 wordlist[5] != ALIstring("+-")) {
0056 std::cerr << "!! Tiltmeter Measurement setConversionFactor: WRONG FORMAT " << std::endl
0057 << "It should be: TILTEMETER factor +- error constant_term +- error" << (wordlist.size() != 7)
0058 << !ALIUtils::IsNumber(wordlist[1]) << !ALIUtils::IsNumber(wordlist[3])
0059 << !ALIUtils::IsNumber(wordlist[4])
0060 << !ALIUtils::IsNumber(wordlist[6])
0061
0062 << std::endl
0063 << "It is: ";
0064 ALIUtils::dumpVS(wordlist, " ", std::cerr);
0065 exit(1);
0066 }
0067 theFactor = atof(wordlist[1].c_str());
0068
0069
0070 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0071 ALIint dimfac = ALIint(gomgr->GlobalOptions()[ALIstring("tiltmeter_meas_value_dimension")]);
0072 if (dimfac == 0) {
0073 theFactor *= 1.;
0074 } else if (dimfac == 1) {
0075 theFactor *= 1.E-3;
0076 } else if (dimfac == 2) {
0077 theFactor *= 1.E-6;
0078 } else {
0079 std::cerr
0080 << " !!!EXITING: error in global option tiltmeter_meas_value_dimension, it can only take values 0,1,2, not "
0081 << dimfac;
0082 }
0083 theFactorSigma = atof(wordlist[3].c_str());
0084 theConstantTerm = atof(wordlist[4].c_str()) * valueDimensionFactor();
0085 theConstantTermSigma = atof(wordlist[6].c_str()) * sigmaDimensionFactor();
0086
0087
0088
0089
0090
0091
0092 }
0093
0094
0095
0096
0097 void MeasurementTiltmeter::correctValueAndSigma() {
0098 ALIdouble val = value()[0];
0099 ALIdouble sig = sigma()[0];
0100 if (ALIUtils::debug >= 4)
0101 std::cout << "MeasurementTiltmeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
0102
0103 val -= theConstantTerm;
0104
0105
0106
0107
0108
0109
0110 sig = sqrt(sig * sig + theConstantTermSigma * theConstantTermSigma);
0111
0112
0113
0114
0115 val *= theFactor;
0116
0117
0118 if (ALIUtils::debug >= 4)
0119 std::cout << "MeasurementTiltmeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
0120 setValue(0, val);
0121 setSigma(0, sig);
0122 }