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 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 (const Parameter &s)=default
 
 Parameter (Parameter &&s)=default
 
 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.

10  {
11  this->id = id;
12  this->procOrRole = procOrRole;
13  this->type = type;
14  this->scalarOrVector = value;
15  this->delim = delimeter;
16  }

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

◆ 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.

96 { return columnNameToIndex; }

References columnNameToIndex.

◆ getId()

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

Definition at line 30 of file Parameter.h.

30 { return id; }

References id.

◆ getProcOrRole()

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

Definition at line 31 of file Parameter.h.

31 { return procOrRole; }

References procOrRole.

◆ getTableColumn()

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

Definition at line 79 of file Parameter.h.

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  }

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

◆ 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.

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  }

References table.

◆ getType()

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

Definition at line 32 of file Parameter.h.

32 { return type; }

References type.

◆ getValue()

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

Definition at line 53 of file Parameter.h.

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  }

References isScalar(), and scalarOrVector.

◆ getValueAsStr()

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

Definition at line 33 of file Parameter.h.

33 { return scalarOrVector; }

References scalarOrVector.

◆ getVector()

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

Definition at line 61 of file Parameter.h.

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  }

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

◆ isScalar()

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

Definition at line 35 of file Parameter.h.

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

Referenced by getValue().

◆ 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.

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

Referenced by getVector().

◆ 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
l1t::Parameter::delim
std::string delim
Definition: Parameter.h:24
l1t::Parameter::type
std::string type
Definition: Parameter.h:23
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
l1t::Parameter::procOrRole
std::string procOrRole
Definition: Parameter.h:23
l1t::Parameter::scalarOrVector
std::string scalarOrVector
Definition: Parameter.h:24
l1t::Parameter::id
std::string id
Definition: Parameter.h:23
l1t::Parameter::isVector
bool isVector(void) const noexcept
Definition: Parameter.h:40
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
l1t::Parameter::columnNameToIndex
std::map< std::string, unsigned int > columnNameToIndex
Definition: Parameter.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
a
double a
Definition: hdecay.h:119
l1t::Parameter::isScalar
bool isScalar(void) const noexcept
Definition: Parameter.h:35
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
bookConverter.elements
elements
Definition: bookConverter.py:147
type
type
Definition: HCALResponse.h:21
l1t::Parameter::table
std::map< std::string, std::vector< std::string > > table
Definition: Parameter.h:26
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:29
ztail.d
d
Definition: ztail.py:151
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37