55 std::shared_ptr<WrapperBase>
getProduct(
unsigned int iStreamIndex,
70 std::vector<std::shared_ptr<edm::WrapperBase>>
const* iWrappers)
76 unsigned int key)
const override;
79 std::vector<WrapperBase const*>& foundContainers,
80 std::vector<unsigned int>&
keys)
const override;
89 std::map<edm::ProductID, size_t>
const*
map_;
90 std::vector<std::shared_ptr<edm::WrapperBase>>
const*
wrappers_;
135 std::shared_ptr<InputFile> filePtr,
136 std::shared_ptr<EventSkipperByID> skipper,
137 std::shared_ptr<DuplicateChecker> duplicateChecker,
138 std::vector<std::shared_ptr<IndexIntoFile>>& indexesIntoFiles);
175 selectorRules_(
pset,
"inputCommands",
"InputSource"),
177 cachedWrappers_(
pset.getUntrackedParameter<unsigned
int>(
"repeatNEvents")),
178 eventAuxs_(cachedWrappers_.
size()),
190 iR.m_streamIndex =
index++;
194 auto logicalFileName =
pset.getUntrackedParameter<
std::string>(
"fileName");
196 auto const& physicalFileName =
catalog.fileCatalogItems().front().fileNames().front();
197 auto const nEventsToSkip =
pset.getUntrackedParameter<
unsigned int>(
"skipEvents");
200 auto duplicateChecker = std::make_shared<DuplicateChecker>(
pset);
202 std::vector<std::shared_ptr<IndexIntoFile>> indexesIntoFiles(1);
205 std::make_shared<InputFile>(physicalFileName.c_str(),
" Initiating request to open file ",
InputType::Primary);
207 logicalFileName, physicalFileName, 0 != nEventsToSkip,
input, skipper, duplicateChecker, indexesIntoFiles);
210 auto const& prodList =
rootFile_->productRegistry()->productList();
215 std::count_if(prodList.begin(), prodList.end(), [](
auto&& iV) {
return iV.second.branchType() ==
edm::InEvent; });
218 for (
auto&
prod : prodList) {
225 cache.resize(nProdsInEvent);
237 std::make_shared<ThinnedAssociationsHelper>(),
247 rootFile_->readCurrentEvent(eventPrincipal);
248 auto const&
aux = eventPrincipal.
aux();
255 throw cms::Exception(
"EventsWithDifferentRuns") <<
"The requested events to cache are from different Runs";
257 if (
lumi !=
aux.luminosityBlock()) {
259 <<
"The requested events to cache are from different LuminosityBlocks";
266 auto& getter = *(itGetter++);
268 cache[branchToIndex.second] =
reader->getProduct(branchToIndex.first, &getter);
283 "Read only a few Events from one EDM/Root file, and repeat them in sequence. The Events are required to be from " 284 "the same Run and LuminosityBlock.");
285 desc.addUntracked<
std::string>(
"fileName")->setComment(
"Name of file to be processed.");
286 desc.addUntracked<
unsigned int>(
"repeatNEvents", 10
U)
287 ->setComment(
"Number of events to read from file and then repeat in sequence.");
288 desc.addUntracked<
unsigned int>(
"skipEvents", 0);
292 descriptions.
add(
"source",
desc);
303 std::shared_ptr<InputFile> filePtr,
304 std::shared_ptr<EventSkipperByID> skipper,
305 std::shared_ptr<DuplicateChecker> duplicateChecker,
306 std::vector<std::shared_ptr<IndexIntoFile>>& indexesIntoFiles) {
307 return std::make_unique<RootFile>(pName,
366 rootFile_->readLuminosityBlock_(lumiPrincipal);
370 return rootFile_->readLuminosityBlockAuxiliary_();
411 return rootFile_->nextProcessBlock_(processBlockPrincipal);
415 rootFile_->readProcessBlock_(processBlockPrincipal);
419 auto itFound =
map_->find(iPID);
420 if (itFound ==
map_->end()) {
423 return (*
wrappers_)[itFound->second].get();
426 std::optional<std::tuple<WrapperBase const*, unsigned int>>
432 std::vector<WrapperBase const*>& foundContainers,
433 std::vector<unsigned int>&
keys)
const {}
std::vector< RCDelayedReader > delayedReaders_
std::map< edm::ProductID, size_t > productIDToWrapperIndex_
void beginJob() override
Begin protected makes it easier to do template programming.
ProcessConfigurationID setProcessConfigurationID()
void readEvent_(EventPrincipal &eventPrincipal) override
EventAuxiliary const & aux() const
std::map< edm::BranchID, size_t > branchIDToWrapperIndex_
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
void readRun_(RunPrincipal &runPrincipal) override
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal() const final
static std::unique_ptr< EventSkipperByID > create(ParameterSet const &pset)
std::vector< size_t > streamToCacheIndex_
unsigned long long eventIndex_
std::unique_ptr< RootFile > rootFile_
void getThinnedProducts(ProductID const &pid, std::vector< WrapperBase const *> &foundContainers, std::vector< unsigned int > &keys) const override
void setParameterSetID(ParameterSetID const &pSetID)
static void fillDescription(ParameterSetDescription &desc, char const *parameterName, std::vector< std::string > const &defaultStrings=defaultSelectionStrings())
void readProcessBlock_(ProcessBlockPrincipal &) override
StreamID streamID() const
unsigned int const defaultCacheSize
unsigned int LuminosityBlockNumber_t
bool readIt(EventID const &id, EventPrincipal &eventPrincipal, StreamContext &streamContext) override
std::vector< RCProductGetter > getters_
unsigned int m_streamIndex
std::vector< EventSelectionID > EventSelectionIDVector
static std::string const input
OptionalThinnedKey getThinnedKeyFrom(ProductID const &parent, unsigned int key, ProductID const &thinned) const override
ItemType getNextItemType() override
ProductID branchIDToProductID(BranchID const &bid) const
std::vector< BranchListIndex > BranchListIndexes
RCProductGetter(std::map< edm::ProductID, size_t > const *iMap, std::vector< std::shared_ptr< edm::WrapperBase >> const *iWrappers)
edm::RepeatingCachedRootSource const * m_source
ProductProvenanceRetriever provRetriever_
ProductSelectorRules selectorRules_
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &, unsigned int key) const override
BranchListIndexes branchListIndexes_
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
WrapperBase const * getIt(ProductID const &) const override
std::shared_ptr< RunAuxiliary > readRunAuxiliary_() override
bool nextProcessBlock_(ProcessBlockPrincipal &) override
RootServiceChecker rootServiceChecker_
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() override
std::shared_ptr< WrapperBase > getProduct(unsigned int iStreamIndex, BranchID const &k, EDProductGetter const *ep) const
void mergeReaders_(edm::DelayedReader *) final
void readLuminosityBlock_(LuminosityBlockPrincipal &lumiPrincipal) override
edm::propagate_const< std::unique_ptr< RunHelperBase > > runHelper_
void fillProcessBlockHelper_() override
RCProductGetter(RCProductGetter const &iOther)
std::shared_ptr< edm::WrapperBase > getProduct_(edm::BranchID const &k, edm::EDProductGetter const *ep) final
void skip(int offset) override
std::vector< std::shared_ptr< edm::WrapperBase > > const * wrappers_
std::vector< std::vector< std::shared_ptr< edm::WrapperBase > > > cachedWrappers_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal() const final
void add(std::string const &label, ParameterSetDescription const &psetDescription)
unsigned int transitionIndex_() const override
RepeatingCachedRootSource(ParameterSet const &pset, InputSourceDescription const &desc)
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
RCProductGetter const & operator=(RCProductGetter const &iOther)
void updateFromInput(ProductList const &other)
EventSelectionIDVector const & eventSelectionIDs() const
unsigned int value() const
std::unique_ptr< RootFile > makeRootFile(std::string const &logicalFileName, std::string const &pName, bool isSkipping, std::shared_ptr< InputFile > filePtr, std::shared_ptr< EventSkipperByID > skipper, std::shared_ptr< DuplicateChecker > duplicateChecker, std::vector< std::shared_ptr< IndexIntoFile >> &indexesIntoFiles)
std::map< edm::ProductID, size_t > const * map_
std::vector< EventAuxiliary > eventAuxs_
BranchListIndexes const & branchListIndexes() const
static ParameterSetID emptyParameterSetID()
EventSelectionIDVector selectionIDs_
DelayedReader * reader() const
bool goToEvent_(EventID const &eventID) override
static void fillDescriptions(ConfigurationDescriptions &descriptions)