LDMX Software
conditions::BaseTableCondition Class Reference

Public Member Functions

 BaseTableCondition (const std::string &name, const std::vector< std::string > &columns)
 Create table with given set of columns.
 
unsigned int getColumnNumber (const std::string &colname) const
 Get a the column number for the given column name.
 
unsigned int getColumnCount () const
 Get the number of columns.
 
const std::string & getColumnName (unsigned int icol) const
 Get the name of the given column.
 
unsigned int getRowId (unsigned int irow) const
 Get the id for the given row.
 
const std::vector< std::string > & getColumnNames () const
 Get the names of the columns.
 
std::size_t getRowCount () const
 Get the number of rows.
 
void setIdMask (unsigned int mask)
 Set an AND mask to be applied to the id.
 
unsigned int getIdMask () const
 Get the AND mask to be applied to the id.
 
virtual std::ostream & streamRow (std::ostream &s, int irow) const
 Streams a given row of this table.
 
- Public Member Functions inherited from framework::ConditionsObject
 ConditionsObject (const std::string &name)
 Class constructor.
 
virtual ~ConditionsObject ()
 Destructor.
 
std::string getName () const
 Get the name of this object.
 

Protected Member Functions

std::size_t findKey (unsigned int id) const
 
std::size_t findKeyInsert (unsigned int id) const
 

Protected Attributes

std::vector< std::string > columns_
 
unsigned int columnCount_
 
std::vector< uint32_t > keys_
 
unsigned int idMask_
 

Detailed Description

Definition at line 22 of file SimpleTableCondition.h.

Constructor & Destructor Documentation

◆ BaseTableCondition()

conditions::BaseTableCondition::BaseTableCondition ( const std::string & name,
const std::vector< std::string > & columns )
inline

Create table with given set of columns.

Definition at line 25 of file SimpleTableCondition.h.

28 columns_{columns},
29 idMask_{0xFFFFFFFFu} {
30 columnCount_ = (unsigned int)(columns.size());
31 }
Base class for all conditions objects, very simple.

Member Function Documentation

◆ findKey()

std::size_t conditions::BaseTableCondition::findKey ( unsigned int id) const
protected

Definition at line 23 of file BaseTableCondition.cxx.

23 {
24 unsigned int effid = id & idMask_;
25 std::vector<unsigned int>::const_iterator ptr =
26 std::lower_bound(keys_.begin(), keys_.end(), effid);
27 if (ptr == keys_.end() || *ptr != effid)
28 return keys_.size();
29 else
30 return std::distance(keys_.begin(), ptr);
31}

◆ findKeyInsert()

std::size_t conditions::BaseTableCondition::findKeyInsert ( unsigned int id) const
protected

Definition at line 33 of file BaseTableCondition.cxx.

33 {
34 unsigned int effid = id & idMask_;
35 std::vector<unsigned int>::const_iterator ptr =
36 std::lower_bound(keys_.begin(), keys_.end(), effid);
37 return std::distance(keys_.begin(), ptr);
38}

◆ getColumnCount()

unsigned int conditions::BaseTableCondition::getColumnCount ( ) const
inline

Get the number of columns.

Definition at line 45 of file SimpleTableCondition.h.

45{ return columnCount_; }

Referenced by ecal::EcalReconConditions::EcalReconConditions(), and ldmx::HgcrocTriggerConditions::HgcrocTriggerConditions().

◆ getColumnName()

const std::string & conditions::BaseTableCondition::getColumnName ( unsigned int icol) const
inline

Get the name of the given column.

Definition at line 50 of file SimpleTableCondition.h.

50 {
51 if (icol >= columnCount_) {
52 EXCEPTION_RAISE("ConditionsException",
53 std::string("Column index out of range in ") + getName());
54 }
55 return columns_[icol];
56 }
std::string getName() const
Get the name of this object.

References framework::ConditionsObject::getName().

◆ getColumnNames()

const std::vector< std::string > & conditions::BaseTableCondition::getColumnNames ( ) const
inline

Get the names of the columns.

Definition at line 72 of file SimpleTableCondition.h.

72{ return columns_; }

Referenced by ecal::EcalReconConditions::EcalReconConditions(), and ldmx::HgcrocTriggerConditions::HgcrocTriggerConditions().

◆ getColumnNumber()

unsigned int conditions::BaseTableCondition::getColumnNumber ( const std::string & colname) const
inline

Get a the column number for the given column name.

Definition at line 36 of file SimpleTableCondition.h.

36 {
37 for (unsigned int i = 0; i < columnCount_; i++)
38 if (colname == columns_[i]) return i;
39 return columnCount_;
40 }

Referenced by conditions::HomogenousTableCondition< T >::getByName(), and ldmx::HgcrocEmulator::getCondition().

◆ getIdMask()

unsigned int conditions::BaseTableCondition::getIdMask ( ) const
inline

Get the AND mask to be applied to the id.

Typically used to "flatten" a table in some manner.

Definition at line 89 of file SimpleTableCondition.h.

89{ return idMask_; }

◆ getRowCount()

std::size_t conditions::BaseTableCondition::getRowCount ( ) const
inline

◆ getRowId()

unsigned int conditions::BaseTableCondition::getRowId ( unsigned int irow) const
inline

Get the id for the given row.

Definition at line 61 of file SimpleTableCondition.h.

61 {
62 if (irow >= getRowCount()) { // raise exception
63 EXCEPTION_RAISE("ConditionsException",
64 "Row out of range: " + std::to_string(irow));
65 }
66 return keys_[irow];
67 }
std::size_t getRowCount() const
Get the number of rows.

References getRowCount().

◆ setIdMask()

void conditions::BaseTableCondition::setIdMask ( unsigned int mask)
inline

Set an AND mask to be applied to the id.

Typically used to "flatten" a table in some manner.

Definition at line 83 of file SimpleTableCondition.h.

83{ idMask_ = mask; }

Referenced by conditions::SimpleCSVTableProvider::getCondition().

◆ streamRow()

virtual std::ostream & conditions::BaseTableCondition::streamRow ( std::ostream & s,
int irow ) const
inlinevirtual

Streams a given row of this table.

Reimplemented in conditions::HomogenousTableCondition< T >, conditions::HomogenousTableCondition< double >, and conditions::HomogenousTableCondition< int >.

Definition at line 94 of file SimpleTableCondition.h.

94 {
95 return s << keys_[irow];
96 }

Member Data Documentation

◆ columnCount_

unsigned int conditions::BaseTableCondition::columnCount_
protected

Definition at line 104 of file SimpleTableCondition.h.

◆ columns_

std::vector<std::string> conditions::BaseTableCondition::columns_
protected

Definition at line 103 of file SimpleTableCondition.h.

◆ idMask_

unsigned int conditions::BaseTableCondition::idMask_
protected

Definition at line 106 of file SimpleTableCondition.h.

◆ keys_

std::vector<uint32_t> conditions::BaseTableCondition::keys_
protected

Definition at line 105 of file SimpleTableCondition.h.


The documentation for this class was generated from the following files: