1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "Geometry/MTDCommonData/interface/MTDBaseNumber.h"
MTDBaseNumber::MTDBaseNumber() : _theLevels(0) {}
MTDBaseNumber::MTDBaseNumber(const MTDBaseNumber& aBaseNumber)
: _sortedName(aBaseNumber._sortedName),
_sortedCopyNumber(aBaseNumber._sortedCopyNumber),
_theLevels(aBaseNumber._theLevels) {}
void MTDBaseNumber::setSize(const int size) {
if (size < MAXLEVEL) {
_sortedName.resize(size);
_sortedCopyNumber.resize(size);
} else {
_sortedName.resize(MAXLEVEL);
_sortedCopyNumber.resize(MAXLEVEL);
edm::LogWarning("MTDGeom") << "Required base number size exceeding maximum";
}
}
void MTDBaseNumber::addLevel(const std::string_view name, const int copyNumber) {
if (_theLevels == MAXLEVEL - 1) {
throw cms::Exception("WrongMTDGeom") << "MTDBaseNumber required to add more levels than maximum allowed";
}
_sortedName[_theLevels] = name;
_sortedCopyNumber[_theLevels] = copyNumber;
_theLevels++;
}
int MTDBaseNumber::getLevels() const { return _theLevels; }
int MTDBaseNumber::getCopyNumber(int level) const { return _sortedCopyNumber[level]; }
int MTDBaseNumber::getCopyNumber(const std::string_view levelName) const {
for (int iLevel = 0; iLevel < _theLevels; iLevel++) {
if (_sortedName[iLevel] == levelName) {
return _sortedCopyNumber[iLevel];
}
}
return 0;
}
std::string_view const& MTDBaseNumber::getLevelName(int level) const { return _sortedName[level]; }
int MTDBaseNumber::getCapacity() { return _sortedName.capacity(); }
void MTDBaseNumber::reset() { _theLevels = 0; }
|