CMS 3D CMS Logo

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

Definition at line 14 of file SummaryTableOutputBranches.h.

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  }

References submitPVResolutionJobs::desc.

Member Function Documentation

◆ fill()

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

◆ 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.

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 }

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

Referenced by fill().

◆ 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.

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 }

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

Referenced by fill().

◆ 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.

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 }

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

◆ 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.

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 }

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

Referenced by updateBranches().

◆ updateBranches()

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

Definition at line 71 of file SummaryTableOutputBranches.cc.

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 }

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().

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().

mps_fire.i
i
Definition: mps_fire.py:428
nanoaod::MergeableCounterTable::intCols
const std::vector< IntColumn > & intCols() const
Definition: MergeableCounterTable.h:109
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
nanoaod::MergeableCounterTable::vfloatWithNormCols
const std::vector< VFloatWithNormColumn > & vfloatWithNormCols() const
Definition: MergeableCounterTable.h:108
patZpeak.handle
handle
Definition: patZpeak.py:23
tree
Definition: tree.py:1
cuy.col
col
Definition: cuy.py:1009
SummaryTableOutputBranches::fillVectorBranches
void fillVectorBranches(const std::vector< Col > &tabcols, std::vector< NamedVectorBranchPtr > &branches)
Definition: SummaryTableOutputBranches.cc:59
SummaryTableOutputBranches::m_floatWithNormBranches
std::vector< NamedBranchPtr > m_floatWithNormBranches
Definition: SummaryTableOutputBranches.h:30
DDAxes::x
SummaryTableOutputBranches::m_vintBranches
std::vector< NamedVectorBranchPtr > m_vintBranches
Definition: SummaryTableOutputBranches.h:40
edm::Handle
Definition: AssociativeIterator.h:50
SummaryTableOutputBranches::m_fills
unsigned long m_fills
Definition: SummaryTableOutputBranches.h:42
nanoaod::MergeableCounterTable::vintCols
const std::vector< VIntColumn > & vintCols() const
Definition: MergeableCounterTable.h:110
edm::OccurrenceForOutput::getByToken
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
Definition: OccurrenceForOutput.cc:44
SummaryTableOutputBranches::updateBranches
void updateBranches(const nanoaod::MergeableCounterTable &tab, TTree &tree)
Definition: SummaryTableOutputBranches.cc:71
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
nanoaod::MergeableCounterTable
Definition: MergeableCounterTable.h:11
SummaryTableOutputBranches::m_token
edm::EDGetToken m_token
Definition: SummaryTableOutputBranches.h:23
SummaryTableOutputBranches::m_floatBranches
std::vector< NamedBranchPtr > m_floatBranches
Definition: SummaryTableOutputBranches.h:30
MainPageGenerator.tree
tree
Definition: MainPageGenerator.py:264
nanoaod::MergeableCounterTable::floatWithNormCols
const std::vector< FloatWithNormColumn > & floatWithNormCols() const
Definition: MergeableCounterTable.h:107
beamvalidation.br
br
Definition: beamvalidation.py:397
value
Definition: value.py:1
nanoaod::MergeableCounterTable::floatCols
const std::vector< FloatColumn > & floatCols() const
Definition: MergeableCounterTable.h:105
SummaryTableOutputBranches::fillScalarBranches
void fillScalarBranches(const std::vector< Col > &tabcols, std::vector< NamedBranchPtr > &branches)
Definition: SummaryTableOutputBranches.cc:47
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
SummaryTableOutputBranches::m_vfloatBranches
std::vector< NamedVectorBranchPtr > m_vfloatBranches
Definition: SummaryTableOutputBranches.h:40
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
cms::Exception
Definition: Exception.h:70
nanoaod::MergeableCounterTable::vfloatCols
const std::vector< VFloatColumn > & vfloatCols() const
Definition: MergeableCounterTable.h:106
SummaryTableOutputBranches::m_intBranches
std::vector< NamedBranchPtr > m_intBranches
Definition: SummaryTableOutputBranches.h:30
SummaryTableOutputBranches::m_vfloatWithNormBranches
std::vector< NamedVectorBranchPtr > m_vfloatWithNormBranches
Definition: SummaryTableOutputBranches.h:40
SummaryTableOutputBranches::makeVectorBranches
void makeVectorBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedVectorBranchPtr > &branches)
Definition: SummaryTableOutputBranches.cc:23
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316