CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RootFile.h
Go to the documentation of this file.
1 #ifndef IOPool_Input_RootFile_h
2 #define IOPool_Input_RootFile_h
3 
4 /*----------------------------------------------------------------------
5 
6 RootFile.h // used by ROOT input sources
7 
8 ----------------------------------------------------------------------*/
9 
10 #include <map>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include "boost/shared_ptr.hpp"
16 #include "boost/utility.hpp"
17 #include "boost/array.hpp"
18 
19 #include "RootTree.h"
31 #include "DataFormats/Provenance/interface/EventProcessHistoryID.h" // backward compatibility
32 
33 namespace edm {
34 
35  //------------------------------------------------------------
36  // Class RootFile: supports file reading.
37 
38  class DuplicateChecker;
39  class ProvenanceAdaptor;
40  class GroupSelectorRules;
41  class EventSkipperByID;
42  class InputFile;
43 
44  class RootFile : private boost::noncopyable {
45  public:
46  typedef boost::array<RootTree*, NumBranchTypes> RootTreePtrArray;
47  RootFile(std::string const& fileName,
48  ProcessConfiguration const& processConfiguration,
49  std::string const& logicalFileName,
50  boost::shared_ptr<InputFile> filePtr,
51  boost::shared_ptr<EventSkipperByID> eventSkipperByID,
52  bool skipAnyEvents,
53  int remainingEvents,
54  int remainingLumis,
55  unsigned int treeCacheSize,
56  int treeMaxVirtualSize,
58  RunNumber_t const& forcedRunNumber,
59  bool noEventSort,
60  GroupSelectorRules const& groupSelectorRules,
61  bool secondaryFile,
62  boost::shared_ptr<DuplicateChecker> duplicateChecker,
63  bool dropDescendantsOfDroppedProducts,
64  std::vector<boost::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
65  std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile,
66  std::vector<ProcessHistoryID>& orderedProcessHistoryIDs,
67  bool usingGoToEvent);
68  ~RootFile();
69  void reportOpened(std::string const& inputType);
70  void close();
72  boost::shared_ptr<RootFile> rootFilePtr,
73  boost::shared_ptr<LuminosityBlockPrincipal> lb = boost::shared_ptr<LuminosityBlockPrincipal>());
75  boost::shared_ptr<RootFile> rootFilePtr,
76  boost::shared_ptr<LuminosityBlockPrincipal> lb = boost::shared_ptr<LuminosityBlockPrincipal>());
77 
78  boost::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_();
79  boost::shared_ptr<RunAuxiliary> readRunAuxiliary_();
80  boost::shared_ptr<RunPrincipal> readRun_(boost::shared_ptr<RunPrincipal> rpCache);
81  boost::shared_ptr<LuminosityBlockPrincipal> readLumi(boost::shared_ptr<LuminosityBlockPrincipal> lbCache);
82  std::string const& file() const {return file_;}
83  boost::shared_ptr<ProductRegistry const> productRegistry() const {return productRegistry_;}
85  EventAuxiliary const& eventAux() const {return eventAux_;}
86  // IndexIntoFile::EntryNumber_t const& entryNumber() const {return indexIntoFileIter().entry();}
87  // LuminosityBlockNumber_t const& luminosityBlockNumber() const {return indexIntoFileIter().lumi();}
88  // RunNumber_t const& runNumber() const {return indexIntoFileIter().run();}
89  EventID const& eventID() const {return eventAux().id();}
90  RootTree const& eventTree() const {return eventTree_;}
91  RootTree const& lumiTree() const {return lumiTree_;}
92  RootTree const& runTree() const {return runTree_;}
95  boost::array<bool, NumBranchTypes> const& hasNewlyDroppedBranch() const {return hasNewlyDroppedBranch_;}
97  boost::shared_ptr<FileBlock> createFileBlock() const;
99  return event ? setEntryAtEvent(run, lumi, event) : (lumi ? setEntryAtLumi(run, lumi) : setEntryAtRun(run));
100  }
105 
106  void rewind() {
108  eventTree_.rewind();
109  lumiTree_.rewind();
110  runTree_.rewind();
111  }
112  void setToLastEntry() {
114  }
115 
116  bool skipEvents(int& offset);
117  bool goToEvent(EventID const& eventID);
118  bool nextEventEntry() {return eventTree_.next();}
120  boost::shared_ptr<IndexIntoFile> indexIntoFileSharedPtr() const {
122  }
123  bool wasLastEventJustRead() const;
124  bool wasFirstEventJustRead() const;
127 
128  private:
130  bool skipThisEntry();
132  void setIfFastClonable(int remainingEvents, int remainingLumis);
133  void validateFile(bool secondaryFile, bool usingGoToEvent);
134  void fillIndexIntoFile();
135  void fillEventAuxiliary();
136  void fillThisEventAuxiliary();
137  void fillHistory();
138  boost::shared_ptr<LuminosityBlockAuxiliary> fillLumiAuxiliary();
139  boost::shared_ptr<RunAuxiliary> fillRunAuxiliary();
140  void overrideRunNumber(RunID& id);
142  void overrideRunNumber(EventID& id, bool isRealData);
143  std::string const& newBranchToOldBranch(std::string const& newBranch) const;
144  void dropOnInput(ProductRegistry& reg, GroupSelectorRules const& rules, bool dropDescendants, bool secondaryFile);
145  void readParentageTree();
147  void readEventHistoryTree();
148  bool isDuplicateEvent();
149 
150  void initializeDuplicateChecker(std::vector<boost::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
151  std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile);
152 
153  boost::shared_ptr<BranchMapper> makeBranchMapper(RootTree& rootTree, BranchType const& type) const;
154 
155  std::string const file_;
156  std::string const logicalFile_;
158  boost::shared_ptr<InputFile> filePtr_;
159  boost::shared_ptr<EventSkipperByID> eventSkipperByID_;
162  boost::shared_ptr<IndexIntoFile> indexIntoFileSharedPtr_;
164  std::vector<ProcessHistoryID>& orderedProcessHistoryIDs_;
168  std::vector<EventProcessHistoryID> eventProcessHistoryIDs_; // backward compatibility
169  std::vector<EventProcessHistoryID>::const_iterator eventProcessHistoryIter_; // backward compatibility
173  boost::array<bool, NumBranchTypes> hasNewlyDroppedBranch_;
181  boost::shared_ptr<ProductRegistry const> productRegistry_;
182  boost::shared_ptr<BranchIDListRegistry::collection_type const> branchIDLists_;
185  std::map<std::string, std::string> newBranchToOldBranch_;
187  boost::shared_ptr<EventSelectionIDVector> eventSelectionIDs_;
188  boost::shared_ptr<BranchListIndexes> branchListIndexes_;
189  boost::shared_ptr<History> history_;
190  boost::shared_ptr<BranchChildren> branchChildren_;
191  boost::shared_ptr<DuplicateChecker> duplicateChecker_;
192  boost::shared_ptr<ProvenanceAdaptor> provenanceAdaptor_;
193  }; // class RootFile
194 
195 }
196 #endif
EventID const & eventID() const
Definition: RootFile.h:89
bool setEntryAtItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: RootFile.h:98
type
Definition: HCALResponse.h:22
boost::shared_ptr< BranchChildren > branchChildren_
Definition: RootFile.h:190
boost::shared_ptr< IndexIntoFile > indexIntoFileSharedPtr() const
Definition: RootFile.h:120
boost::shared_ptr< BranchListIndexes > branchListIndexes_
Definition: RootFile.h:188
boost::shared_ptr< FileBlock > createFileBlock() const
Definition: RootFile.cc:520
RootTree const & lumiTree() const
Definition: RootFile.h:91
bool skipEvents(int &offset)
Definition: RootFile.cc:1120
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:93
boost::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch() const
Definition: RootFile.h:95
bool branchListIndexesUnchanged() const
Definition: RootFile.h:96
bool nextEventEntry()
Definition: RootFile.h:118
unsigned int EventNumber_t
Definition: EventID.h:30
boost::array< bool, NumBranchTypes > hasNewlyDroppedBranch_
Definition: RootFile.h:173
void readParentageTree()
Definition: RootFile.cc:444
int whyNotFastClonable_
Definition: RootFile.h:172
tuple lumi
Definition: fjr2json.py:41
std::map< std::string, std::string > newBranchToOldBranch_
Definition: RootFile.h:185
IndexIntoFile::EntryType getEntryTypeWithSkipping()
Definition: RootFile.cc:599
void fillEventAuxiliary()
Definition: RootFile.cc:1023
bool setEntryAtRun(RunNumber_t run)
Definition: RootFile.cc:1416
RootTree lumiTree_
Definition: RootFile.h:177
boost::array< RootTree *, NumBranchTypes > RootTreePtrArray
Definition: RootFile.h:46
InputSource::ProcessingMode processingMode_
Definition: RootFile.h:183
boost::shared_ptr< History > history_
Definition: RootFile.h:189
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:167
boost::shared_ptr< RunAuxiliary > fillRunAuxiliary()
Definition: RootFile.cc:1102
uint16_t size_type
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
long long EntryNumber_t
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
BranchType
Definition: BranchType.h:11
FileFormatVersion fileFormatVersion_
Definition: RootFile.h:160
void setPosition(IndexIntoFile::IndexIntoFileItr const &position)
Definition: RootFile.cc:550
void rewind()
Definition: RootFile.h:106
std::vector< EventProcessHistoryID >::const_iterator eventProcessHistoryIter_
Definition: RootFile.h:169
void setToLastEntry()
Definition: RootFile.h:112
bool skipThisEntry()
Definition: RootFile.cc:555
IndexIntoFile::EntryType getNextEntryTypeWanted()
Definition: RootFile.cc:626
RootFile(std::string const &fileName, ProcessConfiguration const &processConfiguration, std::string const &logicalFileName, boost::shared_ptr< InputFile > filePtr, boost::shared_ptr< EventSkipperByID > eventSkipperByID, bool skipAnyEvents, int remainingEvents, int remainingLumis, unsigned int treeCacheSize, int treeMaxVirtualSize, InputSource::ProcessingMode processingMode, RunNumber_t const &forcedRunNumber, bool noEventSort, GroupSelectorRules const &groupSelectorRules, bool secondaryFile, boost::shared_ptr< DuplicateChecker > duplicateChecker, bool dropDescendantsOfDroppedProducts, std::vector< boost::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< boost::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile, std::vector< ProcessHistoryID > &orderedProcessHistoryIDs, bool usingGoToEvent)
Definition: RootFile.cc:99
tuple InputFile
Open Root file and provide MEs ############.
FileID fid_
Definition: RootFile.h:161
boost::shared_ptr< DuplicateChecker > duplicateChecker_
Definition: RootFile.h:191
std::string const logicalFile_
Definition: RootFile.h:156
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:166
bool next()
Definition: RootTree.h:81
bool noEventSort_
Definition: RootFile.h:171
bool wasLastEventJustRead() const
Definition: RootFile.cc:651
bool setEntryAtLumi(RunNumber_t run, LuminosityBlockNumber_t lumi)
Definition: RootFile.cc:1408
void close()
Definition: RootFile.cc:992
EventPrincipal * readEvent(EventPrincipal &cache, boost::shared_ptr< RootFile > rootFilePtr, boost::shared_ptr< LuminosityBlockPrincipal > lb=boost::shared_ptr< LuminosityBlockPrincipal >())
Definition: RootFile.cc:1226
RootTree const & runTree() const
Definition: RootFile.h:92
IndexIntoFile::EntryNumber_t lastEventEntryNumberRead_
Definition: RootFile.h:180
BranchIDListRegistry::collection_type const & branchIDLists()
Definition: RootFile.h:84
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
EventAuxiliary const & eventAux() const
Definition: RootFile.h:85
int whyNotFastClonable() const
Definition: RootFile.h:94
bool skipAnyEvents_
Definition: RootFile.h:170
RootTree eventTree_
Definition: RootFile.h:176
void dropOnInput(ProductRegistry &reg, GroupSelectorRules const &rules, bool dropDescendants, bool secondaryFile)
Definition: RootFile.cc:1484
void fillHistory()
Definition: RootFile.cc:1029
bool isDuplicateEvent()
Definition: RootFile.cc:615
unsigned int offset(bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool wasFirstEventJustRead() const
Definition: RootFile.cc:658
EventPrincipal * readCurrentEvent(EventPrincipal &cache, boost::shared_ptr< RootFile > rootFilePtr, boost::shared_ptr< LuminosityBlockPrincipal > lb=boost::shared_ptr< LuminosityBlockPrincipal >())
Definition: RootFile.cc:1243
boost::shared_ptr< EventSelectionIDVector > eventSelectionIDs_
Definition: RootFile.h:187
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:163
RootTree runTree_
Definition: RootFile.h:178
bool goToEvent(EventID const &eventID)
Definition: RootFile.cc:1191
void setAtEventEntry(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1273
boost::shared_ptr< IndexIntoFile > indexIntoFileSharedPtr_
Definition: RootFile.h:162
ProcessConfiguration const & processConfiguration_
Definition: RootFile.h:157
void setIfFastClonable(int remainingEvents, int remainingLumis)
Definition: RootFile.cc:470
void readEntryDescriptionTree()
Definition: RootFile.cc:408
boost::shared_ptr< LuminosityBlockAuxiliary > fillLumiAuxiliary()
Definition: RootFile.cc:1081
boost::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_()
Definition: RootFile.cc:1337
std::string const & file() const
Definition: RootFile.h:82
IndexIntoFile::IndexIntoFileItr indexIntoFileBegin_
Definition: RootFile.h:165
EventID const & id() const
bool branchListIndexesUnchanged_
Definition: RootFile.h:174
void fillIndexIntoFile()
Definition: RootFile.cc:721
author Stefano ARGIRO author Bill Tanenbaum
RootTreePtrArray treePointers_
Definition: RootFile.h:179
boost::shared_ptr< ProductRegistry const > productRegistry_
Definition: RootFile.h:181
boost::shared_ptr< BranchMapper > makeBranchMapper(RootTree &rootTree, BranchType const &type) const
Definition: RootFile.cc:1637
std::vector< ProcessHistoryID > & orderedProcessHistoryIDs_
Definition: RootFile.h:164
RootTreePtrArray & treePointers()
Definition: RootFile.h:129
void overrideRunNumber(RunID &id)
Definition: RootFile.cc:1424
boost::shared_ptr< RunPrincipal > readRun_(boost::shared_ptr< RunPrincipal > rpCache)
Definition: RootFile.cc:1320
boost::shared_ptr< InputFile > filePtr_
Definition: RootFile.h:158
void initializeDuplicateChecker(std::vector< boost::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< boost::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile)
Definition: RootFile.cc:1468
unsigned int RunNumber_t
Definition: EventRange.h:32
boost::shared_ptr< ProvenanceAdaptor > provenanceAdaptor_
Definition: RootFile.h:192
EventAuxiliary eventAux_
Definition: RootFile.h:175
void fillThisEventAuxiliary()
Definition: RootFile.cc:1004
bool setEntryAtEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: RootFile.cc:1400
boost::shared_ptr< BranchIDListRegistry::collection_type const > branchIDLists_
Definition: RootFile.h:182
void rewind()
Definition: RootTree.h:84
RootTree const & eventTree() const
Definition: RootFile.h:90
IndexIntoFile::IndexIntoFileItr indexIntoFileIter() const
Definition: RootFile.cc:545
std::string const & newBranchToOldBranch(std::string const &newBranch) const
Definition: RootFile.cc:536
boost::shared_ptr< EventSkipperByID > eventSkipperByID_
Definition: RootFile.h:159
TTree * eventHistoryTree_
Definition: RootFile.h:186
void validateFile(bool secondaryFile, bool usingGoToEvent)
Definition: RootFile.cc:940
boost::shared_ptr< ProductRegistry const > productRegistry() const
Definition: RootFile.h:83
std::string const file_
Definition: RootFile.h:155
boost::shared_ptr< RunAuxiliary > readRunAuxiliary_()
Definition: RootFile.cc:1278
std::vector< EventProcessHistoryID > eventProcessHistoryIDs_
Definition: RootFile.h:168
void readEventHistoryTree()
Definition: RootFile.cc:1455
int forcedRunOffset_
Definition: RootFile.h:184
void reportOpened(std::string const &inputType)
Definition: RootFile.cc:978
boost::shared_ptr< LuminosityBlockPrincipal > readLumi(boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
Definition: RootFile.cc:1381