LDMX Software
conditions::HomogenousTableCondition< T > Class Template Reference

Public Member Functions

 HomogenousTableCondition (const std::string &name, const std::vector< std::string > &columns)
 
void clear ()
 Clear the contents.
 
void add (unsigned int id, const std::vector< T > &values)
 Add an entry to the table.
 
get (unsigned int id, unsigned int col) const
 Get an entry by DetectorId and number.
 
std::pair< unsigned int, std::vector< T > > getRow (unsigned int irow) const
 Get a row by number Used primarily for persisting the SimpleTableCondition.
 
getByName (unsigned int id, const std::string &colname) const
 Get a column by DetectorId and name Throws an exception when.
 
virtual std::ostream & streamRow (std::ostream &s, int irow) const
 Streams a given row of this table.
 
- Public Member Functions inherited from conditions::BaseTableCondition
 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.
 
- 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.
 

Private Attributes

std::vector< T > values_
 

Additional Inherited Members

- Protected Member Functions inherited from conditions::BaseTableCondition
std::size_t findKey (unsigned int id) const
 
std::size_t findKeyInsert (unsigned int id) const
 
- Protected Attributes inherited from conditions::BaseTableCondition
std::vector< std::string > columns_
 
unsigned int columnCount_
 
std::vector< uint32_t > keys_
 
unsigned int idMask_
 

Detailed Description

template<class T>
class conditions::HomogenousTableCondition< T >

Definition at line 110 of file SimpleTableCondition.h.

Constructor & Destructor Documentation

◆ HomogenousTableCondition()

template<class T >
conditions::HomogenousTableCondition< T >::HomogenousTableCondition ( const std::string & name,
const std::vector< std::string > & columns )
inline

Definition at line 112 of file SimpleTableCondition.h.

114 : BaseTableCondition(name, columns) {}
BaseTableCondition(const std::string &name, const std::vector< std::string > &columns)
Create table with given set of columns.

◆ ~HomogenousTableCondition()

template<class T >
virtual conditions::HomogenousTableCondition< T >::~HomogenousTableCondition ( )
inlinevirtual

Definition at line 116 of file SimpleTableCondition.h.

116{}

Member Function Documentation

◆ add()

template<class T >
void conditions::HomogenousTableCondition< T >::add ( unsigned int id,
const std::vector< T > & values )
inline

Add an entry to the table.

Definition at line 127 of file SimpleTableCondition.h.

127 {
128 if (values.size() != columnCount_) {
129 EXCEPTION_RAISE("ConditionsException",
130 getName() + ": Attempted to insert a row with " +
131 std::to_string(values.size()) +
132 " columns into a table with " +
133 std::to_string(columnCount_) + " columns");
134 }
135 std::size_t loc = findKey(id);
136 if (loc != getRowCount()) {
137 EXCEPTION_RAISE("ConditionsException",
138 "Attempted to add condition in " + getName() +
139 " for existing id " + std::to_string(id));
140 }
141 loc = findKeyInsert(id); // where to put it
142
143 // insert into the keys
144 keys_.insert(keys_.begin() + loc, id);
145 // insert into the values
146 values_.insert(values_.begin() + loc * columnCount_, values.begin(),
147 values.end());
148 }
std::size_t getRowCount() const
Get the number of rows.
std::string getName() const
Get the name of this object.

References framework::ConditionsObject::getName(), and conditions::BaseTableCondition::getRowCount().

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

◆ clear()

template<class T >
void conditions::HomogenousTableCondition< T >::clear ( )
inline

Clear the contents.

Definition at line 121 of file SimpleTableCondition.h.

121 {
122 keys_.clear();
123 values_.clear();
124 }

◆ get()

template<class T >
T conditions::HomogenousTableCondition< T >::get ( unsigned int id,
unsigned int col ) const
inline

Get an entry by DetectorId and number.

Throws an exception when id is unavailble

Definition at line 154 of file SimpleTableCondition.h.

154 {
155 std::size_t irow = findKey(id);
156 if (col >= columnCount_ || irow == getRowCount()) { // raise exception
157 EXCEPTION_RAISE("ConditionsException",
158 "No such column " + std::to_string(col) + " or id " +
159 std::to_string(id));
160 }
161 return values_[irow * columnCount_ + col];
162 }

References conditions::BaseTableCondition::getRowCount().

Referenced by ecal::EcalReconConditions::adcGain(), hcal::HcalReconConditions::adcGain(), ecal::EcalReconConditions::adcPedestal(), hcal::HcalReconConditions::adcPedestal(), ldmx::HgcrocTriggerConditions::adcPedestal(), ldmx::HgcrocTriggerConditions::adcThreshold(), conditions::HomogenousTableCondition< T >::getByName(), ldmx::HgcrocEmulator::getCondition(), hcal::HcalReconConditions::toaCalib(), hcal::HcalReconConditions::totCalib(), ecal::EcalReconConditions::totGain(), ldmx::HgcrocTriggerConditions::totGain(), ecal::EcalReconConditions::totPedestal(), ldmx::HgcrocTriggerConditions::totPedestal(), and ldmx::HgcrocTriggerConditions::totThreshold().

◆ getByName()

template<class T >
T conditions::HomogenousTableCondition< T >::getByName ( unsigned int id,
const std::string & colname ) const
inline

Get a column by DetectorId and name Throws an exception when.

Note
This is an inefficient process. Suggest caching the return of "getColumnNumber()" and using getColumn directly

Definition at line 184 of file SimpleTableCondition.h.

184 {
185 return get(id, getColumnNumber(colname));
186 }
unsigned int getColumnNumber(const std::string &colname) const
Get a the column number for the given column name.
T get(unsigned int id, unsigned int col) const
Get an entry by DetectorId and number.

References conditions::HomogenousTableCondition< T >::get(), and conditions::BaseTableCondition::getColumnNumber().

◆ getRow()

template<class T >
std::pair< unsigned int, std::vector< T > > conditions::HomogenousTableCondition< T >::getRow ( unsigned int irow) const
inline

Get a row by number Used primarily for persisting the SimpleTableCondition.

Definition at line 168 of file SimpleTableCondition.h.

168 {
169 if (irow >= getRowCount()) { // raise exception
170 EXCEPTION_RAISE("ConditionsException",
171 "Row out of range: " + std::to_string(irow));
172 }
173 std::vector<T> rv(&(values_[irow * columnCount_]),
174 &(values_[(irow + 1) * columnCount_]));
175 return std::pair<unsigned int, std::vector<T> >(keys_[irow], rv);
176 }

References conditions::BaseTableCondition::getRowCount().

◆ streamRow()

template<class T >
virtual std::ostream & conditions::HomogenousTableCondition< T >::streamRow ( std::ostream & s,
int irow ) const
inlinevirtual

Streams a given row of this table.

Reimplemented from conditions::BaseTableCondition.

Definition at line 191 of file SimpleTableCondition.h.

191 {
192 if (irow >= getRowCount()) { // raise exception
193 EXCEPTION_RAISE("ConditionsException",
194 "Row out of range: " + std::to_string(irow));
195 }
196 s << keys_[irow];
197 for (int i = 0; i < columnCount_; i++)
198 s << ',' << values_[irow * columnCount_ + i];
199 return s << std::endl;
200 }

References conditions::BaseTableCondition::getRowCount().

Member Data Documentation

◆ values_

template<class T >
std::vector<T> conditions::HomogenousTableCondition< T >::values_
private

Definition at line 203 of file SimpleTableCondition.h.


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