CMS 3D CMS Logo

SummaryTableOutputBranches.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_NanoAOD_SummaryTableOutputBranches_h
2 #define PhysicsTools_NanoAOD_SummaryTableOutputBranches_h
3 
4 #include <string>
5 #include <vector>
6 #include <TTree.h>
11 
13 public:
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  }
19 
20  void fill(const edm::OccurrenceForOutput &iWhatever, TTree &tree);
21 
22 private:
24 
25  struct NamedBranchPtr {
27  TBranch *branch;
28  NamedBranchPtr(const std::string &aname, TBranch *branchptr = nullptr) : name(aname), branch(branchptr) {}
29  };
30  std::vector<NamedBranchPtr> m_intBranches, m_floatBranches, m_floatWithNormBranches;
31 
33  UInt_t count;
34  TBranch *counterBranch;
36  TBranch *counterBranchptr = nullptr,
37  TBranch *valueBranchptr = nullptr)
38  : NamedBranchPtr(aname, valueBranchptr), counterBranch(counterBranchptr) {}
39  };
40  std::vector<NamedVectorBranchPtr> m_vintBranches, m_vfloatBranches, m_vfloatWithNormBranches;
41 
42  unsigned long m_fills;
43 
44  void updateBranches(const nanoaod::MergeableCounterTable &tab, TTree &tree);
45 
46  template <typename T, typename Col>
47  void makeScalarBranches(const std::vector<Col> &tabcols,
48  TTree &tree,
49  const std::string &rootType,
50  std::vector<NamedBranchPtr> &branches);
51  template <typename Col>
52  void makeVectorBranches(const std::vector<Col> &tabcols,
53  TTree &tree,
54  const std::string &rootType,
55  std::vector<NamedVectorBranchPtr> &branches);
56 
57  template <typename Col>
58  void fillScalarBranches(const std::vector<Col> &tabcols, std::vector<NamedBranchPtr> &branches);
59  template <typename Col>
60  void fillVectorBranches(const std::vector<Col> &tabcols, std::vector<NamedVectorBranchPtr> &branches);
61 };
62 
63 #endif
void makeVectorBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedVectorBranchPtr > &branches)
std::vector< NamedVectorBranchPtr > m_vfloatWithNormBranches
void fillVectorBranches(const std::vector< Col > &tabcols, std::vector< NamedVectorBranchPtr > &branches)
std::vector< NamedBranchPtr > m_floatWithNormBranches
std::vector< NamedVectorBranchPtr > m_vintBranches
void updateBranches(const nanoaod::MergeableCounterTable &tab, TTree &tree)
void makeScalarBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedBranchPtr > &branches)
void fillScalarBranches(const std::vector< Col > &tabcols, std::vector< NamedBranchPtr > &branches)
std::vector< NamedVectorBranchPtr > m_vfloatBranches
SummaryTableOutputBranches(const edm::BranchDescription *desc, const edm::EDGetToken &token)
std::vector< NamedBranchPtr > m_intBranches
Definition: tree.py:1
std::vector< NamedBranchPtr > m_floatBranches
void fill(const edm::OccurrenceForOutput &iWhatever, TTree &tree)
NamedVectorBranchPtr(const std::string &aname, TBranch *counterBranchptr=nullptr, TBranch *valueBranchptr=nullptr)
NamedBranchPtr(const std::string &aname, TBranch *branchptr=nullptr)