Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:29

0001 // COCOA class implementation file
0002 // Id:  Measurement.C
0003 // CAT: Model
0004 // ---------------------------------------------------------------------------
0005 // History: v1.0
0006 // Authors:
0007 //   Pedro Arce
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;  // Number of OptO names ( pair of name and '&' )
0027 
0028   //--------- Fill list with names
0029   for (int ii = 0; ii < NPairs; ii++) {
0030     //--- take out Entry names from object names
0031     int isl = wl[ii * 2].rfind('/');
0032     AddOptONameListItem(wl[ii * 2].substr(0, isl));
0033     // Check for separating '&'
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     //---- Fill entry names
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 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
0050 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
0051 void MeasurementDiffEntry::calculateSimulatedValue(ALIbool firstTime) {
0052   if (ALIUtils::debug >= 2)
0053     printStartCalculateSimulatedValue(this);  // important for Examples/FakeMeas
0054 
0055   //---------- Loop list of OptO that take part in measurement
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   //----- Check that there are only two objects
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   //--- This is a special 'measurement': it represents the fact that you have measured two entries one relative to the other (e.g. relative angle of two objects)
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 }