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