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:
16  {
17  if (desc->className() != "nanoaod::MergeableCounterTable") 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) :
29  name(aname), branch(branchptr) {}
30  };
31  std::vector<NamedBranchPtr> m_intBranches, m_floatBranches;
32 
34  UInt_t count;
35  TBranch * counterBranch;
36  NamedVectorBranchPtr(const std::string & aname, TBranch *counterBranchptr = nullptr, TBranch *valueBranchptr = nullptr) :
37  NamedBranchPtr(aname,valueBranchptr), counterBranch(counterBranchptr) {}
38  };
39  std::vector<NamedVectorBranchPtr> m_vintBranches, m_vfloatBranches;
40 
42 
43  void defineBranchesFromFirstEvent(const nanoaod::MergeableCounterTable & tab, TTree & tree) ;
44 
45  template<typename Col> void makeScalarBranches(const std::vector<Col> & tabcols, TTree & tree, const std::string & rootType, std::vector<NamedBranchPtr> & branches);
46  template<typename Col> void makeVectorBranches(const std::vector<Col> & tabcols, TTree & tree, const std::string & rootType, std::vector<NamedVectorBranchPtr> & branches );
47 
48  template<typename Col> void fillScalarBranches(const std::vector<Col> & tabcols, std::vector<NamedBranchPtr> & branches);
49  template<typename Col> void fillVectorBranches(const std::vector<Col> & tabcols, std::vector<NamedVectorBranchPtr> & branches );
50 };
51 
52 #endif
53 
void makeVectorBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedVectorBranchPtr > &branches)
NamedVectorBranchPtr(const std::string &aname, TBranch *counterBranchptr=0, TBranch *valueBranchptr=0)
void fillVectorBranches(const std::vector< Col > &tabcols, std::vector< NamedVectorBranchPtr > &branches)
std::vector< NamedVectorBranchPtr > m_vintBranches
void makeScalarBranches(const std::vector< Col > &tabcols, TTree &tree, const std::string &rootType, std::vector< NamedBranchPtr > &branches)
std::string const & className() const
void defineBranchesFromFirstEvent(const nanoaod::MergeableCounterTable &tab, TTree &tree)
NamedBranchPtr(const std::string &aname, TBranch *branchptr=0)
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)