Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:31:45

0001 #include "Alignment/CocoaModel/interface/OpticalObjectMgr.h"
0002 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
0003 #include "Alignment/CocoaModel/interface/Model.h"
0004 #include <cstdlib>
0005 
0006 OpticalObjectMgr* OpticalObjectMgr::theInstance = nullptr;
0007 
0008 //-----------------------------------------------------------------------

0009 OpticalObjectMgr* OpticalObjectMgr::getInstance() {
0010   if (!theInstance) {
0011     theInstance = new OpticalObjectMgr;
0012     theInstance->theLastCmsSwID = 1;
0013     //    theInstance->verbose = ALIUtils::verbosity();

0014   }
0015   return theInstance;
0016 }
0017 
0018 //-----------------------------------------------------------------------

0019 OpticalObject* OpticalObjectMgr::findOptO(const ALIstring& longName, bool exists) const {
0020   OpticalObject* opto = nullptr;
0021   msopto::const_iterator cite = theOptODict.find(longName);
0022   if (cite == theOptODict.end()) {
0023     if (exists) {
0024       std::cerr << "!!!! EXITING: OptO not found: " << longName << std::endl;
0025       exit(1);
0026     } else {
0027       std::cerr << "!! WARNING: OptO not found: " << longName << std::endl;
0028     }
0029   } else {
0030     opto = (*cite).second;
0031   }
0032 
0033   return opto;
0034 }
0035 
0036 //-----------------------------------------------------------------------

0037 std::vector<OpticalObject*> OpticalObjectMgr::findOptOs(const ALIstring& name, bool exists) const {
0038   std::vector<OpticalObject*> vopto;
0039   msopto::const_iterator cite;
0040   //----- Look for OptO's that contains 'name' in its longName as the last word (after the last '/')

0041   for (cite = theOptODict.begin(); cite != theOptODict.end(); ++cite) {
0042     ALIstring oname = (*cite).first;
0043     int nf = oname.rfind(name);
0044     int sf = oname.rfind('/');
0045     if (nf != -1 && sf <= nf) {
0046       vopto.push_back((*cite).second);
0047     }
0048   }
0049 
0050   if (vopto.empty()) {
0051     if (exists) {
0052       std::cerr << "!!!! EXITING: OptO not found: " << name << std::endl;
0053       exit(1);
0054     } else {
0055       std::cerr << "!! WARNING: OptO not found: " << name << std::endl;
0056     }
0057   }
0058 
0059   return vopto;
0060 }
0061 
0062 //-----------------------------------------------------------------------

0063 void OpticalObjectMgr::dumpOptOs(std::ostream& out) const {
0064   std::cout << "OPTICALOBJECT list size " << theOptODict.size() << std::endl;
0065   std::vector<OpticalObject*>::const_iterator vocite;
0066   for (vocite = Model::OptOList().begin(); vocite != Model::OptOList().end(); ++vocite) {
0067     ALIstring name = (*vocite)->name();
0068     ALIUtils::dump3v((*vocite)->centreGlobal(), name + " CENTRE GLOBAL: ");
0069     if ((*vocite)->parent() != nullptr)
0070       ALIUtils::dump3v((*vocite)->centreLocal(), name + "  CENTRE LOCAL: ");  //not for the 'system'

0071   }
0072 }
0073 
0074 //-----------------------------------------------------------------------

0075 ALIuint OpticalObjectMgr::buildCmsSwID() { return theLastCmsSwID++; }