Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:02

0001 #include "Geometry/EcalCommonData/interface/EcalBaseNumber.h"
0002 #include <algorithm>
0003 
0004 EcalBaseNumber::EcalBaseNumber() : _theLevels(0) {}
0005 
0006 EcalBaseNumber::EcalBaseNumber(const EcalBaseNumber& aBaseNumber)
0007     : _sortedName(aBaseNumber._sortedName),
0008       _sortedCopyNumber(aBaseNumber._sortedCopyNumber),
0009       _theLevels(aBaseNumber._theLevels) {}
0010 
0011 void EcalBaseNumber::setSize(const int& size) {
0012   _sortedName.resize(size);
0013   _sortedCopyNumber.resize(size);
0014 }
0015 
0016 void EcalBaseNumber::addLevel(const std::string& name, const int& copyNumber) {
0017   _sortedName[_theLevels] = name;
0018   _sortedCopyNumber[_theLevels] = copyNumber;
0019   _theLevels++;
0020 }
0021 
0022 int EcalBaseNumber::getLevels() const { return _theLevels; }
0023 
0024 int EcalBaseNumber::getCopyNumber(int level) const { return _sortedCopyNumber[level]; }
0025 
0026 int EcalBaseNumber::getCopyNumber(const std::string& levelName) const {
0027   for (int iLevel = 0; iLevel < _theLevels; iLevel++) {
0028     if (_sortedName[iLevel] == levelName) {
0029       return _sortedCopyNumber[iLevel];
0030     }
0031   }
0032   return 0;
0033 }
0034 
0035 std::string const& EcalBaseNumber::getLevelName(int level) const { return _sortedName[level]; }
0036 
0037 int EcalBaseNumber::getCapacity() { return _sortedName.capacity(); }
0038 
0039 void EcalBaseNumber::reset() { _theLevels = 0; }
0040 
0041 void EcalBaseNumber::reverse() {
0042   std::reverse(std::begin(_sortedName), std::end(_sortedName));
0043   std::reverse(std::begin(_sortedCopyNumber), std::end(_sortedCopyNumber));
0044 }