CMS 3D CMS Logo

MTDBaseNumber.cc
Go to the documentation of this file.
2 
3 MTDBaseNumber::MTDBaseNumber() : _theLevels(0) {}
4 
6  : _sortedName(aBaseNumber._sortedName),
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& 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 
35  for (int iLevel = 0; iLevel < _theLevels; iLevel++) {
36  if (_sortedName[iLevel] == levelName) {
37  return _sortedCopyNumber[iLevel];
38  }
39  }
40  return 0;
41 }
42 
44 
45 int MTDBaseNumber::getCapacity() { return _sortedName.capacity(); }
46 
size
Write out results.
std::vector< std::string > _sortedName
Definition: MTDBaseNumber.h:35
static int MAXLEVEL
Definition: MTDBaseNumber.h:33
std::vector< int > _sortedCopyNumber
Definition: MTDBaseNumber.h:36
int getLevels() const
const char * levelName(LogLevel)
Definition: fwLog.cc:32
void setSize(const int &size)
int getCopyNumber(int level) const
void addLevel(const std::string &name, const int &copyNumber)
std::string const & getLevelName(int level) const