CMS 3D CMS Logo

BranchMapReader.h
Go to the documentation of this file.
1 #ifndef FWLite_BranchMapReader_h
2 #define FWLite_BranchMapReader_h
3 // -*- C++ -*-
4 //
5 // Package: FWLite
6 // Class : BranchMapReader
7 //
16 //
17 // Original Author: Dan Riley
18 // Created: Tue May 20 10:31:32 EDT 2008
19 //
20 
21 // system include files
22 #include <memory>
23 #include "TUUID.h"
24 
25 // user include files
29 
30 // forward declarations
31 class TFile;
32 class TTree;
33 class TBranch;
34 
35 namespace edm {
36  class ThinnedAssociationsHelper;
37 }
38 
39 namespace fwlite {
40  namespace internal {
41  class BMRStrategy {
42  public:
43  BMRStrategy(TFile* file, int fileVersion);
44  virtual ~BMRStrategy();
45 
46  virtual bool updateFile(TFile* file) = 0;
47  virtual bool updateEvent(Long_t eventEntry) = 0;
48  virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry) = 0;
49  virtual bool updateRun(Long_t runEntry) = 0;
50  virtual bool updateMap() = 0;
51  virtual edm::BranchID productToBranchID(const edm::ProductID& pid) = 0;
52  virtual const edm::BranchDescription& productToBranch(const edm::ProductID& pid) = 0;
53  virtual const edm::BranchDescription& branchIDToBranch(const edm::BranchID& bid) const = 0;
54  virtual const std::vector<edm::BranchDescription>& getBranchDescriptions() = 0;
55  virtual const edm::BranchListIndexes& branchListIndexes() const = 0;
56  virtual const edm::ThinnedAssociationsHelper& thinnedAssociationsHelper() const = 0;
57 
62  TUUID fileUUID_;
63  Long_t eventEntry_;
65  Long_t runEntry_;
67  };
68  } // namespace internal
69 
71  public:
72  BranchMapReader(TFile* file);
73  BranchMapReader() : strategy_(nullptr), fileVersion_(0) {}
74 
75  // ---------- const member functions ---------------------
76 
77  // ---------- static member functions --------------------
78 
79  // ---------- member functions ---------------------------
80  bool updateFile(TFile* file);
81  bool updateEvent(Long_t eventEntry);
82  bool updateLuminosityBlock(Long_t luminosityBlockEntry);
83  bool updateRun(Long_t runEntry);
84  edm::BranchID productToBranchID(const edm::ProductID& pid) { return strategy_->productToBranchID(pid); }
85  const edm::BranchDescription& productToBranch(const edm::ProductID& pid);
87  return strategy_->branchIDToBranch(bid);
88  }
89  int getFileVersion(TFile* file);
90  int getFileVersion() const { return fileVersion_; }
91 
92  TFile const* getFile() const { return strategy_->currentFile_; }
93  TFile* getFile() { return strategy_->currentFile_; }
94  TTree const* getEventTree() const { return strategy_->eventTree_; }
95  TTree* getEventTree() { return strategy_->eventTree_; }
96  TTree const* getLuminosityBlockTree() const { return strategy_->luminosityBlockTree_; }
97  TTree* getLuminosityBlockTree() { return strategy_->luminosityBlockTree_; }
98  TTree const* getRunTree() const { return strategy_->runTree_; }
99  TTree* getRunTree() { return strategy_->runTree_; }
100  TUUID getFileUUID() const { return strategy_->fileUUID_; }
101  Long_t getEventEntry() const { return strategy_->eventEntry_; }
102  Long_t getLuminosityBlockEntry() const { return strategy_->luminosityBlockEntry_; }
103  Long_t getRunEntry() const { return strategy_->runEntry_; }
104  const std::vector<edm::BranchDescription>& getBranchDescriptions();
106  strategy_->updateMap();
107  return strategy_->branchListIndexes();
108  }
110  return strategy_->thinnedAssociationsHelper();
111  }
112 
113  // ---------- member data --------------------------------
114  private:
115  std::unique_ptr<internal::BMRStrategy> newStrategy(TFile* file, int fileVersion);
116  std::unique_ptr<internal::BMRStrategy> strategy_; // Contains caches, so we do not propagate_const
118  };
119 } // namespace fwlite
120 
121 #endif
edm::propagate_const< TFile * > currentFile_
std::unique_ptr< internal::BMRStrategy > strategy_
TUUID getFileUUID() const
TFile const * getFile() const
#define nullptr
Long_t getLuminosityBlockEntry() const
const edm::BranchDescription & branchIDToBranch(const edm::BranchID &bid) const
edm::propagate_const< TTree * > eventTree_
Long_t getRunEntry() const
Long_t getEventEntry() const
TTree const * getLuminosityBlockTree() const
std::vector< BranchListIndex > BranchListIndexes
edm::propagate_const< TTree * > luminosityBlockTree_
TTree const * getEventTree() const
const edm::ThinnedAssociationsHelper & thinnedAssociationsHelper() const
TTree const * getRunTree() const
edm::propagate_const< TTree * > runTree_
HLT enums.
edm::BranchID productToBranchID(const edm::ProductID &pid)
const edm::BranchListIndexes & branchListIndexes() const