CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ( const edm::BranchDescription desc,
const edm::EDGetToken token 
)
inline

Definition at line 14 of file SummaryTableOutputBranches.h.

References edm::BranchDescription::className().

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  }
std::string const & className() const

Member Function Documentation

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< FloatWithNormColumn > & floatWithNormCols() const
const std::vector< VIntColumn > & vintCols() const
void fillVectorBranches(const std::vector< Col > &tabcols, std::vector< NamedVectorBranchPtr > &branches)
std::vector< NamedBranchPtr > m_floatWithNormBranches
std::vector< NamedVectorBranchPtr > m_vintBranches
const std::vector< IntColumn > & intCols() const
void updateBranches(const nanoaod::MergeableCounterTable &tab, TTree &tree)
const std::vector< FloatColumn > & floatCols() const
tuple handle
Definition: patZpeak.py:23
void fillScalarBranches(const std::vector< Col > &tabcols, std::vector< NamedBranchPtr > &branches)
const std::vector< VFloatWithNormColumn > & vfloatWithNormCols() const
std::vector< NamedVectorBranchPtr > m_vfloatBranches
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
const std::vector< VFloatColumn > & vfloatCols() const
std::vector< NamedBranchPtr > m_intBranches
std::vector< NamedBranchPtr > m_floatBranches
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, mergeVDriftHistosByStation::name, and relativeConstraints::value.

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 }
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, mergeVDriftHistosByStation::name, and makeHLTPrescaleTable::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 }
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 }
int col
Definition: cuy.py:1009
long double T
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  unsigned 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 }
int col
Definition: cuy.py:1009
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(), MainPageGenerator::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< FloatWithNormColumn > & floatWithNormCols() const
const std::vector< VIntColumn > & vintCols() const
std::vector< NamedBranchPtr > m_floatWithNormBranches
std::vector< NamedVectorBranchPtr > m_vintBranches
const std::vector< IntColumn > & intCols() const
const std::vector< FloatColumn > & floatCols() const
const std::vector< VFloatWithNormColumn > & vfloatWithNormCols() const
std::vector< NamedVectorBranchPtr > m_vfloatBranches
const std::vector< VFloatColumn > & vfloatCols() const
std::vector< NamedBranchPtr > m_intBranches
std::vector< NamedBranchPtr > m_floatBranches

Member Data Documentation

unsigned long SummaryTableOutputBranches::m_fills
private

Definition at line 42 of file SummaryTableOutputBranches.h.

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

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

Definition at line 30 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

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

Definition at line 30 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

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

Definition at line 30 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

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 40 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

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

Definition at line 40 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().

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

Definition at line 40 of file SummaryTableOutputBranches.h.

Referenced by fill(), and updateBranches().