00001
00002
00003
00004
00005
00006
00007 #include "Alignment/CocoaModel/interface/EntryMgr.h"
00008 #include "Alignment/CocoaModel/interface/EntryData.h"
00009 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
00010
00011
00012
00013 EntryMgr* EntryMgr::theInstance = 0;
00014
00015
00016 EntryMgr* EntryMgr::getInstance()
00017 {
00018 if( !theInstance ) {
00019 theInstance = new EntryMgr;
00020 theInstance->dimOutLengthVal = 0;
00021 theInstance->dimOutLengthSig = 0;
00022 theInstance->dimOutAngleVal = 0;
00023 theInstance->dimOutAngleSig = 0;
00024 }
00025
00026 return theInstance;
00027
00028 }
00029
00030
00031
00032 ALIbool EntryMgr::readEntryFromReportOut( const std::vector<ALIstring>& wl )
00033 {
00034
00035 if( wl[0] == "DIMENSIONS:" ) {
00036
00037 dimOutLengthVal = ALIUtils::getDimensionValue( wl[3],"Length");
00038 if(ALIUtils::debug >= 6) std::cout << " dimOutLengthVal " << dimOutLengthVal << " " << ALIUtils::getDimensionValue( wl[3],"Length") << " " << ALIUtils::LengthValueDimensionFactor() << std::endl;
00039 dimOutLengthSig = ALIUtils::getDimensionValue( wl[5],"Length");
00040 dimOutAngleVal = ALIUtils::getDimensionValue( wl[8],"Angle");
00041 if(ALIUtils::debug >= 6) std::cout << " dimOutAngleVal " << dimOutAngleVal << " " << ALIUtils::getDimensionValue( wl[8],"Angle") << " " << ALIUtils::AngleValueDimensionFactor() << std::endl;
00042
00043 dimOutAngleSig = ALIUtils::getDimensionValue( wl[10],"Angle");
00044 } else if( wl[0] == "FIX:" || wl[0] == "CAL:" || wl[0] == "UNK:" ) {
00045
00046 EntryData* data = findEntry( wl );
00047 if( !data ) {
00048 data = new EntryData();
00049 theEntryData.push_back( data );
00050 }
00051 data->fill( wl );
00052 }
00053
00054 return 1;
00055 }
00056
00057
00058
00059 EntryData* EntryMgr::findEntryByShortName( const ALIstring& optoName, const ALIstring& entryName )
00060 {
00061 EntryData* data = 0;
00062
00063 int icount = 0;
00064 std::vector<EntryData*>::iterator ite;
00065 for( ite = theEntryData.begin(); ite != theEntryData.end(); ite++ ) {
00066 if( (*ite)->shortOptOName() == extractShortName(optoName) &&
00067 ( (*ite)->entryName() == entryName || entryName == "" ) ) {
00068 if( icount == 0 ) data = (*ite);
00069 if( entryName != "" ) icount++;
00070 }
00071
00072 }
00073
00074 if( icount > 1 ) {
00075 std::cerr << "!!! WARNING: >1 objects with OptO name= " << optoName << " and entry Name = " << entryName << std::endl;
00076 }
00077 return data;
00078 }
00079
00080
00081
00082 EntryData* EntryMgr::findEntryByLongName( const ALIstring& optoName, const ALIstring& entryName )
00083 {
00084 EntryData* data = 0;
00085
00086 int icount = 0;
00087 std::vector<EntryData*>::iterator ite;
00088 if(ALIUtils::debug >= 6) std::cout << " findEntryByLongName theEntryData size = " << theEntryData.size() << std::endl;
00089 for( ite = theEntryData.begin(); ite != theEntryData.end(); ite++ ) {
00090 if( (*ite)->longOptOName() == optoName &&
00091 ( (*ite)->entryName() == entryName || entryName == "" ) ) {
00092
00093
00094
00095 if( icount == 0 ) data = (*ite);
00096 if(ALIUtils::debug >= 6) std::cout << data << " " << icount << " data longOptOName " << (*ite)->longOptOName() << " entryName " << (*ite)->entryName() << " " << (*ite)->valueOriginal() << std::endl;
00097
00098 if( entryName != "" ) icount++;
00099 }
00100
00101 }
00102
00103 if( icount > 1 ) {
00104 std::cerr << "!!! FATAL ERROR in EntryMgr::findEntryByLongName: >1 objects with OptO name= " << optoName << " and entry name = " << entryName << std::endl;
00105 abort();
00106 }
00107 return data;
00108 }
00109
00110
00111
00112 EntryData* EntryMgr::findEntry( const std::vector<ALIstring>& wl )
00113 {
00114 EntryData* data = 0;
00115 ALIstring optoName = wl[2];
00116 ALIstring entryName = wl[3];
00117 data = findEntryByLongName( optoName, entryName );
00118
00119 return data;
00120
00121 }
00122
00123
00124
00125 ALIstring EntryMgr::extractShortName( const ALIstring& name )
00126 {
00127 ALIint isl = name.rfind("/");
00128 if( isl == -1 ) {
00129 return name ;
00130 } else {
00131 return name.substr( isl+1, name.size() );
00132 }
00133 }