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

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 T , 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)
 
void updateBranches (const nanoaod::MergeableCounterTable &tab, TTree &tree)
 

Private Attributes

unsigned long m_fills
 
std::vector< NamedBranchPtrm_floatBranches
 
std::vector< NamedBranchPtrm_floatWithNormBranches
 
std::vector< NamedBranchPtrm_intBranches
 
edm::EDGetToken m_token
 
std::vector< NamedVectorBranchPtrm_vfloatBranches
 
std::vector< NamedVectorBranchPtrm_vfloatWithNormBranches
 
std::vector< NamedVectorBranchPtrm_vintBranches
 

Detailed Description

Definition at line 12 of file SummaryTableOutputBranches.h.

Constructor & Destructor Documentation

◆ SummaryTableOutputBranches()

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

Definition at line 14 of file SummaryTableOutputBranches.h.

References submitPVResolutionJobs::desc.

15  : m_token(token), m_fills(0) {
16  if (desc->className() != "nanoaod::MergeableCounterTable")
17  throw cms::Exception("Configuration", "NanoAODOutputModule can only write out MergableCounterTable objects");
18  }

Member Function Documentation

◆ fill()

void SummaryTableOutputBranches::fill ( const edm::OccurrenceForOutput iWhatever,
TTree &  tree 
)

Definition at line 88 of file SummaryTableOutputBranches.cc.

References fillScalarBranches(), fillVectorBranches(), nanoaod::MergeableCounterTable::floatCols(), nanoaod::MergeableCounterTable::floatWithNormCols(), edm::OccurrenceForOutput::getByToken(), patZpeak::handle, nanoaod::MergeableCounterTable::intCols(), m_fills, m_floatBranches, m_floatWithNormBranches, m_intBranches, m_token, m_vfloatBranches, m_vfloatWithNormBranches, m_vintBranches, updateBranches(), nanoaod::MergeableCounterTable::vfloatCols(), nanoaod::MergeableCounterTable::vfloatWithNormCols(), and nanoaod::MergeableCounterTable::vintCols().

88  {
90  iWhatever.getByToken(m_token, handle);
92 
93  updateBranches(tab, tree);
94 
101  m_fills++;
102 }
std::vector< NamedVectorBranchPtr > m_vfloatWithNormBranches
const std::vector< VFloatColumn > & vfloatCols() const
const std::vector< FloatWithNormColumn > & floatWithNormCols() const
const std::vector< IntColumn > & intCols() const
void fillVectorBranches(const std::vector< Col > &tabcols, std::vector< NamedVectorBranchPtr > &branches)
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
std::vector< NamedBranchPtr > m_floatWithNormBranches
std::vector< NamedVectorBranchPtr > m_vintBranches
void updateBranches(const nanoaod::MergeableCounterTable &tab, TTree &tree)
const std::vector< VFloatWithNormColumn > & vfloatWithNormCols() const
const std::vector< FloatColumn > & floatCols() const
void fillScalarBranches(const std::vector< Col > &tabcols, std::vector< NamedBranchPtr > &branches)
const std::vector< VIntColumn > & vintCols() const
std::vector< NamedVectorBranchPtr > m_vfloatBranches
std::vector< NamedBranchPtr > m_intBranches
Definition: tree.py:1
std::vector< NamedBranchPtr > m_floatBranches

◆ fillScalarBranches()

template<typename Col >
void SummaryTableOutputBranches::fillScalarBranches ( const std::vector< Col > &  tabcols,
std::vector< NamedBranchPtr > &  branches 
)
private

Definition at line 47 of file SummaryTableOutputBranches.cc.

References Exception, mps_fire::i, dqmiodumpmetadata::n, and Skims_PA_cff::name.

Referenced by fill().

48  {
49  if (tabcols.size() != branches.size())
50  throw cms::Exception("LogicError", "Mismatch in table columns");
51  for (unsigned int i = 0, n = tabcols.size(); i < n; ++i) {
52  if (tabcols[i].name != branches[i].name)
53  throw cms::Exception("LogicError", "Mismatch in table columns");
54  branches[i].branch->SetAddress(const_cast<typename Col::value_type *>(&tabcols[i].value));
55  }
56 }
Definition: value.py:1

◆ fillVectorBranches()

template<typename Col >
void SummaryTableOutputBranches::fillVectorBranches ( const std::vector< Col > &  tabcols,
std::vector< NamedVectorBranchPtr > &  branches 
)
private

Definition at line 59 of file SummaryTableOutputBranches.cc.

References Exception, mps_fire::i, dqmiodumpmetadata::n, Skims_PA_cff::name, and contentValuesCheck::values.

Referenced by fill().

60  {
61  if (tabcols.size() != branches.size())
62  throw cms::Exception("LogicError", "Mismatch in table columns");
63  for (unsigned int i = 0, n = tabcols.size(); i < n; ++i) {
64  if (tabcols[i].name != branches[i].name)
65  throw cms::Exception("LogicError", "Mismatch in table columns");
66  branches[i].count = tabcols[i].values.size();
67  branches[i].branch->SetAddress(const_cast<typename Col::element_type *>(&tabcols[i].values.front()));
68  }
69 }

◆ makeScalarBranches()

template<typename T , typename Col >
void SummaryTableOutputBranches::makeScalarBranches ( const std::vector< Col > &  tabcols,
TTree &  tree,
const std::string &  rootType,
std::vector< NamedBranchPtr > &  branches 
)
private

Definition at line 4 of file SummaryTableOutputBranches.cc.

References beamvalidation::br, cuy::col, mps_fire::i, m_fills, and x.

7  {
8  for (const auto &col : tabcols) {
9  if (std::find_if(branches.begin(), branches.end(), [&col](const NamedBranchPtr &x) {
10  return x.name == col.name;
11  }) == branches.end()) {
12  T backFillValue = 0;
13  auto *br = tree.Branch(col.name.c_str(), &backFillValue, (col.name + "/" + rootType).c_str());
14  br->SetTitle(col.doc.c_str());
15  for (unsigned long i = 0; i < m_fills; i++)
16  br->Fill();
17  branches.emplace_back(col.name, br);
18  }
19  }
20 }
col
Definition: cuy.py:1009
Definition: tree.py:1
long double T

◆ makeVectorBranches()

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 23 of file SummaryTableOutputBranches.cc.

References cuy::col, mps_fire::i, m_fills, and x.

Referenced by updateBranches().

26  {
27  for (const auto &col : tabcols) {
28  if (std::find_if(branches.begin(), branches.end(), [&col](const NamedBranchPtr &x) {
29  return x.name == col.name;
30  }) == branches.end()) {
31  int backFillValue = 0;
32  auto *cbr = tree.Branch(("n" + col.name).c_str(), &backFillValue, ("n" + col.name + "/I").c_str());
33  auto *vbr =
34  tree.Branch(col.name.c_str(), (void *)nullptr, (col.name + "[n" + col.name + "]/" + rootType).c_str());
35  cbr->SetTitle(("Number of entries in " + col.name).c_str());
36  vbr->SetTitle(col.doc.c_str());
37  for (unsigned long i = 0; i < m_fills; i++) {
38  cbr->Fill();
39  vbr->Fill();
40  }
41  branches.emplace_back(col.name, cbr, vbr);
42  }
43  }
44 }
col
Definition: cuy.py:1009
Definition: tree.py:1

◆ updateBranches()

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

Definition at line 71 of file SummaryTableOutputBranches.cc.

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

Referenced by fill().

71  {
72  makeScalarBranches<Long64_t>(tab.intCols(), tree, "L", m_intBranches);
73  makeScalarBranches<Double_t>(tab.floatCols(), tree, "D", m_floatBranches);
74  makeScalarBranches<Double_t>(tab.floatWithNormCols(), tree, "D", m_floatWithNormBranches);
78 
79  // now we go set the pointers for the counter branches
80  for (auto &vbp : m_vintBranches)
81  vbp.counterBranch->SetAddress(&vbp.count);
82  for (auto &vbp : m_vfloatBranches)
83  vbp.counterBranch->SetAddress(&vbp.count);
84  for (auto &vbp : m_vfloatWithNormBranches)
85  vbp.counterBranch->SetAddress(&vbp.count);
86 }
void makeVectorBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedVectorBranchPtr > &branches)
std::vector< NamedVectorBranchPtr > m_vfloatWithNormBranches
const std::vector< VFloatColumn > & vfloatCols() const
const std::vector< FloatWithNormColumn > & floatWithNormCols() const
const std::vector< IntColumn > & intCols() const
std::vector< NamedBranchPtr > m_floatWithNormBranches
std::vector< NamedVectorBranchPtr > m_vintBranches
const std::vector< VFloatWithNormColumn > & vfloatWithNormCols() const
const std::vector< FloatColumn > & floatCols() const
const std::vector< VIntColumn > & vintCols() const
std::vector< NamedVectorBranchPtr > m_vfloatBranches
std::vector< NamedBranchPtr > m_intBranches
std::vector< NamedBranchPtr > m_floatBranches

Member Data Documentation

◆ m_fills

unsigned long SummaryTableOutputBranches::m_fills
private

Definition at line 42 of file SummaryTableOutputBranches.h.

Referenced by fill(), makeScalarBranches(), and makeVectorBranches().

◆ m_floatBranches

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

Definition at line 30 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

◆ m_floatWithNormBranches

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

Definition at line 30 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

◆ m_intBranches

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

Definition at line 30 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

◆ m_token

edm::EDGetToken SummaryTableOutputBranches::m_token
private

Definition at line 23 of file SummaryTableOutputBranches.h.

Referenced by fill().

◆ m_vfloatBranches

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

Definition at line 40 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

◆ m_vfloatWithNormBranches

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

Definition at line 40 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

◆ m_vintBranches

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

Definition at line 40 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().