00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Alignment/CocoaModel/interface/MeasurementTiltmeter.h"
00010 #include "Alignment/CocoaModel/interface/LightRay.h"
00011 #include "Alignment/CocoaModel/interface/OpticalObject.h"
00012 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00013 #include <iostream>
00014 #include <iomanip>
00015
00016
00017
00018
00019 void MeasurementTiltmeter::calculateSimulatedValue( ALIbool firstTime )
00020 {
00021
00022 if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this );
00023
00024
00025 std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
00026 if( OptOList().size() != 1 ||
00027 (*vocite)->type() == "distancemeter") {
00028 std::cerr << "!!! ERROR in MeasurementTiltmeter: " << name() << " There should only be one object of type 'tiltmeter' " << std::endl;
00029 DumpBadOrderOptOs();
00030 exit(1);
00031 }
00032
00033
00034 ALIstring behav = getMeasuringBehaviour(vocite);
00035
00036
00037 LightRay ll;
00038 (*vocite)->participateInMeasurement( ll, *this, behav );
00039
00040 if(ALIUtils::debug >= 5) std::cout << "end calculateSimulatedValue" <<std::endl;
00041
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051 void MeasurementTiltmeter::setConversionFactor( const std::vector<ALIstring>& wordlist )
00052 {
00053
00054 if(wordlist.size() == 1) return;
00055 if( wordlist.size() != 7
00056 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3])
00057 || !ALIUtils::IsNumber(wordlist[4]) || !ALIUtils::IsNumber(wordlist[6])
00058 || wordlist[2] != ALIstring("+-")|| wordlist[5] != ALIstring("+-") ){
00059 std::cerr << "!! Tiltmeter Measurement setConversionFactor: WRONG FORMAT "<< std::endl
00060 << "It should be: TILTEMETER factor +- error constant_term +- error"
00061 << (wordlist.size() != 7)
00062 << !ALIUtils::IsNumber(wordlist[1]) << !ALIUtils::IsNumber(wordlist[3])
00063 << !ALIUtils::IsNumber(wordlist[4]) << !ALIUtils::IsNumber(wordlist[6])
00064
00065 << std::endl
00066 << "It is: ";
00067 ALIUtils::dumpVS( wordlist, " ", std::cerr );
00068 exit(1);
00069 }
00070 theFactor = atof(wordlist[1].c_str());
00071
00072
00073 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00074 ALIint dimfac = ALIint( gomgr->GlobalOptions()[ ALIstring("tiltmeter_meas_value_dimension") ] );
00075 if( dimfac == 0 ) {
00076 theFactor *= 1.;
00077 } else if( dimfac == 1 ) {
00078 theFactor *= 1.E-3;
00079 } else if( dimfac == 2 ) {
00080 theFactor *= 1.E-6;
00081 } else {
00082 std::cerr << " !!!EXITING: error in global option tiltmeter_meas_value_dimension, it can only take values 0,1,2, not " << dimfac;
00083 }
00084 theFactorSigma = atof(wordlist[3].c_str());
00085 theConstantTerm = atof(wordlist[4].c_str()) * valueDimensionFactor();
00086 theConstantTermSigma = atof(wordlist[6].c_str()) * sigmaDimensionFactor();
00087
00088
00089
00090
00091
00092
00093 }
00094
00095
00096
00097
00098
00099 void MeasurementTiltmeter::correctValueAndSigma()
00100 {
00101 ALIdouble val = value()[0];
00102 ALIdouble sig = sigma()[0];
00103 if(ALIUtils::debug >= 4) std::cout << "MeasurementTiltmeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
00104
00105 val -= theConstantTerm;
00106
00107
00108
00109
00110
00111
00112 sig = sqrt( sig*sig + theConstantTermSigma*theConstantTermSigma );
00113
00114
00115
00116
00117 val *= theFactor;
00118
00119
00120 if(ALIUtils::debug >= 4) std::cout << "MeasurementTiltmeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
00121 setValue( 0, val );
00122 setSigma( 0, sig );
00123
00124 }
00125