Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:28

0001 //   COCOA class implementation file

0002 //Id:  EntryMgr.cc

0003 //CAT: Model

0004 //

0005 //   History: v1.0  10/11/01   Pedro Arce

0006 
0007 #include "Alignment/CocoaModel/interface/EntryMgr.h"
0008 #include "Alignment/CocoaModel/interface/EntryData.h"
0009 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
0010 #include <cstdlib>
0011 //----------------------------------------------------------------------------

0012 
0013 EntryMgr* EntryMgr::theInstance = nullptr;
0014 
0015 //----------------------------------------------------------------------------

0016 EntryMgr* EntryMgr::getInstance() {
0017   if (!theInstance) {
0018     theInstance = new EntryMgr;
0019     theInstance->dimOutLengthVal = 0;
0020     theInstance->dimOutLengthSig = 0;
0021     theInstance->dimOutAngleVal = 0;
0022     theInstance->dimOutAngleSig = 0;
0023   }
0024 
0025   return theInstance;
0026 }
0027 
0028 //----------------------------------------------------------------------------

0029 ALIbool EntryMgr::readEntryFromReportOut(const std::vector<ALIstring>& wl) {
0030   //-  std::cout << "  EntryMgr::readEntryFromReportOut " << wl[0] << std::endl;

0031   if (wl[0] == "DIMENSIONS:") {
0032     //----- Set dimensions of all the file

0033     dimOutLengthVal = ALIUtils::getDimensionValue(wl[3], "Length");
0034     if (ALIUtils::debug >= 6)
0035       std::cout << " dimOutLengthVal " << dimOutLengthVal << " " << ALIUtils::getDimensionValue(wl[3], "Length") << " "
0036                 << ALIUtils::LengthValueDimensionFactor() << std::endl;
0037     dimOutLengthSig = ALIUtils::getDimensionValue(wl[5], "Length");
0038     dimOutAngleVal = ALIUtils::getDimensionValue(wl[8], "Angle");
0039     if (ALIUtils::debug >= 6)
0040       std::cout << " dimOutAngleVal " << dimOutAngleVal << " " << ALIUtils::getDimensionValue(wl[8], "Angle") << " "
0041                 << ALIUtils::AngleValueDimensionFactor() << std::endl;
0042 
0043     dimOutAngleSig = ALIUtils::getDimensionValue(wl[10], "Angle");
0044   } else if (wl[0] == "FIX:" || wl[0] == "CAL:" || wl[0] == "UNK:") {
0045     //----- check if it exists

0046     EntryData* data = findEntry(wl);
0047     if (!data) {
0048       data = new EntryData();
0049       theEntryData.push_back(data);
0050     }
0051     data->fill(wl);
0052   }
0053 
0054   return true;
0055 }
0056 
0057 //----------------------------------------------------------------------------

0058 EntryData* EntryMgr::findEntryByShortName(const ALIstring& optoName, const ALIstring& entryName) {
0059   EntryData* data = nullptr;
0060 
0061   int icount = 0;
0062   std::vector<EntryData*>::iterator ite;
0063   for (ite = theEntryData.begin(); ite != theEntryData.end(); ++ite) {
0064     if ((*ite)->shortOptOName() == extractShortName(optoName) &&
0065         ((*ite)->entryName() == entryName || entryName.empty())) {
0066       if (icount == 0)
0067         data = (*ite);
0068       if (!entryName.empty())
0069         icount++;
0070     }
0071     //-    std::cout << icount << " findEntryByShortName " << (*ite)->shortOptOName() << " =?= " << extractShortName(optoName) << std::endl <<  (*ite)->entryName() << " =?= " <<entryName << std::endl;

0072   }
0073 
0074   if (icount > 1) {
0075     std::cerr << "!!! WARNING: >1 objects with OptO name= " << optoName << " and entry Name = " << entryName
0076               << std::endl;
0077   }
0078   return data;
0079 }
0080 
0081 //----------------------------------------------------------------------------

0082 EntryData* EntryMgr::findEntryByLongName(const ALIstring& optoName, const ALIstring& entryName) {
0083   EntryData* data = nullptr;
0084 
0085   int icount = 0;
0086   std::vector<EntryData*>::iterator ite;
0087   if (ALIUtils::debug >= 6)
0088     std::cout << " findEntryByLongName theEntryData size = " << theEntryData.size() << std::endl;
0089   for (ite = theEntryData.begin(); ite != theEntryData.end(); ++ite) {
0090     if ((*ite)->longOptOName() == optoName && ((*ite)->entryName() == entryName || entryName.empty())) {
0091       //-    if( (*ite)->longOptOName() == optoName ) {

0092       //-      std::cout << " equal optoName " << std::endl;

0093       //-      if( (*ite)->entryName() == entryName || entryName == "" ) {

0094       if (icount == 0)
0095         data = (*ite);
0096       if (ALIUtils::debug >= 6)
0097         std::cout << data << " " << icount << " data longOptOName " << (*ite)->longOptOName() << " entryName "
0098                   << (*ite)->entryName() << " " << (*ite)->valueOriginal() << std::endl;
0099 
0100       if (!entryName.empty())
0101         icount++;
0102     }
0103     //-    std::cout << " looking for longOptOName " << optoName << " entryName " << entryName << std::endl;

0104   }
0105 
0106   if (icount > 1) {
0107     std::cerr << "!!! FATAL ERROR in EntryMgr::findEntryByLongName: >1 objects with OptO name= " << optoName
0108               << " and entry name = " << entryName << std::endl;
0109     abort();
0110   }
0111   return data;
0112 }
0113 
0114 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0115 EntryData* EntryMgr::findEntry(const std::vector<ALIstring>& wl) {
0116   EntryData* data = nullptr;
0117   ALIstring optoName = wl[2];
0118   ALIstring entryName = wl[3];
0119   data = findEntryByLongName(optoName, entryName);
0120 
0121   return data;
0122 }
0123 
0124 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0125 ALIstring EntryMgr::extractShortName(const ALIstring& name) {
0126   ALIint isl = name.rfind('/');
0127   if (isl == -1) {
0128     return name;
0129   } else {
0130     return name.substr(isl + 1, name.size());
0131   }
0132 }