CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
FlatTableField< T > Class Template Reference

#include <TableOutputFields.h>

Public Member Functions

void fill (const nanoaod::FlatTable &table, std::size_t i)
 
void fillVectored (const nanoaod::FlatTable &table)
 
 FlatTableField ()=default
 
 FlatTableField (const nanoaod::FlatTable &table, std::size_t i, RNTupleModel &model)
 
const std::string & getFlatTableName () const
 

Private Attributes

RNTupleFieldPtr< Tm_field
 
std::string m_flatTableName
 

Detailed Description

template<typename T>
class FlatTableField< T >

Definition at line 24 of file TableOutputFields.h.

Constructor & Destructor Documentation

◆ FlatTableField() [1/2]

template<typename T >
FlatTableField< T >::FlatTableField ( )
default

◆ FlatTableField() [2/2]

template<typename T >
FlatTableField< T >::FlatTableField ( const nanoaod::FlatTable table,
std::size_t  i,
RNTupleModel &  model 
)
inline

Definition at line 27 of file TableOutputFields.h.

References Exception, mps_fire::i, FlatTableField< T >::m_field, FlatTableField< T >::m_flatTableName, isotrackApplyRegressor::model, and TableParser::table.

27  {
28  m_flatTableName = table.columnName(i);
29  // case 1: field has a name (table may or may not have a name)
30  if (!table.columnName(i).empty()) {
31  m_field = RNTupleFieldPtr<T>(table.columnName(i), table.columnDoc(i), model);
32  return;
33  }
34  // case 2: field doesn't have a name: use the table name as the RNTuple field name
35  if (table.name().empty()) {
36  throw cms::Exception("LogicError", "Empty FlatTable name and field name");
37  }
38  m_field = RNTupleFieldPtr<T>(table.name(), table.doc(), model);
39  }
RNTupleFieldPtr< T > m_field
std::string m_flatTableName

Member Function Documentation

◆ fill()

template<typename T >
void FlatTableField< T >::fill ( const nanoaod::FlatTable table,
std::size_t  i 
)
inline

Definition at line 41 of file TableOutputFields.h.

References Exception, mps_fire::i, FlatTableField< T >::m_field, FlatTableField< T >::m_flatTableName, and TableParser::table.

41  {
42  int col_idx = table.columnIndex(m_flatTableName);
43  if (col_idx == -1) {
44  throw cms::Exception("LogicError", "Missing column in input for " + table.name() + "_" + m_flatTableName);
45  }
46  m_field.fill(table.columnData<T>(col_idx)[i]);
47  }
RNTupleFieldPtr< T > m_field
std::string m_flatTableName
long double T

◆ fillVectored()

template<typename T >
void FlatTableField< T >::fillVectored ( const nanoaod::FlatTable table)
inline

Definition at line 50 of file TableOutputFields.h.

References visDQMUpload::buf, Exception, mps_fire::i, FlatTableField< T >::m_field, FlatTableField< T >::m_flatTableName, and TableParser::table.

50  {
51  int col_idx = table.columnIndex(m_flatTableName);
52  if (col_idx == -1) {
53  throw cms::Exception("LogicError", "Missing column in input for " + table.name() + "_" + m_flatTableName);
54  }
55  std::vector<typename T::value_type> buf(table.size());
56  for (std::size_t i = 0; i < table.size(); i++) {
57  buf[i] = table.columnData<typename T::value_type>(col_idx)[i];
58  }
59  m_field.fill(buf);
60  }
RNTupleFieldPtr< T > m_field
std::string m_flatTableName

◆ getFlatTableName()

template<typename T >
const std::string& FlatTableField< T >::getFlatTableName ( ) const
inline

Definition at line 61 of file TableOutputFields.h.

References FlatTableField< T >::m_flatTableName.

61 { return m_flatTableName; }
std::string m_flatTableName

Member Data Documentation

◆ m_field

template<typename T >
RNTupleFieldPtr<T> FlatTableField< T >::m_field
private

◆ m_flatTableName

template<typename T >
std::string FlatTableField< T >::m_flatTableName
private