CMS 3D CMS Logo

Table Class Reference

#include "Table.h"

Detailed Description

Description: A Table which is a 'structure of arrays'

Usage: A Table provides a 'structure of arrays' using a spreadsheet metaphor. The template arguments of a Table should be edm::soa::Column<> types which declare the type of the column and a label.

constexpr char kEta[] = "eta";
constexpr char kPhi[] = "phi";
using SphereTable = edm::soa::Table<Eta,Phi>;

The same declaration of a column should be shared by different tables in order to allow the functions to be reused across tables. [See TableView]

Accessing data within a Table is done by specifying the column and row to be used. The column is identified by the edm::soa::Column<> type and the row by an integer.

SphereTable sphereTable{...};
...
auto eta1 = sphereTable.get<Eta>(1);

One can iterate over all rows of a Table and get the values of interest

SphereTable sphereTable{...};
...
for(auto const& row: sphereTable) {
std::cout<<row.get<Eta>()<<std::endl;
}
If only some of the columns are of interest, the optimizer of the compiler
is very good at removing code associated with non-used columns and providing
a highly optimized access to just the data of interest.
On can also explicitly iterate over a single column of interest
\code
SphereTable sphereTable{...};
...
for(auto eta: sphereTable.column<Eta>()) {
std::cout<<eta<<std::endl;
}
Usually the optimizer on the compiler is able to make iteration over the entire
row and iterating over just one column compile down to exactly the same machine
instructions.
A Table can be constructed either by
1) passing as many containers as their are columns
\code
std::array<double, 4> eta = {...};
std::array<double, 4> phi = {...};
SphereTable sphereTable{eta,phi};

2) passing a single container of objects where the objects hold the value of interests and where appropriate 'value_for_column' functions are defined [See ColumnFillers.h]

class Vector {
...
double eta() const;
double phi() const;
...
};
double value_for_column(Vector const& iV, Eta*) { return iV.eta(); }
double value_for_column(Vector const& iV, Phi*) { return iV.phi(); }
...
std::vector<Vector> vectors{...};
...
SphereTable sphereTable{ vectors };

Functions which operate over Tables should not take Tables are arguments. Instead, they should take an edm::soa::TableView<>. This will allow the function to operate on any Table that uses the edm::soa::Column<> type needed by the function.

SphereTable sphericalAngles(edm::soa::TableView<X,Y,Z>);

New Table declarations can be created based on existing Table declarations. E.g. say you want a new Table based on an existing Table but with an additional column.

using ATable = edm::soa::Table<...>;
using MyLabel = edm::soa::Column<...>;
using MyATable = AddColumns_t<ATable, MyLabel>;

It is also possible to declare a new Table by removing columns from an existing declaration

using MyBTable = RemoveColumn_t<BTable, Phi>; //Phi is a previously defined Column
SiPixelPI::one
Definition: SiPixelPayloadInspectorHelper.h:39
gather_cfg.cout
cout
Definition: gather_cfg.py:144
to
Vector
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
Table
down
Definition: BitonicSort.h:7
PVValHelper::eta
Definition: PVValidationHelpers.h:69
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9607
a
double a
Definition: hdecay.h:119
edm::soa::value_for_column
col::Eta ::type value_for_column(Object const &x, col::Eta *)
Definition: KinematicColumns.h:24
trackerHitRTTI::single
Definition: trackerHitRTTI.h:10
JetComb::kPhi
Definition: TtSemiLepJetComb.h:17
TagProbeFitTreeAnalyzer_cfi.passing
passing
Definition: TagProbeFitTreeAnalyzer_cfi.py:25
reco::modules::make
S make(const edm::ParameterSet &cfg)
Definition: ParameterAdapter.h:21
DDAxes::phi
timingPdfMaker.can
can
Definition: timingPdfMaker.py:311
edm::soa::TableView
Definition: TableView.h:49
alcaDQMUpload.encode
def encode(args, files)
Definition: alcaDQMUpload.py:32
mps_check.columns
columns
Definition: mps_check.py:244
edm::soa::Table
Definition: Table.h:137
edm::soa::Column
Definition: Column.h:65
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
JetComb::kEta
Definition: TtSemiLepJetComb.h:17
cms::cuda::be
int be
Definition: HistoContainer.h:126
align_cfg.iteration
iteration
Definition: align_cfg.py:5