00001 #ifndef IOPool_Input_RootInputFileSequence_h
00002 #define IOPool_Input_RootInputFileSequence_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <memory>
00013 #include <vector>
00014 #include <string>
00015
00016 #include "Inputfwd.h"
00017
00018 #include "FWCore/Framework/interface/Frameworkfwd.h"
00019 #include "FWCore/Framework/interface/GroupSelectorRules.h"
00020 #include "FWCore/Sources/interface/VectorInputSource.h"
00021 #include "DataFormats/Provenance/interface/BranchDescription.h"
00022 #include "DataFormats/Provenance/interface/EventID.h"
00023 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00024 #include "DataFormats/Provenance/interface/RunID.h"
00025
00026 #include "boost/shared_ptr.hpp"
00027 #include "boost/utility.hpp"
00028
00029 namespace CLHEP {
00030 class RandFlat;
00031 }
00032
00033 namespace edm {
00034
00035 class PoolSource;
00036 class RootFile;
00037 class FileCatalogItem;
00038 class InputFileCatalog;
00039 class FileIndex;
00040 class DuplicateChecker;
00041
00042 class RootInputFileSequence : private boost::noncopyable {
00043 public:
00044 explicit RootInputFileSequence(ParameterSet const& pset, PoolSource const& input, InputFileCatalog const& catalog, bool primarySequence);
00045 virtual ~RootInputFileSequence();
00046
00047 typedef VectorInputSource::EventPrincipalVector EventPrincipalVector;
00048 typedef boost::shared_ptr<RootFile> RootFileSharedPtr;
00049 typedef input::EntryNumber EntryNumber;
00050 std::auto_ptr<EventPrincipal> readEvent_();
00051 boost::shared_ptr<LuminosityBlockPrincipal> readLuminosityBlock_();
00052 boost::shared_ptr<RunPrincipal> readRun_();
00053 boost::shared_ptr<FileBlock> readFile_();
00054 void closeFile_();
00055 void endJob();
00056 InputSource::ItemType getNextItemType();
00057 std::auto_ptr<EventPrincipal> readIt(EventID const& id, LuminosityBlockNumber_t lumi = 0U, bool exact = false);
00058 boost::shared_ptr<LuminosityBlockPrincipal> readIt(LuminosityBlockID const& id);
00059 boost::shared_ptr<RunPrincipal> readIt(RunID const& run);
00060 void skip(int offset);
00061 void rewind_();
00062 void readMany_(int number, EventPrincipalVector& result);
00063 void readMany_(int number, EventPrincipalVector& result, EventID const& id, unsigned int fileSeqNumber);
00064 void readManyRandom_(int number, EventPrincipalVector& result, unsigned int& fileSeqNumber);
00065 void dropUnwantedBranches_(std::vector<std::string> const& wantedBranches);
00066 ProductRegistry const& fileProductRegistry() const;
00067 private:
00068 void initFile(bool skipBadFiles);
00069 void updateProductRegistry() const;
00070 bool nextFile();
00071 bool previousFile();
00072 void rewindFile();
00073 std::auto_ptr<EventPrincipal> readCurrentEvent();
00074 std::vector<FileCatalogItem> const& fileCatalogItems() const;
00075
00076 boost::shared_ptr<ProductRegistry const> productRegistry() const;
00077 boost::shared_ptr<RunPrincipal> runPrincipal() const;
00078 ProcessConfiguration const& processConfiguration() const;
00079 ProductRegistry & productRegistryUpdate() const;
00080 int remainingEvents() const;
00081 int remainingLuminosityBlocks() const;
00082 bool const primary() const;
00083 void logFileAction(const char* msg, std::string const& file);
00084
00085 PoolSource const& input_;
00086 InputFileCatalog const& catalog_;
00087 bool firstFile_;
00088 std::vector<FileCatalogItem>::const_iterator fileIterBegin_;
00089 std::vector<FileCatalogItem>::const_iterator fileIterEnd_;
00090 std::vector<FileCatalogItem>::const_iterator fileIter_;
00091 RootFileSharedPtr rootFile_;
00092 BranchDescription::MatchMode parametersMustMatch_;
00093 BranchDescription::MatchMode branchesMustMatch_;
00094 CLHEP::RandFlat * flatDistribution_;
00095 std::vector<boost::shared_ptr<FileIndex> > fileIndexes_;
00096
00097 int eventsRemainingInFile_;
00098 RunNumber_t startAtRun_;
00099 LuminosityBlockNumber_t startAtLumi_;
00100 EventNumber_t startAtEvent_;
00101 unsigned int eventsToSkip_;
00102 std::vector<LuminosityBlockID> whichLumisToSkip_;
00103 std::vector<EventID> eventsToProcess_;
00104 bool noEventSort_;
00105 bool skipBadFiles_;
00106 unsigned int treeCacheSize_;
00107 int const treeMaxVirtualSize_;
00108 int forcedRunOffset_;
00109 RunNumber_t setRun_;
00110 GroupSelectorRules groupSelectorRules_;
00111 bool dropMetaData_;
00112 bool primarySequence_;
00113 bool randomAccess_;
00114 boost::shared_ptr<edm::DuplicateChecker> duplicateChecker_;
00115
00116 bool dropDescendants_;
00117 };
00118 }
00119 #endif