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