Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/LuminosityBlock.h"
0002 
0003 #include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
0004 #include "FWCore/Framework/interface/Run.h"
0005 #include "FWCore/Framework/interface/TransitionInfoTypes.h"
0006 #include "FWCore/Framework/interface/ProductPutterBase.h"
0007 #include "FWCore/Utilities/interface/Algorithms.h"
0008 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0009 
0010 namespace edm {
0011 
0012   std::string const LuminosityBlock::emptyString_;
0013 
0014   LuminosityBlock::LuminosityBlock(LumiTransitionInfo const& info,
0015                                    ModuleDescription const& md,
0016                                    ModuleCallingContext const* mcc,
0017                                    bool isAtEnd)
0018       : LuminosityBlock(info.principal(), md, mcc, isAtEnd) {}
0019 
0020   LuminosityBlock::LuminosityBlock(LuminosityBlockPrincipal const& lbp,
0021                                    ModuleDescription const& md,
0022                                    ModuleCallingContext const* moduleCallingContext,
0023                                    bool isAtEnd)
0024       : provRecorder_(lbp, md, isAtEnd), aux_(lbp.aux()), run_(), moduleCallingContext_(moduleCallingContext) {}
0025 
0026   LuminosityBlock::~LuminosityBlock() {}
0027 
0028   LuminosityBlockAuxiliary const& LuminosityBlock::luminosityBlockAuxiliary() const { return aux_; }
0029 
0030   LuminosityBlockIndex LuminosityBlock::index() const { return luminosityBlockPrincipal().index(); }
0031 
0032   LuminosityBlock::CacheIdentifier_t LuminosityBlock::cacheIdentifier() const {
0033     return luminosityBlockPrincipal().cacheIdentifier();
0034   }
0035 
0036   void LuminosityBlock::setConsumer(EDConsumerBase const* iConsumer) {
0037     provRecorder_.setConsumer(iConsumer);
0038     if (run_) {
0039       run_->setConsumer(iConsumer);
0040     }
0041   }
0042 
0043   void LuminosityBlock::setSharedResourcesAcquirer(SharedResourcesAcquirer* iResourceAcquirer) {
0044     provRecorder_.setSharedResourcesAcquirer(iResourceAcquirer);
0045     if (run_) {
0046       run_->setSharedResourcesAcquirer(iResourceAcquirer);
0047     }
0048   }
0049 
0050   void LuminosityBlock::fillRun() const {
0051     run_.emplace(
0052         luminosityBlockPrincipal().runPrincipal(), provRecorder_.moduleDescription(), moduleCallingContext_, false);
0053     run_->setSharedResourcesAcquirer(provRecorder_.getSharedResourcesAcquirer());
0054     run_->setConsumer(provRecorder_.getConsumer());
0055   }
0056 
0057   void LuminosityBlock::setProducer(ProducerBase const* iProducer) {
0058     provRecorder_.setProducer(iProducer);
0059     //set appropriate size
0060     putProducts_.resize(provRecorder_.putTokenIndexToProductResolverIndex().size());
0061   }
0062 
0063   LuminosityBlockPrincipal const& LuminosityBlock::luminosityBlockPrincipal() const {
0064     return dynamic_cast<LuminosityBlockPrincipal const&>(provRecorder_.principal());
0065   }
0066 
0067   Provenance const& LuminosityBlock::getProvenance(BranchID const& bid) const {
0068     return luminosityBlockPrincipal().getProvenance(bid);
0069   }
0070 
0071   StableProvenance const& LuminosityBlock::getStableProvenance(BranchID const& bid) const {
0072     return luminosityBlockPrincipal().getStableProvenance(bid);
0073   }
0074 
0075   void LuminosityBlock::getAllStableProvenance(std::vector<StableProvenance const*>& provenances) const {
0076     luminosityBlockPrincipal().getAllStableProvenance(provenances);
0077   }
0078 
0079   void LuminosityBlock::commit_(std::vector<edm::ProductResolverIndex> const& iShouldPut) {
0080     LuminosityBlockPrincipal const& lbp = luminosityBlockPrincipal();
0081     size_t nPut = 0;
0082     for (size_t i = 0; i < putProducts().size(); ++i) {
0083       auto& p = get_underlying_safe(putProducts()[i]);
0084       if (p) {
0085         lbp.put(provRecorder_.putTokenIndexToProductResolverIndex()[i], std::move(p));
0086         ++nPut;
0087       }
0088     }
0089 
0090     auto sz = iShouldPut.size();
0091     if (sz != 0 and sz != nPut) {
0092       //some were missed
0093       auto& p = provRecorder_.principal();
0094       for (auto index : iShouldPut) {
0095         auto resolver = p.getProductResolverByIndex(index);
0096         if (not resolver->productResolved() and isEndTransition(provRecorder_.transition()) ==
0097                                                     resolver->branchDescription().availableOnlyAtEndTransition()) {
0098           dynamic_cast<ProductPutterBase const*>(resolver)->putProduct(std::unique_ptr<WrapperBase>());
0099         }
0100       }
0101     }
0102 
0103     // the cleanup is all or none
0104     putProducts().clear();
0105   }
0106 
0107   ProcessHistoryID const& LuminosityBlock::processHistoryID() const {
0108     return luminosityBlockPrincipal().processHistoryID();
0109   }
0110 
0111   ProcessHistory const& LuminosityBlock::processHistory() const { return provRecorder_.processHistory(); }
0112 
0113   BasicHandle LuminosityBlock::getByLabelImpl(std::type_info const&,
0114                                               std::type_info const& iProductType,
0115                                               const InputTag& iTag) const {
0116     BasicHandle h = provRecorder_.getByLabel_(TypeID(iProductType), iTag, moduleCallingContext_);
0117     return h;
0118   }
0119 }  // namespace edm