CMS 3D CMS Logo

RootInputFileSequence.h
Go to the documentation of this file.
1 #ifndef IOPool_Input_RootInputFileSequence_h
2 #define IOPool_Input_RootInputFileSequence_h
3 
4 /*----------------------------------------------------------------------
5 
6 RootInputFileSequence: This is an InputSource
7 
8 ----------------------------------------------------------------------*/
9 
10 #include "InputFile.h"
15 
16 #include <memory>
17 #include <string>
18 #include <unordered_map>
19 #include <vector>
20 
21 namespace edm {
22 
23  class FileCatalogItem;
24  class IndexIntoFile;
25  class InputFileCatalog;
27  class RootFile;
28 
30  public:
32  virtual ~RootInputFileSequence();
33 
34  RootInputFileSequence(RootInputFileSequence const&) = delete; // Disallow copying and moving
35  RootInputFileSequence& operator=(RootInputFileSequence const&) = delete; // Disallow copying and moving
36 
39  std::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_();
41  std::shared_ptr<RunAuxiliary> readRunAuxiliary_();
42  void readRun_(RunPrincipal& runPrincipal);
43  bool skipToItem(RunNumber_t run,
45  EventNumber_t event,
46  size_t fileNameHash = 0U,
47  bool currentFileFirst = true);
48  std::shared_ptr<ProductRegistry const> fileProductRegistry() const;
49  std::shared_ptr<BranchIDListHelper const> fileBranchIDListHelper() const;
50 
51  void closeFile();
52 
53  protected:
54  typedef std::shared_ptr<RootFile> RootFileSharedPtr;
55  void initFile(bool skipBadFiles) { initFile_(skipBadFiles); }
56  void initTheFile(bool skipBadFiles,
57  bool deleteIndexIntoFile,
59  char const* inputTypeName,
60  InputType inputType);
62  bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash);
63 
64  bool atFirstFile() const { return fileIter_ == fileIterBegin_; }
65  bool atLastFile() const { return fileIter_ + 1 == fileIterEnd_; }
66  bool noMoreFiles() const { return fileIter_ == fileIterEnd_; }
67  bool noFiles() const { return fileIterBegin_ == fileIterEnd_; }
68  size_t sequenceNumberOfFile() const { return fileIter_ - fileIterBegin_; }
69  size_t numberOfFiles() const { return fileIterEnd_ - fileIterBegin_; }
70 
74  void setAtNextFile() { ++fileIter_; }
76 
77  std::string const& fileName() const { return fileIter_->fileName(); }
78  std::string const& logicalFileName() const { return fileIter_->logicalFileName(); }
79  std::string const& fallbackFileName() const { return fileIter_->fallbackFileName(); }
80  std::string const& lfn() const { return lfn_; }
81  std::vector<FileCatalogItem> const& fileCatalogItems() const;
82 
83  std::vector<std::shared_ptr<IndexIntoFile>> const& indexesIntoFiles() const { return indexesIntoFiles_; }
84  void setIndexIntoFile(size_t index);
85  size_t lfnHash() const { return lfnHash_; }
86  bool usedFallback() const { return usedFallback_; }
87 
88  std::shared_ptr<RootFile const> rootFile() const { return get_underlying_safe(rootFile_); }
89  std::shared_ptr<RootFile>& rootFile() { return get_underlying_safe(rootFile_); }
90 
91  private:
94  size_t lfnHash_;
97  std::vector<FileCatalogItem>::const_iterator const fileIterBegin_;
98  std::vector<FileCatalogItem>::const_iterator const fileIterEnd_;
99  std::vector<FileCatalogItem>::const_iterator fileIter_;
100  std::vector<FileCatalogItem>::const_iterator fileIterLastOpened_;
102  std::vector<std::shared_ptr<IndexIntoFile>> indexesIntoFiles_;
103 
104  private:
105  virtual RootFileSharedPtr makeRootFile(std::shared_ptr<InputFile> filePtr) = 0;
106  virtual void initFile_(bool skipBadFiles) = 0;
107  virtual void closeFile_() = 0;
108 
109  }; // class RootInputFileSequence
110 } // namespace edm
111 #endif
std::string const & logicalFileName() const
InputType
Definition: InputType.h:5
void initFile(bool skipBadFiles)
std::string const & fileName() const
void setAtFileSequenceNumber(size_t offset)
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
std::shared_ptr< BranchIDListHelper const > fileBranchIDListHelper() const
unsigned long long EventNumber_t
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const
unsigned int LuminosityBlockNumber_t
static std::string const input
Definition: EdmProvDump.cc:48
std::shared_ptr< RootFile > RootFileSharedPtr
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
std::vector< FileCatalogItem > const & fileCatalogItems() const
std::string const & lfn() const
void initTheFile(bool skipBadFiles, bool deleteIndexIntoFile, InputSource *input, char const *inputTypeName, InputType inputType)
virtual RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr)=0
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
virtual void initFile_(bool skipBadFiles)=0
void readRun_(RunPrincipal &runPrincipal)
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
void readLuminosityBlock_(LuminosityBlockPrincipal &lumiPrincipal)
std::shared_ptr< RootFile const > rootFile() const
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
edm::propagate_const< RootFileSharedPtr > rootFile_
std::shared_ptr< RootFile > & rootFile()
bool containedInCurrentFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
std::shared_ptr< RunAuxiliary > readRunAuxiliary_()
HLT enums.
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_()
def cache(function)
Definition: utilities.py:3
RootInputFileSequence & operator=(RootInputFileSequence const &)=delete
virtual void closeFile_()=0
RootInputFileSequence(ParameterSet const &pset, InputFileCatalog const &catalog)
unsigned int RunNumber_t
void readEvent(EventPrincipal &cache)
std::shared_ptr< ProductRegistry const > fileProductRegistry() const
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
Definition: event.py:1
std::string const & fallbackFileName() const
InputFileCatalog const & catalog_