Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Alignment/CocoaModel/interface/MeasurementDistancemeter3dim.h"
00010 #include "Alignment/CocoaModel/interface/LightRay.h"
00011 #include "Alignment/CocoaModel/interface/OpticalObject.h"
00012 #include <iostream>
00013 #include <iomanip>
00014 #include <cstdlib>
00015 #ifdef COCOA_VIS
00016 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
00017 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
00018 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
00019 #endif
00020 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00021
00022
00023
00024
00025
00026 void MeasurementDistancemeter3dim::calculateSimulatedValue( ALIbool firstTime )
00027 {
00028
00029 if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this );
00030
00031
00032 std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
00033 if( ALIUtils::debug >= 5) std::cout << "OptOList size" <<OptOList().size() << std::endl;
00034
00035
00036 ALIbool right_objects = 0;
00037 if( OptOList().size() == 2 ) {
00038 if( (*vocite)->type() == "distance_target"
00039 && ( (*(vocite+1))->type() == "distancemeter3dim" ) ) {
00040 right_objects = 1;
00041 }
00042 }
00043 if( !right_objects ) {
00044 std::cerr << "!!! ERROR in MeasurementDistancemeter3dim: " << name() << " There should only be two objects of type 'distance_target' and 'distancemeter3dim' " << std::endl;
00045 std::cerr << " 1st " << (*vocite)->name() << " 2nd " << (*vocite+1)->name() << std::endl;
00046 std::cerr << " 1st " << (*vocite)->type() << " 2nd " << (*vocite+1)->type() << std::endl;
00047
00048 DumpBadOrderOptOs();
00049 std::exception();
00050 }
00051
00052 #ifdef COCOA_VIS
00053 ALIVisLightPath* vispath = 0;
00054 if( ALIUtils::getFirstTime() ) {
00055 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00056 if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
00057 vispath = IgCocoaFileMgr::getInstance().newLightPath( name() );
00058 }
00059 }
00060 #endif
00061
00062 ALIuint isec = 0;
00063 for( vocite = OptOList().begin(); vocite != OptOList().end(); vocite++) {
00064 if( ALIUtils::debug >= 2) std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;
00065 isec ++;
00066
00067
00068 ALIstring behav = getMeasuringBehaviour(vocite);
00069
00070
00071 LightRay lightray;
00072 (*vocite)->participateInMeasurement( lightray, *this, behav);
00073
00074 #ifdef COCOA_VIS
00075 if( ALIUtils::getFirstTime() ) {
00076 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00077 if(gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
00078 ALIVRMLMgr::getInstance().addLightPoint( lightray.point() );
00079 if(ALIUtils::debug >= 5)std::cout << "ALIVRMLMg addLightPoint " << lightray.point() << (*vocite)->name() << std::endl;
00080 }
00081 if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
00082 vispath->addLightPoint( lightray.point(), *vocite );
00083 }
00084 }
00085 #endif
00086
00087 if ( isec > OptOList().size() ) {
00088 std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
00089 std::exception();
00090 }
00091 }
00092
00093 if(ALIUtils::debug >= 5) std::cout << "end calculateSimulatedValue" <<std::endl;
00094
00095 }
00096
00097
00098
00099
00100
00101
00102
00103 void MeasurementDistancemeter3dim::setConversionFactor( const std::vector<ALIstring>& wordlist )
00104 {
00105
00106 if(wordlist.size() == 1) return;
00107 if( wordlist.size() != 4
00108 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3])
00109 || wordlist[2] != ALIstring("+-") ){
00110 std::cerr << "!! Distancemeter3dim Measurement setConversionFactor: WRONG FORMAT "<< std::endl
00111 << "It should be: DISTANCEMETER3DIM factor +- error " << std::endl
00112 << "It is: ";
00113 ALIUtils::dumpVS( wordlist, " ", std::cerr );
00114 std::exception();
00115 }
00116 theFactor = atof(wordlist[1].c_str());
00117
00118 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00119 ALIint dimfac = ALIint( gomgr->GlobalOptions()[ ALIstring("distancemeter_meas_value_dimension") ] );
00120 if( dimfac == 0 ) {
00121 theFactor *= 1.;
00122 } else if( dimfac == 1 ) {
00123 theFactor *= 1.E-3;
00124 } else if( dimfac == 2 ) {
00125 theFactor *= 1.E-6;
00126 } else {
00127 std::cerr << " !!!EXITING: error in global option distancemeter3dim_meas_value_dimension, it can only take values 0,1,2, not " << dimfac;
00128 std::exception();
00129 }
00130 theFactorSigma = atof(wordlist[3].c_str());
00131
00132 }
00133
00134
00135
00136
00137
00138 void MeasurementDistancemeter3dim::correctValueAndSigma()
00139 {
00140 ALIdouble val = value()[0];
00141 ALIdouble sig = sigma()[0];
00142 if(ALIUtils::debug >= 4) std::cout << "MeasurementDistancemeter3dim::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
00143
00144
00145 val *= theFactor;
00146
00147
00148 if(ALIUtils::debug >= 4) std::cout << "MeasuremenDistancemeter3dim::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
00149 setValue( 0, val );
00150 setSigma( 0, sig );
00151
00152 }
00153