Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-23 04:29:04

0001 #include "Geometry/MTDCommonData/interface/MTDBaseNumber.h"
0002 
0003 MTDBaseNumber::MTDBaseNumber() : _theLevels(0) {}
0004 
0005 MTDBaseNumber::MTDBaseNumber(const MTDBaseNumber& aBaseNumber)
0006     : _sortedName(aBaseNumber._sortedName),
0007       _sortedCopyNumber(aBaseNumber._sortedCopyNumber),
0008       _theLevels(aBaseNumber._theLevels) {}
0009 
0010 void MTDBaseNumber::setSize(const int size) {
0011   if (size < MAXLEVEL) {
0012     _sortedName.resize(size);
0013     _sortedCopyNumber.resize(size);
0014   } else {
0015     _sortedName.resize(MAXLEVEL);
0016     _sortedCopyNumber.resize(MAXLEVEL);
0017     edm::LogWarning("MTDGeom") << "Required base number size exceeding maximum";
0018   }
0019 }
0020 
0021 void MTDBaseNumber::addLevel(const std::string_view name, const int copyNumber) {
0022   if (_theLevels == MAXLEVEL - 1) {
0023     throw cms::Exception("WrongMTDGeom") << "MTDBaseNumber required to add more levels than maximum allowed";
0024   }
0025   _sortedName[_theLevels] = name;
0026   _sortedCopyNumber[_theLevels] = copyNumber;
0027   _theLevels++;
0028 }
0029 
0030 int MTDBaseNumber::getLevels() const { return _theLevels; }
0031 
0032 int MTDBaseNumber::getCopyNumber(int level) const { return _sortedCopyNumber[level]; }
0033 
0034 int MTDBaseNumber::getCopyNumber(const std::string_view levelName) const {
0035   for (int iLevel = 0; iLevel < _theLevels; iLevel++) {
0036     if (_sortedName[iLevel] == levelName) {
0037       return _sortedCopyNumber[iLevel];
0038     }
0039   }
0040   return 0;
0041 }
0042 
0043 std::string_view const& MTDBaseNumber::getLevelName(int level) const { return _sortedName[level]; }
0044 
0045 int MTDBaseNumber::getCapacity() { return _sortedName.capacity(); }
0046 
0047 void MTDBaseNumber::reset() { _theLevels = 0; }