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);
49  size_t fileNameHash = 0U,
50  bool currentFileFirst = true);
51  std::shared_ptr<ProductRegistry const> fileProductRegistry() const;
52  std::shared_ptr<BranchIDListHelper const> fileBranchIDListHelper() const;
53 
54  protected:
55  typedef std::shared_ptr<RootFile> RootFileSharedPtr;
57  void initTheFile(bool skipBadFiles,
58  bool deleteIndexIntoFile,
60  char const* inputTypeName,
61  InputType inputType);
62 
65 
66  bool atFirstFile() const { return fileIter_ == fileIterBegin_; }
67  bool atLastFile() const { return fileIter_ + 1 == fileIterEnd_; }
68  bool noMoreFiles() const { return fileIter_ == fileIterEnd_; }
69  bool noFiles() const { return fileIterBegin_ == fileIterEnd_; }
70  size_t sequenceNumberOfFile() const { return fileIter_ - fileIterBegin_; }
71  size_t numberOfFiles() const { return fileIterEnd_ - fileIterBegin_; }
72 
76  void setAtNextFile() { ++fileIter_; }
78 
79  std::vector<std::string> const& fileNames() const { return fileIter_->fileNames(); }
80 
81  std::string const& logicalFileName() const { return fileIter_->logicalFileName(); }
82  std::string const& lfn() const { return lfn_; }
83  std::vector<FileCatalogItem> const& fileCatalogItems() const;
84 
85  std::vector<std::shared_ptr<IndexIntoFile>> const& indexesIntoFiles() const { return indexesIntoFiles_; }
86  void setIndexIntoFile(size_t index);
87  size_t lfnHash() const { return lfnHash_; }
88  bool usedFallback() const { return usedFallback_; }
89 
90  std::shared_ptr<RootFile const> rootFile() const { return get_underlying_safe(rootFile_); }
91  std::shared_ptr<RootFile>& rootFile() { return get_underlying_safe(rootFile_); }
92 
93  private:
96  size_t lfnHash_;
99  std::vector<FileCatalogItem>::const_iterator const fileIterBegin_;
100  std::vector<FileCatalogItem>::const_iterator const fileIterEnd_;
101  std::vector<FileCatalogItem>::const_iterator fileIter_;
102  std::vector<FileCatalogItem>::const_iterator fileIterLastOpened_;
104  std::vector<std::shared_ptr<IndexIntoFile>> indexesIntoFiles_;
105 
106  private:
107  virtual RootFileSharedPtr makeRootFile(std::shared_ptr<InputFile> filePtr) = 0;
108  virtual void initFile_(bool skipBadFiles) = 0;
109  virtual void closeFile_() = 0;
110 
111  }; // class RootInputFileSequence
112 } // namespace edm
113 #endif
edm::RootInputFileSequence::noMoreFiles
bool noMoreFiles() const
Definition: RootInputFileSequence.h:68
edm::RootInputFileSequence::findFileForSpecifiedID_
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
Definition: RootInputFileSequence.h:98
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:73
edm::RootInputFileSequence::setAtFileSequenceNumber
void setAtFileSequenceNumber(size_t offset)
Definition: RootInputFileSequence.h:74
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:66
edm::RootInputFileSequence::lfnHash_
size_t lfnHash_
Definition: RootInputFileSequence.h:96
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:87
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:104
remoteMonitoring_LED_IterMethod_cfg.skipBadFiles
skipBadFiles
Definition: remoteMonitoring_LED_IterMethod_cfg.py:24
edm::RootInputFileSequence::logicalFileName
std::string const & logicalFileName() const
Definition: RootInputFileSequence.h:81
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::InputType
InputType
Definition: InputType.h:5
edm::RootInputFileSequence::initFile
void initFile(bool skipBadFiles)
Definition: RootInputFileSequence.h:56
edm::RootInputFileSequence::setIndexIntoFile
void setIndexIntoFile(size_t index)
Definition: RootInputFileSequence.cc:275
edm::RootInputFileSequence::lfn_
std::string lfn_
Definition: RootInputFileSequence.h:95
edm::RootInputFileSequence::RootFileSharedPtr
std::shared_ptr< RootFile > RootFileSharedPtr
Definition: RootInputFileSequence.h:55
edm::propagate_const
Definition: propagate_const.h:32
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::RootInputFileSequence::fileIterBegin_
const std::vector< FileCatalogItem >::const_iterator fileIterBegin_
Definition: RootInputFileSequence.h:99
edm::RootInputFileSequence::fileIter_
std::vector< FileCatalogItem >::const_iterator fileIter_
Definition: RootInputFileSequence.h:101
edm::RootInputFileSequence::setAtNextFile
void setAtNextFile()
Definition: RootInputFileSequence.h:76
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
edm::RootInputFileSequence::atLastFile
bool atLastFile() const
Definition: RootInputFileSequence.h:67
edm::RootInputFileSequence::usedFallback_
bool usedFallback_
Definition: RootInputFileSequence.h:97
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:102
edm::RootInputFileSequence::skipToItemInNewFile
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: RootInputFileSequence.cc:132
edm::RootInputFileSequence::noFiles
bool noFiles() const
Definition: RootInputFileSequence.h:69
edm::RootInputFileSequence::rootFile
std::shared_ptr< RootFile const > rootFile() const
Definition: RootInputFileSequence.h:90
edm::RootInputFileSequence::readEvent
void readEvent(EventPrincipal &cache)
Definition: RootInputFileSequence.cc:84
edm::RootInputFileSequence::containedInCurrentFile
bool containedInCurrentFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: RootInputFileSequence.cc:89
edm::RootInputFileSequence::rootFile_
edm::propagate_const< RootFileSharedPtr > rootFile_
Definition: RootInputFileSequence.h:103
InputFile.h
edm::RootInputFileSequence::~RootInputFileSequence
virtual ~RootInputFileSequence()
Definition: RootInputFileSequence.cc:49
edm::RootInputFileSequence::lfn
std::string const & lfn() const
Definition: RootInputFileSequence.h:82
edm::RootInputFileSequence::catalog_
InputFileCatalog const & catalog_
Definition: RootInputFileSequence.h:94
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:100
Frameworkfwd.h
ParameterSetDescription
edm::RootInputFileSequence::rootFile
std::shared_ptr< RootFile > & rootFile()
Definition: RootInputFileSequence.h:91
edm::RootInputFileSequence::readRunAuxiliary_
std::shared_ptr< RunAuxiliary > readRunAuxiliary_()
Definition: RootInputFileSequence.cc:51
edm::RootInputFileSequence::setNoMoreFiles
void setNoMoreFiles()
Definition: RootInputFileSequence.h:75
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:182
edm::RootInputFileSequence::usedFallback
bool usedFallback() const
Definition: RootInputFileSequence.h:88
edm::RootInputFileSequence::setAtPreviousFile
void setAtPreviousFile()
Definition: RootInputFileSequence.h:77
edm::RootInputFileSequence::indexesIntoFiles
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const
Definition: RootInputFileSequence.h:85
edm::InputSource
Definition: InputSource.h:76
edm::RootInputFileSequence::numberOfFiles
size_t numberOfFiles() const
Definition: RootInputFileSequence.h:71
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:70
edm::RootInputFileSequence::fileNames
std::vector< std::string > const & fileNames() const
Definition: RootInputFileSequence.h:79
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::RootInputFileSequence::readLuminosityBlock_
void readLuminosityBlock_(LuminosityBlockPrincipal &lumiPrincipal)
Definition: RootInputFileSequence.cc:66
edm::RootInputFileSequence::skipToItem
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
Definition: RootInputFileSequence.cc:150
edm::RootInputFileSequence::fileCatalogItems
std::vector< FileCatalogItem > const & fileCatalogItems() const
Definition: RootInputFileSequence.cc:35