CMS 3D CMS Logo

LHCInfoVectorizedFields.cc
Go to the documentation of this file.
3 
5 
6 LHCInfoVectorizedFields::LHCInfoVectorizedFields(size_t iSize, size_t fSize, size_t tSize, size_t sSize) {
7  m_intParams.resize(iSize, std::vector<unsigned int>(1, 0));
8  m_floatParams.resize(fSize, std::vector<float>(1, 0.));
9  m_timeParams.resize(tSize, std::vector<unsigned long long>(1, 0ULL));
10  m_stringParams.resize(sSize, std::vector<std::string>(1, ""));
11 }
12 
13 template <typename T>
14 const T& LHCInfoVectorizedFields::getParams(const std::vector<T>& params, size_t index) {
15  if (index >= params.size())
16  throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range.");
17  return params[index];
18 }
19 
20 template const std::vector<unsigned int>& LHCInfoVectorizedFields::getParams(
21  const std::vector<std::vector<unsigned int>>&, size_t);
22 template const std::vector<float>& LHCInfoVectorizedFields::getParams(const std::vector<std::vector<float>>&, size_t);
23 template const std::vector<unsigned long long>& LHCInfoVectorizedFields::getParams(
24  const std::vector<std::vector<unsigned long long>>&, size_t);
25 template const std::vector<std::string>& LHCInfoVectorizedFields::getParams(
26  const std::vector<std::vector<std::string>>&, size_t);
27 
28 template <typename T>
30  if (index >= params.size())
31  throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range.");
32  return params[index];
33 }
34 
35 template std::vector<unsigned int>& LHCInfoVectorizedFields::accessParams(std::vector<std::vector<unsigned int>>&,
36  size_t);
37 template std::vector<float>& LHCInfoVectorizedFields::accessParams(std::vector<std::vector<float>>&, size_t);
38 template std::vector<unsigned long long>& LHCInfoVectorizedFields::accessParams(
39  std::vector<std::vector<unsigned long long>>&, size_t);
40 template std::vector<std::string>& LHCInfoVectorizedFields::accessParams(std::vector<std::vector<std::string>>&,
41  size_t);
42 
43 template <typename T>
44 const T& LHCInfoVectorizedFields::getOneParam(const std::vector<std::vector<T>>& params, size_t index) {
45  if (index >= params.size())
46  throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range.");
47  const std::vector<T>& inner = params[index];
48  if (inner.empty())
49  throw cond::Exception("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() +
50  " has no value stored.");
51  return inner[0];
52 }
53 
54 template const unsigned int& LHCInfoVectorizedFields::getOneParam(const std::vector<std::vector<unsigned int>>&,
55  size_t);
56 template const float& LHCInfoVectorizedFields::getOneParam(const std::vector<std::vector<float>>&, size_t);
57 template const unsigned long long& LHCInfoVectorizedFields::getOneParam(
58  const std::vector<std::vector<unsigned long long>>&, size_t);
59 template const std::string& LHCInfoVectorizedFields::getOneParam(const std::vector<std::vector<std::string>>&, size_t);
60 
61 template <typename T>
62 void LHCInfoVectorizedFields::setOneParam(std::vector<std::vector<T>>& params, size_t index, const T& value) {
63  if (index >= params.size())
64  throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range.");
65  params[index] = std::vector<T>(1, value);
66 }
67 
68 template void LHCInfoVectorizedFields::setOneParam(std::vector<std::vector<unsigned int>>& params,
69  size_t index,
70  const unsigned int& value);
71 template void LHCInfoVectorizedFields::setOneParam(std::vector<std::vector<float>>& params,
72  size_t index,
73  const float& value);
74 template void LHCInfoVectorizedFields::setOneParam(std::vector<std::vector<unsigned long long>>& params,
75  size_t index,
76  const unsigned long long& value);
77 template void LHCInfoVectorizedFields::setOneParam(std::vector<std::vector<std::string>>& params,
78  size_t index,
79  const std::string& value);
80 
81 template <typename T>
82 void LHCInfoVectorizedFields::setParams(std::vector<T>& params, size_t index, const T& value) {
83  if (index >= params.size())
84  throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range.");
85  params[index] = value;
86 }
87 
88 template void LHCInfoVectorizedFields::setParams(std::vector<std::vector<unsigned int>>& params,
89  size_t index,
90  const std::vector<unsigned int>& value);
91 template void LHCInfoVectorizedFields::setParams(std::vector<std::vector<float>>& params,
92  size_t index,
93  const std::vector<float>& value);
94 template void LHCInfoVectorizedFields::setParams(std::vector<std::vector<unsigned long long>>& params,
95  size_t index,
96  const std::vector<unsigned long long>& value);
97 template void LHCInfoVectorizedFields::setParams(std::vector<std::vector<std::string>>& params,
98  size_t index,
99  const std::vector<std::string>& value);
static void setOneParam(std::vector< std::vector< T > > &params, size_t index, const T &value)
Base exception class for the object to relational access.
Definition: Exception.h:11
std::vector< std::vector< unsigned int > > m_intParams
std::string to_string(const V &value)
Definition: OMSAccess.h:71
std::vector< std::vector< std::string > > m_stringParams
static const T & getOneParam(const std::vector< std::vector< T > > &params, size_t index)
static void setParams(std::vector< T > &params, size_t index, const T &value)
std::vector< std::vector< unsigned long long > > m_timeParams
std::vector< std::vector< float > > m_floatParams
Definition: value.py:1
static const T & getParams(const std::vector< T > &params, size_t index)
long double T
static T & accessParams(std::vector< T > &params, size_t index)