CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Alignment/CocoaModel/src/OpticalObjectMgr.cc

Go to the documentation of this file.
00001 #include "Alignment/CocoaModel/interface/OpticalObjectMgr.h"
00002 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
00003 #include "Alignment/CocoaModel/interface/Model.h"
00004 #include <cstdlib>
00005 
00006 OpticalObjectMgr* OpticalObjectMgr::theInstance = 0;
00007   
00008 //-----------------------------------------------------------------------
00009 OpticalObjectMgr* OpticalObjectMgr::getInstance()
00010 {
00011   if( !theInstance ) {
00012     theInstance = new OpticalObjectMgr;
00013     theInstance->theLastCmsSwID = 1;
00014     //    theInstance->verbose = ALIUtils::verbosity();
00015   }
00016   return theInstance;
00017 }
00018 
00019 
00020 //-----------------------------------------------------------------------
00021 OpticalObject* OpticalObjectMgr::findOptO( const ALIstring& longName, bool exists ) const
00022 {
00023   OpticalObject* opto = 0;
00024   msopto::const_iterator cite = theOptODict.find( longName );
00025   if( cite == theOptODict.end() ) {
00026     if( exists ) {
00027       std::cerr << "!!!! EXITING: OptO not found: " << longName << std::endl;
00028       exit(1);
00029     } else {
00030       std::cerr << "!! WARNING: OptO not found: " << longName << std::endl;
00031     }
00032   } else {
00033     opto = (*cite).second;
00034   }
00035 
00036   return opto;
00037 
00038 }  
00039 
00040 
00041 //-----------------------------------------------------------------------
00042 std::vector<OpticalObject*> OpticalObjectMgr::findOptOs( const ALIstring& name, bool exists ) const
00043 {
00044   std::vector<OpticalObject*> vopto;
00045   msopto::const_iterator cite;
00046   //----- Look for OptO's that contains 'name' in its longName as the last word (after the last '/')
00047   for( cite = theOptODict.begin(); cite != theOptODict.end(); cite++ ) {
00048     ALIstring oname = (*cite).first;
00049     int nf = oname.rfind( name );
00050     int sf = oname.rfind( '/' );
00051     if( nf != -1 && sf <= nf ) {
00052       vopto.push_back( (*cite).second );
00053     }
00054   }
00055 
00056   if( vopto.size() == 0 ) {
00057     if( exists ) {
00058       std::cerr << "!!!! EXITING: OptO not found: " << name << std::endl;
00059       exit(1);
00060     } else {
00061       std::cerr << "!! WARNING: OptO not found: " << name << std::endl;
00062     }
00063   }
00064 
00065   return vopto;
00066 
00067 }
00068 
00069 
00070 //-----------------------------------------------------------------------
00071 void OpticalObjectMgr::dumpOptOs( std::ostream& out ) const
00072 {
00073   std::cout << "OPTICALOBJECT list size " << theOptODict.size() << std::endl;
00074   std::vector< OpticalObject* >::const_iterator vocite;
00075   for( vocite = Model::OptOList().begin(); vocite != Model::OptOList().end(); vocite++ ) {
00076     ALIstring name = (*vocite)->name();
00077     ALIUtils::dump3v( (*vocite)->centreGlobal(), (name + " CENTRE GLOBAL: ").c_str() );
00078     if( (*vocite)->parent() != 0 ) ALIUtils::dump3v( (*vocite)->centreLocal(),  (name + "  CENTRE LOCAL: ").c_str() ); //not for the 'system'
00079   }
00080 
00081 }
00082 
00083 
00084 //-----------------------------------------------------------------------
00085 ALIuint OpticalObjectMgr::buildCmsSwID()
00086 {
00087   return theLastCmsSwID++;
00088 }