CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/Alignment/CocoaModel/src/EntryMgr.cc

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