File indexing completed on 2023-03-17 10:38:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Alignment/CocoaModel/interface/MeasurementDistancemeter.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 MeasurementDistancemeter::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" &&
0038 ((*(vocite + 1))->type() == "distancemeter" || (*(vocite + 1))->type() == "distancemeter1dim")) {
0039 right_objects = true;
0040 }
0041 }
0042 if (!right_objects) {
0043 std::cerr << "!!! ERROR in MeasurementDistancemeter: " << name()
0044 << " There should only be two objects of type 'distance_target' and 'distancemeter' " << std::endl;
0045 std::cerr << " 1st: " << (*vocite)->name() << " 2nd: " << (*vocite + 1)->name() << std::endl;
0046 std::cerr << " 1st " << (*vocite)->type() << " 2nd " << (*vocite + 1)->type() << std::endl;
0047
0048 DumpBadOrderOptOs();
0049 std::exception();
0050 }
0051
0052 #ifdef COCOA_VIS
0053 ALIVisLightPath* vispath = 0;
0054 if (ALIUtils::getFirstTime()) {
0055 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0056 if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0057 vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
0058 }
0059 }
0060 #endif
0061
0062 ALIuint isec = 0;
0063 for (vocite = OptOList().begin(); vocite != OptOList().end(); ++vocite) {
0064 if (ALIUtils::debug >= 2)
0065 std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;
0066 isec++;
0067
0068
0069 ALIstring behav = getMeasuringBehaviour(vocite);
0070
0071
0072 LightRay lightray;
0073 (*vocite)->participateInMeasurement(lightray, *this, behav);
0074
0075 #ifdef COCOA_VIS
0076 if (ALIUtils::getFirstTime()) {
0077 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0078 if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
0079 ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
0080 if (ALIUtils::debug >= 5)
0081 std::cout << "ALIVRMLMg addLightPoint " << lightray.point() << (*vocite)->name() << std::endl;
0082 }
0083 if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0084 vispath->addLightPoint(lightray.point(), *vocite);
0085 }
0086 }
0087 #endif
0088
0089 if (isec > OptOList().size()) {
0090 std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
0091 std::exception();
0092 }
0093 }
0094
0095 if (ALIUtils::debug >= 5)
0096 std::cout << "end calculateSimulatedValue" << std::endl;
0097 }
0098
0099
0100
0101
0102
0103
0104 void MeasurementDistancemeter::setConversionFactor(const std::vector<ALIstring>& wordlist) {
0105
0106 if (wordlist.size() == 1)
0107 return;
0108 if (wordlist.size() != 4 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) ||
0109 wordlist[2] != ALIstring("+-")) {
0110 std::cerr << "!! Distancemeter Measurement setConversionFactor: WRONG FORMAT " << std::endl
0111 << "It should be: DISTANCEMETER factor +- error " << std::endl
0112 << "It is: ";
0113 ALIUtils::dumpVS(wordlist, " ", std::cerr);
0114 std::exception();
0115 }
0116 theFactor = atof(wordlist[1].c_str());
0117
0118 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0119 ALIint dimfac = ALIint(gomgr->GlobalOptions()[ALIstring("distancemeter_meas_value_dimension")]);
0120 if (dimfac == 0) {
0121 theFactor *= 1.;
0122 } else if (dimfac == 1) {
0123 theFactor *= 1.E-3;
0124 } else if (dimfac == 2) {
0125 theFactor *= 1.E-6;
0126 } else {
0127 std::cerr
0128 << " !!!EXITING: error in global option distancemeter_meas_value_dimension, it can only take values 0,1,2, not "
0129 << dimfac;
0130 std::exception();
0131 }
0132 theFactorSigma = atof(wordlist[3].c_str());
0133 }
0134
0135
0136
0137
0138 void MeasurementDistancemeter::correctValueAndSigma() {
0139 ALIdouble val = value()[0];
0140 ALIdouble sig = sigma()[0];
0141 if (ALIUtils::debug >= 4)
0142 std::cout << "MeasurementDistancemeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
0143
0144
0145 val *= theFactor;
0146
0147
0148 if (ALIUtils::debug >= 4)
0149 std::cout << "MeasuremenDistancemeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
0150 setValue(0, val);
0151 setSigma(0, sig);
0152 }