Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-18 22:30:21

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