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 19 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 22 of file TableOutputFields.h.

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

22  {
23  m_flatTableName = table.columnName(i);
24  // case 1: field has a name (table may or may not have a name)
25  if (!table.columnName(i).empty()) {
26  m_field = RNTupleFieldPtr<T>(table.columnName(i), table.columnDoc(i), model);
27  return;
28  }
29  // case 2: field doesn't have a name: use the table name as the RNTuple field name
30  if (table.name().empty()) {
31  throw cms::Exception("LogicError", "Empty FlatTable name and field name");
32  }
33  m_field = RNTupleFieldPtr<T>(table.name(), table.doc(), model);
34  }
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 36 of file TableOutputFields.h.

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

36  {
37  int col_idx = table.columnIndex(m_flatTableName);
38  if (col_idx == -1) {
39  throw cms::Exception("LogicError", "Missing column in input for " + table.name() + "_" + m_flatTableName);
40  }
41  m_field.fill(table.columnData<T>(col_idx)[i]);
42  }
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 45 of file TableOutputFields.h.

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

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

◆ getFlatTableName()

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

Definition at line 56 of file TableOutputFields.h.

References FlatTableField< T >::m_flatTableName.

56 { 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