CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
l1t::Setting Class Reference

#include <Setting.h>

Public Member Functions

void addTableRow (const std::string &row, const std::vector< std::string > &types, const std::vector< std::string > &columns)
 
std::string getId ()
 
l1t::LUT getLUT (size_t addrWidth=0, size_t dataWidth=31, int padding=-1, std::string delim=",")
 
std::string getProcRole ()
 
std::vector< TableRowgetTableRows ()
 
std::string getType ()
 
template<class varType >
varType getValue ()
 
std::string getValueAsStr ()
 
template<class varType >
std::vector< varType > getVector ()
 
Settingoperator= (const Setting &aSet)
 
void resetTableRows ()
 
void setId (const std::string &id)
 
void setLogStringVar (std::string *strVar)
 
void setProcRole (const std::string &procRole)
 
 Setting ()
 
 Setting (const std::string &type, const std::string &id, const std::string &value, const std::string &procRole, std::string *lt, const std::string &delim="")
 
 Setting (const std::string &id, const std::string &columns, const std::string &types, const std::vector< std::string > &rows, const std::string &procRole, std::string *lt, const std::string &delim)
 
void setValue (const std::string &value)
 
 ~Setting ()
 

Private Attributes

std::string delim_
 
std::string id_
 
std::string * logText_
 
std::string procRole_
 
std::vector< TableRowTableRows_
 
std::string type_
 
std::string value_
 

Detailed Description

Definition at line 48 of file Setting.h.

Constructor & Destructor Documentation

l1t::Setting::Setting ( )
inline

Definition at line 51 of file Setting.h.

51 {};
l1t::Setting::Setting ( const std::string &  type,
const std::string &  id,
const std::string &  value,
const std::string &  procRole,
std::string *  lt,
const std::string &  delim = "" 
)

Definition at line 7 of file Setting.cc.

References delim_, logText_, lt, and setValue().

7  :
8 type_(type),
9 id_(id),
10 value_(value),
11 procRole_(procRole),
12 delim_(delim)
13 {
14  if ( delim.empty() )
15  delim_ = ",";
16 
17  logText_ = lt;
18 
19  setValue(value);
20 }
type
Definition: HCALResponse.h:21
std::string * logText_
Definition: Setting.h:74
std::string value_
Definition: Setting.h:72
std::string procRole_
Definition: Setting.h:72
void setValue(const std::string &value)
Definition: Setting.cc:60
std::string id_
Definition: Setting.h:72
< trclass="colgroup">< tdclass="colgroup"colspan=5 > DT local reconstruction</td ></tr >< tr >< td >< ahref="classDTRecHit1DPair.html"> DTRecHit1DPair</a ></td >< td >< ahref="DataFormats_DTRecHit.html"> edm::RangeMap & lt
std::string delim_
Definition: Setting.h:72
std::string type_
Definition: Setting.h:72
l1t::Setting::Setting ( const std::string &  id,
const std::string &  columns,
const std::string &  types,
const std::vector< std::string > &  rows,
const std::string &  procRole,
std::string *  lt,
const std::string &  delim 
)

Definition at line 22 of file Setting.cc.

References delim_, logText_, lt, l1t::str2VecStr_(), and TableRows_.

22  :
23 type_("table"),
24 id_(id),
25 procRole_(procRole),
26 delim_(delim)
27 {
28  if ( delim.empty() )
29  delim_ = ",";
30 
31  logText_ = lt;
32  // str2VecStr_(columns, delim_, tableColumns_);
33 
34  // str2VecStr_(types, delim_, tableTypes_);
35 
36  for (auto it=rows.begin(); it!=rows.end(); ++it)
37  {
38  // std::vector<std::string> aRow;
39  // str2VecStr_(*it, delim_, aRow);
40 
41  //TableRow temp(aRow);
42  //temp.setTableId(id);
43  //temp.setRowTypes(tableTypes_);
44  //temp.setRowColumns(tableColumns_);
45  TableRows_.push_back(TableRow(str2VecStr_(*it, delim_),logText_));
46  TableRows_.back().setTableId(id);
47  // TableRows_.back().setRowTypes(tableTypes_);
48  // TableRows_.back().setRowColumns(tableColumns_);
49  TableRows_.back().setRowTypes(str2VecStr_(types, delim_));
50  TableRows_.back().setRowColumns(str2VecStr_(columns, delim_));
51 
52  }
53 }
std::string * logText_
Definition: Setting.h:74
std::string procRole_
Definition: Setting.h:72
std::vector< std::string > str2VecStr_(const std::string &aStr, const std::string &delim)
Definition: Tools.cc:23
std::string id_
Definition: Setting.h:72
std::vector< TableRow > TableRows_
Definition: Setting.h:73
< trclass="colgroup">< tdclass="colgroup"colspan=5 > DT local reconstruction</td ></tr >< tr >< td >< ahref="classDTRecHit1DPair.html"> DTRecHit1DPair</a ></td >< td >< ahref="DataFormats_DTRecHit.html"> edm::RangeMap & lt
tuple columns
Definition: mps_check.py:210
std::string delim_
Definition: Setting.h:72
std::string type_
Definition: Setting.h:72
l1t::Setting::~Setting ( )

Definition at line 55 of file Setting.cc.

56 {
57  ;
58 }

Member Function Documentation

void l1t::Setting::addTableRow ( const std::string &  row,
const std::vector< std::string > &  types,
const std::vector< std::string > &  columns 
)

Definition at line 144 of file Setting.cc.

References delim_, logText_, l1t::str2VecStr_(), TableRows_, type_, and create_public_pileup_plots::vals.

145 {
146  if (type_.find("table") == std::string::npos)
147  throw std::runtime_error("You cannot add a table row in type: " + type_ + ". Type is not table.");
148 
149  std::vector<std::string> vals;
150  str2VecStr_(row, delim_, vals);
151 
152  // TableRow tempRow(vals);
153  // tempRow.setRowTypes(tableTypes_);
154  // tempRow.setRowColumns(tableColumns_);
155  TableRows_.push_back(TableRow(vals, logText_));
156  TableRows_.back().setRowTypes(types);
157  TableRows_.back().setRowColumns(columns);
158 
159 }
std::string * logText_
Definition: Setting.h:74
std::vector< std::string > str2VecStr_(const std::string &aStr, const std::string &delim)
Definition: Tools.cc:23
std::vector< TableRow > TableRows_
Definition: Setting.h:73
tuple columns
Definition: mps_check.py:210
std::string delim_
Definition: Setting.h:72
std::string type_
Definition: Setting.h:72
std::string l1t::Setting::getId ( )
inline

Definition at line 63 of file Setting.h.

References id_.

Referenced by getValue(), and getVector().

63 { return id_; } ;
std::string id_
Definition: Setting.h:72
l1t::LUT l1t::Setting::getLUT ( size_t  addrWidth = 0,
size_t  dataWidth = 31,
int  padding = -1,
std::string  delim = "," 
)

Definition at line 97 of file Setting.cc.

References i, lumiPlot::lut, l1t::LUT::read(), contentValuesCheck::ss, and type_.

98 {
99  if ( type_.find("vector:uint") == std::string::npos )
100  throw std::runtime_error("Cannot build LUT from type: " + type_ + ". Only vector:unsigned int is allowed.");
101 
102  if ( delim.empty() )
103  delim = ",";
104 
105  std::vector<unsigned int> vec = getVector<unsigned int>();
106 
107  // if the addrWidth parameter is 0 calculate the address width from the LUT length
108  if (addrWidth == 0) {
109  size_t nEntries = vec.size();
110  while (nEntries >>= 1) {
111  ++addrWidth;
112  }
113  }
114 
115  // write the stream to fill the LUT
116  std::stringstream ss;
117  ss << "#<header> V1 " << addrWidth << " " << dataWidth << " </header>" << std::endl;
118  size_t i = 0;
119  for (; i < vec.size() && i < (size_t)(1<<addrWidth); ++i) {
120  ss << i << " " << vec[i] << std::endl;
121  }
122  // add padding to 2^addrWidth rows
123  if (padding >= 0 && i < (size_t)(1<<addrWidth)) {
124  for (; i < (size_t)(1<<addrWidth); ++i) {
125  ss << i << " " << padding << std::endl;
126  }
127  }
128 
129  l1t::LUT lut;
130  lut.read(ss);
131 
132  return lut;
133 }
int i
Definition: DBlmapReader.cc:9
int read(std::istream &stream)
Definition: LUT.cc:35
tuple lut
Definition: lumiPlot.py:244
Definition: LUT.h:29
std::string type_
Definition: Setting.h:72
std::string l1t::Setting::getProcRole ( )
inline

Definition at line 60 of file Setting.h.

References procRole_.

60 { return procRole_; };
std::string procRole_
Definition: Setting.h:72
std::vector<TableRow> l1t::Setting::getTableRows ( )
inline

Definition at line 66 of file Setting.h.

References TableRows_.

66 { return TableRows_; };
std::vector< TableRow > TableRows_
Definition: Setting.h:73
std::string l1t::Setting::getType ( void  )
inline

Definition at line 62 of file Setting.h.

References type_.

62 { return type_; };
std::string type_
Definition: Setting.h:72
template<class varType >
varType l1t::Setting::getValue ( )

Definition at line 100 of file Setting.h.

References getId(), getValueAsStr(), logText_, type_, and value_.

101 {
102 
103  if ( type_.find("vector") != std::string::npos )
104  throw std::runtime_error("The registered type: " + type_ + " is vector so you need to call the getVector method");
105 
106  if ( logText_ )
107  {
108  std::ostringstream tempStr;
109  tempStr << "l1t::Setting::getValue\tReturning value " << this->getValueAsStr() << " from parameter with id: " << this->getId() << std::endl;
110  logText_->append(tempStr.str());
111  }
112  return convertVariable<varType>(value_);
113 }
std::string * logText_
Definition: Setting.h:74
std::string value_
Definition: Setting.h:72
std::string getId()
Definition: Setting.h:63
std::string getValueAsStr()
Definition: Setting.h:61
std::string type_
Definition: Setting.h:72
std::string l1t::Setting::getValueAsStr ( )
inline

Definition at line 61 of file Setting.h.

References value_.

Referenced by getValue(), and getVector().

61 { return value_; };
std::string value_
Definition: Setting.h:72
template<typename varType >
std::vector< varType > l1t::Setting::getVector ( )

Definition at line 78 of file Setting.h.

References delim_, getId(), getValueAsStr(), logText_, l1t::str2VecStr_(), type_, create_public_pileup_plots::vals, and value_.

79 {
80 
81  if ( type_.find("vector") == std::string::npos )
82  throw std::runtime_error("The registered type: " + type_ + " is not vector so you need to call the getValue method");
83 
84  std::vector<std::string> vals;
85  str2VecStr_(value_, delim_, vals);
86 
87  std::vector<varType> newVals;
88  for(auto it=vals.begin(); it!=vals.end(); it++)
89  newVals.push_back(convertVariable<varType>(*it));
90 
91  if ( logText_ )
92  {
93  std::ostringstream tempStr;
94  tempStr << "l1t::Setting::getVector\tReturning vector with values " << this->getValueAsStr() << " from parameter with id: " << this->getId() << std::endl;
95  logText_->append(tempStr.str());
96  }
97  return newVals;
98 }
std::string * logText_
Definition: Setting.h:74
std::string value_
Definition: Setting.h:72
std::vector< std::string > str2VecStr_(const std::string &aStr, const std::string &delim)
Definition: Tools.cc:23
std::string getId()
Definition: Setting.h:63
std::string getValueAsStr()
Definition: Setting.h:61
std::string delim_
Definition: Setting.h:72
std::string type_
Definition: Setting.h:72
Setting & l1t::Setting::operator= ( const Setting aSet)

Definition at line 135 of file Setting.cc.

References id_, procRole_, type_, and value_.

136 {
137  value_ = aSet.value_;
138  id_ = aSet.id_;
139  type_ = aSet.type_;
140  procRole_ = aSet.procRole_;
141  return *this;
142 }
std::string value_
Definition: Setting.h:72
std::string procRole_
Definition: Setting.h:72
std::string id_
Definition: Setting.h:72
std::string type_
Definition: Setting.h:72
void l1t::Setting::resetTableRows ( )
inline

Definition at line 59 of file Setting.h.

References TableRows_.

59 { TableRows_.clear();};
std::vector< TableRow > TableRows_
Definition: Setting.h:73
void l1t::Setting::setId ( const std::string &  id)
inline

Definition at line 56 of file Setting.h.

References id_.

56 { id_ = id; } ;
std::string id_
Definition: Setting.h:72
void l1t::Setting::setLogStringVar ( std::string *  strVar)
inline

Definition at line 57 of file Setting.h.

References logText_.

57 {logText_ = strVar;};
std::string * logText_
Definition: Setting.h:74
void l1t::Setting::setProcRole ( const std::string &  procRole)
inline

Definition at line 54 of file Setting.h.

References procRole_.

54 { procRole_ = procRole; };
std::string procRole_
Definition: Setting.h:72
void l1t::Setting::setValue ( const std::string &  value)

Definition at line 60 of file Setting.cc.

References delim_, l1t::str2VecStr_(), type_, create_public_pileup_plots::vals, relativeConstraints::value, and value_.

Referenced by Setting().

61 {
62  if ( type_.find("bool") != std::string::npos )
63  {
64  std::ostringstream convString;
65 
66  if ( type_.find("vector") != std::string::npos )
67  {
68  if (delim_.empty())
69  delim_ = ",";
70 
71  std::vector<std::string> vals;
72  str2VecStr_(value_,delim_, vals);
73 
74  for(std::vector<std::string>::iterator it=vals.begin(); it!=vals.end(); ++it)
75  {
76  if ( it->find("true") != std::string::npos )
77  convString << "1, ";
78  else
79  convString << "0, ";
80  }
81  }
82  else
83  {
84  if ( value.find("true") != std::string::npos )
85  convString << "1";
86  else
87  convString << "0";
88  }
89 
90  value_ = convString.str();
91  }
92  else
93  value_ = value;
94 }
std::string value_
Definition: Setting.h:72
std::vector< std::string > str2VecStr_(const std::string &aStr, const std::string &delim)
Definition: Tools.cc:23
std::string delim_
Definition: Setting.h:72
std::string type_
Definition: Setting.h:72

Member Data Documentation

std::string l1t::Setting::delim_
private

Definition at line 72 of file Setting.h.

Referenced by addTableRow(), getVector(), Setting(), and setValue().

std::string l1t::Setting::id_
private

Definition at line 72 of file Setting.h.

Referenced by getId(), operator=(), and setId().

std::string* l1t::Setting::logText_
private

Definition at line 74 of file Setting.h.

Referenced by addTableRow(), getValue(), getVector(), setLogStringVar(), and Setting().

std::string l1t::Setting::procRole_
private

Definition at line 72 of file Setting.h.

Referenced by getProcRole(), operator=(), and setProcRole().

std::vector<TableRow> l1t::Setting::TableRows_
private

Definition at line 73 of file Setting.h.

Referenced by addTableRow(), getTableRows(), resetTableRows(), and Setting().

std::string l1t::Setting::type_
private
std::string l1t::Setting::value_
private

Definition at line 72 of file Setting.h.

Referenced by getValue(), getValueAsStr(), getVector(), operator=(), and setValue().