Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:16

0001 
0002 #include "DataFormats/Provenance/interface/Provenance.h"
0003 #include "FWCore/Utilities/interface/EDGetToken.h"
0004 #include "FWCore/Utilities/interface/InputTag.h"
0005 #include "FWCore/Utilities/interface/TypeID.h"
0006 
0007 #include <TBranch.h>
0008 
0009 #include <string>
0010 #include <vector>
0011 
0012 class ProductInfo {
0013 public:
0014   ProductInfo(const edm::Provenance &prov, TBranch &branch, edm::EDGetToken const &token);
0015 
0016   Long64_t size() const { return m_size; }
0017   const edm::InputTag &tag() const { return m_tag; }
0018   const edm::TypeID &type() const { return m_type; }
0019   const edm::EDGetToken &token() const { return m_token; }
0020   static bool sort(const ProductInfo &x, const ProductInfo &y);
0021 
0022 private:
0023   static void addBranchSizes(TBranch &branch, Long64_t &size);
0024 
0025   edm::InputTag m_tag;
0026   edm::TypeID m_type;
0027   edm::EDGetToken m_token;
0028   Long64_t m_size;
0029 };
0030 
0031 ProductInfo::ProductInfo(const edm::Provenance &prov, TBranch &branch, edm::EDGetToken const &token)
0032     : m_tag(prov.moduleLabel(), prov.productInstanceName(), prov.processName()),
0033       m_type(prov.branchDescription().unwrappedTypeID()),
0034       m_token(token),
0035       m_size(0) {
0036   addBranchSizes(branch, m_size);
0037 }
0038 
0039 void ProductInfo::addBranchSizes(TBranch &branch, Long64_t &size) {
0040   size += branch.GetTotalSize();  // Includes size of branch metadata
0041   // Now recurse through any subbranches.
0042   Long64_t nB = branch.GetListOfBranches()->GetEntries();
0043   for (Long64_t i = 0; i < nB; ++i) {
0044     TBranch *btemp = (TBranch *)branch.GetListOfBranches()->At(i);
0045     if (btemp != nullptr) {
0046       addBranchSizes(*btemp, size);
0047     }
0048   }
0049 }
0050 
0051 bool ProductInfo::sort(ProductInfo const &x, ProductInfo const &y) { return x.size() < y.size(); }
0052 
0053 typedef std::vector<ProductInfo> ProductInfos;