CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MTDBaseNumber.cc
Go to the documentation of this file.
2 
3 MTDBaseNumber::MTDBaseNumber() : _theLevels(0) {}
4 
6  : _sortedName(aBaseNumber._sortedName),
7  _sortedCopyNumber(aBaseNumber._sortedCopyNumber),
8  _theLevels(aBaseNumber._theLevels) {}
9 
10 void MTDBaseNumber::setSize(const int size) {
11  if (size < MAXLEVEL) {
12  _sortedName.resize(size);
13  _sortedCopyNumber.resize(size);
14  } else {
15  _sortedName.resize(MAXLEVEL);
17  edm::LogWarning("MTDGeom") << "Required base number size exceeding maximum";
18  }
19 }
20 
21 void MTDBaseNumber::addLevel(const std::string_view name, const int copyNumber) {
22  if (_theLevels == MAXLEVEL - 1) {
23  throw cms::Exception("WrongMTDGeom") << "MTDBaseNumber required to add more levels than maximum allowed";
24  }
26  _sortedCopyNumber[_theLevels] = copyNumber;
27  _theLevels++;
28 }
29 
30 int MTDBaseNumber::getLevels() const { return _theLevels; }
31 
33 
34 int MTDBaseNumber::getCopyNumber(const std::string_view levelName) const {
35  for (int iLevel = 0; iLevel < _theLevels; iLevel++) {
36  if (_sortedName[iLevel] == levelName) {
37  return _sortedCopyNumber[iLevel];
38  }
39  }
40  return 0;
41 }
42 
43 std::string_view const& MTDBaseNumber::getLevelName(int level) const { return _sortedName[level]; }
44 
45 int MTDBaseNumber::getCapacity() { return _sortedName.capacity(); }
46 
void addLevel(const std::string_view name, const int copyNumber)
std::vector< int > _sortedCopyNumber
Definition: MTDBaseNumber.h:36
int getLevels() const
static constexpr int MAXLEVEL
Definition: MTDBaseNumber.h:33
const char * levelName(LogLevel)
Definition: fwLog.cc:32
int getCopyNumber(int level) const
std::string_view const & getLevelName(int level) const
tuple level
Definition: testEve_cfg.py:47
Log< level::Warning, false > LogWarning
tuple size
Write out results.
void setSize(const int size)
std::vector< std::string_view > _sortedName
Definition: MTDBaseNumber.h:35