Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-05 04:09:54

0001 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 //#define EDM_ML_DEBUG
0005 
0006 void MuonBaseNumber::addBase(const LevelBaseNumber& num) {
0007   basenumber_type::iterator cur = sortedBaseNumber.begin();
0008   basenumber_type::iterator end = sortedBaseNumber.end();
0009 
0010   // do a small check if level is already occupied
0011 
0012   while (cur != end) {
0013     if (num.level() == (*cur).level()) {
0014 #ifdef EDM_ML_DEBUG
0015       edm::LogVerbatim("MuonGeom") << "MuonBaseNumber::addBase was asked to add " << num.level() << " " << num.super()
0016                                    << " " << num.base() << " to existing level " << (*cur).level() << " "
0017                                    << (*cur).super() << " " << (*cur).base() << " but refused.";
0018 #endif
0019       return;  // don't overwrite current volume stored
0020     }
0021     cur++;
0022   }
0023 
0024   cur = sortedBaseNumber.begin();
0025   while (cur != end) {
0026     if (num.level() < (*cur).level())
0027       break;
0028     cur++;
0029   }
0030   sortedBaseNumber.insert(cur, num);
0031 
0032 #ifdef EDM_ML_DEBUG
0033   cur = sortedBaseNumber.begin();
0034   end = sortedBaseNumber.end();
0035   edm::LogVerbatim("MuonGeom") << "MuonBaseNumber::AddBase ";
0036   unsigned int k(0);
0037   while (cur != end) {
0038     edm::LogVerbatim("MuonGeom") << "[" << k << "] " << (*cur).level() << " " << (*cur).super() << " " << (*cur).base();
0039     cur++;
0040     ++k;
0041   }
0042 #endif
0043 }
0044 
0045 void MuonBaseNumber::addBase(const int level, const int super, const int base) {
0046   LevelBaseNumber num(level, super, base);
0047   addBase(num);
0048 }
0049 
0050 int MuonBaseNumber::getLevels() const { return sortedBaseNumber.size(); }
0051 
0052 int MuonBaseNumber::getSuperNo(int level) const {
0053   basenumber_type::const_iterator cur = sortedBaseNumber.begin();
0054   basenumber_type::const_iterator end = sortedBaseNumber.end();
0055   while (cur != end) {
0056     if ((*cur).level() == level) {
0057       return (*cur).super();
0058     }
0059     cur++;
0060   }
0061   return 0;
0062 }
0063 
0064 int MuonBaseNumber::getBaseNo(int level) const {
0065   basenumber_type::const_iterator cur = sortedBaseNumber.begin();
0066   basenumber_type::const_iterator end = sortedBaseNumber.end();
0067   while (cur != end) {
0068     if ((*cur).level() == level) {
0069       return (*cur).base();
0070     }
0071     cur++;
0072   }
0073   return 0;
0074 }