CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Alignment/CocoaModel/src/MeasurementDiffEntry.cc

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