Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-28 02:52:57

0001 #include "FWCore/Framework/interface/Run.h"
0002 
0003 #include "FWCore/Framework/interface/RunPrincipal.h"
0004 #include "FWCore/Framework/interface/TransitionInfoTypes.h"
0005 #include "FWCore/Framework/interface/ProductPutterBase.h"
0006 #include "FWCore/Utilities/interface/Algorithms.h"
0007 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0008 
0009 namespace edm {
0010 
0011   std::string const Run::emptyString_;
0012 
0013   Run::Run(RunTransitionInfo const& info, ModuleDescription const& md, ModuleCallingContext const* mcc, bool isAtEnd)
0014       : Run(info.principal(), md, mcc, isAtEnd) {}
0015 
0016   Run::Run(RunPrincipal const& rp,
0017            ModuleDescription const& md,
0018            ModuleCallingContext const* moduleCallingContext,
0019            bool isAtEnd)
0020       : provRecorder_(rp, md, isAtEnd), aux_(rp.aux()), moduleCallingContext_(moduleCallingContext) {}
0021 
0022   Run::~Run() {}
0023 
0024   RunAuxiliary const& Run::runAuxiliary() const { return aux_; }
0025 
0026   Run::CacheIdentifier_t Run::cacheIdentifier() const { return runPrincipal().cacheIdentifier(); }
0027 
0028   RunIndex Run::index() const { return runPrincipal().index(); }
0029 
0030   RunPrincipal const& Run::runPrincipal() const { return dynamic_cast<RunPrincipal const&>(provRecorder_.principal()); }
0031 
0032   Provenance const& Run::getProvenance(BranchID const& bid) const { return runPrincipal().getProvenance(bid); }
0033 
0034   StableProvenance const& Run::getStableProvenance(BranchID const& bid) const {
0035     return runPrincipal().getStableProvenance(bid);
0036   }
0037 
0038   void Run::getAllStableProvenance(std::vector<StableProvenance const*>& provenances) const {
0039     runPrincipal().getAllStableProvenance(provenances);
0040   }
0041 
0042   /* Not yet fully implemented
0043   bool
0044   Run::getProcessParameterSet(std::string const& processName, std::vector<ParameterSet>& psets) const {
0045     // Get the relevant ProcessHistoryIDs
0046     ProcessHistoryRegistry* phreg = ProcessHistoryRegistry::instance();
0047     // Need to fill these in.
0048     std::vector<ProcessHistoryID> historyIDs;
0049 
0050 
0051     // Get the relevant ParameterSetIDs.
0052     // Need to fill these in.
0053     std::vector<ParameterSetID> psetIdsUsed;
0054     for(std::vector<ProcessHistoryID>::const_iterator
0055            i = historyIDs.begin(),
0056            e = historyIDs.end();
0057          i != e;
0058          ++i) {
0059       ProcessHistory temp;
0060       phreg->getMapped(*i, temp);
0061     }
0062 
0063     // Look up the ParameterSets for these IDs.
0064     pset::Registry* psreg = pset::Registry::instance();
0065     for(std::vector<ParameterSetID>::const_iterator
0066            i = psetIdsUsed.begin(),
0067            e = psetIdsUsed.end();
0068          i != e;
0069          ++i) {
0070       ParameterSet temp;
0071       psreg->getMapped(*i, temp);
0072       psets.push_back(temp);
0073     }
0074 
0075     return false;
0076   }
0077 */
0078 
0079   void Run::setProducer(ProducerBase const* iProducer) {
0080     provRecorder_.setProducer(iProducer);
0081     //set appropriate size
0082     putProducts_.resize(provRecorder_.putTokenIndexToProductResolverIndex().size());
0083   }
0084 
0085   void Run::commit_(std::vector<edm::ProductResolverIndex> const& iShouldPut) {
0086     RunPrincipal const& rp = runPrincipal();
0087     size_t nPut = 0;
0088     for (size_t i = 0; i < putProducts().size(); ++i) {
0089       auto& p = get_underlying_safe(putProducts()[i]);
0090       if (p) {
0091         rp.put(provRecorder_.putTokenIndexToProductResolverIndex()[i], std::move(p));
0092         ++nPut;
0093       }
0094     }
0095 
0096     auto sz = iShouldPut.size();
0097     if (sz != 0 and sz != nPut) {
0098       //some were missed
0099       auto& p = provRecorder_.principal();
0100       for (auto index : iShouldPut) {
0101         auto resolver = p.getProductResolverByIndex(index);
0102         if (not resolver->productResolved() and isEndTransition(provRecorder_.transition()) ==
0103                                                     resolver->branchDescription().availableOnlyAtEndTransition()) {
0104           dynamic_cast<ProductPutterBase const*>(resolver)->putProduct(std::unique_ptr<WrapperBase>());
0105         }
0106       }
0107     }
0108 
0109     // the cleanup is all or none
0110     putProducts().clear();
0111   }
0112 
0113   ProcessHistoryID const& Run::processHistoryID() const { return runPrincipal().processHistoryID(); }
0114 
0115   ProcessHistory const& Run::processHistory() const { return provRecorder_.processHistory(); }
0116 
0117   BasicHandle Run::getByLabelImpl(std::type_info const&,
0118                                   std::type_info const& iProductType,
0119                                   const InputTag& iTag) const {
0120     BasicHandle h = provRecorder_.getByLabel_(TypeID(iProductType), iTag, moduleCallingContext_);
0121     return h;
0122   }
0123 }  // namespace edm