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. initTheFile tries to open
7 a file using a list of PFN names constructed from multiple data catalogs
8 in site-local-config.xml. These are accessed via FileCatalogItem iterator
9 fileIter_.
10 
11 ----------------------------------------------------------------------*/
12 
13 #include "InputFile.h"
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 
24 namespace edm {
25 
26  class FileCatalogItem;
27  class IndexIntoFile;
28  class InputFileCatalog;
30  class RootFile;
31 
33  public:
35  virtual ~RootInputFileSequence();
36 
37  RootInputFileSequence(RootInputFileSequence const&) = delete; // Disallow copying and moving
38  RootInputFileSequence& operator=(RootInputFileSequence const&) = delete; // Disallow copying and moving
39 
42  std::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_();
44  std::shared_ptr<RunAuxiliary> readRunAuxiliary_();
45  bool readRun_(RunPrincipal& runPrincipal);
52  size_t fileNameHash = 0U,
53  bool currentFileFirst = true);
54  std::shared_ptr<ProductRegistry const> fileProductRegistry() const;
55  std::shared_ptr<BranchIDListHelper const> fileBranchIDListHelper() const;
56 
57  void closeFile();
58 
59  protected:
60  typedef std::shared_ptr<RootFile> RootFileSharedPtr;
62  void initTheFile(bool skipBadFiles,
63  bool deleteIndexIntoFile,
65  char const* inputTypeName,
66  InputType inputType);
67 
70 
71  bool atFirstFile() const { return fileIter_ == fileIterBegin_; }
72  bool atLastFile() const { return fileIter_ + 1 == fileIterEnd_; }
73  bool noMoreFiles() const { return fileIter_ == fileIterEnd_; }
74  bool noFiles() const { return fileIterBegin_ == fileIterEnd_; }
75  size_t sequenceNumberOfFile() const { return fileIter_ - fileIterBegin_; }
76  size_t numberOfFiles() const { return fileIterEnd_ - fileIterBegin_; }
77 
81  void setAtNextFile() { ++fileIter_; }
83 
84  std::vector<std::string> const& fileNames() const { return fileIter_->fileNames(); }
85 
86  std::string const& logicalFileName() const { return fileIter_->logicalFileName(); }
87  std::string const& lfn() const { return lfn_; }
88  std::vector<FileCatalogItem> const& fileCatalogItems() const;
89 
90  std::vector<std::shared_ptr<IndexIntoFile>> const& indexesIntoFiles() const { return indexesIntoFiles_; }
91  void setIndexIntoFile(size_t index);
92  size_t lfnHash() const { return lfnHash_; }
93  bool usedFallback() const { return usedFallback_; }
94 
95  std::shared_ptr<RootFile const> rootFile() const { return get_underlying_safe(rootFile_); }
96  std::shared_ptr<RootFile>& rootFile() { return get_underlying_safe(rootFile_); }
97 
98  private:
101  size_t lfnHash_;
104  std::vector<FileCatalogItem>::const_iterator const fileIterBegin_;
105  std::vector<FileCatalogItem>::const_iterator const fileIterEnd_;
106  std::vector<FileCatalogItem>::const_iterator fileIter_;
107  std::vector<FileCatalogItem>::const_iterator fileIterLastOpened_;
109  std::vector<std::shared_ptr<IndexIntoFile>> indexesIntoFiles_;
110 
111  private:
112  virtual RootFileSharedPtr makeRootFile(std::shared_ptr<InputFile> filePtr) = 0;
113  virtual void initFile_(bool skipBadFiles) = 0;
114  virtual void closeFile_() = 0;
115 
116  }; // class RootInputFileSequence
117 } // namespace edm
118 #endif
InputType
Definition: InputType.h:5
void initFile(bool skipBadFiles)
void setAtFileSequenceNumber(size_t offset)
bool readLuminosityBlock_(LuminosityBlockPrincipal &lumiPrincipal)
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
std::string const & logicalFileName() const
unsigned long long EventNumber_t
void readProcessBlock_(ProcessBlockPrincipal &)
bool readRun_(RunPrincipal &runPrincipal)
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
unsigned int LuminosityBlockNumber_t
std::shared_ptr< ProductRegistry const > fileProductRegistry() const
std::vector< std::string > const & fileNames() const
static std::string const input
Definition: EdmProvDump.cc:47
std::shared_ptr< RootFile > RootFileSharedPtr
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
bool nextProcessBlock_(ProcessBlockPrincipal &)
void initTheFile(bool skipBadFiles, bool deleteIndexIntoFile, InputSource *input, char const *inputTypeName, InputType inputType)
virtual RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr)=0
virtual void initFile_(bool skipBadFiles)=0
std::shared_ptr< RootFile const > rootFile() const
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
std::vector< FileCatalogItem > const & fileCatalogItems() const
edm::propagate_const< RootFileSharedPtr > rootFile_
std::shared_ptr< RootFile > & rootFile()
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
std::shared_ptr< RunAuxiliary > readRunAuxiliary_()
bool containedInCurrentFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
HLT enums.
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_()
def cache(function)
Definition: utilities.py:3
RootInputFileSequence & operator=(RootInputFileSequence const &)=delete
std::string const & lfn() const
virtual void closeFile_()=0
RootInputFileSequence(ParameterSet const &pset, InputFileCatalog const &catalog)
unsigned int RunNumber_t
std::shared_ptr< BranchIDListHelper const > fileBranchIDListHelper() const
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
bool readEvent(EventPrincipal &cache)
Definition: event.py:1
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const
InputFileCatalog const & catalog_