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
fwlite::internal::BMRStrategy::updateRun
virtual bool updateRun(Long_t runEntry)=0
fwlite
Definition: TFileDirectory.h:16
fwlite::internal::BMRStrategy::branchListIndexes
virtual const edm::BranchListIndexes & branchListIndexes() const =0
propagate_const.h
edm
HLT enums.
Definition: AlignableModifier.h:19
fwlite::internal::BMRStrategy::fileUUID_
TUUID fileUUID_
Definition: BranchMapReader.h:62
fwlite::BranchMapReader::getEventEntry
Long_t getEventEntry() const
Definition: BranchMapReader.h:101
fwlite::BranchMapReader::getLuminosityBlockEntry
Long_t getLuminosityBlockEntry() const
Definition: BranchMapReader.h:102
edm::BranchListIndexes
std::vector< BranchListIndex > BranchListIndexes
Definition: BranchListIndex.h:18
fwlite::internal::BMRStrategy::~BMRStrategy
virtual ~BMRStrategy()
Definition: BranchMapReader.cc:55
fwlite::BranchMapReader::branchIDToBranch
const edm::BranchDescription & branchIDToBranch(const edm::BranchID &bid) const
Definition: BranchMapReader.h:86
fwlite::internal::BMRStrategy::eventEntry_
Long_t eventEntry_
Definition: BranchMapReader.h:63
fwlite::BranchMapReader::productToBranchID
edm::BranchID productToBranchID(const edm::ProductID &pid)
Definition: BranchMapReader.h:84
fwlite::BranchMapReader::getEventTree
TTree const * getEventTree() const
Definition: BranchMapReader.h:94
fwlite::BranchMapReader::updateLuminosityBlock
bool updateLuminosityBlock(Long_t luminosityBlockEntry)
Definition: BranchMapReader.cc:606
fwlite::BranchMapReader::updateEvent
bool updateEvent(Long_t eventEntry)
Definition: BranchMapReader.cc:604
fwlite::BranchMapReader::getRunTree
TTree * getRunTree()
Definition: BranchMapReader.h:99
fwlite::BranchMapReader::updateFile
bool updateFile(TFile *file)
Definition: BranchMapReader.cc:610
fwlite::BranchMapReader::getLuminosityBlockTree
TTree * getLuminosityBlockTree()
Definition: BranchMapReader.h:97
edm::propagate_const< TFile * >
fwlite::internal::BMRStrategy::eventTree_
edm::propagate_const< TTree * > eventTree_
Definition: BranchMapReader.h:59
BranchListIndex.h
edm::BranchID
Definition: BranchID.h:14
fwlite::internal::BMRStrategy::getBranchDescriptions
virtual const std::vector< edm::BranchDescription > & getBranchDescriptions()=0
fwlite::BranchMapReader::thinnedAssociationsHelper
const edm::ThinnedAssociationsHelper & thinnedAssociationsHelper() const
Definition: BranchMapReader.h:109
fwlite::internal::BMRStrategy::luminosityBlockEntry_
Long_t luminosityBlockEntry_
Definition: BranchMapReader.h:64
fwlite::BranchMapReader::getLuminosityBlockTree
TTree const * getLuminosityBlockTree() const
Definition: BranchMapReader.h:96
fwlite::BranchMapReader::BranchMapReader
BranchMapReader()
Definition: BranchMapReader.h:73
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:35
BranchDescription.h
fwlite::internal::BMRStrategy::updateEvent
virtual bool updateEvent(Long_t eventEntry)=0
fwlite::internal::BMRStrategy::currentFile_
edm::propagate_const< TFile * > currentFile_
Definition: BranchMapReader.h:58
fwlite::BranchMapReader::getEventTree
TTree * getEventTree()
Definition: BranchMapReader.h:95
fwlite::BranchMapReader::getRunEntry
Long_t getRunEntry() const
Definition: BranchMapReader.h:103
fwlite::BranchMapReader::productToBranch
const edm::BranchDescription & productToBranch(const edm::ProductID &pid)
Definition: BranchMapReader.cc:637
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
fwlite::BranchMapReader::getRunTree
TTree const * getRunTree() const
Definition: BranchMapReader.h:98
fwlite::internal::BMRStrategy::luminosityBlockTree_
edm::propagate_const< TTree * > luminosityBlockTree_
Definition: BranchMapReader.h:60
fwlite::internal::BMRStrategy::updateMap
virtual bool updateMap()=0
fwlite::internal::BMRStrategy
Definition: BranchMapReader.h:41
fwlite::internal::BMRStrategy::updateFile
virtual bool updateFile(TFile *file)=0
fwlite::BranchMapReader::getBranchDescriptions
const std::vector< edm::BranchDescription > & getBranchDescriptions()
Definition: BranchMapReader.cc:641
fwlite::BranchMapReader::fileVersion_
int fileVersion_
Definition: BranchMapReader.h:117
fwlite::internal::BMRStrategy::productToBranch
virtual const edm::BranchDescription & productToBranch(const edm::ProductID &pid)=0
fwlite::BranchMapReader::getFile
TFile const * getFile() const
Definition: BranchMapReader.h:92
fwlite::BranchMapReader::getFileVersion
int getFileVersion() const
Definition: BranchMapReader.h:90
fwlite::internal::BMRStrategy::BMRStrategy
BMRStrategy(TFile *file, int fileVersion)
Definition: BranchMapReader.cc:42
fwlite::BranchMapReader
Definition: BranchMapReader.h:70
fwlite::BranchMapReader::getFile
TFile * getFile()
Definition: BranchMapReader.h:93
fwlite::internal::BMRStrategy::updateLuminosityBlock
virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry)=0
internal
Definition: ROOTFilePB.pb.h:39
edm::BranchDescription
Definition: BranchDescription.h:32
fwlite::BranchMapReader::newStrategy
std::unique_ptr< internal::BMRStrategy > newStrategy(TFile *file, int fileVersion)
Definition: BranchMapReader.cc:645
fwlite::internal::BMRStrategy::runEntry_
Long_t runEntry_
Definition: BranchMapReader.h:65
fwlite::BranchMapReader::updateRun
bool updateRun(Long_t runEntry)
Definition: BranchMapReader.cc:608
fwlite::BranchMapReader::branchListIndexes
const edm::BranchListIndexes & branchListIndexes() const
Definition: BranchMapReader.h:105
fwlite::internal::BMRStrategy::runTree_
edm::propagate_const< TTree * > runTree_
Definition: BranchMapReader.h:61
fwlite::internal::BMRStrategy::fileVersion_
int fileVersion_
Definition: BranchMapReader.h:66
fwlite::BranchMapReader::strategy_
std::unique_ptr< internal::BMRStrategy > strategy_
Definition: BranchMapReader.h:116
fwlite::internal::BMRStrategy::branchIDToBranch
virtual const edm::BranchDescription & branchIDToBranch(const edm::BranchID &bid) const =0
fwlite::internal::BMRStrategy::thinnedAssociationsHelper
virtual const edm::ThinnedAssociationsHelper & thinnedAssociationsHelper() const =0
edm::ProductID
Definition: ProductID.h:27
fwlite::BranchMapReader::getFileUUID
TUUID getFileUUID() const
Definition: BranchMapReader.h:100
fwlite::internal::BMRStrategy::productToBranchID
virtual edm::BranchID productToBranchID(const edm::ProductID &pid)=0