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