CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Static Protected Attributes
MTDBaseNumber Class Reference

#include <MTDBaseNumber.h>

Public Member Functions

void addLevel (const std::string_view name, const int copyNumber)
 
int getCapacity ()
 
int getCopyNumber (int level) const
 
int getCopyNumber (const std::string_view levelName) const
 
std::string_view const & getLevelName (int level) const
 
int getLevels () const
 
 MTDBaseNumber ()
 
 MTDBaseNumber (const MTDBaseNumber &aBaseNumber)
 
void reset ()
 
void setSize (const int size)
 
 ~MTDBaseNumber ()
 

Protected Attributes

std::vector< int > _sortedCopyNumber
 
std::vector< std::string_view > _sortedName
 
int _theLevels
 

Static Protected Attributes

static constexpr int MAXLEVEL = 20
 

Detailed Description

Cloned from the EcalBaseNumber class

Definition at line 15 of file MTDBaseNumber.h.

Constructor & Destructor Documentation

◆ MTDBaseNumber() [1/2]

MTDBaseNumber::MTDBaseNumber ( )

Definition at line 3 of file MTDBaseNumber.cc.

3 : _theLevels(0) {}

◆ MTDBaseNumber() [2/2]

MTDBaseNumber::MTDBaseNumber ( const MTDBaseNumber aBaseNumber)

Definition at line 5 of file MTDBaseNumber.cc.

6  : _sortedName(aBaseNumber._sortedName),
8  _theLevels(aBaseNumber._theLevels) {}
std::vector< int > _sortedCopyNumber
Definition: MTDBaseNumber.h:36
std::vector< std::string_view > _sortedName
Definition: MTDBaseNumber.h:35

◆ ~MTDBaseNumber()

MTDBaseNumber::~MTDBaseNumber ( )
inline

Definition at line 19 of file MTDBaseNumber.h.

19 {}

Member Function Documentation

◆ addLevel()

void MTDBaseNumber::addLevel ( const std::string_view  name,
const int  copyNumber 
)

Definition at line 21 of file MTDBaseNumber.cc.

References _sortedCopyNumber, _sortedName, _theLevels, Exception, MAXLEVEL, and Skims_PA_cff::name.

Referenced by MtdSD::getBaseNumber().

21  {
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 }
std::vector< int > _sortedCopyNumber
Definition: MTDBaseNumber.h:36
static constexpr int MAXLEVEL
Definition: MTDBaseNumber.h:33
std::vector< std::string_view > _sortedName
Definition: MTDBaseNumber.h:35

◆ getCapacity()

int MTDBaseNumber::getCapacity ( )

Definition at line 45 of file MTDBaseNumber.cc.

References _sortedName.

Referenced by MtdSD::getBaseNumber().

45 { return _sortedName.capacity(); }
std::vector< std::string_view > _sortedName
Definition: MTDBaseNumber.h:35

◆ getCopyNumber() [1/2]

int MTDBaseNumber::getCopyNumber ( int  level) const

◆ getCopyNumber() [2/2]

int MTDBaseNumber::getCopyNumber ( const std::string_view  levelName) const

Definition at line 34 of file MTDBaseNumber.cc.

References _sortedCopyNumber, _sortedName, _theLevels, and fwlog::levelName().

34  {
35  for (int iLevel = 0; iLevel < _theLevels; iLevel++) {
36  if (_sortedName[iLevel] == levelName) {
37  return _sortedCopyNumber[iLevel];
38  }
39  }
40  return 0;
41 }
std::vector< int > _sortedCopyNumber
Definition: MTDBaseNumber.h:36
const char * levelName(LogLevel)
Definition: fwLog.cc:32
std::vector< std::string_view > _sortedName
Definition: MTDBaseNumber.h:35

◆ getLevelName()

std::string_view const & MTDBaseNumber::getLevelName ( int  level) const

Definition at line 43 of file MTDBaseNumber.cc.

References _sortedName, and personalPlayback::level.

Referenced by BTLNumberingScheme::getUnitID(), and ETLNumberingScheme::getUnitID().

43 { return _sortedName[level]; }
std::vector< std::string_view > _sortedName
Definition: MTDBaseNumber.h:35

◆ getLevels()

int MTDBaseNumber::getLevels ( ) const

Definition at line 30 of file MTDBaseNumber.cc.

References _theLevels.

Referenced by BTLNumberingScheme::getUnitID(), and ETLNumberingScheme::getUnitID().

30 { return _theLevels; }

◆ reset()

void MTDBaseNumber::reset ( void  )

Definition at line 47 of file MTDBaseNumber.cc.

References _theLevels.

Referenced by MtdSD::getBaseNumber().

47 { _theLevels = 0; }

◆ setSize()

void MTDBaseNumber::setSize ( const int  size)

Definition at line 10 of file MTDBaseNumber.cc.

References _sortedCopyNumber, _sortedName, MAXLEVEL, and findQualityFiles::size.

Referenced by MtdSD::getBaseNumber().

10  {
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 }
size
Write out results.
std::vector< int > _sortedCopyNumber
Definition: MTDBaseNumber.h:36
static constexpr int MAXLEVEL
Definition: MTDBaseNumber.h:33
Log< level::Warning, false > LogWarning
std::vector< std::string_view > _sortedName
Definition: MTDBaseNumber.h:35

Member Data Documentation

◆ _sortedCopyNumber

std::vector<int> MTDBaseNumber::_sortedCopyNumber
protected

Definition at line 36 of file MTDBaseNumber.h.

Referenced by addLevel(), getCopyNumber(), and setSize().

◆ _sortedName

std::vector<std::string_view> MTDBaseNumber::_sortedName
protected

Definition at line 35 of file MTDBaseNumber.h.

Referenced by addLevel(), getCapacity(), getCopyNumber(), getLevelName(), and setSize().

◆ _theLevels

int MTDBaseNumber::_theLevels
protected

Definition at line 37 of file MTDBaseNumber.h.

Referenced by addLevel(), getCopyNumber(), getLevels(), and reset().

◆ MAXLEVEL

constexpr int MTDBaseNumber::MAXLEVEL = 20
staticprotected

Definition at line 33 of file MTDBaseNumber.h.

Referenced by addLevel(), and setSize().