File indexing completed on 2024-04-06 11:56:02
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Alignment/CocoaModel/interface/MeasurementDiffEntry.h"
0010 #include "Alignment/CocoaModel/interface/Model.h"
0011 #include "Alignment/CocoaModel/interface/OpticalObject.h"
0012 #include "Alignment/CocoaModel/interface/Entry.h"
0013 #include "Alignment/CocoaUtilities/interface/ALIFileIn.h"
0014 #include <iostream>
0015 #include <iomanip>
0016 #include <cstdlib>
0017 #include <cmath> // include floating-point std::abs functions
0018 #ifdef COCOA_VIS
0019 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
0020 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
0021 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
0022 #endif
0023
0024
0025 void MeasurementDiffEntry::buildOptONamesList(const std::vector<ALIstring>& wl) {
0026 int NPairs = (wl.size() + 1) / 2;
0027
0028
0029 for (int ii = 0; ii < NPairs; ii++) {
0030
0031 int isl = wl[ii * 2].rfind('/');
0032 AddOptONameListItem(wl[ii * 2].substr(0, isl));
0033
0034 if (ii != NPairs - 1 && wl[2 * ii + 1] != ALIstring("&")) {
0035 ALIFileIn::getInstance(Model::SDFName()).ErrorInLine();
0036 std::cerr << "!!! Measured Optical Objects should be separated by '&', not by" << wl[2 * ii + 1] << std::endl;
0037 exit(2);
0038 }
0039
0040 if (ii == 0) {
0041 theEntryNameFirst = wl[ii * 2].substr(isl + 1, 999);
0042 } else if (ii == 1) {
0043 theEntryNameSecond = wl[ii * 2].substr(isl + 1, 999);
0044 }
0045 }
0046 }
0047
0048
0049
0050
0051 void MeasurementDiffEntry::calculateSimulatedValue(ALIbool firstTime) {
0052 if (ALIUtils::debug >= 2)
0053 printStartCalculateSimulatedValue(this);
0054
0055
0056 std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
0057 if (ALIUtils::debug >= 5)
0058 std::cout << "OptOList size" << OptOList().size() << std::endl;
0059
0060
0061 if (OptOList().size() == !true) {
0062 std::cerr << "!!! ERROR in MeasurementDiffEntry: " << name() << " There should only be two objects " << std::endl;
0063 std::cerr << " 1st " << (*vocite)->name() << " 2nd " << (*vocite + 1)->name() << std::endl;
0064 DumpBadOrderOptOs();
0065 std::exception();
0066 }
0067
0068 #ifdef COCOA_VIS
0069 ALIVisLightPath* vispath = 0;
0070 if (ALIUtils::getFirstTime()) {
0071 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0072 if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0073 vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
0074 }
0075 }
0076 #endif
0077
0078
0079 Entry* entry1 = Model::getEntryByName((*(OptOList().begin()))->longName(), theEntryNameFirst);
0080 Entry* entry2 = Model::getEntryByName((*(OptOList().begin() + 1))->longName(), theEntryNameSecond);
0081 if (ALIUtils::debug >= 5)
0082 std::cout << " entry1 " << (*(OptOList().begin()))->longName() << "/" << entry1->name() << " ->valueDisplaced() "
0083 << entry1->valueDisplaced() << " entry2 " << (*(OptOList().begin() + 1))->longName() << "/"
0084 << entry2->name() << " ->valueDisplaced() " << entry2->valueDisplaced() << std::endl;
0085 setValueSimulated(0, entry1->valueDisplaced() - entry2->valueDisplaced());
0086
0087 if (ALIUtils::debug >= 2) {
0088 ALIdouble detD = 1000 * valueSimulated(0);
0089 if (std::abs(detD) <= 1.e-9)
0090 detD = 0.;
0091 std::cout << "REAL value: "
0092 << "D: " << 1000. * value()[0] << " (mm) " << (this)->name() << " DIFF= " << detD - 1000 * value()[0]
0093 << std::endl;
0094 std::cout << "SIMU value: "
0095 << "D: " << detD << " (mm) " << (this)->name() << std::endl;
0096 }
0097
0098 if (ALIUtils::debug >= 5)
0099 std::cout << "end calculateSimulatedValue" << std::endl;
0100 }