CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Private Types | 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
< FilledGroupPtr,
GroupCollection::const_iterator > 
const_iterator
typedef Group const * ConstGroupPtr
typedef std::vector
< boost::shared_ptr< Group > > 
GroupCollection
typedef std::string ProcessName
typedef
ProcessHistory::const_iterator 
ProcessNameConstIterator
typedef boost::shared_ptr< GroupSharedGroupPtr
typedef GroupCollection::size_type size_type

Public Member Functions

void addGroupAliased (boost::shared_ptr< ConstBranchDescription > bd)
void addGroupInput (boost::shared_ptr< ConstBranchDescription > bd)
void addGroupScheduled (boost::shared_ptr< ConstBranchDescription > bd)
void addGroupSource (boost::shared_ptr< ConstBranchDescription > bd)
void addOnDemandGroup (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 * findGroupByTag (TypeID const &typeID, InputTag const &tag) const
void getAllProvenance (std::vector< Provenance const * > &provenances) const
BasicHandle getByLabel (TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName, size_t &cachedOffset, int &fillCount) const
OutputHandle getForOutput (BranchID const &bid, bool getProd) const
ConstGroupPtr getGroup (BranchID const &oid, bool resolveProd, bool fillOnDemand) const
void getManyByType (TypeID const &tid, BasicHandleVec &results) const
size_t getMatchingSequence (TypeID const &typeID, std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, BasicHandle &result) const
Provenance getProvenance (BranchID const &bid) const
void maybeFlushCache (TypeID const &tid, InputTag const &tag) const
 Principal (boost::shared_ptr< ProductRegistry const > reg, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender)
ProcessConfiguration const & processConfiguration () const
ProcessHistory const & processHistory () const
ProcessHistoryID const & processHistoryID () const
EDProductGetter const * prodGetter () const
ProductRegistry const & productRegistry () const
DelayedReaderreader () const
void recombine (Principal &other, std::vector< BranchID > const &bids)
size_t size () const
virtual ~Principal ()

Protected Member Functions

void addGroup_ (std::auto_ptr< Group > g)
void addGroupOrThrow (std::auto_ptr< Group > g)
void checkUniquenessAndType (WrapperOwningHolder const &prod, Group const *group) const
GroupgetExistingGroup (Group const &g)
GroupgetExistingGroup (BranchID const &branchID)
ConstGroupPtr getGroupByIndex (ProductTransientIndex const &oid, bool resolveProd, bool fillOnDemand) const
void putOrMerge (WrapperOwningHolder const &prod, ProductProvenance &prov, Group *group)
void putOrMerge (WrapperOwningHolder const &prod, Group const *group) const
void resolveProduct (Group const &g, bool fillOnDemand) const

Private Types

typedef TransientProductLookupMap TypeLookup

Private Member Functions

size_t findGroup (TypeID const &typeID, TypeLookup const &typeLookup, std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, BasicHandle &result) const
ProductData const * findGroupByLabel (TypeID const &typeID, TypeLookup const &typeLookup, std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, size_t &cachedOffset, int &fillCount) const
size_t findGroups (TypeID const &typeID, TypeLookup const &typeLookup, BasicHandleVec &results) const
virtual WrapperHolder getIt (ProductID const &) const
virtual void resolveProduct_ (Group const &, bool) const
virtual bool unscheduledFill (std::string const &moduleLabel) const =0

Private Attributes

BranchType branchType_
GroupCollection groups_
HistoryAppenderhistoryAppender_
boost::shared_ptr
< ProductRegistry const > 
preg_
ProcessConfiguration const * processConfiguration_
ProcessHistoryID processHistoryID_
ProcessHistory const * processHistoryPtr_
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<FilledGroupPtr, GroupCollection::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::vector<boost::shared_ptr<Group> > edm::Principal::GroupCollection

Definition at line 54 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 boost::shared_ptr<Group> edm::Principal::SharedGroupPtr

Definition at line 61 of file Principal.h.

typedef GroupCollection::size_type edm::Principal::size_type

Definition at line 59 of file Principal.h.

Definition at line 188 of file Principal.h.


Constructor & Destructor Documentation

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

Definition at line 83 of file Principal.cc.

References addGroupAliased(), addGroupInput(), addGroupScheduled(), addGroupSource(), addOnDemandGroup(), edm::BranchDescription::branchType(), branchType_, edm::InEvent, edm::BranchDescription::isAlias(), edm::BranchDescription::moduleLabel(), edm::BranchDescription::onDemand(), parseEventContent::prod, edm::BranchDescription::produced(), LaserTracksInput_cfi::source, and AlCaHLTBitMon_QueryRunRegistry::string.

                                                         :
    EDProductGetter(),
    processHistoryPtr_(0),
    processHistoryID_(),
    processConfiguration_(&pc),
    groups_(reg->constProductList().size(), SharedGroupPtr()),
    preg_(reg),
    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 group takes as an argument the group for which it is an alias.
    // So, the non-alias groups 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) {
              addGroupSource(cbd);
            } else if(bd.onDemand()) {
              assert(branchType_ == InEvent);
              addOnDemandGroup(cbd);
            } else {
              addGroupScheduled(cbd);
            }
          } else {
            addGroupInput(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));
          addGroupAliased(cbd);
        }
      }
    }
  }
edm::Principal::~Principal ( ) [virtual]

Definition at line 139 of file Principal.cc.

                        {
  }

Member Function Documentation

void edm::Principal::addGroup_ ( std::auto_ptr< Group g) [protected]

Definition at line 291 of file Principal.cc.

References edm::ConstBranchDescription::branchID(), edm::ConstBranchDescription::className(), edm::ConstBranchDescription::friendlyClassName(), g, groups_, getHLTprescales::index, edm::ProductRegistry::kInvalidIndex, edm::ConstBranchDescription::moduleLabel(), preg_, and edm::ConstBranchDescription::processName().

Referenced by addGroupOrThrow().

                                               {
    ConstBranchDescription const& bd = group->branchDescription();
    assert (!bd.className().empty());
    assert (!bd.friendlyClassName().empty());
    assert (!bd.moduleLabel().empty());
    assert (!bd.processName().empty());
    SharedGroupPtr g(group);

    ProductTransientIndex index = preg_->indexFrom(bd.branchID());
    assert(index != ProductRegistry::kInvalidIndex);
    groups_[index] = g;
  }
void edm::Principal::addGroupAliased ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 205 of file Principal.cc.

References addGroupOrThrow(), g, groups_, getHLTprescales::index, edm::ProductRegistry::kInvalidIndex, and preg_.

Referenced by Principal().

                                                                       {
    ProductTransientIndex index = preg_->indexFrom(bd->originalBranchID());
    assert(index != ProductRegistry::kInvalidIndex);

    std::auto_ptr<Group> g(new AliasGroup(bd, dynamic_cast<ProducedGroup&>(*groups_[index])));
    addGroupOrThrow(g);
  }
void edm::Principal::addGroupInput ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 193 of file Principal.cc.

References addGroupOrThrow(), and g.

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

                                                                     {
    std::auto_ptr<Group> g(new InputGroup(bd));
    addGroupOrThrow(g);
  }
void edm::Principal::addGroupOrThrow ( std::auto_ptr< Group g) [protected]

Definition at line 305 of file Principal.cc.

References addGroup_(), Exception, edm::ConstBranchDescription::friendlyClassName(), g, getExistingGroup(), edm::errors::InsertFailure, edm::ConstBranchDescription::moduleLabel(), edm::ConstBranchDescription::processName(), and edm::ConstBranchDescription::productInstanceName().

Referenced by addGroupAliased(), addGroupInput(), addGroupScheduled(), addGroupSource(), and addOnDemandGroup().

                                                     {
    Group const* g = getExistingGroup(*group);
    if(g != 0) {
      ConstBranchDescription const& bd = group->branchDescription();
      throw Exception(errors::InsertFailure, "AlreadyPresent")
          << "addGroupOrThrow: Problem found while adding product, "
          << "product already exists for ("
          << bd.friendlyClassName() << ","
          << bd.moduleLabel() << ","
          << bd.productInstanceName() << ","
          << bd.processName()
          << ")\n";
    }
    addGroup_(group);
  }
void edm::Principal::addGroupScheduled ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 181 of file Principal.cc.

References addGroupOrThrow(), and g.

Referenced by Principal().

                                                                         {
    std::auto_ptr<Group> g(new ScheduledGroup(bd));
    addGroupOrThrow(g);
  }
void edm::Principal::addGroupSource ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 187 of file Principal.cc.

References addGroupOrThrow(), and g.

Referenced by Principal().

                                                                      {
    std::auto_ptr<Group> g(new SourceGroup(bd));
    addGroupOrThrow(g);
  }
void edm::Principal::addOnDemandGroup ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 199 of file Principal.cc.

References addGroupOrThrow(), and g.

Referenced by Principal().

                                                                        {
    std::auto_ptr<Group> g(new UnscheduledGroup(bd));
    addGroupOrThrow(g);
  }
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 744 of file Principal.cc.

References addGroupInput(), begin(), branchType_, end(), groups_, i, getHLTprescales::index, edm::ProductRegistry::kInvalidIndex, and preg_.

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

                                                       {
    if(preg_->constProductList().size() > groups_.size()) {
      GroupCollection newGroups(preg_->constProductList().size(), SharedGroupPtr());
      for (Principal::const_iterator i = begin(), iEnd = end(); i != iEnd; ++i) {
        ProductTransientIndex index = preg_->indexFrom((*i)->branchDescription().branchID());
        assert(index != ProductRegistry::kInvalidIndex);
        newGroups[index] = *i;
      }
      groups_.swap(newGroups);
      // Now we must add new groups for any new product registry entries.
      ProductRegistry::ProductList const& prodsList = preg_->productList();
      for(ProductRegistry::ProductList::const_iterator itProdInfo = prodsList.begin(),
          itProdInfoEnd = prodsList.end();
          itProdInfo != itProdInfoEnd;
          ++itProdInfo) {
        if(itProdInfo->second.branchType() == branchType_) {
          ProductTransientIndex index = preg_->indexFrom(itProdInfo->second.branchID());
          assert(index != ProductRegistry::kInvalidIndex);
          if(!groups_[index]) {
            // no group.  Must add one. The new entry must be an input group.
            assert(!itProdInfo->second.produced());
            boost::shared_ptr<ConstBranchDescription> bd(new ConstBranchDescription(itProdInfo->second));
            addGroupInput(bd);
          }
        }
      }
    }
    assert(preg_->constProductList().size() == groups_.size());
  }
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

Definition at line 159 of file Principal.cc.

References edm::Group::branchDescription(), edm::ConstBranchDescription::branchName(), branchType_, edm::ProductRegistry::constProductList(), g, getExistingGroup(), groups_, edm::ProductRegistry::productList(), and edm::Group::resetBranchDescription().

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

                                                                  {
    if(reg.constProductList().size() > groups_.size()) {
      return false;
    }
    ProductRegistry::ProductList const& prodsList = reg.productList();
    for(ProductRegistry::ProductList::const_iterator itProdInfo = prodsList.begin(),
          itProdInfoEnd = prodsList.end();
        itProdInfo != itProdInfoEnd;
        ++itProdInfo) {
    if(!itProdInfo->second.produced() && (itProdInfo->second.branchType() == branchType_)) {
        boost::shared_ptr<ConstBranchDescription> bd(new ConstBranchDescription(itProdInfo->second));
        Group *g = getExistingGroup(itProdInfo->second.branchID());
        if(g == 0 || g->branchDescription().branchName() != bd->branchName()) {
            return false;
        }
        g->resetBranchDescription(bd);
      }
    }
    return true;
  }
const_iterator edm::Principal::begin ( void  ) const [inline]
BranchType const& edm::Principal::branchType ( ) const [inline]

Definition at line 142 of file Principal.h.

References branchType_.

Referenced by maybeFlushCache().

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

Definition at line 705 of file Principal.cc.

References edm::Group::branchDescription(), edm::ConstBranchDescription::branchName(), edm::Group::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) {
      g->checkType(prod);
      const_cast<WrapperOwningHolder&>(prod).reset();
      throwCorruptionException("checkUniquenessAndType", g->branchDescription().branchName());
    }
    // Checks that the real type of the product matches the branch.
    g->checkType(prod);
  }
void edm::Principal::clearPrincipal ( )

Definition at line 215 of file Principal.cc.

References begin(), end(), i, processHistoryID_, processHistoryPtr_, productPtrs_, and reader_.

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

                            {
    processHistoryPtr_ = 0;
    processHistoryID_ = ProcessHistoryID();
    reader_ = 0;
    for (Principal::const_iterator i = begin(), iEnd = end(); i != iEnd; ++i) {
      (*i)->resetProductData();
    }
    productPtrs_.clear();
  }
void edm::Principal::deleteProduct ( BranchID const &  id)

Definition at line 226 of file Principal.cc.

References edm::Group::deleteProduct(), g, getExistingGroup(), edm::Group::product(), and productPtrs_.

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

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

Definition at line 238 of file Principal.cc.

References edm::HistoryAppender::appendToProcessHistory(), branchType_, emptyProcessHistory_, Exception, edm::detail::ThreadSafeRegistry< KEY, T, E >::getMapped(), estimatePileup::hist, historyAppender_, edm::CachedHistory::inputProcessHistory(), instance, edm::Hash< I >::isValid(), edm::errors::LogicError, preg_, processConfiguration_, edm::CachedHistory::processHistory(), edm::CachedHistory::processHistoryID(), processHistoryID_, processHistoryPtr_, edm::ProcessConfiguration::processName(), productRegistry(), reader(), reader_, and PhysicsTools::registry.

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;        
    }

    preg_->productLookup().reorderIfNecessary(branchType_, *inputProcessHistory,
                                         processConfiguration_->processName());
    preg_->elementLookup().reorderIfNecessary(branchType_, *inputProcessHistory,
                                         processConfiguration_->processName());
  }
size_t edm::Principal::findGroup ( TypeID const &  typeID,
TypeLookup const &  typeLookup,
std::string const &  moduleLabel,
std::string const &  productInstanceName,
std::string const &  processName,
BasicHandle result 
) const [private]

Definition at line 445 of file Principal.cc.

References branchType_, prof2calltree::count, edm::TransientProductLookupMap::equal_range(), getGroupByIndex(), edm::BasicHandle::isValid(), edm::max(), edm::maybeThrowMissingDictionaryException(), edm::ConstBranchDescription::moduleLabel(), preg_, edm::ConstBranchDescription::processName(), edm::ConstBranchDescription::productInstanceName(), resolveProduct(), and edm::throwProductDeletedException().

Referenced by getMatchingSequence().

                                                  {
    assert(!result.isValid());

    size_t count = 0U;

    typedef TransientProductLookupMap TypeLookup;
    // A class without a dictionary cannot be in an Event/Lumi/Run.
    // First, we check if the class has a dictionary.  If it does not, we throw an exception.
    // The missing dictionary might be for the class itself, the wrapped class, or a component of the class.
    std::pair<TypeLookup::const_iterator, TypeLookup::const_iterator> const range = typeLookup.equal_range(TypeInBranchType(typeID, branchType_));
    if(range.first == range.second) {
      maybeThrowMissingDictionaryException(typeID, &typeLookup == &preg_->elementLookup(), preg_->missingDictionaries());
    }

    unsigned int processLevelFound = std::numeric_limits<unsigned int>::max();
    for(TypeLookup::const_iterator it = range.first; it != range.second; ++it) {
      if(it->processIndex() > processLevelFound) {
        //this is for a less recent process and we've already found a match for a more recent process
        continue;
      }

      ConstBranchDescription const& bd = *(it->branchDescription());

      if ( moduleLabel == bd.moduleLabel() &&
           productInstanceName == bd.productInstanceName() &&
           (processName.empty() || processName == bd.processName())) {

        //now see if the data is actually available
        ConstGroupPtr const& group = getGroupByIndex(it->index(), false, false);
        if(group && group->productWasDeleted()) {
          throwProductDeletedException("findGroup",
                                       typeID,
                                       bd.moduleLabel(),
                                       bd.productInstanceName(),
                                       bd.processName());
        }

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

          this->resolveProduct(*group, true);
          // If the product is a dummy filler, group will now be marked unavailable.
          // Unscheduled execution can fail to produce the EDProduct so check
          if(group->product() && !group->productUnavailable() && !group->onDemand()) {
            if(it->processIndex() < processLevelFound) {
              processLevelFound = it->processIndex();
              count = 0U;
            }
            if(count == 0U) {
              // Found a unique (so far) match, save it
              result = BasicHandle(group->productData());
            }
            ++count;
          }
        }
      }
    }
    if(count != 1) result = BasicHandle();
    return count;
  }
ProductData const * edm::Principal::findGroupByLabel ( TypeID const &  typeID,
TypeLookup const &  typeLookup,
std::string const &  moduleLabel,
std::string const &  productInstanceName,
std::string const &  processName,
size_t &  cachedOffset,
int &  fillCount 
) const [private]

Definition at line 512 of file Principal.cc.

References edm::TransientProductLookupMap::begin(), branchType_, edm::TransientProductLookupMap::end(), edm::TransientProductLookupMap::equal_range(), edm::TransientProductLookupMap::fillCount(), getGroupByIndex(), edm::maybeThrowMissingDictionaryException(), preg_, resolveProduct(), and edm::throwProductDeletedException().

Referenced by findGroupByTag(), and getByLabel().

                                                    {

    typedef TransientProductLookupMap TypeLookup;
    bool isCached = (fillCount > 0 && fillCount == typeLookup.fillCount());
    bool toBeCached = (fillCount >= 0 && !isCached);

    std::pair<TypeLookup::const_iterator, TypeLookup::const_iterator> range =
        (isCached ? std::make_pair(typeLookup.begin() + cachedOffset, typeLookup.end()) : typeLookup.equal_range(TypeInBranchType(typeID, branchType_), moduleLabel, productInstanceName));

    if(toBeCached) {
      cachedOffset = range.first - typeLookup.begin();
      fillCount = typeLookup.fillCount();
    }

    if(range.first == range.second) {
      if(toBeCached) {
        cachedOffset = typeLookup.end() - typeLookup.begin();
      }
      // We check for a missing dictionary.  We do this only in this error leg.
      // A class without a dictionary cannot be in an Event/Lumi/Run.
      // We check if the class has a dictionary.  If it does not, we throw an exception.
      // The missing dictionary might be for the class itself, the wrapped class, or a component of the class.
      std::pair<TypeLookup::const_iterator, TypeLookup::const_iterator> const typeRange = typeLookup.equal_range(TypeInBranchType(typeID, branchType_));
      if(typeRange.first == typeRange.second) {
        maybeThrowMissingDictionaryException(typeID, &typeLookup == &preg_->elementLookup(), preg_->missingDictionaries());
      }
      return 0;
    }

    if(!processName.empty()) {
      if(isCached) {
        assert(processName == range.first->branchDescription()->processName());
        range.second = range.first + 1;
      } else if(toBeCached) {
        bool processFound = false;
        for(TypeLookup::const_iterator it = range.first; it != range.second; ++it) {
          if(it->isFirst() && it != range.first) {
            break;
          }
          if(processName == it->branchDescription()->processName()) {
            processFound = true;
            range.first = it;
            cachedOffset = range.first - typeLookup.begin();
            range.second = range.first + 1;
            break;
          }
        }
        if(!processFound) {
          cachedOffset = typeLookup.end() - typeLookup.begin();
          return 0;
        }
      } // end if(toBeCached)
    }

    for(TypeLookup::const_iterator it = range.first; it != range.second; ++it) {
      if(it->isFirst() && it != range.first) {
        return 0;
      }
      if(!processName.empty() && processName != it->branchDescription()->processName()) {
        continue;
      }
      //now see if the data is actually available
      ConstGroupPtr const& group = getGroupByIndex(it->index(), false, false);
      if(group && group->productWasDeleted()) {
        throwProductDeletedException("findGroupByLabel",
                                     typeID,
                                     moduleLabel,
                                     productInstanceName,
                                     processName);
      }

      // Skip product if not available.
      if(group && !group->productUnavailable()) {
        this->resolveProduct(*group, true);
        // If the product is a dummy filler, group will now be marked unavailable.
        // Unscheduled execution can fail to produce the EDProduct so check
        if(group->product() && !group->productUnavailable() && !group->onDemand()) {
          // Found the match
          return &group->productData();
        }
      }
    }
    return 0;
  }
ProductData const * edm::Principal::findGroupByTag ( TypeID const &  typeID,
InputTag const &  tag 
) const

Definition at line 604 of file Principal.cc.

References edm::InputTag::cachedOffset(), edm::InputTag::fillCount(), findGroupByLabel(), edm::InputTag::instance(), edm::InputTag::label(), preg_, edm::InputTag::process(), and edm::throwNotFoundException().

Referenced by edm::getProductByTag().

                                                                           {
    ProductData const* productData =
        findGroupByLabel(typeID,
                         preg_->productLookup(),
                         tag.label(),
                         tag.instance(),
                         tag.process(),
                         tag.cachedOffset(),
                         tag.fillCount());
    if(productData == 0) {
      throwNotFoundException("findProductByTag", typeID, tag);
    }
    return productData;
  }
size_t edm::Principal::findGroups ( TypeID const &  typeID,
TypeLookup const &  typeLookup,
BasicHandleVec results 
) const [private]

Definition at line 392 of file Principal.cc.

References branchType_, edm::TransientProductLookupMap::equal_range(), getGroupByIndex(), edm::ConstBranchDescription::isAlias(), edm::maybeThrowMissingDictionaryException(), edm::ConstBranchDescription::moduleLabel(), preg_, edm::ConstBranchDescription::processName(), edm::ConstBranchDescription::productInstanceName(), resolveProduct(), and edm::throwProductDeletedException().

Referenced by getManyByType().

                                                       {
    assert(results.empty());

    typedef TransientProductLookupMap TypeLookup;
    // A class without a dictionary cannot be in an Event/Lumi/Run.
    // First, we check if the class has a dictionary.  If it does not, we throw an exception.
    // The missing dictionary might be for the class itself, the wrapped class, or a component of the class.
    std::pair<TypeLookup::const_iterator, TypeLookup::const_iterator> const range = typeLookup.equal_range(TypeInBranchType(typeID, branchType_));
    if(range.first == range.second) {
      maybeThrowMissingDictionaryException(typeID, &typeLookup == &preg_->elementLookup(), preg_->missingDictionaries());
    }

    results.reserve(range.second - range.first);

    for(TypeLookup::const_iterator it = range.first; it != range.second; ++it) {

      ConstBranchDescription const& bd = *(it->branchDescription());

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

      //now see if the data is actually available
      ConstGroupPtr const& group = getGroupByIndex(it->index(), false, false);
      //NOTE sometimes 'group->productUnavailable()' is true if was already deleted
      if(group && group->productWasDeleted()) {
        throwProductDeletedException("findGroups",
                                     typeID,
                                     bd.moduleLabel(),
                                     bd.productInstanceName(),
                                     bd.processName());
      }

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

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

Definition at line 660 of file Principal.cc.

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

                                                                             {
    provenances.clear();
    for (auto const& group : *this) {
      if(group->provenanceAvailable() && !group->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(group->provenance()->product().present()) {
           provenances.push_back(group->provenance());
        }
      }
    }
  }
BasicHandle edm::Principal::getByLabel ( TypeID const &  tid,
std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName,
size_t &  cachedOffset,
int &  fillCount 
) const

Definition at line 344 of file Principal.cc.

References findGroupByLabel(), diffTwoXMLs::label, edm::makeNotFoundException(), preg_, and query::result.

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

                                              {

    ProductData const* result = findGroupByLabel(productType,
                                                 preg_->productLookup(),
                                                 label,
                                                 productInstanceName,
                                                 processName,
                                                 cachedOffset,
                                                 fillCount);

    if(result == 0) {
      boost::shared_ptr<cms::Exception> whyFailed = makeNotFoundException("getByLabel", productType, label, productInstanceName, processName);
      return BasicHandle(whyFailed);
    }
    return BasicHandle(*result);
  }
Group * edm::Principal::getExistingGroup ( BranchID const &  branchID) [protected]
Group * edm::Principal::getExistingGroup ( Group const &  g) [protected]

Definition at line 284 of file Principal.cc.

References edm::Group::branchDescription(), edm::ConstBranchDescription::branchID(), g, and getExistingGroup().

                                                {
    Group* g = getExistingGroup(group.branchDescription().branchID());
    assert(0 == g || BranchKey(group.branchDescription()) == BranchKey(g->branchDescription()));
    return g;
  }
OutputHandle edm::Principal::getForOutput ( BranchID const &  bid,
bool  getProd 
) const

Definition at line 620 of file Principal.cc.

References g, getGroup(), edm::errors::LogicError, edm::throwGroupNotFoundException(), and edm::throwProductDeletedException().

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

                                                                 {
    ConstGroupPtr const g = getGroup(bid, getProd, true);
    if(g == 0) {
      throwGroupNotFoundException("getForOutput", errors::LogicError, bid);
    }
    if (g->productWasDeleted()) {
      throwProductDeletedException("getForOutput",g->productType(),
                                   g->moduleLabel(),
                                   g->productInstanceName(),
                                   g->processName());
    }
    if(!g->provenance() || (!g->product() && !g->productProvenancePtr())) {
      return OutputHandle();
    }
    return OutputHandle(WrapperHolder(g->product().get(), g->productData().getInterface()), &g->branchDescription(), g->productProvenancePtr());
  }
Principal::ConstGroupPtr edm::Principal::getGroup ( BranchID const &  oid,
bool  resolveProd,
bool  fillOnDemand 
) const
Principal::ConstGroupPtr edm::Principal::getGroupByIndex ( ProductTransientIndex const &  oid,
bool  resolveProd,
bool  fillOnDemand 
) const [protected]

Definition at line 331 of file Principal.cc.

References g, groups_, getHLTprescales::index, and resolveProduct().

Referenced by findGroup(), findGroupByLabel(), findGroups(), and getGroup().

                                                                                                          {

    ConstGroupPtr const g = groups_[index].get();
    if(0 == g) {
      return g;
    }
    if(resolveProd && !g->productUnavailable()) {
      this->resolveProduct(*g, fillOnDemand);
    }
    return g;
  }
WrapperHolder edm::Principal::getIt ( ProductID const &  ) const [private, virtual]

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 686 of file Principal.cc.

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

Definition at line 367 of file Principal.cc.

References findGroups(), preg_, and python::entryComment::results.

                                                          {

    findGroups(productType,
               preg_->productLookup(),
               results);
    return;
  }
size_t edm::Principal::getMatchingSequence ( TypeID const &  typeID,
std::string const &  moduleLabel,
std::string const &  productInstanceName,
std::string const &  processName,
BasicHandle result 
) const

Definition at line 377 of file Principal.cc.

References findGroup(), preg_, and query::result.

                                                            {

    return findGroup(typeID,
                     preg_->elementLookup(),
                     moduleLabel,
                     productInstanceName,
                     processName,
                     result);
  }
Provenance edm::Principal::getProvenance ( BranchID const &  bid) const

Definition at line 638 of file Principal.cc.

References g, getGroup(), edm::errors::ProductNotFound, edm::throwGroupNotFoundException(), and unscheduledFill().

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

                                                    {
    ConstGroupPtr const g = getGroup(bid, false, true);
    if(g == 0) {
      throwGroupNotFoundException("getProvenance", errors::ProductNotFound, bid);
    }

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

    return *g->provenance();
  }
void edm::Principal::maybeFlushCache ( TypeID const &  tid,
InputTag const &  tag 
) const

Definition at line 692 of file Principal.cc.

References branchType(), edm::InputTag::branchType(), edm::InputTag::cachedOffset(), edm::InputTag::fillCount(), productRegistry(), edm::InputTag::productRegistry(), and edm::InputTag::typeID().

Referenced by edm::getProductByTag().

                                                                         {
    if(tag.typeID() != tid ||
        tag.branchType() != branchType() ||
        tag.productRegistry() != &productRegistry()) {
      tag.fillCount() = 0;
      tag.cachedOffset() = 0U;
      tag.typeID() = tid;
      tag.branchType() = branchType();
      tag.productRegistry() = &productRegistry();
    }
  }
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const [inline]

Definition at line 125 of file Principal.h.

References processConfiguration_.

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

Definition at line 117 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 91 of file Principal.h.

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

Definition at line 732 of file Principal.cc.

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

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

Definition at line 674 of file Principal.cc.

References groups_, getHLTprescales::index, edm::ProductRegistry::kInvalidIndex, edm::DelayedReader::mergeReaders(), preg_, reader(), and reader_.

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

                                                                        {
    for (std::vector<BranchID>::const_iterator it = bids.begin(), itEnd = bids.end(); it != itEnd; ++it) {
      ProductTransientIndex index= preg_->indexFrom(*it);
      assert(index!=ProductRegistry::kInvalidIndex);
      ProductTransientIndex indexO = other.preg_->indexFrom(*it);
      assert(indexO!=ProductRegistry::kInvalidIndex);
      groups_[index].swap(other.groups_[indexO]);
    }
    reader_->mergeReaders(other.reader());
  }
void edm::Principal::resolveProduct ( Group const &  g,
bool  fillOnDemand 
) const [inline, protected]

Definition at line 173 of file Principal.h.

References resolveProduct_().

Referenced by findGroup(), findGroupByLabel(), findGroups(), and getGroupByIndex().

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

Reimplemented in edm::EventPrincipal.

Definition at line 210 of file Principal.h.

Referenced by resolveProduct().

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

Definition at line 146 of file Principal.cc.

References begin(), edm::Group::branchDescription(), edm::ConstBranchDescription::dropped(), end(), g, edm::Group::onDemand(), and edm::Group::productUnavailable().

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

                        {
    size_t size = 0U;
    for(const_iterator it = this->begin(), itEnd = this->end(); it != itEnd; ++it) {
      Group const& g = **it;
      if(!g.productUnavailable() && !g.onDemand() && !g.branchDescription().dropped()) {
        ++size;
      }
    }
    return size;
  }
virtual bool edm::Principal::unscheduledFill ( std::string const &  moduleLabel) const [private, pure virtual]

Member Data Documentation

Definition at line 239 of file Principal.h.

Referenced by fillPrincipal().

Definition at line 237 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 216 of file Principal.h.

Referenced by fillPrincipal(), and processConfiguration().

Definition at line 214 of file Principal.h.

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

Definition at line 212 of file Principal.h.

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

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

Definition at line 230 of file Principal.h.

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

Definition at line 227 of file Principal.h.

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