00001 // COCOA class implementation file 00002 // Id: Measurement.C 00003 // CAT: Model 00004 // --------------------------------------------------------------------------- 00005 // History: v1.0 00006 // Authors: 00007 // Pedro Arce 00008 00009 #include "Alignment/CocoaModel/interface/MeasurementDiffEntry.h" 00010 #include "Alignment/CocoaModel/interface/Model.h" 00011 #include "Alignment/CocoaModel/interface/OpticalObject.h" 00012 #include "Alignment/CocoaModel/interface/Entry.h" 00013 #include "Alignment/CocoaUtilities/interface/ALIFileIn.h" 00014 #include <iostream> 00015 #include <iomanip> 00016 #ifdef COCOA_VIS 00017 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h" 00018 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h" 00019 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h" 00020 #endif 00021 00022 00023 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 00024 void MeasurementDiffEntry::buildOptONamesList( const std::vector<ALIstring>& wl ) 00025 { 00026 00027 int NPairs = (wl.size()+1)/2; // Number of OptO names ( pair of name and '&' ) 00028 00029 //--------- Fill list with names 00030 for ( int ii=0; ii<NPairs; ii++ ) { 00031 //--- take out Entry names from object names 00032 int isl = wl[ii*2].rfind("/"); 00033 AddOptONameListItem( wl[ii*2].substr(0,isl) ); 00034 // Check for separating '&' 00035 if (ii != NPairs-1 && wl[2*ii+1] != ALIstring("&") ) { 00036 ALIFileIn::getInstance( Model::SDFName() ).ErrorInLine(); 00037 std::cerr << "!!! Measured Optical Objects should be separated by '&', not by" 00038 << wl[2*ii+1] << std::endl; 00039 exit(2); 00040 } 00041 //---- Fill entry names 00042 if( ii == 0 ){ 00043 theEntryNameFirst = wl[ii*2].substr(isl+1,999); 00044 }else if( ii == 1 ){ 00045 theEntryNameSecond = wl[ii*2].substr(isl+1,999); 00046 } 00047 00048 } 00049 00050 } 00051 00052 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 00053 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement 00054 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 00055 void MeasurementDiffEntry::calculateSimulatedValue( ALIbool firstTime ) 00056 { 00057 00058 if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this ); // important for Examples/FakeMeas 00059 00060 //---------- Loop list of OptO that take part in measurement 00061 std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin(); 00062 if( ALIUtils::debug >= 5) std::cout << "OptOList size" <<OptOList().size() << std::endl; 00063 00064 //----- Check that there are only two objects 00065 if( OptOList().size() == !2 ) { 00066 std::cerr << "!!! ERROR in MeasurementDiffEntry: " << name() << " There should only be two objects " << std::endl; 00067 std::cerr << " 1st " << (*vocite)->name() << " 2nd " << (*vocite+1)->name() << std::endl; 00068 DumpBadOrderOptOs(); 00069 std::exception(); 00070 } 00071 00072 #ifdef COCOA_VIS 00073 ALIVisLightPath* vispath = 0; 00074 if( ALIUtils::getFirstTime() ) { 00075 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance(); 00076 if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) { 00077 vispath = IgCocoaFileMgr::getInstance().newLightPath( name() ); 00078 } 00079 } 00080 #endif 00081 00082 //--- 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) 00083 Entry* entry1 = Model::getEntryByName( (*(OptOList().begin()))->longName(), theEntryNameFirst ); 00084 Entry* entry2 = Model::getEntryByName( (*(OptOList().begin()+1))->longName(), theEntryNameSecond ); 00085 if( ALIUtils::debug >= 5) std::cout << " entry1 " << (*(OptOList().begin()))->longName() << "/" << entry1->name() << " ->valueDisplaced() " << entry1->valueDisplaced() << " entry2 " << (*(OptOList().begin()+1))->longName() << "/" << entry2->name() << " ->valueDisplaced() " << entry2->valueDisplaced() << std::endl; 00086 setValueSimulated( 0, entry1->valueDisplaced() - entry2->valueDisplaced() ); 00087 00088 if (ALIUtils::debug >= 2) { 00089 ALIdouble detD = 1000*valueSimulated(0); if(fabs(detD) <= 1.e-9 ) detD = 0.; 00090 std::cout << "REAL value: " <<"D: " << 1000.*value()[0] << " (mm) " << (this)->name() 00091 << " DIFF= " << detD-1000*value()[0] << std::endl; 00092 std::cout << "SIMU value: " << "D: " << detD << " (mm) " << (this)->name() << std::endl; 00093 } 00094 00095 if(ALIUtils::debug >= 5) std::cout << "end calculateSimulatedValue" <<std::endl; 00096 00097 } 00098