CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/Alignment/CocoaModel/src/FittedEntriesReader.cc

Go to the documentation of this file.
00001 #include "Alignment/CocoaModel/interface/FittedEntriesReader.h"
00002 #include "Alignment/CocoaModel/interface/Model.h"
00003 #include "Alignment/CocoaModel/interface/Entry.h"
00004 #include "Alignment/CocoaModel/interface/OpticalObject.h"
00005 #include "Alignment/CocoaModel/interface/ALIRmDataFromFile.h"
00006 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
00007   
00008 
00009 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00010 FittedEntriesReader::FittedEntriesReader( const ALIstring& filename ) 
00011 {
00012   theFileName = filename;
00013   theFile = ALIFileIn::getInstance( filename );
00014   std::vector<ALIstring> wl;
00015   theFile.getWordsInLine( wl );
00016   if (wl[0] == ALIstring( "DIMENSIONS:" ) ){
00017     theLengthDim = ALIUtils::CalculateLengthDimensionFactorFromString( wl[3] );
00018     theLengthErrorDim = ALIUtils::CalculateLengthDimensionFactorFromString( wl[5] );
00019     theAngleDim = ALIUtils::CalculateAngleDimensionFactorFromString( wl[8] );
00020     theAngleErrorDim = ALIUtils::CalculateAngleDimensionFactorFromString( wl[10] );
00021   } else {
00022     ALIUtils::dumpVS( wl, "!!! FATAL ERROR FittedEntriesReader: first line is not dimensions " );
00023     std::exception();
00024   }
00025 
00026 }
00027 
00028 
00029 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00030 ALIbool FittedEntriesReader::readFittedEntriesFromFile()
00031 {
00032   if( ALIUtils::debug >= 5) std::cout << " readFittedEntriesFromFile " << theFileName << std::endl;
00033   std::map<OpticalObject*,ALIRmDataFromFile> affAngles;
00034 
00035   std::vector<ALIstring> wl;
00036   theFile.getWordsInLine( wl );
00037   unsigned int siz = wl.size();
00038   for( size_t ii = 1; ii < siz; ii+=3 ){
00039     ALIstring optOentryName = substitutePointBySlash( wl[ii] );
00040     Entry* entry = Model::getEntryByName( optOentryName );
00041     if( ALIUtils::debug >= 5) std::cout << entry->name() << " readFittedEntriesFromFile " << entry->value() << " " << ALIUtils::getFloat( wl[ii+1] ) << std::endl;
00042     if( entry->name().substr(0,6) != "angles" ) {
00043       entry->displaceOriginalOriginal(entry->value() - ALIUtils::getFloat( wl[ii+1] )*theLengthDim);
00044     } else {
00045       OpticalObject* opto = entry->OptOCurrent();
00046       if( affAngles.find(opto) == affAngles.end() ){
00047         affAngles[opto] = ALIRmDataFromFile();
00048       }
00049       std::map<OpticalObject*,ALIRmDataFromFile>::iterator ite = affAngles.find(opto);
00050       (*ite).second.setAngle( optOentryName.substr(optOentryName.size()-1,1), ALIUtils::getFloat( wl[ii+1] )*theAngleDim );
00051       if( ALIUtils::debug >= 5) std::cout << " setting angle from file " << ALIUtils::getFloat( wl[ii+1] )*theAngleDim << " " << wl[ii+1] << " " << theAngleDim << std::endl;
00052     }
00053     entry->setSigma( ALIUtils::getFloat( wl[ii+2] )*theAngleDim );
00054     //  ar.lass6.laser.angles_X -159.7524 7.2208261 
00055 
00056   }
00057 
00058   ALIstring coordi("XYZ");
00059   std::map<OpticalObject*,ALIRmDataFromFile>::const_iterator ite;
00060   for( ite = affAngles.begin(); ite != affAngles.end(); ite++ ){
00061     ALIRmDataFromFile dff = (*ite).second;
00062     OpticalObject* opto = (*ite).first;
00063     for( size_t ii = 0; ii < 3; ii++ ) {
00064       int ifound =  dff.dataFilled().find( coordi[ii] );
00065       if( ALIUtils::debug >= 5) std::cout << ii << " dataFilled " << ifound << std::endl; 
00066       if( ifound == -1 ) { //angles not read from file are taken as the original value
00067         ALIdouble entval = opto->getEntryRMangle(coordi.substr(ii,1));
00068         dff.setAngle( coordi.substr(ii,1), entval );
00069       } 
00070     }
00071     dff.constructRm();
00072     opto->setGlobalRMOriginalOriginal( dff.rm() );
00073   }
00074     
00075   return true; // to avoid warning
00076   
00077 }
00078 
00079 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00080 ALIstring FittedEntriesReader::substitutePointBySlash( const ALIstring& nameWithPoints ) const
00081 {
00082   ALIstring nameWithSlash = nameWithPoints;
00083 
00084   size_t siz = nameWithPoints.length();
00085 
00086   for( size_t ii = 0; ii < siz; ii++ ){
00087     if( nameWithSlash[ii] == '.' ) nameWithSlash[ii] = '/'; 
00088   }
00089   nameWithSlash = "s/" + nameWithSlash;
00090   if( ALIUtils::debug >= 5) std::cout << " substitutePointBySlash " << nameWithSlash << " " << std::endl;
00091 
00092 
00093   return nameWithSlash;
00094 }