Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:14

0001 #include "FWCore/Framework/interface/RunPrincipal.h"
0002 
0003 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0004 #include "DataFormats/Provenance/interface/ProductRegistry.h"
0005 #include "FWCore/Framework/interface/ProductResolverBase.h"
0006 #include "FWCore/Framework/interface/MergeableRunProductMetadata.h"
0007 #include "FWCore/Framework/interface/ProductPutterBase.h"
0008 #include "FWCore/Framework/src/ProductPutOrMergerBase.h"
0009 
0010 namespace edm {
0011   RunPrincipal::RunPrincipal(std::shared_ptr<ProductRegistry const> reg,
0012                              ProcessConfiguration const& pc,
0013                              HistoryAppender* historyAppender,
0014                              unsigned int iRunIndex,
0015                              bool isForPrimaryProcess,
0016                              MergeableRunProductProcesses const* mergeableRunProductProcesses)
0017       : Base(reg, reg->productLookup(InRun), pc, InRun, historyAppender, isForPrimaryProcess), index_(iRunIndex) {
0018     if (mergeableRunProductProcesses) {  // primary RunPrincipals of EventProcessor
0019       mergeableRunProductMetadataPtr_ = (std::make_unique<MergeableRunProductMetadata>(*mergeableRunProductProcesses));
0020     }
0021   }
0022 
0023   RunPrincipal::~RunPrincipal() {}
0024 
0025   void RunPrincipal::fillRunPrincipal(ProcessHistoryRegistry const& processHistoryRegistry, DelayedReader* reader) {
0026     m_reducedHistoryID = processHistoryRegistry.reducedProcessHistoryID(aux_.processHistoryID());
0027     auto history = processHistoryRegistry.getMapped(aux_.processHistoryID());
0028     fillPrincipal(aux_.processHistoryID(), history, reader);
0029 
0030     for (auto& prod : *this) {
0031       prod->setMergeableRunProductMetadata(mergeableRunProductMetadataPtr_.get());
0032     }
0033   }
0034 
0035   void RunPrincipal::put(BranchDescription const& bd, std::unique_ptr<WrapperBase> edp) const {
0036     put_(bd, std::move(edp));
0037   }
0038 
0039   void RunPrincipal::put(ProductResolverIndex index, std::unique_ptr<WrapperBase> edp) const {
0040     auto phb = getProductResolverByIndex(index);
0041     dynamic_cast<ProductPutterBase const*>(phb)->putProduct(std::move(edp));
0042   }
0043 
0044   void RunPrincipal::putOrMerge(BranchDescription const& bd, std::unique_ptr<WrapperBase> prod) const {
0045     if (prod.get() == nullptr) {
0046       throw edm::Exception(edm::errors::InsertFailure, "Null Pointer")
0047           << "putOrMerge: Cannot put because unique_ptr to product is null."
0048           << "\n";
0049     }
0050     auto phb = getExistingProduct(bd.branchID());
0051     assert(phb);
0052     dynamic_cast<ProductPutOrMergerBase const*>(phb)->putOrMergeProduct(std::move(prod));
0053   }
0054 
0055   unsigned int RunPrincipal::transitionIndex_() const { return index().value(); }
0056 
0057   void RunPrincipal::preReadFile() {
0058     if (mergeableRunProductMetadataPtr_) {
0059       mergeableRunProductMetadataPtr_->preReadFile();
0060     }
0061   }
0062 
0063 }  // namespace edm