CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
l1t::Parameter Class Reference

#include <Parameter.h>

Public Member Functions

std::map< std::string, unsigned int > getColumnIndices (void) const noexcept
 
std::string getId (void) const noexcept
 
std::string getProcOrRole (void) const noexcept
 
template<class T >
std::vector< TgetTableColumn (const char *colName) const
 
template<class T >
std::map< std::string, TgetTableRow (unsigned long rowNum) const
 
std::string getType (void) const noexcept
 
template<class T >
T getValue (void) const
 
std::string getValueAsStr (void) const noexcept
 
template<class T >
std::vector< TgetVector (void) const
 
bool isScalar (void) const noexcept
 
bool isTable (void) const noexcept
 
bool isVector (void) const noexcept
 
Parameteroperator= (const Parameter &s)=default
 
Parameteroperator= (Parameter &&s)=default
 
 Parameter (const Parameter &s)=default
 
 Parameter (Parameter &&s)=default
 
 Parameter (const char *id, const char *procOrRole, const char *type, const char *value, const char *delimeter=",")
 
 Parameter (const char *id, const char *procOrRole, const char *types, const char *columns, const std::vector< std::string > &rows, const char *delimeter=",")
 
 Parameter (void)
 
 ~Parameter (void)
 

Private Attributes

std::map< std::string, unsigned int > columnNameToIndex
 
std::string delim
 
std::string id
 
std::string procOrRole
 
std::string scalarOrVector
 
std::map< std::string, std::vector< std::string > > table
 
std::string type
 

Detailed Description

Definition at line 21 of file Parameter.h.

Constructor & Destructor Documentation

◆ Parameter() [1/5]

l1t::Parameter::Parameter ( const Parameter s)
default

◆ Parameter() [2/5]

l1t::Parameter::Parameter ( Parameter &&  s)
default

◆ Parameter() [3/5]

l1t::Parameter::Parameter ( const char *  id,
const char *  procOrRole,
const char *  type,
const char *  value,
const char *  delimeter = "," 
)

Definition at line 9 of file Parameter.cc.

References l1ctLayer2EG_cff::id, and relativeConstraints::value.

10  {
11  this->id = id;
12  this->procOrRole = procOrRole;
13  this->type = type;
14  this->scalarOrVector = value;
15  this->delim = delimeter;
16  }
std::string scalarOrVector
Definition: Parameter.h:24
std::string delim
Definition: Parameter.h:24
std::string procOrRole
Definition: Parameter.h:23
std::string type
Definition: Parameter.h:23
std::string id
Definition: Parameter.h:23

◆ Parameter() [4/5]

l1t::Parameter::Parameter ( const char *  id,
const char *  procOrRole,
const char *  types,
const char *  columns,
const std::vector< std::string > &  rows,
const char *  delimeter = "," 
)

◆ Parameter() [5/5]

l1t::Parameter::Parameter ( void  )
inline

Definition at line 111 of file Parameter.h.

111 {}

◆ ~Parameter()

l1t::Parameter::~Parameter ( void  )
inline

Definition at line 112 of file Parameter.h.

112 {}

Member Function Documentation

◆ getColumnIndices()

std::map<std::string, unsigned int> l1t::Parameter::getColumnIndices ( void  ) const
inlinenoexcept

Definition at line 96 of file Parameter.h.

References columnNameToIndex.

96 { return columnNameToIndex; }
std::map< std::string, unsigned int > columnNameToIndex
Definition: Parameter.h:27

◆ getId()

std::string l1t::Parameter::getId ( void  ) const
inlinenoexcept

Definition at line 30 of file Parameter.h.

References id.

30 { return id; }
std::string id
Definition: Parameter.h:23

◆ getProcOrRole()

std::string l1t::Parameter::getProcOrRole ( void  ) const
inlinenoexcept

Definition at line 31 of file Parameter.h.

References procOrRole.

31 { return procOrRole; }
std::string procOrRole
Definition: Parameter.h:23

◆ getTableColumn()

template<class T >
std::vector<T> l1t::Parameter::getTableColumn ( const char *  colName) const
inline

Definition at line 79 of file Parameter.h.

References a, AlCaHLTBitMon_QueryRunRegistry::string, table, and HcalDetIdTransform::transform().

79  {
80  const std::vector<std::string> &column = table.at(colName);
81  std::vector<T> retval(column.size());
83  column.begin(), column.end(), retval.begin(), [](std::string a) -> T { return castTo<T>(a.c_str()); });
84  return retval;
85  }
std::map< std::string, std::vector< std::string > > table
Definition: Parameter.h:26
double a
Definition: hdecay.h:121
long double T
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ getTableRow()

template<class T >
std::map<std::string, T> l1t::Parameter::getTableRow ( unsigned long  rowNum) const
inline

Definition at line 88 of file Parameter.h.

References table.

88  {
89  std::map<std::string, T> retval;
90  for (auto &column :
91  table) // insert below is never going to fail as the source map doesn't have duplicated by design
92  retval.insert(std::make_pair(column.first, castTo<T>(column.second.at(rowNum).c_str())));
93  return retval;
94  }
std::map< std::string, std::vector< std::string > > table
Definition: Parameter.h:26

◆ getType()

std::string l1t::Parameter::getType ( void  ) const
inlinenoexcept

Definition at line 32 of file Parameter.h.

References type.

32 { return type; }
std::string type
Definition: Parameter.h:23

◆ getValue()

template<class T >
T l1t::Parameter::getValue ( void  ) const
inline

Definition at line 53 of file Parameter.h.

References isScalar(), and scalarOrVector.

53  {
54  if (!isScalar())
55  throw std::runtime_error("The registered type: '" + type +
56  "' is not a scalar -> try getVector() or getTable()");
57  return castTo<T>(scalarOrVector.c_str());
58  }
bool isScalar(void) const noexcept
Definition: Parameter.h:35
std::string scalarOrVector
Definition: Parameter.h:24

◆ getValueAsStr()

std::string l1t::Parameter::getValueAsStr ( void  ) const
inlinenoexcept

Definition at line 33 of file Parameter.h.

References scalarOrVector.

33 { return scalarOrVector; }
std::string scalarOrVector
Definition: Parameter.h:24

◆ getVector()

template<class T >
std::vector<T> l1t::Parameter::getVector ( void  ) const
inline

Definition at line 61 of file Parameter.h.

References filterCSVwithJSON::copy, ztail::d, delim, MillePedeFileConverter_cfg::e, bookConverter::elements, isVector(), B2GTnPMonitor_cfi::item, scalarOrVector, and AlCaHLTBitMon_QueryRunRegistry::string.

61  {
62  if (!isVector())
63  throw std::runtime_error("The registered type: '" + type + "' is not a vector");
64  // split the vector into elements
65  const char *d = delim.c_str();
66  std::list<T> elements;
67  std::unique_ptr<char, void (*)(void *)> copy(strdup(scalarOrVector.c_str()), free);
68  char *saveptr;
69  for (const char *item = strtok_r(copy.get(), d, &saveptr); item != nullptr; item = strtok_r(nullptr, d, &saveptr))
70  try {
71  elements.push_back(castTo<T>(item));
72  } catch (std::runtime_error &e) {
73  throw std::runtime_error(std::string(e.what()) + "; check if delimeter '" + delim + "' is correct");
74  }
75  return std::vector<T>(elements.begin(), elements.end());
76  }
bool isVector(void) const noexcept
Definition: Parameter.h:40
std::string scalarOrVector
Definition: Parameter.h:24
std::string delim
Definition: Parameter.h:24
d
Definition: ztail.py:151

◆ isScalar()

bool l1t::Parameter::isScalar ( void  ) const
inlinenoexcept

Definition at line 35 of file Parameter.h.

Referenced by getValue().

35  {
36  if (type.find("vector") != std::string::npos || type.find("table") != std::string::npos)
37  return false;
38  return true;
39  }

◆ isTable()

bool l1t::Parameter::isTable ( void  ) const
inlinenoexcept

Definition at line 45 of file Parameter.h.

45  {
46  if (type.find("table") == std::string::npos)
47  return false;
48  return true;
49  }

◆ isVector()

bool l1t::Parameter::isVector ( void  ) const
inlinenoexcept

Definition at line 40 of file Parameter.h.

Referenced by getVector().

40  {
41  if (type.find("vector") == std::string::npos)
42  return false;
43  return true;
44  }

◆ operator=() [1/2]

Parameter& l1t::Parameter::operator= ( const Parameter s)
default

◆ operator=() [2/2]

Parameter& l1t::Parameter::operator= ( Parameter &&  s)
default

Member Data Documentation

◆ columnNameToIndex

std::map<std::string, unsigned int> l1t::Parameter::columnNameToIndex
private

Definition at line 27 of file Parameter.h.

Referenced by getColumnIndices().

◆ delim

std::string l1t::Parameter::delim
private

Definition at line 24 of file Parameter.h.

Referenced by getVector().

◆ id

std::string l1t::Parameter::id
private

Definition at line 23 of file Parameter.h.

Referenced by getId().

◆ procOrRole

std::string l1t::Parameter::procOrRole
private

Definition at line 23 of file Parameter.h.

Referenced by getProcOrRole().

◆ scalarOrVector

std::string l1t::Parameter::scalarOrVector
private

Definition at line 24 of file Parameter.h.

Referenced by getValue(), getValueAsStr(), and getVector().

◆ table

std::map<std::string, std::vector<std::string> > l1t::Parameter::table
private

Definition at line 26 of file Parameter.h.

Referenced by getTableColumn(), and getTableRow().

◆ type

std::string l1t::Parameter::type
private