CMS 3D CMS Logo

SummaryTableOutputFields.cc
Go to the documentation of this file.
2 
3 template <typename T, typename Col>
4 std::vector<RNTupleFieldPtr<T>> SummaryTableOutputFields::makeFields(const std::vector<Col> &tabcols,
5  RNTupleModel &model) {
6  std::vector<RNTupleFieldPtr<T>> fields;
7  fields.reserve(tabcols.size());
8  for (const auto &col : tabcols) {
9  // TODO field description
10  fields.emplace_back(RNTupleFieldPtr<T>(col.name, col.doc, model));
11  }
12  return fields;
13 }
14 
15 template <typename T, typename Col>
16 void SummaryTableOutputFields::fillScalarFields(const std::vector<Col> &tabcols,
18  if (tabcols.size() != fields.size()) {
19  throw cms::Exception("LogicError", "Mismatch in table columns");
20  }
21  for (std::size_t i = 0; i < tabcols.size(); ++i) {
22  if (tabcols[i].name != fields[i].getFieldName()) {
23  throw cms::Exception("LogicError", "Mismatch in table columns");
24  }
25  fields[i].fill(tabcols[i].value);
26  }
27 }
28 
29 template <typename T, typename Col>
30 void SummaryTableOutputFields::fillVectorFields(const std::vector<Col> &tabcols,
32  if (tabcols.size() != fields.size()) {
33  throw cms::Exception("LogicError", "Mismatch in table columns");
34  }
35  for (std::size_t i = 0; i < tabcols.size(); ++i) {
36  if (tabcols[i].name != fields[i].getFieldName()) {
37  throw cms::Exception("LogicError", "Mismatch in table columns");
38  }
39  auto data = tabcols[i].values;
40  // TODO remove this awful hack when std::int64_t is supported
41  // -- turns std::vector<int64_t> into std::vector<uint64_t>
42  T casted_data(data.begin(), data.end());
43  fields[i].fill(casted_data);
44  }
45 }
46 
48  // TODO use std::int64_t when supported
49  m_intFields = makeFields<std::uint64_t>(tab.intCols(), model);
50  m_floatFields = makeFields<double>(tab.floatCols(), model);
51  m_floatWithNormFields = makeFields<double>(tab.floatWithNormCols(), model);
52  m_vintFields = makeFields<std::vector<std::uint64_t>>(tab.vintCols(), model);
53  m_vfloatFields = makeFields<std::vector<double>>(tab.vfloatCols(), model);
54  m_vfloatWithNormFields = makeFields<std::vector<double>>(tab.vfloatWithNormCols(), model);
55 }
56 
64 }
SummaryTableOutputFields()=default
std::vector< RNTupleFieldPtr< std::uint64_t > > m_intFields
const std::vector< VFloatColumn > & vfloatCols() const
std::vector< RNTupleFieldPtr< std::vector< double > > > m_vfloatWithNormFields
const std::vector< FloatWithNormColumn > & floatWithNormCols() const
const std::vector< IntColumn > & intCols() const
const std::vector< VFloatWithNormColumn > & vfloatWithNormCols() const
std::vector< RNTupleFieldPtr< std::vector< double > > > m_vfloatFields
std::vector< RNTupleFieldPtr< double > > m_floatWithNormFields
const std::vector< FloatColumn > & floatCols() const
std::vector< RNTupleFieldPtr< T > > makeFields(const std::vector< Col > &tabcols, RNTupleModel &model)
Definition: value.py:1
std::vector< RNTupleFieldPtr< double > > m_floatFields
std::vector< RNTupleFieldPtr< std::vector< std::uint64_t > > > m_vintFields
const std::vector< VIntColumn > & vintCols() const
static void fillVectorFields(const std::vector< Col > &tabcols, std::vector< RNTupleFieldPtr< T >> fields)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
col
Definition: cuy.py:1009
long double T
static void fillScalarFields(const std::vector< Col > &tabcols, std::vector< RNTupleFieldPtr< T >> fields)
void fill(const nanoaod::MergeableCounterTable &tab)