CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SummaryTableOutputBranches Class Reference

#include <SummaryTableOutputBranches.h>

Classes

struct  NamedBranchPtr
 
struct  NamedVectorBranchPtr
 

Public Member Functions

void fill (const edm::OccurrenceForOutput &iWhatever, TTree &tree)
 
 SummaryTableOutputBranches (const edm::BranchDescription *desc, const edm::EDGetToken &token)
 

Private Member Functions

void defineBranchesFromFirstEvent (const nanoaod::MergeableCounterTable &tab, TTree &tree)
 
template<typename Col >
void fillScalarBranches (const std::vector< Col > &tabcols, std::vector< NamedBranchPtr > &branches)
 
template<typename Col >
void fillVectorBranches (const std::vector< Col > &tabcols, std::vector< NamedVectorBranchPtr > &branches)
 
template<typename Col >
void makeScalarBranches (const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedBranchPtr > &branches)
 
template<typename Col >
void makeVectorBranches (const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedVectorBranchPtr > &branches)
 

Private Attributes

bool m_branchesBooked
 
std::vector< NamedBranchPtrm_floatBranches
 
std::vector< NamedBranchPtrm_intBranches
 
edm::EDGetToken m_token
 
std::vector< NamedVectorBranchPtrm_vfloatBranches
 
std::vector< NamedVectorBranchPtrm_vintBranches
 

Detailed Description

Definition at line 12 of file SummaryTableOutputBranches.h.

Constructor & Destructor Documentation

SummaryTableOutputBranches::SummaryTableOutputBranches ( const edm::BranchDescription desc,
const edm::EDGetToken token 
)
inline

Definition at line 14 of file SummaryTableOutputBranches.h.

References edm::BranchDescription::className(), and fill().

14  :
15  m_token(token), m_branchesBooked(false)
16  {
17  if (desc->className() != "nanoaod::MergeableCounterTable") throw cms::Exception("Configuration", "NanoAODOutputModule can only write out MergableCounterTable objects");
18  }
std::string const & className() const

Member Function Documentation

void SummaryTableOutputBranches::defineBranchesFromFirstEvent ( const nanoaod::MergeableCounterTable tab,
TTree &  tree 
)
private

Definition at line 49 of file SummaryTableOutputBranches.cc.

References nanoaod::MergeableCounterTable::floatCols(), nanoaod::MergeableCounterTable::intCols(), m_floatBranches, m_intBranches, m_vfloatBranches, m_vintBranches, makeScalarBranches(), makeVectorBranches(), compare::tree, nanoaod::MergeableCounterTable::vfloatCols(), and nanoaod::MergeableCounterTable::vintCols().

Referenced by fill().

50 {
55 
56  // now we go set the pointers for the counter branches
57  for (auto & vbp : m_vintBranches) vbp.counterBranch->SetAddress( & vbp.count );
58  for (auto & vbp : m_vfloatBranches) vbp.counterBranch->SetAddress( & vbp.count );
59 }
void makeVectorBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedVectorBranchPtr > &branches)
const std::vector< VIntColumn > & vintCols() const
std::vector< NamedVectorBranchPtr > m_vintBranches
const std::vector< IntColumn > & intCols() const
void makeScalarBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedBranchPtr > &branches)
const std::vector< FloatColumn > & floatCols() const
std::vector< NamedVectorBranchPtr > m_vfloatBranches
const std::vector< VFloatColumn > & vfloatCols() const
std::vector< NamedBranchPtr > m_intBranches
std::vector< NamedBranchPtr > m_floatBranches
void SummaryTableOutputBranches::fill ( const edm::OccurrenceForOutput iWhatever,
TTree &  tree 
)

Definition at line 62 of file SummaryTableOutputBranches.cc.

References defineBranchesFromFirstEvent(), fillScalarBranches(), fillVectorBranches(), nanoaod::MergeableCounterTable::floatCols(), edm::OccurrenceForOutput::getByToken(), cmsBatch::handle, nanoaod::MergeableCounterTable::intCols(), m_branchesBooked, m_floatBranches, m_intBranches, m_token, m_vfloatBranches, m_vintBranches, nanoaod::MergeableCounterTable::vfloatCols(), and nanoaod::MergeableCounterTable::vintCols().

Referenced by SummaryTableOutputBranches().

63 {
65  iWhatever.getByToken(m_token, handle);
67 
68  if(!m_branchesBooked) {
70  m_branchesBooked=true;
71  }
76 }
const std::vector< VIntColumn > & vintCols() const
void fillVectorBranches(const std::vector< Col > &tabcols, std::vector< NamedVectorBranchPtr > &branches)
std::vector< NamedVectorBranchPtr > m_vintBranches
const std::vector< IntColumn > & intCols() const
const std::vector< FloatColumn > & floatCols() const
bool getByToken(EDGetToken token, TypeID const &typeID, BasicHandle &result) const
void defineBranchesFromFirstEvent(const nanoaod::MergeableCounterTable &tab, TTree &tree)
void fillScalarBranches(const std::vector< Col > &tabcols, std::vector< NamedBranchPtr > &branches)
std::vector< NamedVectorBranchPtr > m_vfloatBranches
const std::vector< VFloatColumn > & vfloatCols() const
std::vector< NamedBranchPtr > m_intBranches
Definition: tree.py:1
std::vector< NamedBranchPtr > m_floatBranches
template<typename Col >
void SummaryTableOutputBranches::fillScalarBranches ( const std::vector< Col > &  tabcols,
std::vector< NamedBranchPtr > &  branches 
)
private

Definition at line 27 of file SummaryTableOutputBranches.cc.

References Exception, mps_fire::i, gen::n, and dataset::name.

Referenced by fill().

27  {
28  if (tabcols.size() != branches.size()) throw cms::Exception("LogicError", "Mismatch in table columns");
29  for (unsigned int i = 0, n = tabcols.size(); i < n; ++i) {
30  if (tabcols[i].name != branches[i].name) throw cms::Exception("LogicError", "Mismatch in table columns");
31  branches[i].branch->SetAddress( const_cast<typename Col::value_type *>(& tabcols[i].value) );
32  }
33 }
Definition: value.py:1
template<typename Col >
void SummaryTableOutputBranches::fillVectorBranches ( const std::vector< Col > &  tabcols,
std::vector< NamedVectorBranchPtr > &  branches 
)
private

Definition at line 37 of file SummaryTableOutputBranches.cc.

References Exception, mps_fire::i, gen::n, dataset::name, and MuonErrorMatrixValues_cff::values.

Referenced by fill().

37  {
38  if (tabcols.size() != branches.size()) throw cms::Exception("LogicError", "Mismatch in table columns");
39  for (unsigned int i = 0, n = tabcols.size(); i < n; ++i) {
40  if (tabcols[i].name != branches[i].name) throw cms::Exception("LogicError", "Mismatch in table columns");
41  branches[i].count = tabcols[i].values.size();
42  branches[i].branch->SetAddress( const_cast<typename Col::element_type *>(& tabcols[i].values.front()) );
43  }
44 }
template<typename Col >
void SummaryTableOutputBranches::makeScalarBranches ( const std::vector< Col > &  tabcols,
TTree &  tree,
const std::string &  rootType,
std::vector< NamedBranchPtr > &  branches 
)
private

Definition at line 5 of file SummaryTableOutputBranches.cc.

References beamvalidation::br, and cuy::col.

Referenced by defineBranchesFromFirstEvent().

5  {
6  for (const auto & col : tabcols) {
7  auto * br = tree.Branch(col.name.c_str(), (void*)nullptr, (col.name+"/"+rootType).c_str());
8  br->SetTitle(col.doc.c_str());
9  branches.emplace_back(col.name, br);
10  }
11 }
col
Definition: cuy.py:1008
Definition: tree.py:1
template<typename Col >
void SummaryTableOutputBranches::makeVectorBranches ( const std::vector< Col > &  tabcols,
TTree &  tree,
const std::string &  rootType,
std::vector< NamedVectorBranchPtr > &  branches 
)
private

Definition at line 15 of file SummaryTableOutputBranches.cc.

References cuy::col.

Referenced by defineBranchesFromFirstEvent().

15  {
16  for (const auto & col : tabcols) {
17  auto * cbr = tree.Branch(("n"+col.name).c_str(), (void*)nullptr, ("n"+col.name+"/i").c_str());
18  auto * vbr = tree.Branch(col.name.c_str(), (void*)nullptr, (col.name+"[n"+col.name+"]/"+rootType).c_str());
19  cbr->SetTitle(("Number of entries in "+col.name).c_str());
20  vbr->SetTitle(col.doc.c_str());
21  branches.emplace_back(col.name, cbr, vbr);
22  }
23 }
col
Definition: cuy.py:1008
Definition: tree.py:1

Member Data Documentation

bool SummaryTableOutputBranches::m_branchesBooked
private

Definition at line 41 of file SummaryTableOutputBranches.h.

Referenced by fill().

std::vector<NamedBranchPtr> SummaryTableOutputBranches::m_floatBranches
private

Definition at line 31 of file SummaryTableOutputBranches.h.

Referenced by defineBranchesFromFirstEvent(), and fill().

std::vector<NamedBranchPtr> SummaryTableOutputBranches::m_intBranches
private

Definition at line 31 of file SummaryTableOutputBranches.h.

Referenced by defineBranchesFromFirstEvent(), and fill().

edm::EDGetToken SummaryTableOutputBranches::m_token
private

Definition at line 23 of file SummaryTableOutputBranches.h.

Referenced by fill().

std::vector<NamedVectorBranchPtr> SummaryTableOutputBranches::m_vfloatBranches
private

Definition at line 39 of file SummaryTableOutputBranches.h.

Referenced by defineBranchesFromFirstEvent(), and fill().

std::vector<NamedVectorBranchPtr> SummaryTableOutputBranches::m_vintBranches
private

Definition at line 39 of file SummaryTableOutputBranches.h.

Referenced by defineBranchesFromFirstEvent(), and fill().