CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::Principal Class Referenceabstract

#include <Principal.h>

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

Public Types

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

Public Member Functions

void addAliasedProduct (std::shared_ptr< BranchDescription const > bd)
 
void addInputProduct (std::shared_ptr< BranchDescription const > bd)
 
void addScheduledProduct (std::shared_ptr< BranchDescription const > bd)
 
void addSourceProduct (std::shared_ptr< BranchDescription const > bd)
 
void addUnscheduledProduct (std::shared_ptr< BranchDescription const > bd)
 
void adjustIndexesAfterProductRegistryAddition ()
 
bool adjustToNewProductRegistry (ProductRegistry const &reg)
 
const_iterator begin () const
 
BranchType const & branchType () const
 
CacheIdentifier_t cacheIdentifier () const
 
void clearPrincipal ()
 
void deleteProduct (BranchID const &id)
 
const_iterator end () const
 
void fillPrincipal (ProcessHistoryID const &hist, ProcessHistoryRegistry const &phr, DelayedReader *reader)
 
ProductData const * findProductByTag (TypeID const &typeID, InputTag const &tag, ModuleCallingContext const *mcc) const
 
void getAllProvenance (std::vector< Provenance const * > &provenances) const
 
BasicHandle getByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
BasicHandle getByLabel (KindOfType kindOfType, TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
BasicHandle getByToken (KindOfType kindOfType, TypeID const &typeID, ProductHolderIndex index, bool skipCurrentProcess, bool &ambiguous, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
OutputHandle getForOutput (BranchID const &bid, bool getProd, ModuleCallingContext const *mcc) const
 
void getManyByType (TypeID const &typeID, BasicHandleVec &results, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
ConstProductHolderPtr getProductHolder (BranchID const &oid) const
 
ConstProductHolderPtr getProductHolderByIndex (ProductHolderIndex const &oid) const
 
Provenance getProvenance (BranchID const &bid, ModuleCallingContext const *mcc) const
 
bool isComplete () const
 
std::vector< unsigned int > const & lookupProcessOrder () const
 
void prefetch (ProductHolderIndex index, bool skipCurrentProcess, ModuleCallingContext const *mcc) const
 
 Principal (std::shared_ptr< ProductRegistry const > reg, std::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 readFromSource (ProductHolderBase const &phb, ModuleCallingContext const *mcc) const
 
void recombine (Principal &other, std::vector< BranchID > const &bids)
 
size_t size () const
 
virtual bool unscheduledFill (std::string const &moduleLabel, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
 
virtual ~Principal ()
 
- Public Member Functions inherited from edm::EDProductGetter
 EDProductGetter ()
 
 EDProductGetter (EDProductGetter const &)=delete
 
EDProductGetter const & operator= (EDProductGetter const &)=delete
 
unsigned int transitionIndex () const
 
virtual ~EDProductGetter ()
 

Protected Member Functions

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

Private Member Functions

ProductData const * findProductByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
ProductData const * findProductByLabel (KindOfType kindOfType, TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void findProducts (std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
virtual WrapperBase const * getIt (ProductID const &) const override
 
virtual WrapperBase const * getThinnedProduct (ProductID const &, unsigned int &) const override
 
virtual void getThinnedProducts (ProductID const &, std::vector< WrapperBase const * > &, std::vector< unsigned int > &) const override
 
virtual bool isComplete_ () const
 
virtual void readFromSource_ (ProductHolderBase const &, ModuleCallingContext const *) const
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProductGetter
static void assignEDProductGetter (EDProductGetter const *&)
 
static EDProductGetter const * switchProductGetter (EDProductGetter const *)
 These can only be used internally by the framework. More...
 

Detailed Description

Definition at line 54 of file Principal.h.

Member Typedef Documentation

Definition at line 60 of file Principal.h.

typedef unsigned long edm::Principal::CacheIdentifier_t

Definition at line 173 of file Principal.h.

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

Definition at line 57 of file Principal.h.

Definition at line 59 of file Principal.h.

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

Definition at line 64 of file Principal.h.

Definition at line 58 of file Principal.h.

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

Definition at line 56 of file Principal.h.

Definition at line 63 of file Principal.h.

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

Definition at line 61 of file Principal.h.

Constructor & Destructor Documentation

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

Definition at line 140 of file Principal.cc.

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

144  :
145  EDProductGetter(),
149  productHolders_(reg->getNextIndexValue(bt), SharedProductPtr()),
150  preg_(reg),
153  reader_(),
154  productPtrs_(),
155  branchType_(bt),
156  historyAppender_(historyAppender),
158  {
159 
160  //Now that these have been set, we can create the list of Branches we need.
161  std::string const source("source");
162  ProductRegistry::ProductList const& prodsList = reg->productList();
163  // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
164  // So, the non-alias product holders must be created first.
165  // Therefore, on this first pass, skip current EDAliases.
166  bool hasAliases = false;
167  for(auto const& prod : prodsList) {
168  BranchDescription const& bd = prod.second;
169  if(bd.branchType() == branchType_) {
170  if(bd.isAlias()) {
171  hasAliases = true;
172  } else {
173  auto cbd = std::make_shared<BranchDescription const>(bd);
174  if(bd.produced()) {
175  if(bd.moduleLabel() == source) {
176  addSourceProduct(cbd);
177  } else if(bd.onDemand()) {
180  } else {
181  addScheduledProduct(cbd);
182  }
183  } else {
184  addInputProduct(cbd);
185  }
186  }
187  }
188  }
189  // Now process any EDAliases
190  if(hasAliases) {
191  for(auto const& prod : prodsList) {
192  BranchDescription const& bd = prod.second;
193  if(bd.isAlias() && bd.branchType() == branchType_) {
194  auto cbd = std::make_shared<BranchDescription const>(bd);
195  addAliasedProduct(cbd);
196  }
197  }
198  }
199 
200  // Now create the ProductHolders that search in reverse process
201  // order and are used for queries where the process name is the
202  // empty string
203  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
204  std::vector<ProductHolderIndex> matchingHolders(lookupProcessNames.size(), ProductHolderIndexInvalid);
205  std::vector<bool> ambiguous(lookupProcessNames.size(), false);
206  unsigned int beginElements = productLookup_->beginElements();
207  std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
208  std::vector<ProductHolderIndexHelper::Range> const& ranges = productLookup_->ranges();
209  std::vector<ProductHolderIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
210  std::vector<char> const& processNamesCharArray = productLookup_->processNames();
211 
212  if (!sortedTypeIDs.empty()) {
213  ProductHolderIndex productHolderIndex = ProductHolderIndexInvalid;
214  for(unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
215  ProductHolderIndexHelper::Range const& range = ranges.at(k);
216  for (unsigned int i = range.begin(); i < range.end(); ++i) {
217  ProductHolderIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
218  if (product.startInProcessNames() == 0) {
219  if (productHolderIndex != ProductHolderIndexInvalid) {
220  std::shared_ptr<ProductHolderBase> newHolder = std::make_shared<NoProcessProductHolder>(matchingHolders, ambiguous, this);
221  productHolders_.at(productHolderIndex) = newHolder;
222  matchingHolders.assign(lookupProcessNames.size(), ProductHolderIndexInvalid);
223  ambiguous.assign(lookupProcessNames.size(), false);
224  }
225  productHolderIndex = product.index();
226  } else {
227  std::string process(&processNamesCharArray.at(product.startInProcessNames()));
228  auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
229  assert(iter != lookupProcessNames.end());
230  ProductHolderIndex iMatchingIndex = product.index();
231  assert(iMatchingIndex != ProductHolderIndexInvalid);
232  if (iMatchingIndex == ProductHolderIndexAmbiguous) {
233  assert(k >= beginElements);
234  ambiguous.at(iter - lookupProcessNames.begin()) = true;
235  } else {
236  matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
237  }
238  }
239  }
240  }
241  std::shared_ptr<ProductHolderBase> newHolder = std::make_shared<NoProcessProductHolder>(matchingHolders, ambiguous, this);
242  productHolders_.at(productHolderIndex) = newHolder;
243  }
244  }
BranchType branchType_
Definition: Principal.h:276
int i
Definition: DBlmapReader.cc:9
DelayedReader * reader_
Definition: Principal.h:271
HistoryAppender * historyAppender_
Definition: Principal.h:281
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:63
static std::string const source("source")
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:252
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:136
ProcessHistoryID processHistoryID_
Definition: Principal.h:254
assert(m_qm.get())
unsigned int ProductHolderIndex
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:297
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:266
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:285
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:283
ProductHolderCollection productHolders_
Definition: Principal.h:259
void addSourceProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:291
std::set< void const * > productPtrs_
Definition: Principal.h:274
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:264
string ranges
Definition: diffTwoXMLs.py:78
PixelRecoRange< float > Range
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:303
std::vector< std::string > const & lookupProcessNames() const
tuple process
Definition: LaserDQM_cfg.py:3
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:309
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:256
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:154
edm::Principal::~Principal ( )
virtual

Definition at line 246 of file Principal.cc.

246  {
247  }

Member Function Documentation

void edm::Principal::addAliasedProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 309 of file Principal.cc.

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

Referenced by Principal().

309  {
310  ProductHolderIndex index = preg_->indexFrom(bd->originalBranchID());
312 
313  std::auto_ptr<ProductHolderBase> phb(new AliasProductHolder(bd, dynamic_cast<ProducedProductHolder&>(*productHolders_[index])));
314  addProductOrThrow(phb);
315  }
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
ProductHolderCollection productHolders_
Definition: Principal.h:259
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:437
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 297 of file Principal.cc.

References addProductOrThrow().

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

297  {
298  std::auto_ptr<ProductHolderBase> phb(new InputProductHolder(bd, this));
299  addProductOrThrow(phb);
300  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:437
void edm::Principal::addProduct_ ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 423 of file Principal.cc.

References assert(), edm::BranchDescription::branchID(), edm::BranchDescription::className(), edm::BranchDescription::friendlyClassName(), cmsHarvester::index, edm::BranchDescription::moduleLabel(), preg_, edm::BranchDescription::processName(), edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by addProductOrThrow().

423  {
424  BranchDescription const& bd = productHolder->branchDescription();
425  assert (!bd.className().empty());
426  assert (!bd.friendlyClassName().empty());
427  assert (!bd.moduleLabel().empty());
428  assert (!bd.processName().empty());
429  SharedProductPtr phb(productHolder.release());
430 
431  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
433  productHolders_[index] = phb;
434  }
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:63
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
ProductHolderCollection productHolders_
Definition: Principal.h:259
void edm::Principal::addProductOrThrow ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 437 of file Principal.cc.

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

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

437  {
438  ProductHolderBase const* phb = getExistingProduct(*productHolder);
439  if(phb != nullptr) {
440  BranchDescription const& bd = productHolder->branchDescription();
441  throw Exception(errors::InsertFailure, "AlreadyPresent")
442  << "addProductOrThrow: Problem found while adding product, "
443  << "product already exists for ("
444  << bd.friendlyClassName() << ","
445  << bd.moduleLabel() << ","
446  << bd.productInstanceName() << ","
447  << bd.processName()
448  << ")\n";
449  }
450  addProduct_(productHolder);
451  }
void addProduct_(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:423
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:398
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 285 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

285  {
286  std::auto_ptr<ProductHolderBase> phb(new ScheduledProductHolder(bd));
287  addProductOrThrow(phb);
288  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:437
void edm::Principal::addSourceProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 291 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

291  {
292  std::auto_ptr<ProductHolderBase> phb(new SourceProductHolder(bd));
293  addProductOrThrow(phb);
294  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:437
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 303 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

303  {
304  std::auto_ptr<ProductHolderBase> phb(new UnscheduledProductHolder(bd, this));
305  addProductOrThrow(phb);
306  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:437
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 876 of file Principal.cc.

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

Referenced by edm::PrincipalCache::adjustEventsToNewProductRegistry(), and edm::StreamerInputSource::read().

876  {
877  if(preg_->getNextIndexValue(branchType_) != productHolders_.size()) {
878  productHolders_.resize(preg_->getNextIndexValue(branchType_));
879  for(auto const& prod : preg_->productList()) {
880  BranchDescription const& bd = prod.second;
881  if(bd.branchType() == branchType_) {
882  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
884  if(!productHolders_[index]) {
885  // no product holder. Must add one. The new entry must be an input product holder.
886  assert(!bd.produced());
887  auto cbd = std::make_shared<BranchDescription const>(bd);
888  addInputProduct(cbd);
889  }
890  }
891  }
892  }
893  assert(preg_->getNextIndexValue(branchType_) == productHolders_.size());
894  }
BranchType branchType_
Definition: Principal.h:276
assert(m_qm.get())
unsigned int ProductHolderIndex
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:297
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
ProductHolderCollection productHolders_
Definition: Principal.h:259
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

Definition at line 268 of file Principal.cc.

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

Referenced by edm::PrincipalCache::adjustEventsToNewProductRegistry(), and edm::StreamerInputSource::read().

268  {
269  ProductRegistry::ProductList const& prodsList = reg.productList();
270  for(auto const& prod : prodsList) {
271  BranchDescription const& bd = prod.second;
272  if(!bd.produced() && (bd.branchType() == branchType_)) {
273  auto cbd = std::make_shared<BranchDescription const>(bd);
274  ProductHolderBase* phb = getExistingProduct(cbd->branchID());
275  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
276  return false;
277  }
278  phb->resetBranchDescription(cbd);
279  }
280  }
281  return true;
282  }
BranchType branchType_
Definition: Principal.h:276
std::map< BranchKey, BranchDescription > ProductList
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:398
const_iterator edm::Principal::begin ( void  ) const
inline

Definition at line 162 of file Principal.h.

References productHolders_.

Referenced by edm::check(), edm::PoolOutputModule::updateBranchParents(), and edm::ProvenanceCheckerOutputModule::write().

162 {return boost::make_filter_iterator<FilledProductPtr>(productHolders_.begin(), productHolders_.end());}
ProductHolderCollection productHolders_
Definition: Principal.h:259
BranchType const& edm::Principal::branchType ( ) const
inline

Definition at line 170 of file Principal.h.

References branchType_.

Referenced by edm::PrincipalGetAdapter::branchType(), findProductByLabel(), and getManyByType().

170 {return branchType_;}
BranchType branchType_
Definition: Principal.h:276
CacheIdentifier_t edm::Principal::cacheIdentifier ( ) const
inline

Definition at line 174 of file Principal.h.

References cacheIdentifier_.

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

174 {return cacheIdentifier_;}
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:283
void edm::Principal::checkUniquenessAndType ( WrapperBase const *  prod,
ProductHolderBase const *  productHolder 
) const
protected

Definition at line 838 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::BranchDescription::branchName(), edm::ProductHolderBase::checkType(), productPtrs_, and edm::throwCorruptionException().

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

838  {
839  if(prod == nullptr) return;
840  // These are defensive checks against things that should never happen, but have.
841  // Checks that the same physical product has not already been put into the event.
842  bool alreadyPresent = !productPtrs_.insert(prod).second;
843  if(alreadyPresent) {
844  phb->checkType(*prod);
845  throwCorruptionException("checkUniquenessAndType", phb->branchDescription().branchName());
846  }
847  // Checks that the real type of the product matches the branch.
848  phb->checkType(*prod);
849  }
static void throwCorruptionException(char const *where, std::string const &branchName)
Definition: Principal.cc:64
std::set< void const * > productPtrs_
Definition: Principal.h:274
void edm::Principal::clearPrincipal ( )

Definition at line 319 of file Principal.cc.

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

Referenced by edm::EventPrincipal::clearEventPrincipal(), and edm::PoolSource::readEvent_().

319  {
320  processHistoryPtr_.reset();
322  reader_ = nullptr;
323  for(auto const& prod : *this) {
324  prod->resetProductData();
325  }
326  productPtrs_.clear();
327  }
DelayedReader * reader_
Definition: Principal.h:271
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:252
ProcessHistoryID processHistoryID_
Definition: Principal.h:254
Hash< ProcessHistoryType > ProcessHistoryID
std::set< void const * > productPtrs_
Definition: Principal.h:274
void edm::Principal::deleteProduct ( BranchID const &  id)

Definition at line 330 of file Principal.cc.

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

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

330  {
331  ProductHolderBase* phb = getExistingProduct(id);
332  assert(nullptr != phb);
333  auto itFound = productPtrs_.find(phb->product());
334  if(itFound != productPtrs_.end()) {
335  productPtrs_.erase(itFound);
336  }
337  phb->deleteProduct();
338  }
assert(m_qm.get())
std::set< void const * > productPtrs_
Definition: Principal.h:274
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:398
const_iterator edm::Principal::end ( void  ) const
inline

Definition at line 163 of file Principal.h.

References productHolders_.

Referenced by edm::check(), Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), edm::PoolOutputModule::updateBranchParents(), and edm::ProvenanceCheckerOutputModule::write().

163 {return boost::make_filter_iterator<FilledProductPtr>(productHolders_.end(), productHolders_.end());}
ProductHolderCollection productHolders_
Definition: Principal.h:259
void edm::Principal::fillPrincipal ( ProcessHistoryID const &  hist,
ProcessHistoryRegistry const &  phr,
DelayedReader reader 
)

Definition at line 342 of file Principal.cc.

References edm::HistoryAppender::appendToProcessHistory(), cacheIdentifier_, Exception, spr::find(), edm::ProcessHistoryRegistry::getMapped(), estimatePileup::hist, historyAppender_, edm::Hash< I >::isValid(), relval_steps::k, edm::errors::LogicError, lookupProcessOrder_, edm::nextIdentifier(), orderProcessHistoryID_, processConfiguration_, processHistoryID_, processHistoryPtr_, productLookup_, productRegistry(), reader(), reader_, and edm::s_emptyProcessHistory.

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

344  {
345  //increment identifier here since clearPrincipal isn't called for Run/Lumi
347  if(reader) {
348  reader_ = reader;
349  }
350 
351  if (historyAppender_ && productRegistry().anyProductProduced()) {
354  processHistoryRegistry.getMapped(hist),
357  }
358  else {
359  std::shared_ptr<ProcessHistory const> inputProcessHistory;
360  if (hist.isValid()) {
361  //does not own the pointer
362  auto noDel =[](void const*){};
363  inputProcessHistory =
364  std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist),noDel);
365  if (inputProcessHistory.get() == nullptr) {
367  << "Principal::fillPrincipal\n"
368  << "Input ProcessHistory not found in registry\n"
369  << "Contact a Framework developer\n";
370  }
371  } else {
372  //Since this is static we don't want it deleted
373  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory,[](void const*){});
374  }
376  processHistoryPtr_ = inputProcessHistory;
377  }
378 
380  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
381  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
382  unsigned int k = 0;
383  for (auto iter = processHistoryPtr_->rbegin(),
384  iEnd = processHistoryPtr_->rend();
385  iter != iEnd; ++iter) {
386  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
387  if (nameIter == lookupProcessNames.end()) {
388  continue;
389  }
390  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
391  ++k;
392  }
394  }
395  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:35
ProductRegistry const & productRegistry() const
Definition: Principal.h:152
DelayedReader * reader_
Definition: Principal.h:271
HistoryAppender * historyAppender_
Definition: Principal.h:281
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:252
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:136
ProcessHistoryID processHistoryID_
Definition: Principal.h:254
std::shared_ptr< ProcessHistory const > appendToProcessHistory(ProcessHistoryID const &inputPHID, ProcessHistory const *inputProcessHistory, ProcessConfiguration const &pc)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:266
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:283
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:267
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:264
DelayedReader * reader() const
Definition: Principal.h:176
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:256
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumer,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 642 of file Principal.cc.

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

Referenced by findProductByTag(), and getByLabel().

647  {
648 
649  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
650 
651  ProductHolderIndex index = inputTag.indexFor(typeID, branchType(), &productRegistry());
652 
653  if (index == ProductHolderIndexInvalid) {
654 
655  char const* processName = inputTag.process().c_str();
656  if (skipCurrentProcess) {
657  processName = "\0";
658  }
659 
660  index = productLookup().index(kindOfType,
661  typeID,
662  inputTag.label().c_str(),
663  inputTag.instance().c_str(),
664  processName);
665 
666  if(index == ProductHolderIndexAmbiguous) {
667  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
668  } else if (index == ProductHolderIndexInvalid) {
669  ProductHolderIndexHelper::Matches matches =
670  productLookup().relatedIndexes(kindOfType, typeID);
671 
672  if (matches.numberOfMatches() == 0) {
673  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
674  }
675  return 0;
676  }
677  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
678  }
679  if(unlikely( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
680  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),inputTag.process());
681  }
682 
683 
684  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
685 
686  ProductHolderBase::ResolveStatus resolveStatus;
687  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess, sra, mcc);
688  if(resolveStatus == ProductHolderBase::Ambiguous) {
689  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
690  }
691  return productData;
692  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:152
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
ProductHolderIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
unsigned int ProductHolderIndex
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:100
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
BranchType const & branchType() const
Definition: Principal.h:170
ProductHolderCollection productHolders_
Definition: Principal.h:259
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< TypeID > const &missingDictionaries)
Definition: Principal.cc:39
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:154
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
EDConsumerBase const *  consumer,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 695 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, branchType(), edm::ELEMENT_TYPE, edm::ProductHolderIndexHelper::index(), cmsHarvester::index, matches, edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup(), edm::EDConsumerBase::registeredToConsume(), edm::ProductHolderIndexHelper::relatedIndexes(), edm::throwAmbiguousException(), and unlikely.

702  {
703 
705  typeID,
706  label.c_str(),
707  instance.c_str(),
708  process.c_str());
709 
710  if(index == ProductHolderIndexAmbiguous) {
711  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
712  } else if (index == ProductHolderIndexInvalid) {
713  ProductHolderIndexHelper::Matches matches =
714  productLookup().relatedIndexes(kindOfType, typeID);
715 
716  if (matches.numberOfMatches() == 0) {
717  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
718  }
719  return 0;
720  }
721 
722  if(unlikely( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
723  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
724  }
725 
726  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
727 
728  ProductHolderBase::ResolveStatus resolveStatus;
729  ProductData const* productData = productHolder->resolveProduct(resolveStatus, false, sra, mcc);
730  if(resolveStatus == ProductHolderBase::Ambiguous) {
731  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
732  }
733  return productData;
734  }
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
static PFTauRenderPlugin instance
ProductHolderIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
unsigned int ProductHolderIndex
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:100
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
BranchType const & branchType() const
Definition: Principal.h:170
ProductHolderCollection productHolders_
Definition: Principal.h:259
tuple process
Definition: LaserDQM_cfg.py:3
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< TypeID > const &missingDictionaries)
Definition: Principal.cc:39
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:154
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 737 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

737  {
738  ProductData const* productData =
740  typeID,
741  tag,
742  nullptr,
743  nullptr,
744  mcc);
745  return productData;
746  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:642
void edm::Principal::findProducts ( std::vector< ProductHolderBase const * > const &  holders,
TypeID const &  typeID,
BasicHandleVec results,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 611 of file Principal.cc.

References edm::BranchDescription::isAlias(), LaserDQM_cfg::process, processHistoryPtr_, edm::BranchDescription::processName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getManyByType().

615  {
616 
617  for (auto iter = processHistoryPtr_->rbegin(),
618  iEnd = processHistoryPtr_->rend();
619  iter != iEnd; ++iter) {
620  std::string const& process = iter->processName();
621  for (auto productHolder : holders) {
622  BranchDescription const& bd = productHolder->branchDescription();
623  if (process == bd.processName()) {
624 
625  // Ignore aliases to avoid matching the same product multiple times.
626  if(bd.isAlias()) {
627  continue;
628  }
629 
630  ProductHolderBase::ResolveStatus resolveStatus;
631  ProductData const* productData = productHolder->resolveProduct(resolveStatus, false, sra, mcc);
632  if(productData) {
633  // Skip product if not available.
634  results.emplace_back(*productData);
635  }
636  }
637  }
638  }
639  }
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:252
tuple process
Definition: LaserDQM_cfg.py:3
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 792 of file Principal.cc.

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

792  {
793  provenances.clear();
794  for(auto const& productHolder : *this) {
795  if(productHolder->singleProduct() && productHolder->provenanceAvailable() && !productHolder->branchDescription().isAlias()) {
796  // We do not attempt to get the event/lumi/run status from the provenance,
797  // because the per event provenance may have been dropped.
798  if(productHolder->provenance()->product().present()) {
799  provenances.push_back(productHolder->provenance());
800  }
801  }
802  }
803  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 470 of file Principal.cc.

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

Referenced by edm::check(), PileUpEventPrincipal::getByLabel(), edm::PrincipalGetAdapter::getByLabel_(), edm::PrincipalGetAdapter::getMatchingSequenceByLabel_(), and edm::detail::TriggerResultsBasedEventSelector::wantEvent().

475  {
476 
477  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, sra, mcc);
478  if(result == 0) {
479  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
480  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process());
481  }));
482  }
483  return BasicHandle(*result);
484  }
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
tuple result
Definition: query.py:137
static std::shared_ptr< cms::Exception > makeNotFoundException(char const *where, KindOfType kindOfType, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:71
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:642
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 487 of file Principal.cc.

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

494  {
495 
496  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, sra, mcc);
497  if(result == 0) {
498  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
499  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
500  }));
501  }
502  return BasicHandle(*result);
503  }
static PFTauRenderPlugin instance
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
tuple result
Definition: query.py:137
static std::shared_ptr< cms::Exception > makeNotFoundException(char const *where, KindOfType kindOfType, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:71
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:642
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductHolderIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 506 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, assert(), cmsHarvester::index, edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by edm::PrincipalGetAdapter::getByToken_().

512  {
514  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
515  assert(0!=productHolder.get());
516  ProductHolderBase::ResolveStatus resolveStatus;
517  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess, sra, mcc);
518  if(resolveStatus == ProductHolderBase::Ambiguous) {
519  ambiguous = true;
520  return BasicHandle();
521  }
522  if(productData == 0) {
523  return BasicHandle();
524  }
525  return BasicHandle(*productData);
526  }
assert(m_qm.get())
ProductHolderCollection productHolders_
Definition: Principal.h:259
ProductHolderBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 398 of file Principal.cc.

References assert(), cmsHarvester::index, preg_, edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by addProductOrThrow(), adjustToNewProductRegistry(), deleteProduct(), getExistingProduct(), edm::RunPrincipal::put(), edm::LuminosityBlockPrincipal::put(), edm::EventPrincipal::put(), and edm::EventPrincipal::putOnRead().

398  {
399  ProductHolderIndex index = preg_->indexFrom(branchID);
401  SharedProductPtr ptr = productHolders_.at(index);
402  return ptr.get();
403  }
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:63
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
ProductHolderCollection productHolders_
Definition: Principal.h:259
ProductHolderBase * edm::Principal::getExistingProduct ( ProductHolderBase const &  phb)
protected

Definition at line 406 of file Principal.cc.

References assert(), edm::ProductHolderBase::branchDescription(), edm::BranchDescription::branchID(), edm::BranchDescription::branchName(), Exception, dqmPostProcessing_online::existing, and getExistingProduct().

406  {
407  ProductHolderBase* phb = getExistingProduct(productHolder.branchDescription().branchID());
408  if(nullptr != phb && BranchKey(productHolder.branchDescription()) != BranchKey(phb->branchDescription())) {
409  BranchDescription const& newProduct = phb->branchDescription();
410  BranchDescription const& existing = productHolder.branchDescription();
411  if(newProduct.branchName() != existing.branchName() && newProduct.branchID() == existing.branchID()) {
412  throw cms::Exception("HashCollision") << "Principal::getExistingProduct\n" <<
413  " Branch " << newProduct.branchName() << " has same branch ID as branch " << existing.branchName() << "\n" <<
414  "Workaround: change process name or product instance name of " << newProduct.branchName() << "\n";
415  } else {
416  assert(nullptr == phb || BranchKey(productHolder.branchDescription()) == BranchKey(phb->branchDescription()));
417  }
418  }
419  return phb;
420  }
assert(m_qm.get())
BranchDescription const & branchDescription() const
Definition: ProductHolder.h:93
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:398
OutputHandle edm::Principal::getForOutput ( BranchID const &  bid,
bool  getProd,
ModuleCallingContext const *  mcc 
) const

Definition at line 749 of file Principal.cc.

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

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

750  {
751  ConstProductHolderPtr const phb = getProductHolder(bid);
752  if(phb == nullptr) {
754  }
755  if (phb->productWasDeleted()) {
756  throwProductDeletedException("getForOutput",phb->productType(),
757  phb->moduleLabel(),
758  phb->productInstanceName(),
759  phb->processName());
760  }
761  if(getProd) {
763  phb->resolveProduct(status,false,nullptr, mcc);
764  }
765  if(!phb->provenance() || (!phb->product() && !phb->productProvenancePtr())) {
766  return OutputHandle();
767  }
768  return OutputHandle(phb->product(), &phb->branchDescription(), phb->productProvenancePtr());
769  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:454
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:59
static void throwProductDeletedException(ProductID const &pid, edm::EventPrincipal::ConstProductHolderPtr const phb)
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:57
tuple status
Definition: ntuplemaker.py:245
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 819 of file Principal.cc.

References assert().

819  {
820  assert(nullptr);
821  return nullptr;
822  }
assert(m_qm.get())
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 539 of file Principal.cc.

References assert(), branchType(), findProducts(), i, edm::ProductHolderIndexHelper::Matches::index(), cmsHarvester::index, edm::ProductHolderIndexHelper::Matches::isFullyResolved(), matches, edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::PRODUCT_TYPE, productHolders_, productLookup(), edm::EDConsumerBase::registeredToConsumeMany(), edm::ProductHolderIndexHelper::relatedIndexes(), and unlikely.

Referenced by edm::PrincipalGetAdapter::getManyByType_().

543  {
544 
545  assert(results.empty());
546 
547  if(unlikely(consumer and (not consumer->registeredToConsumeMany(typeID,branchType())))) {
548  failedToRegisterConsumesMany(typeID);
549  }
550 
551  // This finds the indexes to all the ProductHolder's matching the type
552  ProductHolderIndexHelper::Matches matches =
554 
555  if (matches.numberOfMatches() == 0) {
556  maybeThrowMissingDictionaryException(typeID, false, preg_->missingDictionaries());
557  return;
558  }
559 
560  results.reserve(matches.numberOfMatches());
561 
562  // Loop over the ProductHolders. Add the products that are actually
563  // present into the results. This will also trigger delayed reading,
564  // on demand production, and check for deleted products as appropriate.
565 
566  // Over the years the code that uses getManyByType has grown to depend
567  // on the ordering of the results. The order originally was just an
568  // accident of how previous versions of the code were written, but
569  // here we have to go through some extra effort to preserve that ordering.
570 
571  // We build a list of holders that match a particular label and instance.
572  // When that list is complete we call findProducts, which loops over
573  // that list in reverse order of the ProcessHistory (starts with the
574  // most recent). Then we clear the list and repeat this until all the
575  // matching label and instance subsets have been dealt with.
576 
577  // Note that the function isFullyResolved returns true for the ProductHolders
578  // that are associated with an empty process name. Those are the ones that
579  // know how to search for the most recent process name matching
580  // a label and instance. We do not need these for getManyByType and
581  // skip them. In addition to skipping them, we make use of the fact
582  // that they mark the beginning of each subset of holders with the same
583  // label and instance. They tell us when to call findProducts.
584 
585  std::vector<ProductHolderBase const*> holders;
586 
587  for(unsigned int i = 0; i < matches.numberOfMatches(); ++i) {
588 
589  ProductHolderIndex index = matches.index(i);
590 
591  if(!matches.isFullyResolved(i)) {
592  if(!holders.empty()) {
593  // Process the ones with a particular module label and instance
594  findProducts(holders, typeID, results, sra, mcc);
595  holders.clear();
596  }
597  } else {
598  ProductHolderBase const* productHolder = productHolders_.at(index).get();
599  assert(productHolder);
600  holders.push_back(productHolder);
601  }
602  }
603  // Do not miss the last subset of products
604  if(!holders.empty()) {
605  findProducts(holders, typeID, results, sra, mcc);
606  }
607  return;
608  }
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
unsigned int ProductHolderIndex
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
BranchType const & branchType() const
Definition: Principal.h:170
ProductHolderCollection productHolders_
Definition: Principal.h:259
void findProducts(std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:611
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< TypeID > const &missingDictionaries)
Definition: Principal.cc:39
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:154
Principal::ConstProductHolderPtr edm::Principal::getProductHolder ( BranchID const &  oid) const

Definition at line 454 of file Principal.cc.

References getProductHolderByIndex(), cmsHarvester::index, preg_, and edm::ProductHolderIndexInvalid.

Referenced by edm::EventPrincipal::getByProductID(), getForOutput(), getProvenance(), edm::EventPrincipal::getThinnedAssociation(), and edm::SubProcess::propagateProducts().

454  {
455  ProductHolderIndex index = preg_->indexFrom(bid);
456  if(index == ProductHolderIndexInvalid){
457  return ConstProductHolderPtr();
458  }
459  return getProductHolderByIndex(index);
460  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:59
unsigned int ProductHolderIndex
ConstProductHolderPtr getProductHolderByIndex(ProductHolderIndex const &oid) const
Definition: Principal.cc:463
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
Principal::ConstProductHolderPtr edm::Principal::getProductHolderByIndex ( ProductHolderIndex const &  oid) const

Definition at line 463 of file Principal.cc.

References cmsHarvester::index, and productHolders_.

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

463  {
464 
465  ConstProductHolderPtr const phb = productHolders_[index].get();
466  return phb;
467  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:59
ProductHolderCollection productHolders_
Definition: Principal.h:259
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

Definition at line 772 of file Principal.cc.

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

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

773  {
774  ConstProductHolderPtr const phb = getProductHolder(bid);
775  if(phb == nullptr) {
777  }
778 
779  if(phb->onDemand()) {
781  if(not phb->resolveProduct(status,false, nullptr, mcc) ) {
782  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
783  }
784  }
785  return *phb->provenance();
786  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:454
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:59
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:57
tuple status
Definition: ntuplemaker.py:245
WrapperBase const * edm::Principal::getThinnedProduct ( ProductID const &  ,
unsigned int &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 825 of file Principal.cc.

References assert().

825  {
826  assert(nullptr);
827  return nullptr;
828  }
assert(m_qm.get())
void edm::Principal::getThinnedProducts ( ProductID const &  ,
std::vector< WrapperBase const * > &  ,
std::vector< unsigned int > &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 831 of file Principal.cc.

References assert().

833  {
834  assert(nullptr);
835  }
assert(m_qm.get())
bool edm::Principal::isComplete ( ) const
inline

Definition at line 199 of file Principal.h.

References isComplete_().

Referenced by edm::PrincipalGetAdapter::isComplete().

199 {return isComplete_();}
virtual bool isComplete_() const
Definition: Principal.h:250
virtual bool edm::Principal::isComplete_ ( ) const
inlineprivatevirtual

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

Definition at line 250 of file Principal.h.

Referenced by isComplete().

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

Definition at line 195 of file Principal.h.

References lookupProcessOrder_.

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

195 { return lookupProcessOrder_; }
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:266
void edm::Principal::prefetch ( ProductHolderIndex  index,
bool  skipCurrentProcess,
ModuleCallingContext const *  mcc 
) const

Definition at line 529 of file Principal.cc.

References assert(), and productHolders_.

531  {
532  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_.at(index);
533  assert(0!=productHolder.get());
534  ProductHolderBase::ResolveStatus resolveStatus;
535  productHolder->resolveProduct(resolveStatus, skipCurrentProcess, nullptr, mcc);
536  }
assert(m_qm.get())
ProductHolderCollection productHolders_
Definition: Principal.h:259
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 150 of file Principal.h.

References processConfiguration_.

150 {return *processConfiguration_;}
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:256
ProcessHistory const& edm::Principal::processHistory ( ) const
inline
ProcessHistoryID const& edm::Principal::processHistoryID ( ) const
inline
EDProductGetter const* edm::Principal::prodGetter ( ) const
inline

Definition at line 94 of file Principal.h.

Referenced by edm::PrincipalGetAdapter::prodGetter().

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

Definition at line 154 of file Principal.h.

References productLookup_.

Referenced by findProductByLabel(), edm::PrincipalGetAdapter::getBranchDescription(), and getManyByType().

154 {return *productLookup_;}
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:264
ProductRegistry const& edm::Principal::productRegistry ( ) const
inline

Definition at line 152 of file Principal.h.

References preg_.

Referenced by fillPrincipal(), findProductByLabel(), edm::PrincipalGetAdapter::getBranchDescription(), edm::SubProcess::process(), and edm::ProvenanceCheckerOutputModule::write().

152 {return *preg_;}
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductHolderBase const *  productHolder 
) const
protected

Definition at line 852 of file Principal.cc.

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

Referenced by edm::RunPrincipal::put(), edm::LuminosityBlockPrincipal::put(), edm::RunPrincipal::resolveProductImmediate(), and edm::LuminosityBlockPrincipal::resolveProductImmediate().

852  {
853  bool willBePut = phb->putOrMergeProduct();
854  if(willBePut) {
855  checkUniquenessAndType(prod.get(), phb);
856  phb->putProduct(std::move(prod));
857  } else {
858  phb->checkType(*prod);
859  phb->mergeProduct(std::move(prod));
860  }
861  }
void checkUniquenessAndType(WrapperBase const *prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:838
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductProvenance prov,
ProductHolderBase productHolder 
)
protected

Definition at line 864 of file Principal.cc.

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

864  {
865  bool willBePut = phb->putOrMergeProduct();
866  if(willBePut) {
867  checkUniquenessAndType(prod.get(), phb);
868  phb->putProduct(std::move(prod), prov);
869  } else {
870  phb->checkType(*prod);
871  phb->mergeProduct(std::move(prod), prov);
872  }
873  }
void checkUniquenessAndType(WrapperBase const *prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:838
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::readFromSource ( ProductHolderBase const &  phb,
ModuleCallingContext const *  mcc 
) const
inline

Definition at line 187 of file Principal.h.

References readFromSource_().

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

187  {
188  readFromSource_(phb, mcc);
189  }
virtual void readFromSource_(ProductHolderBase const &, ModuleCallingContext const *) const
Definition: Principal.h:248
virtual void edm::Principal::readFromSource_ ( ProductHolderBase const &  ,
ModuleCallingContext const *   
) const
inlineprivatevirtual

Reimplemented in edm::EventPrincipal.

Definition at line 248 of file Principal.h.

Referenced by readFromSource().

248 {}
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

Definition at line 806 of file Principal.cc.

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

Referenced by edm::PoolSource::readEvent_(), edm::PoolSource::readLuminosityBlock_(), and edm::PoolSource::readRun_().

806  {
807  for(auto const& prod : bids) {
808  ProductHolderIndex index= preg_->indexFrom(prod);
810  ProductHolderIndex indexO = other.preg_->indexFrom(prod);
812  productHolders_[index].swap(other.productHolders_[indexO]);
813  productHolders_[index]->setPrincipal(this);
814  }
815  reader_->mergeReaders(other.reader());
816  }
DelayedReader * reader_
Definition: Principal.h:271
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:24
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:263
ProductHolderCollection productHolders_
Definition: Principal.h:259
size_t edm::Principal::size ( void  ) const

Definition at line 253 of file Principal.cc.

References parseEventContent::prod.

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

253  {
254  size_t size = 0U;
255  for(auto const& prod : *this) {
256  if(prod->singleProduct() && // Not a NoProcessProductHolder
257  !prod->productUnavailable() &&
258  !prod->onDemand() &&
259  !prod->branchDescription().dropped()) {
260  ++size;
261  }
262  }
263  return size;
264  }
size_t size() const
Definition: Principal.cc:253
virtual bool edm::Principal::unscheduledFill ( std::string const &  moduleLabel,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
pure virtual

Member Data Documentation

BranchType edm::Principal::branchType_
private
CacheIdentifier_t edm::Principal::cacheIdentifier_
private

Definition at line 283 of file Principal.h.

Referenced by cacheIdentifier(), and fillPrincipal().

HistoryAppender* edm::Principal::historyAppender_
private

Definition at line 281 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 266 of file Principal.h.

Referenced by fillPrincipal(), and lookupProcessOrder().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

Definition at line 267 of file Principal.h.

Referenced by fillPrincipal().

std::shared_ptr<ProductRegistry const> edm::Principal::preg_
private
ProcessConfiguration const* edm::Principal::processConfiguration_
private

Definition at line 256 of file Principal.h.

Referenced by fillPrincipal(), and processConfiguration().

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 254 of file Principal.h.

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

std::shared_ptr<ProcessHistory const> edm::Principal::processHistoryPtr_
private

Definition at line 252 of file Principal.h.

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

ProductHolderCollection edm::Principal::productHolders_
private
std::shared_ptr<ProductHolderIndexHelper const> edm::Principal::productLookup_
private

Definition at line 264 of file Principal.h.

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

std::set<void const*> edm::Principal::productPtrs_
mutableprivate

Definition at line 274 of file Principal.h.

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

DelayedReader* edm::Principal::reader_
private

Definition at line 271 of file Principal.h.

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