File indexing completed on 2024-04-06 11:56:02
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Alignment/CocoaModel/interface/MeasurementDistancemeter3dim.h"
0010 #include "Alignment/CocoaModel/interface/LightRay.h"
0011 #include "Alignment/CocoaModel/interface/OpticalObject.h"
0012 #include <iostream>
0013 #include <iomanip>
0014 #include <cstdlib>
0015 #ifdef COCOA_VIS
0016 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
0017 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
0018 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
0019 #endif
0020 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0021
0022
0023
0024
0025 void MeasurementDistancemeter3dim::calculateSimulatedValue(ALIbool firstTime) {
0026 if (ALIUtils::debug >= 2)
0027 printStartCalculateSimulatedValue(this);
0028
0029
0030 std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
0031 if (ALIUtils::debug >= 5)
0032 std::cout << "OptOList size" << OptOList().size() << std::endl;
0033
0034
0035 ALIbool right_objects = false;
0036 if (OptOList().size() == 2) {
0037 if ((*vocite)->type() == "distance_target" && ((*(vocite + 1))->type() == "distancemeter3dim")) {
0038 right_objects = true;
0039 }
0040 }
0041 if (!right_objects) {
0042 std::cerr << "!!! ERROR in MeasurementDistancemeter3dim: " << name()
0043 << " There should only be two objects of type 'distance_target' and 'distancemeter3dim' " << std::endl;
0044 std::cerr << " 1st " << (*vocite)->name() << " 2nd " << (*vocite + 1)->name() << std::endl;
0045 std::cerr << " 1st " << (*vocite)->type() << " 2nd " << (*vocite + 1)->type() << std::endl;
0046
0047 DumpBadOrderOptOs();
0048 std::exception();
0049 }
0050
0051 #ifdef COCOA_VIS
0052 ALIVisLightPath* vispath = 0;
0053 if (ALIUtils::getFirstTime()) {
0054 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0055 if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0056 vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
0057 }
0058 }
0059 #endif
0060
0061 ALIuint isec = 0;
0062 for (vocite = OptOList().begin(); vocite != OptOList().end(); ++vocite) {
0063 if (ALIUtils::debug >= 2)
0064 std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;
0065 isec++;
0066
0067
0068 ALIstring behav = getMeasuringBehaviour(vocite);
0069
0070
0071 LightRay lightray;
0072 (*vocite)->participateInMeasurement(lightray, *this, behav);
0073
0074 #ifdef COCOA_VIS
0075 if (ALIUtils::getFirstTime()) {
0076 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0077 if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
0078 ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
0079 if (ALIUtils::debug >= 5)
0080 std::cout << "ALIVRMLMg addLightPoint " << lightray.point() << (*vocite)->name() << std::endl;
0081 }
0082 if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0083 vispath->addLightPoint(lightray.point(), *vocite);
0084 }
0085 }
0086 #endif
0087
0088 if (isec > OptOList().size()) {
0089 std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
0090 std::exception();
0091 }
0092 }
0093
0094 if (ALIUtils::debug >= 5)
0095 std::cout << "end calculateSimulatedValue" << std::endl;
0096 }
0097
0098
0099
0100
0101
0102
0103 void MeasurementDistancemeter3dim::setConversionFactor(const std::vector<ALIstring>& wordlist) {
0104
0105 if (wordlist.size() == 1)
0106 return;
0107 if (wordlist.size() != 4 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) ||
0108 wordlist[2] != ALIstring("+-")) {
0109 std::cerr << "!! Distancemeter3dim Measurement setConversionFactor: WRONG FORMAT " << std::endl
0110 << "It should be: DISTANCEMETER3DIM factor +- error " << std::endl
0111 << "It is: ";
0112 ALIUtils::dumpVS(wordlist, " ", std::cerr);
0113 std::exception();
0114 }
0115 theFactor = atof(wordlist[1].c_str());
0116
0117 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0118 ALIint dimfac = ALIint(gomgr->GlobalOptions()[ALIstring("distancemeter_meas_value_dimension")]);
0119 if (dimfac == 0) {
0120 theFactor *= 1.;
0121 } else if (dimfac == 1) {
0122 theFactor *= 1.E-3;
0123 } else if (dimfac == 2) {
0124 theFactor *= 1.E-6;
0125 } else {
0126 std::cerr << " !!!EXITING: error in global option distancemeter3dim_meas_value_dimension, it can only take values "
0127 "0,1,2, not "
0128 << dimfac;
0129 std::exception();
0130 }
0131 theFactorSigma = atof(wordlist[3].c_str());
0132 }
0133
0134
0135
0136
0137 void MeasurementDistancemeter3dim::correctValueAndSigma() {
0138 ALIdouble val = value()[0];
0139 ALIdouble sig = sigma()[0];
0140 if (ALIUtils::debug >= 4)
0141 std::cout << "MeasurementDistancemeter3dim::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
0142
0143
0144 val *= theFactor;
0145
0146
0147 if (ALIUtils::debug >= 4)
0148 std::cout << "MeasuremenDistancemeter3dim::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
0149 setValue(0, val);
0150 setSigma(0, sig);
0151 }