CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:23:39 2009 for CMSSW by  doxygen 1.5.4