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;
57 
62  TUUID fileUUID_;
63  Long_t eventEntry_;
65  Long_t runEntry_;
67  };
68  } // namespace internal
69 
71  public:
72  BranchMapReader(TFile* file);
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); }
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
TTree const * getLuminosityBlockTree() const
virtual bool updateFile(TFile *file)=0
virtual const edm::BranchDescription & branchIDToBranch(const edm::BranchID &bid) const =0
std::unique_ptr< internal::BMRStrategy > newStrategy(TFile *file, int fileVersion)
virtual const std::vector< edm::BranchDescription > & getBranchDescriptions()=0
edm::propagate_const< TFile * > currentFile_
BMRStrategy(TFile *file, int fileVersion)
std::unique_ptr< internal::BMRStrategy > strategy_
bool updateEvent(Long_t eventEntry)
bool updateFile(TFile *file)
TTree const * getEventTree() const
Long_t getLuminosityBlockEntry() const
const edm::ThinnedAssociationsHelper & thinnedAssociationsHelper() const
virtual bool updateRun(Long_t runEntry)=0
bool updateLuminosityBlock(Long_t luminosityBlockEntry)
edm::propagate_const< TTree * > eventTree_
std::vector< BranchListIndex > BranchListIndexes
const edm::BranchDescription & branchIDToBranch(const edm::BranchID &bid) const
Long_t getEventEntry() const
edm::propagate_const< TTree * > luminosityBlockTree_
TFile const * getFile() const
virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry)=0
Long_t getRunEntry() const
virtual const edm::BranchDescription & productToBranch(const edm::ProductID &pid)=0
virtual edm::BranchID productToBranchID(const edm::ProductID &pid)=0
const edm::BranchDescription & productToBranch(const edm::ProductID &pid)
virtual const edm::ThinnedAssociationsHelper & thinnedAssociationsHelper() const =0
edm::propagate_const< TTree * > runTree_
virtual bool updateEvent(Long_t eventEntry)=0
TTree const * getRunTree() const
HLT enums.
bool updateRun(Long_t runEntry)
virtual const edm::BranchListIndexes & branchListIndexes() const =0
edm::BranchID productToBranchID(const edm::ProductID &pid)
const edm::BranchListIndexes & branchListIndexes() const
const std::vector< edm::BranchDescription > & getBranchDescriptions()