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 boost::filter_iterator
< FilledProductPtr,
ProductHolderCollection::iterator > 
iterator
 
typedef std::string ProcessName
 
typedef
ProcessHistory::const_iterator 
ProcessNameConstIterator
 
typedef std::vector
< propagate_const
< 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
 
iterator begin ()
 
BranchType const & branchType () const
 
CacheIdentifier_t cacheIdentifier () const
 
void clearPrincipal ()
 
void deleteProduct (BranchID const &id) const
 
const_iterator end () const
 
iterator end ()
 
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
 
ProductHolderBasegetModifiableProductHolder (BranchID const &oid)
 
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
 
void readAllFromSourceAndMergeImmediately ()
 
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::unique_ptr< ProductHolderBase > phb)
 
void addProductOrThrow (std::unique_ptr< ProductHolderBase > phb)
 
void checkUniquenessAndType (WrapperBase const *prod, ProductHolderBase const *productHolder) const
 
ProductHolderBasegetExistingProduct (BranchID const &branchID)
 
ProductHolderBase const * getExistingProduct (BranchID const &branchID) const
 
ProductHolderBase const * getExistingProduct (ProductHolderBase const &phb) const
 
void putOrMerge (BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
 

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
 
void putOrMerge (std::unique_ptr< WrapperBase > prod, ProductHolderBase const *productHolder) const
 
virtual void readFromSource_ (ProductHolderBase const &, ModuleCallingContext const *) const
 
void resolveProductImmediately (ProductHolderBase &phb)
 

Private Attributes

BranchType branchType_
 
CacheIdentifier_t cacheIdentifier_
 
edm::propagate_const
< HistoryAppender * > 
historyAppender_
 
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 55 of file Principal.h.

Member Typedef Documentation

Definition at line 62 of file Principal.h.

typedef unsigned long edm::Principal::CacheIdentifier_t

Definition at line 182 of file Principal.h.

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

Definition at line 58 of file Principal.h.

Definition at line 61 of file Principal.h.

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

Definition at line 59 of file Principal.h.

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

Definition at line 66 of file Principal.h.

Definition at line 60 of file Principal.h.

Definition at line 57 of file Principal.h.

Definition at line 65 of file Principal.h.

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

Definition at line 63 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 142 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_2017::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.

146  :
147  EDProductGetter(),
151  productHolders_(),
152  preg_(reg),
155  reader_(),
156  productPtrs_(),
157  branchType_(bt),
158  historyAppender_(historyAppender),
160  {
161  productHolders_.resize(reg->getNextIndexValue(bt));
162  //Now that these have been set, we can create the list of Branches we need.
163  std::string const source("source");
164  ProductRegistry::ProductList const& prodsList = reg->productList();
165  // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
166  // So, the non-alias product holders must be created first.
167  // Therefore, on this first pass, skip current EDAliases.
168  bool hasAliases = false;
169  for(auto const& prod : prodsList) {
170  BranchDescription const& bd = prod.second;
171  if(bd.branchType() == branchType_) {
172  if(bd.isAlias()) {
173  hasAliases = true;
174  } else {
175  auto cbd = std::make_shared<BranchDescription const>(bd);
176  if(bd.produced()) {
177  if(bd.moduleLabel() == source) {
178  addSourceProduct(cbd);
179  } else if(bd.onDemand()) {
182  } else {
183  addScheduledProduct(cbd);
184  }
185  } else {
186  addInputProduct(cbd);
187  }
188  }
189  }
190  }
191  // Now process any EDAliases
192  if(hasAliases) {
193  for(auto const& prod : prodsList) {
194  BranchDescription const& bd = prod.second;
195  if(bd.isAlias() && bd.branchType() == branchType_) {
196  auto cbd = std::make_shared<BranchDescription const>(bd);
197  addAliasedProduct(cbd);
198  }
199  }
200  }
201 
202  // Now create the ProductHolders that search in reverse process
203  // order and are used for queries where the process name is the
204  // empty string
205  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
206  std::vector<ProductHolderIndex> matchingHolders(lookupProcessNames.size(), ProductHolderIndexInvalid);
207  std::vector<bool> ambiguous(lookupProcessNames.size(), false);
208  unsigned int beginElements = productLookup_->beginElements();
209  std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
210  std::vector<ProductHolderIndexHelper::Range> const& ranges = productLookup_->ranges();
211  std::vector<ProductHolderIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
212  std::vector<char> const& processNamesCharArray = productLookup_->processNames();
213 
214  if (!sortedTypeIDs.empty()) {
215  ProductHolderIndex productHolderIndex = ProductHolderIndexInvalid;
216  for(unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
217  ProductHolderIndexHelper::Range const& range = ranges.at(k);
218  for (unsigned int i = range.begin(); i < range.end(); ++i) {
219  ProductHolderIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
220  if (product.startInProcessNames() == 0) {
221  if (productHolderIndex != ProductHolderIndexInvalid) {
222  std::shared_ptr<ProductHolderBase> newHolder = std::make_shared<NoProcessProductHolder>(matchingHolders, ambiguous);
223  productHolders_.at(productHolderIndex) = newHolder;
224  matchingHolders.assign(lookupProcessNames.size(), ProductHolderIndexInvalid);
225  ambiguous.assign(lookupProcessNames.size(), false);
226  }
227  productHolderIndex = product.index();
228  } else {
229  std::string process(&processNamesCharArray.at(product.startInProcessNames()));
230  auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
231  assert(iter != lookupProcessNames.end());
232  ProductHolderIndex iMatchingIndex = product.index();
233  assert(iMatchingIndex != ProductHolderIndexInvalid);
234  if (iMatchingIndex == ProductHolderIndexAmbiguous) {
235  assert(k >= beginElements);
236  ambiguous.at(iter - lookupProcessNames.begin()) = true;
237  } else {
238  matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
239  }
240  }
241  }
242  }
243  std::shared_ptr<ProductHolderBase> newHolder = std::make_shared<NoProcessProductHolder>(matchingHolders, ambiguous);
244  productHolders_.at(productHolderIndex) = newHolder;
245  }
246  }
BranchType branchType_
Definition: Principal.h:290
int i
Definition: DBlmapReader.cc:9
DelayedReader * reader_
Definition: Principal.h:285
static std::string const source("source")
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:266
PixelRecoRange< float > Range
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:138
ProcessHistoryID processHistoryID_
Definition: Principal.h:268
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:299
edm::propagate_const< HistoryAppender * > historyAppender_
Definition: Principal.h:295
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:280
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:287
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:297
ProductHolderCollection productHolders_
Definition: Principal.h:273
void addSourceProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:293
std::set< void const * > productPtrs_
Definition: Principal.h:288
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:278
string ranges
Definition: diffTwoXMLs.py:78
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:305
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:311
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:270
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:156
edm::Principal::~Principal ( )
virtual

Definition at line 248 of file Principal.cc.

248  {
249  }

Member Function Documentation

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

Definition at line 311 of file Principal.cc.

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

Referenced by Principal().

311  {
312  ProductHolderIndex index = preg_->indexFrom(bd->originalBranchID());
314 
315  std::unique_ptr<ProductHolderBase> phb(new AliasProductHolder(bd, dynamic_cast<ProducedProductHolder&>(*productHolders_[index])));
317  }
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
ProductHolderCollection productHolders_
Definition: Principal.h:273
def move
Definition: eostools.py:510
void addProductOrThrow(std::unique_ptr< ProductHolderBase > phb)
Definition: Principal.cc:443
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 299 of file Principal.cc.

References addProductOrThrow(), and eostools::move().

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

299  {
300  std::unique_ptr<ProductHolderBase> phb(new InputProductHolder(bd));
302  }
def move
Definition: eostools.py:510
void addProductOrThrow(std::unique_ptr< ProductHolderBase > phb)
Definition: Principal.cc:443
void edm::Principal::addProduct_ ( std::unique_ptr< ProductHolderBase phb)
protected

Definition at line 429 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().

429  {
430  BranchDescription const& bd = productHolder->branchDescription();
431  assert (!bd.className().empty());
432  assert (!bd.friendlyClassName().empty());
433  assert (!bd.moduleLabel().empty());
434  assert (!bd.processName().empty());
435  SharedProductPtr phb(productHolder.release());
436 
437  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
439  productHolders_[index] = phb;
440  }
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:65
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
ProductHolderCollection productHolders_
Definition: Principal.h:273
void edm::Principal::addProductOrThrow ( std::unique_ptr< ProductHolderBase phb)
protected

Definition at line 443 of file Principal.cc.

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

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

443  {
444  ProductHolderBase const* phb = getExistingProduct(*productHolder);
445  if(phb != nullptr) {
446  BranchDescription const& bd = productHolder->branchDescription();
447  throw Exception(errors::InsertFailure, "AlreadyPresent")
448  << "addProductOrThrow: Problem found while adding product, "
449  << "product already exists for ("
450  << bd.friendlyClassName() << ","
451  << bd.moduleLabel() << ","
452  << bd.productInstanceName() << ","
453  << bd.processName()
454  << ")\n";
455  }
456  addProduct_(std::move(productHolder));
457  }
def move
Definition: eostools.py:510
void addProduct_(std::unique_ptr< ProductHolderBase > phb)
Definition: Principal.cc:429
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 287 of file Principal.cc.

References addProductOrThrow(), and eostools::move().

Referenced by Principal().

287  {
288  std::unique_ptr<ProductHolderBase> phb(new ScheduledProductHolder(bd));
290  }
def move
Definition: eostools.py:510
void addProductOrThrow(std::unique_ptr< ProductHolderBase > phb)
Definition: Principal.cc:443
void edm::Principal::addSourceProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 293 of file Principal.cc.

References addProductOrThrow(), and eostools::move().

Referenced by Principal().

293  {
294  std::unique_ptr<ProductHolderBase> phb(new SourceProductHolder(bd));
296  }
def move
Definition: eostools.py:510
void addProductOrThrow(std::unique_ptr< ProductHolderBase > phb)
Definition: Principal.cc:443
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 305 of file Principal.cc.

References addProductOrThrow(), and eostools::move().

Referenced by Principal().

305  {
306  std::unique_ptr<ProductHolderBase> phb(new UnscheduledProductHolder(bd));
308  }
def move
Definition: eostools.py:510
void addProductOrThrow(std::unique_ptr< ProductHolderBase > phb)
Definition: Principal.cc:443
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 883 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().

883  {
884  if(preg_->getNextIndexValue(branchType_) != productHolders_.size()) {
885  productHolders_.resize(preg_->getNextIndexValue(branchType_));
886  for(auto const& prod : preg_->productList()) {
887  BranchDescription const& bd = prod.second;
888  if(bd.branchType() == branchType_) {
889  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
891  if(!productHolders_[index]) {
892  // no product holder. Must add one. The new entry must be an input product holder.
893  assert(!bd.produced());
894  auto cbd = std::make_shared<BranchDescription const>(bd);
895  addInputProduct(cbd);
896  }
897  }
898  }
899  }
900  assert(preg_->getNextIndexValue(branchType_) == productHolders_.size());
901  }
BranchType branchType_
Definition: Principal.h:290
assert(m_qm.get())
unsigned int ProductHolderIndex
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:299
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
ProductHolderCollection productHolders_
Definition: Principal.h:273
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

Definition at line 270 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().

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

Definition at line 168 of file Principal.h.

References productHolders_.

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

168 {return boost::make_filter_iterator<FilledProductPtr>(productHolders_.begin(), productHolders_.end());}
ProductHolderCollection productHolders_
Definition: Principal.h:273
iterator edm::Principal::begin ( void  )
inline

Definition at line 171 of file Principal.h.

References productHolders_.

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

Definition at line 179 of file Principal.h.

References branchType_.

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

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

Definition at line 183 of file Principal.h.

References cacheIdentifier_.

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

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

Definition at line 843 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_().

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

Definition at line 321 of file Principal.cc.

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

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

321  {
322  processHistoryPtr_.reset();
324  reader_ = nullptr;
325  for(auto& prod : *this) {
326  prod->resetProductData();
327  }
328  productPtrs_.clear();
329  }
DelayedReader * reader_
Definition: Principal.h:285
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:266
ProcessHistoryID processHistoryID_
Definition: Principal.h:268
Hash< ProcessHistoryType > ProcessHistoryID
std::set< void const * > productPtrs_
Definition: Principal.h:288
void edm::Principal::deleteProduct ( BranchID const &  id) const

Definition at line 332 of file Principal.cc.

References assert(), getExistingProduct(), and productPtrs_.

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

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

Definition at line 169 of file Principal.h.

References productHolders_.

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

169 {return boost::make_filter_iterator<FilledProductPtr>(productHolders_.end(), productHolders_.end());}
ProductHolderCollection productHolders_
Definition: Principal.h:273
iterator edm::Principal::end ( void  )
inline

Definition at line 172 of file Principal.h.

References productHolders_.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

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

Definition at line 344 of file Principal.cc.

References cacheIdentifier_, Exception, spr::find(), edm::ProcessHistoryRegistry::getMapped(), estimatePileup::hist, historyAppender_, edm::Hash< I >::isValid(), relval_2017::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().

346  {
347  //increment identifier here since clearPrincipal isn't called for Run/Lumi
349  if(reader) {
350  reader_ = reader;
351  }
352 
353  if (historyAppender_ && productRegistry().anyProductProduced()) {
355  historyAppender_->appendToProcessHistory(hist,
356  processHistoryRegistry.getMapped(hist),
359  }
360  else {
361  std::shared_ptr<ProcessHistory const> inputProcessHistory;
362  if (hist.isValid()) {
363  //does not own the pointer
364  auto noDel =[](void const*){};
365  inputProcessHistory =
366  std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist),noDel);
367  if (inputProcessHistory.get() == nullptr) {
369  << "Principal::fillPrincipal\n"
370  << "Input ProcessHistory not found in registry\n"
371  << "Contact a Framework developer\n";
372  }
373  } else {
374  //Since this is static we don't want it deleted
375  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory,[](void const*){});
376  }
378  processHistoryPtr_ = inputProcessHistory;
379  }
380 
382  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
383  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
384  unsigned int k = 0;
385  for (auto iter = processHistoryPtr_->rbegin(),
386  iEnd = processHistoryPtr_->rend();
387  iter != iEnd; ++iter) {
388  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
389  if (nameIter == lookupProcessNames.end()) {
390  continue;
391  }
392  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
393  ++k;
394  }
396  }
397  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:35
ProductRegistry const & productRegistry() const
Definition: Principal.h:154
DelayedReader * reader_
Definition: Principal.h:285
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:266
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:138
ProcessHistoryID processHistoryID_
Definition: Principal.h:268
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
edm::propagate_const< HistoryAppender * > historyAppender_
Definition: Principal.h:295
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:280
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:297
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:281
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:278
DelayedReader * reader() const
Definition: Principal.h:185
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:270
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 648 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().

653  {
654 
655  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
656 
657  ProductHolderIndex index = inputTag.indexFor(typeID, branchType(), &productRegistry());
658 
659  if (index == ProductHolderIndexInvalid) {
660 
661  char const* processName = inputTag.process().c_str();
662  if (skipCurrentProcess) {
663  processName = "\0";
664  }
665 
666  index = productLookup().index(kindOfType,
667  typeID,
668  inputTag.label().c_str(),
669  inputTag.instance().c_str(),
670  processName);
671 
672  if(index == ProductHolderIndexAmbiguous) {
673  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
674  } else if (index == ProductHolderIndexInvalid) {
675  ProductHolderIndexHelper::Matches matches =
676  productLookup().relatedIndexes(kindOfType, typeID);
677 
678  if (matches.numberOfMatches() == 0) {
679  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
680  }
681  return 0;
682  }
683  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
684  }
685  if(unlikely( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
686  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),inputTag.process());
687  }
688 
689 
690  auto const& productHolder = productHolders_[index];
691 
692  ProductHolderBase::ResolveStatus resolveStatus;
693  ProductData const* productData = productHolder->resolveProduct(resolveStatus, *this, skipCurrentProcess, sra, mcc);
694  if(resolveStatus == ProductHolderBase::Ambiguous) {
695  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
696  }
697  return productData;
698  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:154
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:102
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
BranchType const & branchType() const
Definition: Principal.h:179
ProductHolderCollection productHolders_
Definition: Principal.h:273
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< TypeID > const &missingDictionaries)
Definition: Principal.cc:39
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:156
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 701 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.

708  {
709 
711  typeID,
712  label.c_str(),
713  instance.c_str(),
714  process.c_str());
715 
716  if(index == ProductHolderIndexAmbiguous) {
717  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
718  } else if (index == ProductHolderIndexInvalid) {
719  ProductHolderIndexHelper::Matches matches =
720  productLookup().relatedIndexes(kindOfType, typeID);
721 
722  if (matches.numberOfMatches() == 0) {
723  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
724  }
725  return 0;
726  }
727 
728  if(unlikely( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
729  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
730  }
731 
732  auto const& productHolder = productHolders_[index];
733 
734  ProductHolderBase::ResolveStatus resolveStatus;
735  ProductData const* productData = productHolder->resolveProduct(resolveStatus, *this, false, sra, mcc);
736  if(resolveStatus == ProductHolderBase::Ambiguous) {
737  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
738  }
739  return productData;
740  }
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:102
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
BranchType const & branchType() const
Definition: Principal.h:179
ProductHolderCollection productHolders_
Definition: Principal.h:273
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:156
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 743 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

743  {
744  ProductData const* productData =
746  typeID,
747  tag,
748  nullptr,
749  nullptr,
750  mcc);
751  return productData;
752  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:648
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 617 of file Principal.cc.

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

Referenced by getManyByType().

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

Definition at line 798 of file Principal.cc.

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

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

Definition at line 476 of file Principal.cc.

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

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

481  {
482 
483  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, sra, mcc);
484  if(result == 0) {
485  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
486  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process());
487  }));
488  }
489  return BasicHandle(*result);
490  }
tuple result
Definition: mps_fire.py:95
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
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:73
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:648
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 493 of file Principal.cc.

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

500  {
501 
502  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, sra, mcc);
503  if(result == 0) {
504  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
505  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
506  }));
507  }
508  return BasicHandle(*result);
509  }
static PFTauRenderPlugin instance
tuple result
Definition: mps_fire.py:95
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
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:73
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:648
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 512 of file Principal.cc.

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

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

518  {
520  auto& productHolder = productHolders_[index];
521  assert(0!=productHolder.get());
522  ProductHolderBase::ResolveStatus resolveStatus;
523  ProductData const* productData = productHolder->resolveProduct(resolveStatus, *this, skipCurrentProcess, sra, mcc);
524  if(resolveStatus == ProductHolderBase::Ambiguous) {
525  ambiguous = true;
526  return BasicHandle();
527  }
528  if(productData == 0) {
529  return BasicHandle();
530  }
531  return BasicHandle(*productData);
532  }
assert(m_qm.get())
ProductHolderCollection productHolders_
Definition: Principal.h:273
ProductHolderBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 400 of file Principal.cc.

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

400  {
401  return const_cast<ProductHolderBase*>( const_cast<const Principal*>(this)->getExistingProduct(branchID));
402  }
Principal(std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductHolderIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender)
Definition: Principal.cc:142
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
ProductHolderBase const * edm::Principal::getExistingProduct ( BranchID const &  branchID) const
protected

Definition at line 405 of file Principal.cc.

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

405  {
406  ProductHolderIndex index = preg_->indexFrom(branchID);
408  return productHolders_.at(index).get();
409  }
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
ProductHolderCollection productHolders_
Definition: Principal.h:273
ProductHolderBase const * edm::Principal::getExistingProduct ( ProductHolderBase const &  phb) const
protected

Definition at line 412 of file Principal.cc.

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

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

Definition at line 755 of file Principal.cc.

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

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

756  {
757  ConstProductHolderPtr const phb = getProductHolder(bid);
758  if(phb == nullptr) {
760  }
761  if (phb->productWasDeleted()) {
762  throwProductDeletedException("getForOutput",phb->productType(),
763  phb->moduleLabel(),
764  phb->productInstanceName(),
765  phb->processName());
766  }
767  if(getProd) {
769  phb->resolveProduct(status,*this,false,nullptr, mcc);
770  }
771  if(!phb->provenance() || (!phb->product() && !phb->productProvenancePtr())) {
772  return OutputHandle();
773  }
774  return OutputHandle(phb->product(), &phb->branchDescription(), phb->productProvenancePtr());
775  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:460
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:61
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:59
tuple status
Definition: mps_update.py:57
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 824 of file Principal.cc.

References assert().

824  {
825  assert(nullptr);
826  return nullptr;
827  }
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 545 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_().

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

Definition at line 161 of file Principal.h.

References getProductHolder().

Referenced by edm::SubProcess::propagateProducts().

161  {
162  return const_cast<ProductHolderBase*>( const_cast<const Principal*>(this)->getProductHolder(oid));
163  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:460
Principal(std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductHolderIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender)
Definition: Principal.cc:142
Principal::ConstProductHolderPtr edm::Principal::getProductHolder ( BranchID const &  oid) const

Definition at line 460 of file Principal.cc.

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

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

460  {
461  ProductHolderIndex index = preg_->indexFrom(bid);
462  if(index == ProductHolderIndexInvalid){
463  return ConstProductHolderPtr();
464  }
465  return getProductHolderByIndex(index);
466  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:61
unsigned int ProductHolderIndex
ConstProductHolderPtr getProductHolderByIndex(ProductHolderIndex const &oid) const
Definition: Principal.cc:469
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
Principal::ConstProductHolderPtr edm::Principal::getProductHolderByIndex ( ProductHolderIndex const &  oid) const

Definition at line 469 of file Principal.cc.

References cmsHarvester::index, and productHolders_.

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

469  {
470 
471  ConstProductHolderPtr const phb = productHolders_[index].get();
472  return phb;
473  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:61
ProductHolderCollection productHolders_
Definition: Principal.h:273
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

Definition at line 778 of file Principal.cc.

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

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

779  {
780  ConstProductHolderPtr const phb = getProductHolder(bid);
781  if(phb == nullptr) {
783  }
784 
785  if(phb->onDemand()) {
787  if(not phb->resolveProduct(status,*this,false, nullptr, mcc) ) {
788  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
789  }
790  }
791  return *phb->provenance();
792  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:460
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:61
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:59
tuple status
Definition: mps_update.py:57
WrapperBase const * edm::Principal::getThinnedProduct ( ProductID const &  ,
unsigned int &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 830 of file Principal.cc.

References assert().

830  {
831  assert(nullptr);
832  return nullptr;
833  }
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 836 of file Principal.cc.

References assert().

838  {
839  assert(nullptr);
840  }
assert(m_qm.get())
bool edm::Principal::isComplete ( ) const
inline

Definition at line 210 of file Principal.h.

References isComplete_().

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

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

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

Definition at line 262 of file Principal.h.

Referenced by isComplete().

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

Definition at line 206 of file Principal.h.

References lookupProcessOrder_.

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

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

Definition at line 535 of file Principal.cc.

References assert(), and productHolders_.

537  {
538  auto const& productHolder = productHolders_.at(index);
539  assert(0!=productHolder.get());
540  ProductHolderBase::ResolveStatus resolveStatus;
541  productHolder->resolveProduct(resolveStatus, *this,skipCurrentProcess, nullptr, mcc);
542  }
assert(m_qm.get())
ProductHolderCollection productHolders_
Definition: Principal.h:273
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 152 of file Principal.h.

References processConfiguration_.

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

Definition at line 96 of file Principal.h.

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

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

Definition at line 156 of file Principal.h.

References productLookup_.

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

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

Definition at line 154 of file Principal.h.

References preg_.

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

154 {return *preg_;}
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
void edm::Principal::putOrMerge ( BranchDescription const &  bd,
std::unique_ptr< WrapperBase edp 
) const
protected

Definition at line 869 of file Principal.cc.

References assert(), edm::BranchDescription::branchID(), Exception, getExistingProduct(), edm::errors::InsertFailure, and eostools::move().

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

869  {
870  if(edp.get() == nullptr) {
871  throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
872  << "put: Cannot put because unique_ptr to product is null."
873  << "\n";
874  }
875  auto phb = getExistingProduct(bd.branchID());
876  assert(phb);
877  // ProductHolder assumes ownership
878  putOrMerge(std::move(edp), phb);
879  }
assert(m_qm.get())
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
Definition: Principal.cc:869
def move
Definition: eostools.py:510
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductHolderBase const *  productHolder 
) const
private

Definition at line 857 of file Principal.cc.

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

857  {
858  bool willBePut = phb->putOrMergeProduct();
859  if(willBePut) {
860  checkUniquenessAndType(prod.get(), phb);
861  phb->putProduct(std::move(prod));
862  } else {
863  phb->checkType(*prod);
864  phb->mergeProduct(std::move(prod));
865  }
866  }
void checkUniquenessAndType(WrapperBase const *prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:843
def move
Definition: eostools.py:510
void edm::Principal::readAllFromSourceAndMergeImmediately ( )

Definition at line 904 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), parseEventContent::prod, edm::BranchDescription::produced(), edm::ProductHolderBase::productUnavailable(), resolveProductImmediately(), and edm::ProductHolderBase::singleProduct().

Referenced by edm::RootFile::readLuminosityBlock_(), and edm::RootFile::readRun_().

904  {
905  for(auto & prod : *this) {
906  ProductHolderBase & phb = *prod;
907  if(phb.singleProduct() && !phb.branchDescription().produced()) {
908  if(!phb.productUnavailable()) {
910  }
911  }
912  }
913  }
void resolveProductImmediately(ProductHolderBase &phb)
Definition: Principal.cc:915
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::readFromSource ( ProductHolderBase const &  phb,
ModuleCallingContext const *  mcc 
) const
inline

Definition at line 196 of file Principal.h.

References readFromSource_().

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

196  {
197  readFromSource_(phb, mcc);
198  }
virtual void readFromSource_(ProductHolderBase const &, ModuleCallingContext const *) const
Definition: Principal.h:258
virtual void edm::Principal::readFromSource_ ( ProductHolderBase const &  ,
ModuleCallingContext const *   
) const
inlineprivatevirtual

Reimplemented in edm::EventPrincipal.

Definition at line 258 of file Principal.h.

Referenced by readFromSource().

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

Definition at line 812 of file Principal.cc.

References assert(), edm::get_underlying_safe(), 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_().

812  {
813  for(auto& prod : bids) {
814  ProductHolderIndex index= preg_->indexFrom(prod);
816  ProductHolderIndex indexO = other.preg_->indexFrom(prod);
818  get_underlying_safe(productHolders_[index]).swap(get_underlying_safe(other.productHolders_[indexO]));
819  }
820  reader_->mergeReaders(other.reader());
821  }
DelayedReader * reader_
Definition: Principal.h:285
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:24
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:277
ProductHolderCollection productHolders_
Definition: Principal.h:273
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void edm::Principal::resolveProductImmediately ( ProductHolderBase phb)
private

Definition at line 915 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::getProduct(), eostools::move(), edm::BranchDescription::produced(), putOrMerge(), and reader().

Referenced by readAllFromSourceAndMergeImmediately().

915  {
916  if(phb.branchDescription().produced()) return; // nothing to do.
917  if(!reader()) return; // nothing to do.
918 
919  // must attempt to load from persistent store
920  BranchKey const bk = BranchKey(phb.branchDescription());
921  std::unique_ptr<WrapperBase> edp(reader()->getProduct(bk, this));
922 
923  // Now fix up the ProductHolder
924  if(edp.get() != nullptr) {
925  putOrMerge(std::move(edp), &phb);
926  }
927  }
T const * getProduct(RefCore const &ref)
Definition: RefCoreGet.h:41
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
Definition: Principal.cc:869
def move
Definition: eostools.py:510
DelayedReader * reader() const
Definition: Principal.h:185
size_t edm::Principal::size ( void  ) const

Definition at line 255 of file Principal.cc.

References parseEventContent::prod.

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

255  {
256  size_t size = 0U;
257  for(auto const& prod : *this) {
258  if(prod->singleProduct() && // Not a NoProcessProductHolder
259  !prod->productUnavailable() &&
260  !prod->onDemand() &&
261  !prod->branchDescription().dropped()) {
262  ++size;
263  }
264  }
265  return size;
266  }
size_t size() const
Definition: Principal.cc:255
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 297 of file Principal.h.

Referenced by cacheIdentifier(), and fillPrincipal().

edm::propagate_const<HistoryAppender*> edm::Principal::historyAppender_
private

Definition at line 295 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 280 of file Principal.h.

Referenced by fillPrincipal(), and lookupProcessOrder().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

Referenced by fillPrincipal(), and processConfiguration().

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 268 of file Principal.h.

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

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

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

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

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

Definition at line 288 of file Principal.h.

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

DelayedReader* edm::Principal::reader_
private

Definition at line 285 of file Principal.h.

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