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  }
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);
86  const edm::BranchDescription& branchIDToBranch(const edm::BranchID& bid) const { return strategy_->branchIDToBranch(bid); }
87  int getFileVersion(TFile* file);
88  int getFileVersion() const { return fileVersion_;}
89 
90  TFile const* getFile() const { return strategy_->currentFile_; }
91  TFile* getFile() { return strategy_->currentFile_; }
92  TTree const* getEventTree() const { return strategy_->eventTree_; }
93  TTree* getEventTree() { return strategy_->eventTree_; }
94  TTree const* getLuminosityBlockTree() const { return strategy_->luminosityBlockTree_; }
95  TTree* getLuminosityBlockTree() { return strategy_->luminosityBlockTree_; }
96  TTree const* getRunTree() const { return strategy_->runTree_; }
97  TTree* getRunTree() { return strategy_->runTree_; }
98  TUUID getFileUUID() const { return strategy_->fileUUID_; }
99  Long_t getEventEntry() const { return strategy_->eventEntry_; }
100  Long_t getLuminosityBlockEntry() const { return strategy_->luminosityBlockEntry_; }
101  Long_t getRunEntry() const { return strategy_->runEntry_; }
102  const std::vector<edm::BranchDescription>& getBranchDescriptions();
103  const edm::BranchListIndexes& branchListIndexes() const { strategy_->updateMap(); return strategy_->branchListIndexes(); }
104  const edm::ThinnedAssociationsHelper& thinnedAssociationsHelper() const { return strategy_->thinnedAssociationsHelper(); }
105 
106  // ---------- member data --------------------------------
107  private:
108  std::unique_ptr<internal::BMRStrategy> newStrategy(TFile* file, int fileVersion);
109  std::unique_ptr<internal::BMRStrategy> strategy_; // Contains caches, so we do not propagate_const
111  };
112 }
113 
114 #endif
edm::propagate_const< TFile * > currentFile_
std::unique_ptr< internal::BMRStrategy > strategy_
TUUID getFileUUID() const
TFile const * getFile() const
Long_t getLuminosityBlockEntry() const
#define nullptr
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