CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

edm::Principal Class Reference

#include <Principal.h>

Inheritance diagram for edm::Principal:
edm::EDProductGetter edm::EventPrincipal edm::LuminosityBlockPrincipal edm::RunPrincipal

List of all members.

Public Types

typedef std::vector< BasicHandleBasicHandleVec
typedef boost::filter_iterator
< FilledProductPtr,
ProductHolderCollection::const_iterator > 
const_iterator
typedef ProductHolderBase const * ConstProductPtr
typedef std::string ProcessName
typedef
ProcessHistory::const_iterator 
ProcessNameConstIterator
typedef std::vector
< boost::shared_ptr
< ProductHolderBase > > 
ProductHolderCollection
typedef boost::shared_ptr
< ProductHolderBase
SharedProductPtr
typedef
ProductHolderCollection::size_type 
size_type

Public Member Functions

void addAliasedProduct (boost::shared_ptr< ConstBranchDescription > bd)
void addInputProduct (boost::shared_ptr< ConstBranchDescription > bd)
void addScheduledProduct (boost::shared_ptr< ConstBranchDescription > bd)
void addSourceProduct (boost::shared_ptr< ConstBranchDescription > bd)
void addUnscheduledProduct (boost::shared_ptr< ConstBranchDescription > bd)
void adjustIndexesAfterProductRegistryAddition ()
bool adjustToNewProductRegistry (ProductRegistry const &reg)
const_iterator begin () const
BranchType const & branchType () const
void clearPrincipal ()
void deleteProduct (BranchID const &id)
const_iterator end () const
void fillPrincipal (ProcessHistoryID const &hist, DelayedReader *reader)
ProductData const * findProductByTag (TypeID const &typeID, InputTag const &tag) const
void getAllProvenance (std::vector< Provenance const * > &provenances) const
BasicHandle getByLabel (KindOfType kindOfType, TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process) const
BasicHandle getByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
BasicHandle getByToken (KindOfType kindOfType, TypeID const &typeID, ProductHolderIndex index, bool skipCurrentProcess, bool &ambiguous) const
OutputHandle getForOutput (BranchID const &bid, bool getProd) const
void getManyByType (TypeID const &typeID, BasicHandleVec &results) const
ConstProductPtr getProductByIndex (ProductHolderIndex const &oid, bool resolveProd, bool fillOnDemand) const
ConstProductPtr getProductHolder (BranchID const &oid, bool resolveProd, bool fillOnDemand) const
Provenance getProvenance (BranchID const &bid) const
bool isComplete () const
std::vector< unsigned int > const & lookupProcessOrder () const
 Principal (boost::shared_ptr< ProductRegistry const > reg, boost::shared_ptr< ProductHolderIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender)
ProcessConfiguration const & processConfiguration () const
ProcessHistory const & processHistory () const
ProcessHistoryID const & processHistoryID () const
EDProductGetter const * prodGetter () const
ProductHolderIndexHelper const & productLookup () const
ProductRegistry const & productRegistry () const
DelayedReaderreader () const
void recombine (Principal &other, std::vector< BranchID > const &bids)
void resolveProduct (ProductHolderBase const &phb, bool fillOnDemand) const
size_t size () const
virtual bool unscheduledFill (std::string const &moduleLabel) const =0
virtual ~Principal ()

Protected Member Functions

void addProduct_ (std::auto_ptr< ProductHolderBase > phb)
void addProductOrThrow (std::auto_ptr< ProductHolderBase > phb)
void checkUniquenessAndType (WrapperOwningHolder const &prod, ProductHolderBase const *productHolder) const
ProductHolderBasegetExistingProduct (ProductHolderBase const &phb)
ProductHolderBasegetExistingProduct (BranchID const &branchID)
void putOrMerge (WrapperOwningHolder const &prod, ProductHolderBase const *productHolder) const
void putOrMerge (WrapperOwningHolder const &prod, ProductProvenance &prov, ProductHolderBase *productHolder)

Private Member Functions

ProductData const * findProductByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
ProductData const * findProductByLabel (KindOfType kindOfType, TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process) const
void findProducts (std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results) const
virtual WrapperHolder getIt (ProductID const &) const
virtual bool isComplete_ () const
virtual void resolveProduct_ (ProductHolderBase const &, bool) const

Private Attributes

BranchType branchType_
HistoryAppenderhistoryAppender_
std::vector< unsigned int > lookupProcessOrder_
ProcessHistoryID orderProcessHistoryID_
boost::shared_ptr
< ProductRegistry const > 
preg_
ProcessConfiguration const * processConfiguration_
ProcessHistoryID processHistoryID_
ProcessHistory const * processHistoryPtr_
ProductHolderCollection productHolders_
boost::shared_ptr
< ProductHolderIndexHelper
const > 
productLookup_
std::set< void const * > productPtrs_
DelayedReaderreader_

Static Private Attributes

static const ProcessHistory emptyProcessHistory_

Detailed Description

Definition at line 52 of file Principal.h.


Member Typedef Documentation

Definition at line 58 of file Principal.h.

typedef boost::filter_iterator<FilledProductPtr, ProductHolderCollection::const_iterator> edm::Principal::const_iterator

Definition at line 55 of file Principal.h.

Reimplemented in edm::EventPrincipal.

Definition at line 57 of file Principal.h.

typedef std::string edm::Principal::ProcessName

Definition at line 62 of file Principal.h.

Definition at line 56 of file Principal.h.

typedef std::vector<boost::shared_ptr<ProductHolderBase> > edm::Principal::ProductHolderCollection

Definition at line 54 of file Principal.h.

Definition at line 61 of file Principal.h.

typedef ProductHolderCollection::size_type edm::Principal::size_type

Definition at line 59 of file Principal.h.


Constructor & Destructor Documentation

edm::Principal::Principal ( boost::shared_ptr< ProductRegistry const >  reg,
boost::shared_ptr< ProductHolderIndexHelper const >  productLookup,
ProcessConfiguration const &  pc,
BranchType  bt,
HistoryAppender historyAppender 
)

Definition at line 103 of file Principal.cc.

References addAliasedProduct(), addInputProduct(), addScheduledProduct(), addSourceProduct(), addUnscheduledProduct(), edm::ProductHolderIndexHelper::Range::begin(), edm::BranchDescription::branchType(), branchType_, edm::ProductHolderIndexHelper::Range::end(), spr::find(), i, edm::ProductHolderIndexHelper::IndexAndNames::index(), edm::InEvent, edm::BranchDescription::isAlias(), gen::k, edm::BranchDescription::moduleLabel(), edm::BranchDescription::onDemand(), LaserDQM_cfg::process, parseEventContent::prod, edm::BranchDescription::produced(), edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup_, diffTwoXMLs::ranges, LaserTracksInput_cfi::source, edm::ProductHolderIndexHelper::IndexAndNames::startInProcessNames(), and AlCaHLTBitMon_QueryRunRegistry::string.

                                                         :
    EDProductGetter(),
    processHistoryPtr_(nullptr),
    processHistoryID_(),
    processConfiguration_(&pc),
    productHolders_(reg->getNextIndexValue(bt), SharedProductPtr()),
    preg_(reg),
    productLookup_(productLookup),
    lookupProcessOrder_(productLookup->lookupProcessNames().size(), 0),
    reader_(),
    productPtrs_(),
    branchType_(bt),
    historyAppender_(historyAppender) {

    //Now that these have been set, we can create the list of Branches we need.
    std::string const source("source");
    ProductRegistry::ProductList const& prodsList = reg->productList();
    // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
    // So, the non-alias product holders must be created first.
    // Therefore, on this first pass, skip current EDAliases.
    bool hasAliases = false;
    for(auto const& prod : prodsList) {
      BranchDescription const& bd = prod.second;
      if(bd.branchType() == branchType_) {
        if(bd.isAlias()) {
          hasAliases = true;
        } else {
          boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
          if(bd.produced()) {
            if(bd.moduleLabel() == source) {
              addSourceProduct(cbd);
            } else if(bd.onDemand()) {
              assert(branchType_ == InEvent);
              addUnscheduledProduct(cbd);
            } else {
              addScheduledProduct(cbd);
            }
          } else {
            addInputProduct(cbd);
          }
        }
      }
    }
    // Now process any EDAliases
    if(hasAliases) {
      for(auto const& prod : prodsList) {
        BranchDescription const& bd = prod.second;
        if(bd.isAlias() && bd.branchType() == branchType_) {
          boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
          addAliasedProduct(cbd);
        }
      }
    }

    // Now create the ProductHolders that search in reverse process
    // order and are used for queries where the process name is the
    // empty string
    std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
    std::vector<ProductHolderIndex> matchingHolders(lookupProcessNames.size(), ProductHolderIndexInvalid);
    std::vector<bool> ambiguous(lookupProcessNames.size(), false);
    unsigned int beginElements = productLookup_->beginElements();
    std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
    std::vector<ProductHolderIndexHelper::Range> const& ranges = productLookup_->ranges();
    std::vector<ProductHolderIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
    std::vector<char> const& processNamesCharArray = productLookup_->processNames();

    if (!sortedTypeIDs.empty()) {
      ProductHolderIndex productHolderIndex = ProductHolderIndexInvalid;
      for(unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
        ProductHolderIndexHelper::Range const& range = ranges.at(k);
        for (unsigned int i = range.begin(); i < range.end(); ++i) {
          ProductHolderIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
          if (product.startInProcessNames() == 0) {
            if (productHolderIndex != ProductHolderIndexInvalid) {
              boost::shared_ptr<ProductHolderBase> newHolder(new NoProcessProductHolder(matchingHolders, ambiguous, this));
              productHolders_.at(productHolderIndex) = newHolder;
              matchingHolders.assign(lookupProcessNames.size(), ProductHolderIndexInvalid);
              ambiguous.assign(lookupProcessNames.size(), false);
            }
            productHolderIndex = product.index();
          } else {
            std::string process(&processNamesCharArray.at(product.startInProcessNames()));
            auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
            assert(iter != lookupProcessNames.end());
            ProductHolderIndex iMatchingIndex = product.index();
            assert(iMatchingIndex != ProductHolderIndexInvalid);
            if (iMatchingIndex == ProductHolderIndexAmbiguous) {
              assert(k >= beginElements);
              ambiguous.at(iter - lookupProcessNames.begin()) = true;
            } else {
              matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
            }
          }
        }
      }
      boost::shared_ptr<ProductHolderBase> newHolder(new NoProcessProductHolder(matchingHolders, ambiguous, this));
      productHolders_.at(productHolderIndex) = newHolder;
    }
  }
edm::Principal::~Principal ( ) [virtual]

Definition at line 207 of file Principal.cc.

                        {
  }

Member Function Documentation

void edm::Principal::addAliasedProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 270 of file Principal.cc.

References addProductOrThrow(), getHLTprescales::index, preg_, edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by Principal().

                                                                         {
    ProductHolderIndex index = preg_->indexFrom(bd->originalBranchID());
    assert(index != ProductHolderIndexInvalid);

    std::auto_ptr<ProductHolderBase> phb(new AliasProductHolder(bd, dynamic_cast<ProducedProductHolder&>(*productHolders_[index])));
    addProductOrThrow(phb);
  }
void edm::Principal::addInputProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 258 of file Principal.cc.

References addProductOrThrow().

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

                                                                       {
    std::auto_ptr<ProductHolderBase> phb(new InputProductHolder(bd, this));
    addProductOrThrow(phb);
  }
void edm::Principal::addProduct_ ( std::auto_ptr< ProductHolderBase phb) [protected]

Definition at line 368 of file Principal.cc.

References edm::ConstBranchDescription::branchID(), edm::ConstBranchDescription::className(), edm::ConstBranchDescription::friendlyClassName(), getHLTprescales::index, edm::ConstBranchDescription::moduleLabel(), preg_, edm::ConstBranchDescription::processName(), edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by addProductOrThrow().

                                                                     {
    ConstBranchDescription const& bd = productHolder->branchDescription();
    assert (!bd.className().empty());
    assert (!bd.friendlyClassName().empty());
    assert (!bd.moduleLabel().empty());
    assert (!bd.processName().empty());
    SharedProductPtr phb(productHolder);

    ProductHolderIndex index = preg_->indexFrom(bd.branchID());
    assert(index != ProductHolderIndexInvalid);
    productHolders_[index] = phb;
  }
void edm::Principal::addProductOrThrow ( std::auto_ptr< ProductHolderBase phb) [protected]

Definition at line 382 of file Principal.cc.

References addProduct_(), Exception, edm::ConstBranchDescription::friendlyClassName(), getExistingProduct(), edm::errors::InsertFailure, edm::ConstBranchDescription::moduleLabel(), edm::ConstBranchDescription::processName(), and edm::ConstBranchDescription::productInstanceName().

Referenced by addAliasedProduct(), addInputProduct(), addScheduledProduct(), addSourceProduct(), and addUnscheduledProduct().

                                                                           {
    ProductHolderBase const* phb = getExistingProduct(*productHolder);
    if(phb != nullptr) {
      ConstBranchDescription const& bd = productHolder->branchDescription();
      throw Exception(errors::InsertFailure, "AlreadyPresent")
          << "addProductOrThrow: Problem found while adding product, "
          << "product already exists for ("
          << bd.friendlyClassName() << ","
          << bd.moduleLabel() << ","
          << bd.productInstanceName() << ","
          << bd.processName()
          << ")\n";
    }
    addProduct_(productHolder);
  }
void edm::Principal::addScheduledProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 246 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

                                                                           {
    std::auto_ptr<ProductHolderBase> phb(new ScheduledProductHolder(bd));
    addProductOrThrow(phb);
  }
void edm::Principal::addSourceProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 252 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

                                                                        {
    std::auto_ptr<ProductHolderBase> phb(new SourceProductHolder(bd));
    addProductOrThrow(phb);
  }
void edm::Principal::addUnscheduledProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 264 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

                                                                             {
    std::auto_ptr<ProductHolderBase> phb(new UnscheduledProductHolder(bd, this));
    addProductOrThrow(phb);
  }
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 785 of file Principal.cc.

References addInputProduct(), edm::BranchDescription::branchID(), edm::BranchDescription::branchType(), branchType_, getHLTprescales::index, preg_, parseEventContent::prod, edm::BranchDescription::produced(), edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by edm::StreamerInputSource::read().

                                                       {
    if(preg_->getNextIndexValue(branchType_) != productHolders_.size()) {
      productHolders_.resize(preg_->getNextIndexValue(branchType_));
      for(auto const& prod : preg_->productList()) {
        BranchDescription const& bd = prod.second;
        if(bd.branchType() == branchType_) {
          ProductHolderIndex index = preg_->indexFrom(bd.branchID());
          assert(index != ProductHolderIndexInvalid);
          if(!productHolders_[index]) {
            // no product holder.  Must add one. The new entry must be an input product holder.
            assert(!bd.produced());
            boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
            addInputProduct(cbd);
          }
        }
      }
    }
    assert(preg_->getNextIndexValue(branchType_) == productHolders_.size());
  }
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

Definition at line 229 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::ConstBranchDescription::branchName(), edm::BranchDescription::branchType(), branchType_, getExistingProduct(), parseEventContent::prod, edm::BranchDescription::produced(), edm::ProductRegistry::productList(), and edm::ProductHolderBase::resetBranchDescription().

Referenced by edm::StreamerInputSource::read().

                                                                  {
    ProductRegistry::ProductList const& prodsList = reg.productList();
    for(auto const& prod : prodsList) {
      BranchDescription const& bd = prod.second;
      if(!bd.produced() && (bd.branchType() == branchType_)) {
        boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
        ProductHolderBase* phb = getExistingProduct(cbd->branchID());
        if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
            return false;
        }
        phb->resetBranchDescription(cbd);
      }
    }
    return true;
  }
const_iterator edm::Principal::begin ( void  ) const [inline]
BranchType const& edm::Principal::branchType ( ) const [inline]

Definition at line 152 of file Principal.h.

References branchType_.

Referenced by findProductByLabel().

{return branchType_;}
void edm::Principal::checkUniquenessAndType ( WrapperOwningHolder const &  prod,
ProductHolderBase const *  productHolder 
) const [protected]

Definition at line 746 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::ConstBranchDescription::branchName(), edm::ProductHolderBase::checkType(), edm::WrapperHolder::isValid(), parseEventContent::prod, productPtrs_, reset(), edm::second(), edm::throwCorruptionException(), and edm::WrapperHolder::wrapper().

Referenced by edm::EventPrincipal::put(), edm::EventPrincipal::putOnRead(), putOrMerge(), and edm::EventPrincipal::resolveProduct_().

                                                                                                       {
    if(!prod.isValid()) return;
    // These are defensive checks against things that should never happen, but have.
    // Checks that the same physical product has not already been put into the event.
    bool alreadyPresent = !productPtrs_.insert(prod.wrapper()).second;
    if(alreadyPresent) {
      phb->checkType(prod);
      const_cast<WrapperOwningHolder&>(prod).reset();
      throwCorruptionException("checkUniquenessAndType", phb->branchDescription().branchName());
    }
    // Checks that the real type of the product matches the branch.
    phb->checkType(prod);
  }
void edm::Principal::clearPrincipal ( )

Definition at line 280 of file Principal.cc.

References processHistoryID_, processHistoryPtr_, parseEventContent::prod, productPtrs_, and reader_.

Referenced by edm::EventPrincipal::clearEventPrincipal().

                            {
    processHistoryPtr_ = 0;
    processHistoryID_ = ProcessHistoryID();
    reader_ = 0;
    for(auto const& prod : *this) {
      prod->resetProductData();
    }
    productPtrs_.clear();
  }
void edm::Principal::deleteProduct ( BranchID const &  id)

Definition at line 291 of file Principal.cc.

References edm::ProductHolderBase::deleteProduct(), getExistingProduct(), edm::ProductHolderBase::product(), and productPtrs_.

Referenced by edm::EarlyDeleteHelper::moduleRan().

                                             {
    ProductHolderBase* phb = getExistingProduct(id);
    assert(nullptr != phb);
    auto itFound = productPtrs_.find(phb->product().get());
    if(itFound != productPtrs_.end()) {
      productPtrs_.erase(itFound);
    } 
    phb->deleteProduct();
  }
const_iterator edm::Principal::end ( void  ) const [inline]
void edm::Principal::fillPrincipal ( ProcessHistoryID const &  hist,
DelayedReader reader 
)

Definition at line 303 of file Principal.cc.

References edm::HistoryAppender::appendToProcessHistory(), emptyProcessHistory_, Exception, spr::find(), edm::detail::ThreadSafeRegistry< KEY, T, E >::getMapped(), estimatePileup::hist, historyAppender_, edm::CachedHistory::inputProcessHistory(), instance, edm::Hash< I >::isValid(), gen::k, edm::errors::LogicError, lookupProcessOrder_, orderProcessHistoryID_, processConfiguration_, edm::CachedHistory::processHistory(), edm::CachedHistory::processHistoryID(), processHistoryID_, processHistoryPtr_, productLookup_, productRegistry(), edm::ProcessHistory::rbegin(), reader(), reader_, PhysicsTools::registry(), and edm::ProcessHistory::rend().

Referenced by edm::EventPrincipal::fillEventPrincipal(), edm::LuminosityBlockPrincipal::fillLuminosityBlockPrincipal(), and edm::RunPrincipal::fillRunPrincipal().

                                                                              {
    if(reader) {
      reader_ = reader;
    }

    ProcessHistory const* inputProcessHistory = 0;
    if (historyAppender_ && productRegistry().anyProductProduced()) {
      CachedHistory const& cachedHistory = 
        historyAppender_->appendToProcessHistory(hist,
                                                *processConfiguration_);
      processHistoryPtr_ = cachedHistory.processHistory();
      processHistoryID_ = cachedHistory.processHistoryID();
      inputProcessHistory = cachedHistory.inputProcessHistory();
    }
    else {
      if (hist.isValid()) {
        ProcessHistoryRegistry* registry = ProcessHistoryRegistry::instance();
        inputProcessHistory = registry->getMapped(hist);
        if (inputProcessHistory == 0) {
          throw Exception(errors::LogicError)
            << "Principal::fillPrincipal\n"
            << "Input ProcessHistory not found in registry\n"
            << "Contact a Framework developer\n";
        }
      } else {
        inputProcessHistory = &emptyProcessHistory_;
      }
      processHistoryID_ = hist;
      processHistoryPtr_ = inputProcessHistory;        
    }

    if (orderProcessHistoryID_ != processHistoryID_) {
      std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
      lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
      unsigned int k = 0;
      for (auto iter = processHistoryPtr_->rbegin(),
                iEnd = processHistoryPtr_->rend();
           iter != iEnd; ++iter) {
        auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
        if (nameIter == lookupProcessNames.end()) {
          continue;
        }
        lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
        ++k;
      }
      orderProcessHistoryID_ = processHistoryID_;
    }
  }
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag 
) const [private]

Definition at line 581 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, branchType(), edm::ELEMENT_TYPE, getHLTprescales::index, edm::ProductHolderIndexHelper::index(), edm::InputTag::indexFor(), edm::InputTag::instance(), edm::InputTag::label(), edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::InputTag::process(), edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup(), productRegistry(), edm::ProductHolderIndexHelper::relatedIndexes(), edm::throwAmbiguousException(), edm::InputTag::tryToCacheIndex(), and edm::InputTag::willSkipCurrentProcess().

Referenced by findProductByTag(), and getByLabel().

                                                                {

    bool skipCurrentProcess = inputTag.willSkipCurrentProcess();

    ProductHolderIndex index = inputTag.indexFor(typeID, branchType(), &productRegistry());

    if (index == ProductHolderIndexInvalid) {

      char const* processName = inputTag.process().c_str();
      if (skipCurrentProcess) {
        processName = "\0";
      }

      index = productLookup().index(kindOfType,
                                    typeID,
                                    inputTag.label().c_str(),
                                    inputTag.instance().c_str(),
                                    processName);

      if(index == ProductHolderIndexAmbiguous) {
        throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
      } else if (index == ProductHolderIndexInvalid) {
        ProductHolderIndexHelper::Matches matches =
          productLookup().relatedIndexes(kindOfType, typeID);

        if (matches.numberOfMatches() == 0) {
          maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
        }
        return 0;
      }
      inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
    }

    boost::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];

    ProductHolderBase::ResolveStatus resolveStatus;
    ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess);
    if(resolveStatus == ProductHolderBase::Ambiguous) {
      throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
    }
    return productData;
  }
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process 
) const [private]

Definition at line 627 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, edm::ELEMENT_TYPE, getHLTprescales::index, edm::ProductHolderIndexHelper::index(), edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup(), edm::ProductHolderIndexHelper::relatedIndexes(), and edm::throwAmbiguousException().

                                                                {

    ProductHolderIndex index = productLookup().index(kindOfType,
                                                     typeID,
                                                     label.c_str(),
                                                     instance.c_str(),
                                                     process.c_str());
   
    if(index == ProductHolderIndexAmbiguous) {
      throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
    } else if (index == ProductHolderIndexInvalid) {
      ProductHolderIndexHelper::Matches matches =
        productLookup().relatedIndexes(kindOfType, typeID);

      if (matches.numberOfMatches() == 0) {
        maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
      }
      return 0;
    }
    boost::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];

    ProductHolderBase::ResolveStatus resolveStatus;
    ProductData const* productData = productHolder->resolveProduct(resolveStatus, false);
    if(resolveStatus == ProductHolderBase::Ambiguous) {
      throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
    }
    return productData;
  }
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag 
) const

Definition at line 661 of file Principal.cc.

References findProductByLabel(), edm::PRODUCT_TYPE, and edm::throwNotFoundException().

Referenced by edm::getProductByTag().

                                                                             {
    ProductData const* productData =
      findProductByLabel(PRODUCT_TYPE,
                         typeID,
                         tag);
    if(productData == nullptr) {
      throwNotFoundException("findProductByTag", typeID, tag);
    }
    return productData;
  }
void edm::Principal::findProducts ( std::vector< ProductHolderBase const * > const &  holders,
TypeID const &  typeID,
BasicHandleVec results 
) const [private]

Definition at line 537 of file Principal.cc.

References edm::ConstBranchDescription::isAlias(), edm::ConstBranchDescription::moduleLabel(), LaserDQM_cfg::process, processHistoryPtr_, edm::ConstBranchDescription::processName(), edm::ConstBranchDescription::productInstanceName(), edm::ProcessHistory::rbegin(), edm::ProcessHistory::rend(), resolveProduct(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::throwProductDeletedException().

Referenced by getManyByType().

                                                         {

    for (auto iter = processHistoryPtr_->rbegin(),
              iEnd = processHistoryPtr_->rend();
         iter != iEnd; ++iter) {
      std::string const& process = iter->processName();
      for (auto productHolder : holders) {
        ConstBranchDescription const& bd = productHolder->branchDescription();
        if (process == bd.processName()) {

          // Ignore aliases to avoid matching the same product multiple times.
          if(bd.isAlias()) {
            continue;
          }

          //NOTE sometimes 'productHolder->productUnavailable()' is true if was already deleted
          if(productHolder->productWasDeleted()) {
            throwProductDeletedException("findProducts",
                                         typeID,
                                         bd.moduleLabel(),
                                         bd.productInstanceName(),
                                         bd.processName());
          }

          // Skip product if not available.
          if(!productHolder->productUnavailable()) {

            this->resolveProduct(*productHolder, true);
            // If the product is a dummy filler, product holder will now be marked unavailable.
            // Unscheduled execution can fail to produce the EDProduct so check
            if(productHolder->product() && !productHolder->productUnavailable() && !productHolder->onDemand()) {
              // Found a good match, save it
              BasicHandle bh(productHolder->productData());
              results.push_back(bh);
            }
          }
        }
      }
    }
  }
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 713 of file Principal.cc.

Referenced by edm::Event::getAllProvenance(), edm::Run::getAllProvenance(), edm::LuminosityBlock::getAllProvenance(), and edm::AsciiOutputModule::write().

                                                                             {
    provenances.clear();
    for(auto const& productHolder : *this) {
      if(productHolder->singleProduct() && productHolder->provenanceAvailable() && !productHolder->branchDescription().isAlias()) {
        // We do not attempt to get the event/lumi/run status from the provenance,
        // because the per event provenance may have been dropped.
        if(productHolder->provenance()->product().present()) {
           provenances.push_back(productHolder->provenance());
        }
      }
    }
  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag 
) const

Definition at line 421 of file Principal.cc.

References findProductByLabel(), edm::InputTag::instance(), edm::InputTag::label(), edm::makeNotFoundException(), edm::InputTag::process(), and query::result.

Referenced by edm::check(), and PileUpEventPrincipal::getByLabel().

                                                        {

    ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag);
    if(result == 0) {
      boost::shared_ptr<cms::Exception> whyFailed =
        makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process());
      return BasicHandle(whyFailed);
    }
    return BasicHandle(*result);
  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process 
) const

Definition at line 435 of file Principal.cc.

References findProductByLabel(), edm::makeNotFoundException(), and query::result.

                                                        {

    ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process);
    if(result == 0) {
      boost::shared_ptr<cms::Exception> whyFailed =
        makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
      return BasicHandle(whyFailed);
    }
    return BasicHandle(*result);
  }
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductHolderIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous 
) const

Definition at line 451 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, getHLTprescales::index, edm::ProductHolderIndexInvalid, and productHolders_.

                                               {
    assert(index !=ProductHolderIndexInvalid);
    boost::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
    assert(0!=productHolder.get());
    ProductHolderBase::ResolveStatus resolveStatus;
    ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess);
    if(resolveStatus == ProductHolderBase::Ambiguous) {
      ambiguous = true;
      return BasicHandle();
    }
    if(productData == 0) {
      return BasicHandle();
    }
    return BasicHandle(*productData);    
  }
ProductHolderBase * edm::Principal::getExistingProduct ( BranchID const &  branchID) [protected]
ProductHolderBase * edm::Principal::getExistingProduct ( ProductHolderBase const &  phb) [protected]

Definition at line 361 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::ConstBranchDescription::branchID(), and getExistingProduct().

                                                                      {
    ProductHolderBase* phb = getExistingProduct(productHolder.branchDescription().branchID());
    assert(nullptr == phb || BranchKey(productHolder.branchDescription()) == BranchKey(phb->branchDescription()));
    return phb;
  }
OutputHandle edm::Principal::getForOutput ( BranchID const &  bid,
bool  getProd 
) const

Definition at line 673 of file Principal.cc.

References getProductHolder(), edm::errors::LogicError, edm::throwProductDeletedException(), and edm::throwProductNotFoundException().

Referenced by edm::check(), edm::RootOutputFile::fillBranches(), edm::StreamSerializer::serializeEvent(), and edm::ProvenanceCheckerOutputModule::write().

                                                                 {
    ConstProductPtr const phb = getProductHolder(bid, getProd, true);
    if(phb == nullptr) {
      throwProductNotFoundException("getForOutput", errors::LogicError, bid);
    }
    if (phb->productWasDeleted()) {
      throwProductDeletedException("getForOutput",phb->productType(),
                                   phb->moduleLabel(),
                                   phb->productInstanceName(),
                                   phb->processName());
    }
    if(!phb->provenance() || (!phb->product() && !phb->productProvenancePtr())) {
      return OutputHandle();
    }
    return OutputHandle(WrapperHolder(phb->product().get(), phb->productData().getInterface()), &phb->branchDescription(), phb->productProvenancePtr());
  }
WrapperHolder edm::Principal::getIt ( ProductID const &  ) const [private, virtual]

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 740 of file Principal.cc.

                                         {
    assert(nullptr);
    return WrapperHolder();
  }
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results 
) const

Definition at line 472 of file Principal.cc.

References findProducts(), i, getHLTprescales::index, edm::maybeThrowMissingDictionaryException(), preg_, edm::PRODUCT_TYPE, productHolders_, productLookup(), and edm::ProductHolderIndexHelper::relatedIndexes().

                                                          {

    assert(results.empty());

    // This finds the indexes to all the ProductHolder's matching the type
    ProductHolderIndexHelper::Matches matches =
      productLookup().relatedIndexes(PRODUCT_TYPE, typeID);

    if (matches.numberOfMatches() == 0) {
      maybeThrowMissingDictionaryException(typeID, false, preg_->missingDictionaries());
      return;
    }

    results.reserve(matches.numberOfMatches());

    // Loop over the ProductHolders. Add the products that are actually
    // present into the results. This will also trigger delayed reading,
    // on demand production, and check for deleted products as appropriate.

    // Over the years the code that uses getManyByType has grown to depend
    // on the ordering of the results. The order originally was just an
    // accident of how previous versions of the code were written, but
    // here we have to go through some extra effort to preserve that ordering.

    // We build a list of holders that match a particular label and instance.
    // When that list is complete we call findProducts, which loops over
    // that list in reverse order of the ProcessHistory (starts with the
    // most recent).  Then we clear the list and repeat this until all the
    // matching label and instance subsets have been dealt with.

    // Note that the function isFullyResolved returns true for the ProductHolders
    // that are associated with an empty process name. Those are the ones that
    // know how to search for the most recent process name matching
    // a label and instance. We do not need these for getManyByType and
    // skip them. In addition to skipping them, we make use of the fact
    // that they mark the beginning of each subset of holders with the same
    // label and instance. They tell us when to call findProducts. 

    std::vector<ProductHolderBase const*> holders;

    for(unsigned int i = 0; i < matches.numberOfMatches(); ++i) {

      ProductHolderIndex index = matches.index(i);

      if(!matches.isFullyResolved(i)) {
        if(!holders.empty()) {
          // Process the ones with a particular module label and instance
          findProducts(holders, typeID, results);
          holders.clear();
        }
      } else {
        ProductHolderBase const* productHolder = productHolders_.at(index).get();
        assert(productHolder);
        holders.push_back(productHolder);
      }
    }
    // Do not miss the last subset of products
    if(!holders.empty()) {
      findProducts(holders, typeID, results);
    }
    return;
  }
Principal::ConstProductPtr edm::Principal::getProductByIndex ( ProductHolderIndex const &  oid,
bool  resolveProd,
bool  fillOnDemand 
) const

Definition at line 408 of file Principal.cc.

References getHLTprescales::index, productHolders_, and resolveProduct().

Referenced by getProductHolder(), and edm::NoProcessProductHolder::resolveProduct_().

                                                                                                         {

    ConstProductPtr const phb = productHolders_[index].get();
    if(nullptr == phb) {
      return phb;
    }
    if(resolveProd && !phb->productUnavailable()) {
      this->resolveProduct(*phb, fillOnDemand);
    }
    return phb;
  }
Principal::ConstProductPtr edm::Principal::getProductHolder ( BranchID const &  oid,
bool  resolveProd,
bool  fillOnDemand 
) const
Provenance edm::Principal::getProvenance ( BranchID const &  bid) const

Definition at line 691 of file Principal.cc.

References getProductHolder(), edm::errors::ProductNotFound, edm::throwProductNotFoundException(), and unscheduledFill().

Referenced by edm::LuminosityBlock::getProvenance(), edm::Run::getProvenance(), and edm::Event::getProvenance().

                                                    {
    ConstProductPtr const phb = getProductHolder(bid, false, true);
    if(phb == nullptr) {
      throwProductNotFoundException("getProvenance", errors::ProductNotFound, bid);
    }

    if(phb->onDemand()) {
      unscheduledFill(phb->branchDescription().moduleLabel());
    }
    // We already tried to produce the unscheduled products above
    // If they still are not there, then throw
    if(phb->onDemand()) {
      throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
    }

    return *phb->provenance();
  }
bool edm::Principal::isComplete ( ) const [inline]

Definition at line 177 of file Principal.h.

References isComplete_().

{return isComplete_();}
virtual bool edm::Principal::isComplete_ ( ) const [inline, private, virtual]

Reimplemented in edm::LuminosityBlockPrincipal, and edm::RunPrincipal.

Definition at line 216 of file Principal.h.

Referenced by isComplete().

{return true;}
std::vector<unsigned int> const& edm::Principal::lookupProcessOrder ( ) const [inline]

Definition at line 171 of file Principal.h.

References lookupProcessOrder_.

Referenced by edm::NoProcessProductHolder::resolveProduct_().

{ return lookupProcessOrder_; }
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const [inline]

Definition at line 133 of file Principal.h.

References processConfiguration_.

ProcessHistory const& edm::Principal::processHistory ( ) const [inline]

Definition at line 125 of file Principal.h.

References processHistoryPtr_.

Referenced by edm::StreamSerializer::serializeEvent(), and edm::AsciiOutputModule::write().

                                                 {
      return *processHistoryPtr_;
    }
ProcessHistoryID const& edm::Principal::processHistoryID ( ) const [inline]
EDProductGetter const* edm::Principal::prodGetter ( ) const [inline]

Definition at line 92 of file Principal.h.

{return this;}
ProductHolderIndexHelper const& edm::Principal::productLookup ( ) const [inline]

Definition at line 137 of file Principal.h.

References productLookup_.

Referenced by findProductByLabel(), and getManyByType().

{return *productLookup_;}
ProductRegistry const& edm::Principal::productRegistry ( ) const [inline]
void edm::Principal::putOrMerge ( WrapperOwningHolder const &  prod,
ProductHolderBase const *  productHolder 
) const [protected]
void edm::Principal::putOrMerge ( WrapperOwningHolder const &  prod,
ProductProvenance prov,
ProductHolderBase productHolder 
) [protected]

Definition at line 773 of file Principal.cc.

References edm::ProductHolderBase::checkType(), checkUniquenessAndType(), edm::ProductHolderBase::mergeProduct(), edm::ProductHolderBase::putOrMergeProduct(), and edm::ProductHolderBase::putProduct().

                                                                                                        {
    bool willBePut = phb->putOrMergeProduct();
    if(willBePut) {
      checkUniquenessAndType(prod, phb);
      phb->putProduct(prod, prov);
    } else {
      phb->checkType(prod);
      phb->mergeProduct(prod, prov);
    }
  }
DelayedReader* edm::Principal::reader ( ) const [inline]
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

Definition at line 727 of file Principal.cc.

References getHLTprescales::index, edm::DelayedReader::mergeReaders(), preg_, parseEventContent::prod, edm::ProductHolderIndexInvalid, productHolders_, reader(), and reader_.

Referenced by edm::PoolSource::readEvent_().

                                                                        {
    for(auto const& prod : bids) {
      ProductHolderIndex index= preg_->indexFrom(prod);
      assert(index!=ProductHolderIndexInvalid);
      ProductHolderIndex indexO = other.preg_->indexFrom(prod);
      assert(indexO!=ProductHolderIndexInvalid);
      productHolders_[index].swap(other.productHolders_[indexO]);
      productHolders_[index]->setPrincipal(this);
    }
    reader_->mergeReaders(other.reader());
  }
void edm::Principal::resolveProduct ( ProductHolderBase const &  phb,
bool  fillOnDemand 
) const [inline]

Definition at line 167 of file Principal.h.

References resolveProduct_().

Referenced by findProducts(), getProductByIndex(), and edm::InputProductHolder::resolveProduct_().

{resolveProduct_(phb, fillOnDemand);}
virtual void edm::Principal::resolveProduct_ ( ProductHolderBase const &  ,
bool   
) const [inline, private, virtual]

Reimplemented in edm::EventPrincipal.

Definition at line 214 of file Principal.h.

Referenced by resolveProduct().

{}
size_t edm::Principal::size ( void  ) const

Definition at line 214 of file Principal.cc.

References parseEventContent::prod.

Referenced by edm::SecSourceAnalyzer::getBranches(), edm::StreamerInputSource::read(), and edm::Event::size().

                        {
    size_t size = 0U;
    for(auto const& prod : *this) {
      if(prod->singleProduct() && // Not a NoProcessProductHolder
         !prod->productUnavailable() &&
         !prod->onDemand() &&
         !prod->branchDescription().dropped()) {
        ++size;
      }
    }
    return size;
  }
virtual bool edm::Principal::unscheduledFill ( std::string const &  moduleLabel) const [pure virtual]

Member Data Documentation

Definition at line 249 of file Principal.h.

Referenced by fillPrincipal().

Definition at line 247 of file Principal.h.

Referenced by fillPrincipal().

std::vector<unsigned int> edm::Principal::lookupProcessOrder_ [private]

Definition at line 232 of file Principal.h.

Referenced by fillPrincipal(), and lookupProcessOrder().

Definition at line 233 of file Principal.h.

Referenced by fillPrincipal().

boost::shared_ptr<ProductRegistry const> edm::Principal::preg_ [private]

Definition at line 222 of file Principal.h.

Referenced by fillPrincipal(), and processConfiguration().

Definition at line 220 of file Principal.h.

Referenced by clearPrincipal(), fillPrincipal(), and processHistoryID().

Definition at line 218 of file Principal.h.

Referenced by clearPrincipal(), fillPrincipal(), findProducts(), and processHistory().

boost::shared_ptr<ProductHolderIndexHelper const> edm::Principal::productLookup_ [private]

Definition at line 230 of file Principal.h.

Referenced by fillPrincipal(), Principal(), and productLookup().

std::set<void const*> edm::Principal::productPtrs_ [mutable, private]

Definition at line 240 of file Principal.h.

Referenced by checkUniquenessAndType(), clearPrincipal(), and deleteProduct().

Definition at line 237 of file Principal.h.

Referenced by clearPrincipal(), fillPrincipal(), reader(), and recombine().