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  void 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  protected:
58  typedef std::shared_ptr<RootFile> RootFileSharedPtr;
60  void initTheFile(bool skipBadFiles,
61  bool deleteIndexIntoFile,
63  char const* inputTypeName,
64  InputType inputType);
65 
68 
69  bool atFirstFile() const { return fileIter_ == fileIterBegin_; }
70  bool atLastFile() const { return fileIter_ + 1 == fileIterEnd_; }
71  bool noMoreFiles() const { return fileIter_ == fileIterEnd_; }
72  bool noFiles() const { return fileIterBegin_ == fileIterEnd_; }
73  size_t sequenceNumberOfFile() const { return fileIter_ - fileIterBegin_; }
74  size_t numberOfFiles() const { return fileIterEnd_ - fileIterBegin_; }
75 
79  void setAtNextFile() { ++fileIter_; }
81 
82  std::vector<std::string> const& fileNames() const { return fileIter_->fileNames(); }
83 
84  std::string const& logicalFileName() const { return fileIter_->logicalFileName(); }
85  std::string const& lfn() const { return lfn_; }
86  std::vector<FileCatalogItem> const& fileCatalogItems() const;
87 
88  std::vector<std::shared_ptr<IndexIntoFile>> const& indexesIntoFiles() const { return indexesIntoFiles_; }
89  void setIndexIntoFile(size_t index);
90  size_t lfnHash() const { return lfnHash_; }
91  bool usedFallback() const { return usedFallback_; }
92 
93  std::shared_ptr<RootFile const> rootFile() const { return get_underlying_safe(rootFile_); }
94  std::shared_ptr<RootFile>& rootFile() { return get_underlying_safe(rootFile_); }
95 
96  private:
99  size_t lfnHash_;
102  std::vector<FileCatalogItem>::const_iterator const fileIterBegin_;
103  std::vector<FileCatalogItem>::const_iterator const fileIterEnd_;
104  std::vector<FileCatalogItem>::const_iterator fileIter_;
105  std::vector<FileCatalogItem>::const_iterator fileIterLastOpened_;
107  std::vector<std::shared_ptr<IndexIntoFile>> indexesIntoFiles_;
108 
109  private:
110  virtual RootFileSharedPtr makeRootFile(std::shared_ptr<InputFile> filePtr) = 0;
111  virtual void initFile_(bool skipBadFiles) = 0;
112  virtual void closeFile_() = 0;
113 
114  }; // class RootInputFileSequence
115 } // namespace edm
116 #endif
edm::RootInputFileSequence::noMoreFiles
bool noMoreFiles() const
Definition: RootInputFileSequence.h:71
edm::RootInputFileSequence::findFileForSpecifiedID_
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
Definition: RootInputFileSequence.h:101
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
edm::RootInputFileSequence::fileProductRegistry
std::shared_ptr< ProductRegistry const > fileProductRegistry() const
Definition: RootInputFileSequence.cc:39
input
static const std::string input
Definition: EdmProvDump.cc:48
edm::RootInputFileSequence::setAtFirstFile
void setAtFirstFile()
Definition: RootInputFileSequence.h:76
edm::RootInputFileSequence::setAtFileSequenceNumber
void setAtFileSequenceNumber(size_t offset)
Definition: RootInputFileSequence.h:77
getEcalConditions_orcoffint2r_cff.catalog
catalog
Definition: getEcalConditions_orcoffint2r_cff.py:40
edm::RootInputFileSequence::closeFile_
virtual void closeFile_()=0
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::RootInputFileSequence::atFirstFile
bool atFirstFile() const
Definition: RootInputFileSequence.h:69
edm::RootInputFileSequence::lfnHash_
size_t lfnHash_
Definition: RootInputFileSequence.h:99
edm::RootInputFileSequence::makeRootFile
virtual RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr)=0
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
edm::RootInputFileSequence::lfnHash
size_t lfnHash() const
Definition: RootInputFileSequence.h:90
edm::InputFileCatalog
Definition: InputFileCatalog.h:32
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
InputFileCatalog.h
edm::RootInputFileSequence::indexesIntoFiles_
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
Definition: RootInputFileSequence.h:107
remoteMonitoring_LED_IterMethod_cfg.skipBadFiles
skipBadFiles
Definition: remoteMonitoring_LED_IterMethod_cfg.py:24
edm::RootInputFileSequence::logicalFileName
std::string const & logicalFileName() const
Definition: RootInputFileSequence.h:84
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::ProcessBlockPrincipal
Definition: ProcessBlockPrincipal.h:22
edm::InputType
InputType
Definition: InputType.h:5
edm::RootInputFileSequence::initFile
void initFile(bool skipBadFiles)
Definition: RootInputFileSequence.h:59
edm::RootInputFileSequence::setIndexIntoFile
void setIndexIntoFile(size_t index)
Definition: RootInputFileSequence.cc:290
edm::RootInputFileSequence::lfn_
std::string lfn_
Definition: RootInputFileSequence.h:98
edm::RootInputFileSequence::RootFileSharedPtr
std::shared_ptr< RootFile > RootFileSharedPtr
Definition: RootInputFileSequence.h:58
edm::propagate_const
Definition: propagate_const.h:32
edm::EventPrincipal
Definition: EventPrincipal.h:48
edm::RootInputFileSequence::fileIterBegin_
const std::vector< FileCatalogItem >::const_iterator fileIterBegin_
Definition: RootInputFileSequence.h:102
edm::RootInputFileSequence::nextProcessBlock_
bool nextProcessBlock_(ProcessBlockPrincipal &)
Definition: RootInputFileSequence.cc:71
edm::RootInputFileSequence::fileIter_
std::vector< FileCatalogItem >::const_iterator fileIter_
Definition: RootInputFileSequence.h:104
edm::RootInputFileSequence::setAtNextFile
void setAtNextFile()
Definition: RootInputFileSequence.h:79
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
edm::RootInputFileSequence::atLastFile
bool atLastFile() const
Definition: RootInputFileSequence.h:70
edm::RootInputFileSequence::usedFallback_
bool usedFallback_
Definition: RootInputFileSequence.h:100
edm::RootInputFileSequence::readLuminosityBlockAuxiliary_
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_()
Definition: RootInputFileSequence.cc:56
edm::RootInputFileSequence::readRun_
void readRun_(RunPrincipal &runPrincipal)
Definition: RootInputFileSequence.cc:61
utilities.cache
def cache(function)
Definition: utilities.py:3
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
InputType.h
edm::RootInputFileSequence::RootInputFileSequence
RootInputFileSequence(ParameterSet const &pset, InputFileCatalog const &catalog)
Definition: RootInputFileSequence.cc:22
edm::RootInputFileSequence::fillProcessBlockHelper_
void fillProcessBlockHelper_()
Definition: RootInputFileSequence.cc:66
edm::RootInputFileSequence::initFile_
virtual void initFile_(bool skipBadFiles)=0
edm::RootInputFileSequence
Definition: RootInputFileSequence.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
edm::RootInputFileSequence::operator=
RootInputFileSequence & operator=(RootInputFileSequence const &)=delete
edm::RootInputFileSequence::fileIterLastOpened_
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
Definition: RootInputFileSequence.h:105
edm::RootInputFileSequence::skipToItemInNewFile
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: RootInputFileSequence.cc:147
edm::RootInputFileSequence::noFiles
bool noFiles() const
Definition: RootInputFileSequence.h:72
edm::RootInputFileSequence::rootFile
std::shared_ptr< RootFile const > rootFile() const
Definition: RootInputFileSequence.h:93
edm::RootInputFileSequence::containedInCurrentFile
bool containedInCurrentFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: RootInputFileSequence.cc:104
edm::RootInputFileSequence::rootFile_
edm::propagate_const< RootFileSharedPtr > rootFile_
Definition: RootInputFileSequence.h:106
InputFile.h
edm::RootInputFileSequence::readEvent
bool readEvent(EventPrincipal &cache)
Definition: RootInputFileSequence.cc:99
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::RootInputFileSequence::~RootInputFileSequence
virtual ~RootInputFileSequence()
Definition: RootInputFileSequence.cc:49
edm::RootInputFileSequence::lfn
std::string const & lfn() const
Definition: RootInputFileSequence.h:85
edm::RootInputFileSequence::catalog_
InputFileCatalog const & catalog_
Definition: RootInputFileSequence.h:97
edm::RootInputFileSequence::fileBranchIDListHelper
std::shared_ptr< BranchIDListHelper const > fileBranchIDListHelper() const
Definition: RootInputFileSequence.cc:44
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::RootInputFileSequence::fileIterEnd_
const std::vector< FileCatalogItem >::const_iterator fileIterEnd_
Definition: RootInputFileSequence.h:103
Frameworkfwd.h
ParameterSetDescription
edm::RootInputFileSequence::rootFile
std::shared_ptr< RootFile > & rootFile()
Definition: RootInputFileSequence.h:94
edm::RootInputFileSequence::readRunAuxiliary_
std::shared_ptr< RunAuxiliary > readRunAuxiliary_()
Definition: RootInputFileSequence.cc:51
edm::RootInputFileSequence::setNoMoreFiles
void setNoMoreFiles()
Definition: RootInputFileSequence.h:78
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::RootInputFileSequence::initTheFile
void initTheFile(bool skipBadFiles, bool deleteIndexIntoFile, InputSource *input, char const *inputTypeName, InputType inputType)
Definition: RootInputFileSequence.cc:197
edm::RootInputFileSequence::usedFallback
bool usedFallback() const
Definition: RootInputFileSequence.h:91
edm::RootInputFileSequence::setAtPreviousFile
void setAtPreviousFile()
Definition: RootInputFileSequence.h:80
edm::RootInputFileSequence::indexesIntoFiles
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const
Definition: RootInputFileSequence.h:88
edm::RootInputFileSequence::readProcessBlock_
void readProcessBlock_(ProcessBlockPrincipal &)
Definition: RootInputFileSequence.cc:76
edm::InputSource
Definition: InputSource.h:52
edm::RootInputFileSequence::numberOfFiles
size_t numberOfFiles() const
Definition: RootInputFileSequence.h:74
edm::RunPrincipal
Definition: RunPrincipal.h:34
event
Definition: event.py:1
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
get_underlying_safe.h
lumi
Definition: LumiSectionData.h:20
edm::RootInputFileSequence::sequenceNumberOfFile
size_t sequenceNumberOfFile() const
Definition: RootInputFileSequence.h:73
edm::RootInputFileSequence::fileNames
std::vector< std::string > const & fileNames() const
Definition: RootInputFileSequence.h:82
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::RootInputFileSequence::readLuminosityBlock_
void readLuminosityBlock_(LuminosityBlockPrincipal &lumiPrincipal)
Definition: RootInputFileSequence.cc:81
edm::RootInputFileSequence::skipToItem
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
Definition: RootInputFileSequence.cc:165
edm::RootInputFileSequence::fileCatalogItems
std::vector< FileCatalogItem > const & fileCatalogItems() const
Definition: RootInputFileSequence.cc:35