LDMX Software
Public Member Functions | Private Attributes | List of all members
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 109 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 111 of file SimpleTableCondition.h.

113 : 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 115 of file SimpleTableCondition.h.

115{}

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 126 of file SimpleTableCondition.h.

126 {
127 if (values.size() != columnCount_) {
128 EXCEPTION_RAISE("ConditionsException",
129 getName() + ": Attempted to insert a row with " +
130 std::to_string(values.size()) +
131 " columns into a table with " +
132 std::to_string(columnCount_) + " columns");
133 }
134 std::size_t loc = findKey(id);
135 if (loc != getRowCount()) {
136 EXCEPTION_RAISE("ConditionsException",
137 "Attempted to add condition in " + getName() +
138 " for existing id " + std::to_string(id));
139 }
140 loc = findKeyInsert(id); // where to put it
141
142 // insert into the keys
143 keys_.insert(keys_.begin() + loc, id);
144 // insert into the values
145 values_.insert(values_.begin() + loc * columnCount_, values.begin(),
146 values.end());
147 }
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 120 of file SimpleTableCondition.h.

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

◆ 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 153 of file SimpleTableCondition.h.

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

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 183 of file SimpleTableCondition.h.

183 {
184 return get(id, getColumnNumber(colname));
185 }
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 167 of file SimpleTableCondition.h.

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

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 190 of file SimpleTableCondition.h.

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

References conditions::BaseTableCondition::getRowCount().

Member Data Documentation

◆ values_

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

Definition at line 202 of file SimpleTableCondition.h.


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