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, 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, ModuleCallingContext const *mcc) const
 
BasicHandle getByToken (KindOfType kindOfType, TypeID const &typeID, ProductHolderIndex index, bool skipCurrentProcess, bool &ambiguous, 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, 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, ModuleCallingContext const *mcc) const =0
 
virtual ~Principal ()
 
- Public Member Functions inherited from edm::EDProductGetter
 EDProductGetter ()
 
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, 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, ModuleCallingContext const *mcc) const
 
void findProducts (std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, ModuleCallingContext const *mcc) const
 
virtual WrapperBase const * getIt (ProductID const &) const
 
virtual bool isComplete_ () const
 
virtual void readFromSource_ (ProductHolderBase const &phb, ModuleCallingContext const *mcc) 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 53 of file Principal.h.

Member Typedef Documentation

Definition at line 59 of file Principal.h.

typedef unsigned long edm::Principal::CacheIdentifier_t

Definition at line 168 of file Principal.h.

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

Definition at line 56 of file Principal.h.

Definition at line 58 of file Principal.h.

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

Definition at line 63 of file Principal.h.

Definition at line 57 of file Principal.h.

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

Definition at line 55 of file Principal.h.

Definition at line 62 of file Principal.h.

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

Definition at line 60 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 125 of file Principal.cc.

References addAliasedProduct(), addInputProduct(), addScheduledProduct(), addSourceProduct(), addUnscheduledProduct(), edm::ProductHolderIndexHelper::Range::begin(), edm::BranchDescription::branchType(), branchType_, edm::ProductHolderIndexHelper::Range::end(), spr::find(), i, edm::ProductHolderIndexHelper::IndexAndNames::index(), edm::InEvent, edm::BranchDescription::isAlias(), getDQMSummary::iter, gen::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.

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

Definition at line 231 of file Principal.cc.

231  {
232  }

Member Function Documentation

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

Definition at line 294 of file Principal.cc.

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

Referenced by Principal().

294  {
295  ProductHolderIndex index = preg_->indexFrom(bd->originalBranchID());
296  assert(index != ProductHolderIndexInvalid);
297 
298  std::auto_ptr<ProductHolderBase> phb(new AliasProductHolder(bd, dynamic_cast<ProducedProductHolder&>(*productHolders_[index])));
299  addProductOrThrow(phb);
300  }
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
ProductHolderCollection productHolders_
Definition: Principal.h:245
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:412
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 282 of file Principal.cc.

References addProductOrThrow().

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

282  {
283  std::auto_ptr<ProductHolderBase> phb(new InputProductHolder(bd, this));
284  addProductOrThrow(phb);
285  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:412
void edm::Principal::addProduct_ ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 398 of file Principal.cc.

References 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().

398  {
399  BranchDescription const& bd = productHolder->branchDescription();
400  assert (!bd.className().empty());
401  assert (!bd.friendlyClassName().empty());
402  assert (!bd.moduleLabel().empty());
403  assert (!bd.processName().empty());
404  SharedProductPtr phb(productHolder.release());
405 
406  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
407  assert(index != ProductHolderIndexInvalid);
408  productHolders_[index] = phb;
409  }
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:62
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
ProductHolderCollection productHolders_
Definition: Principal.h:245
void edm::Principal::addProductOrThrow ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 412 of file Principal.cc.

References addProduct_(), edm::hlt::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().

412  {
413  ProductHolderBase const* phb = getExistingProduct(*productHolder);
414  if(phb != nullptr) {
415  BranchDescription const& bd = productHolder->branchDescription();
416  throw Exception(errors::InsertFailure, "AlreadyPresent")
417  << "addProductOrThrow: Problem found while adding product, "
418  << "product already exists for ("
419  << bd.friendlyClassName() << ","
420  << bd.moduleLabel() << ","
421  << bd.productInstanceName() << ","
422  << bd.processName()
423  << ")\n";
424  }
425  addProduct_(productHolder);
426  }
void addProduct_(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:398
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:383
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 270 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

270  {
271  std::auto_ptr<ProductHolderBase> phb(new ScheduledProductHolder(bd));
272  addProductOrThrow(phb);
273  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:412
void edm::Principal::addSourceProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 276 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

276  {
277  std::auto_ptr<ProductHolderBase> phb(new SourceProductHolder(bd));
278  addProductOrThrow(phb);
279  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:412
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 288 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

288  {
289  std::auto_ptr<ProductHolderBase> phb(new UnscheduledProductHolder(bd, this));
290  addProductOrThrow(phb);
291  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:412
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 830 of file Principal.cc.

References addInputProduct(), 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().

830  {
831  if(preg_->getNextIndexValue(branchType_) != productHolders_.size()) {
832  productHolders_.resize(preg_->getNextIndexValue(branchType_));
833  for(auto const& prod : preg_->productList()) {
834  BranchDescription const& bd = prod.second;
835  if(bd.branchType() == branchType_) {
836  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
837  assert(index != ProductHolderIndexInvalid);
838  if(!productHolders_[index]) {
839  // no product holder. Must add one. The new entry must be an input product holder.
840  assert(!bd.produced());
841  auto cbd = std::make_shared<BranchDescription const>(bd);
842  addInputProduct(cbd);
843  }
844  }
845  }
846  }
847  assert(preg_->getNextIndexValue(branchType_) == productHolders_.size());
848  }
BranchType branchType_
Definition: Principal.h:262
unsigned int ProductHolderIndex
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:282
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
ProductHolderCollection productHolders_
Definition: Principal.h:245
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

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

253  {
254  ProductRegistry::ProductList const& prodsList = reg.productList();
255  for(auto const& prod : prodsList) {
256  BranchDescription const& bd = prod.second;
257  if(!bd.produced() && (bd.branchType() == branchType_)) {
258  auto cbd = std::make_shared<BranchDescription const>(bd);
259  ProductHolderBase* phb = getExistingProduct(cbd->branchID());
260  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
261  return false;
262  }
263  phb->resetBranchDescription(cbd);
264  }
265  }
266  return true;
267  }
BranchType branchType_
Definition: Principal.h:262
std::map< BranchKey, BranchDescription > ProductList
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
Definition: ProductHolder.h:98
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:383
const_iterator edm::Principal::begin ( void  ) const
inline

Definition at line 157 of file Principal.h.

References productHolders_.

Referenced by edm::check(), edm::OutputModule::updateBranchParents(), edm::one::OutputModuleBase::updateBranchParents(), and edm::ProvenanceCheckerOutputModule::write().

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

Definition at line 165 of file Principal.h.

References branchType_.

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

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

Definition at line 169 of file Principal.h.

References cacheIdentifier_.

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

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

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

792  {
793  if(prod == nullptr) return;
794  // These are defensive checks against things that should never happen, but have.
795  // Checks that the same physical product has not already been put into the event.
796  bool alreadyPresent = !productPtrs_.insert(prod).second;
797  if(alreadyPresent) {
798  phb->checkType(*prod);
799  throwCorruptionException("checkUniquenessAndType", phb->branchDescription().branchName());
800  }
801  // Checks that the real type of the product matches the branch.
802  phb->checkType(*prod);
803  }
static void throwCorruptionException(char const *where, std::string const &branchName)
Definition: Principal.cc:54
std::set< void const * > productPtrs_
Definition: Principal.h:260
void edm::Principal::clearPrincipal ( )

Definition at line 304 of file Principal.cc.

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

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

304  {
305  processHistoryPtr_.reset();
307  reader_ = nullptr;
308  for(auto const& prod : *this) {
309  prod->resetProductData();
310  }
311  productPtrs_.clear();
312  }
DelayedReader * reader_
Definition: Principal.h:257
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:238
ProcessHistoryID processHistoryID_
Definition: Principal.h:240
Hash< ProcessHistoryType > ProcessHistoryID
std::set< void const * > productPtrs_
Definition: Principal.h:260
void edm::Principal::deleteProduct ( BranchID const &  id)

Definition at line 315 of file Principal.cc.

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

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

315  {
316  ProductHolderBase* phb = getExistingProduct(id);
317  assert(nullptr != phb);
318  auto itFound = productPtrs_.find(phb->product());
319  if(itFound != productPtrs_.end()) {
320  productPtrs_.erase(itFound);
321  }
322  phb->deleteProduct();
323  }
std::set< void const * > productPtrs_
Definition: Principal.h:260
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:383
const_iterator edm::Principal::end ( void  ) const
inline
void edm::Principal::fillPrincipal ( ProcessHistoryID const &  hist,
ProcessHistoryRegistry const &  phr,
DelayedReader reader 
)

Definition at line 327 of file Principal.cc.

References edm::HistoryAppender::appendToProcessHistory(), cacheIdentifier_, edm::hlt::Exception, spr::find(), edm::ProcessHistoryRegistry::getMapped(), estimatePileup::hist, historyAppender_, edm::Hash< I >::isValid(), getDQMSummary::iter, gen::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().

329  {
330  //increment identifier here since clearPrincipal isn't called for Run/Lumi
332  if(reader) {
333  reader_ = reader;
334  }
335 
336  if (historyAppender_ && productRegistry().anyProductProduced()) {
339  processHistoryRegistry.getMapped(hist),
342  }
343  else {
344  std::shared_ptr<ProcessHistory const> inputProcessHistory;
345  if (hist.isValid()) {
346  //does not own the pointer
347  auto noDel =[](void const*){};
348  inputProcessHistory =
349  std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist),noDel);
350  if (inputProcessHistory.get() == nullptr) {
352  << "Principal::fillPrincipal\n"
353  << "Input ProcessHistory not found in registry\n"
354  << "Contact a Framework developer\n";
355  }
356  } else {
357  //Since this is static we don't want it deleted
358  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory,[](void const*){});
359  }
361  processHistoryPtr_ = inputProcessHistory;
362  }
363 
365  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
366  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
367  unsigned int k = 0;
368  for (auto iter = processHistoryPtr_->rbegin(),
369  iEnd = processHistoryPtr_->rend();
370  iter != iEnd; ++iter) {
371  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
372  if (nameIter == lookupProcessNames.end()) {
373  continue;
374  }
375  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
376  ++k;
377  }
379  }
380  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:34
ProductRegistry const & productRegistry() const
Definition: Principal.h:147
DelayedReader * reader_
Definition: Principal.h:257
HistoryAppender * historyAppender_
Definition: Principal.h:267
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:238
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:121
ProcessHistoryID processHistoryID_
Definition: Principal.h:240
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:252
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:269
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:253
int k[5][pyjets_maxn]
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:250
DelayedReader * reader() const
Definition: Principal.h:171
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:242
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumer,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 612 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(), edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::InputTag::process(), 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().

616  {
617 
618  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
619 
620  ProductHolderIndex index = inputTag.indexFor(typeID, branchType(), &productRegistry());
621 
622  if (index == ProductHolderIndexInvalid) {
623 
624  char const* processName = inputTag.process().c_str();
625  if (skipCurrentProcess) {
626  processName = "\0";
627  }
628 
629  index = productLookup().index(kindOfType,
630  typeID,
631  inputTag.label().c_str(),
632  inputTag.instance().c_str(),
633  processName);
634 
635  if(index == ProductHolderIndexAmbiguous) {
636  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
637  } else if (index == ProductHolderIndexInvalid) {
638  ProductHolderIndexHelper::Matches matches =
639  productLookup().relatedIndexes(kindOfType, typeID);
640 
641  if (matches.numberOfMatches() == 0) {
642  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
643  }
644  return 0;
645  }
646  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
647  }
648  if(unlikely( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
649  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),inputTag.process());
650  }
651 
652 
653  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
654 
655  ProductHolderBase::ResolveStatus resolveStatus;
656  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess, mcc);
657  if(resolveStatus == ProductHolderBase::Ambiguous) {
658  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
659  }
660  return productData;
661  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:147
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:90
#define unlikely(x)
Definition: Likely.h:21
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
BranchType const & branchType() const
Definition: Principal.h:165
ProductHolderCollection productHolders_
Definition: Principal.h:245
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< std::string > const &missingDictionaries)
Definition: Principal.cc:38
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
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,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 664 of file Principal.cc.

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

670  {
671 
673  typeID,
674  label.c_str(),
675  instance.c_str(),
676  process.c_str());
677 
678  if(index == ProductHolderIndexAmbiguous) {
679  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
680  } else if (index == ProductHolderIndexInvalid) {
681  ProductHolderIndexHelper::Matches matches =
682  productLookup().relatedIndexes(kindOfType, typeID);
683 
684  if (matches.numberOfMatches() == 0) {
685  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
686  }
687  return 0;
688  }
689 
690  if(unlikely( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
691  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
692  }
693 
694  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
695 
696  ProductHolderBase::ResolveStatus resolveStatus;
697  ProductData const* productData = productHolder->resolveProduct(resolveStatus, false, mcc);
698  if(resolveStatus == ProductHolderBase::Ambiguous) {
699  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
700  }
701  return productData;
702  }
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:90
#define unlikely(x)
Definition: Likely.h:21
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
BranchType const & branchType() const
Definition: Principal.h:165
ProductHolderCollection productHolders_
Definition: Principal.h:245
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< std::string > const &missingDictionaries)
Definition: Principal.cc:38
tuple process
Definition: LaserDQM_cfg.py:3
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 705 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

705  {
706  ProductData const* productData =
708  typeID,
709  tag,
710  nullptr,
711  mcc);
712  return productData;
713  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, ModuleCallingContext const *mcc) const
Definition: Principal.cc:612
void edm::Principal::findProducts ( std::vector< ProductHolderBase const * > const &  holders,
TypeID const &  typeID,
BasicHandleVec results,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 582 of file Principal.cc.

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

Referenced by getManyByType().

585  {
586 
587  for (auto iter = processHistoryPtr_->rbegin(),
588  iEnd = processHistoryPtr_->rend();
589  iter != iEnd; ++iter) {
590  std::string const& process = iter->processName();
591  for (auto productHolder : holders) {
592  BranchDescription const& bd = productHolder->branchDescription();
593  if (process == bd.processName()) {
594 
595  // Ignore aliases to avoid matching the same product multiple times.
596  if(bd.isAlias()) {
597  continue;
598  }
599 
600  ProductHolderBase::ResolveStatus resolveStatus;
601  ProductData const* productData = productHolder->resolveProduct(resolveStatus, false, mcc);
602  if(productData) {
603  // Skip product if not available.
604  results.emplace_back(*productData);
605  }
606  }
607  }
608  }
609  }
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:238
tuple process
Definition: LaserDQM_cfg.py:3
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 759 of file Principal.cc.

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

759  {
760  provenances.clear();
761  for(auto const& productHolder : *this) {
762  if(productHolder->singleProduct() && productHolder->provenanceAvailable() && !productHolder->branchDescription().isAlias()) {
763  // We do not attempt to get the event/lumi/run status from the provenance,
764  // because the per event provenance may have been dropped.
765  if(productHolder->provenance()->product().present()) {
766  provenances.push_back(productHolder->provenance());
767  }
768  }
769  }
770  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumes,
ModuleCallingContext const *  mcc 
) const

Definition at line 445 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(), edm::detail::NamedEventSelector::fill(), PileUpEventPrincipal::getByLabel(), edm::PrincipalGetAdapter::getByLabel_(), edm::PrincipalGetAdapter::getMatchingSequenceByLabel_(), and FRDEventOutputModule< Consumer >::write().

449  {
450 
451  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, mcc);
452  if(result == 0) {
453  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
454  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process());
455  }));
456  }
457  return BasicHandle(*result);
458  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, ModuleCallingContext const *mcc) const
Definition: Principal.cc:612
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:61
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
EDConsumerBase const *  consumes,
ModuleCallingContext const *  mcc 
) const

Definition at line 461 of file Principal.cc.

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

467  {
468 
469  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, mcc);
470  if(result == 0) {
471  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
472  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
473  }));
474  }
475  return BasicHandle(*result);
476  }
static PFTauRenderPlugin instance
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, ModuleCallingContext const *mcc) const
Definition: Principal.cc:612
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:61
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductHolderIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
ModuleCallingContext const *  mcc 
) const

Definition at line 479 of file Principal.cc.

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

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

484  {
486  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
487  assert(0!=productHolder.get());
488  ProductHolderBase::ResolveStatus resolveStatus;
489  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess, mcc);
490  if(resolveStatus == ProductHolderBase::Ambiguous) {
491  ambiguous = true;
492  return BasicHandle();
493  }
494  if(productData == 0) {
495  return BasicHandle();
496  }
497  return BasicHandle(*productData);
498  }
ProductHolderCollection productHolders_
Definition: Principal.h:245
ProductHolderBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 383 of file Principal.cc.

References 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().

383  {
384  ProductHolderIndex index = preg_->indexFrom(branchID);
385  assert(index != ProductHolderIndexInvalid);
386  SharedProductPtr ptr = productHolders_.at(index);
387  return ptr.get();
388  }
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:62
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
ProductHolderCollection productHolders_
Definition: Principal.h:245
ProductHolderBase * edm::Principal::getExistingProduct ( ProductHolderBase const &  phb)
protected

Definition at line 391 of file Principal.cc.

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

391  {
392  ProductHolderBase* phb = getExistingProduct(productHolder.branchDescription().branchID());
393  assert(nullptr == phb || BranchKey(productHolder.branchDescription()) == BranchKey(phb->branchDescription()));
394  return phb;
395  }
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:383
OutputHandle edm::Principal::getForOutput ( BranchID const &  bid,
bool  getProd,
ModuleCallingContext const *  mcc 
) const

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

717  {
718  ConstProductHolderPtr const phb = getProductHolder(bid);
719  if(phb == nullptr) {
721  }
722  if (phb->productWasDeleted()) {
723  throwProductDeletedException("getForOutput",phb->productType(),
724  phb->moduleLabel(),
725  phb->productInstanceName(),
726  phb->processName());
727  }
728  if(getProd) {
730  phb->resolveProduct(status,false,mcc);
731  }
732  if(!phb->provenance() || (!phb->product() && !phb->productProvenancePtr())) {
733  return OutputHandle();
734  }
735  return OutputHandle(phb->product(), &phb->branchDescription(), phb->productProvenancePtr());
736  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:429
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
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:47
tuple status
Definition: ntuplemaker.py:245
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
privatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 786 of file Principal.cc.

786  {
787  assert(nullptr);
788  return nullptr;
789  }
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results,
EDConsumerBase const *  consumes,
ModuleCallingContext const *  mcc 
) const

Definition at line 511 of file Principal.cc.

References branchType(), findProducts(), i, edm::ProductHolderIndexHelper::Matches::index(), cmsHarvester::index, edm::ProductHolderIndexHelper::Matches::isFullyResolved(), 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_().

514  {
515 
516  assert(results.empty());
517 
518  if(unlikely(consumer and (not consumer->registeredToConsumeMany(typeID,branchType())))) {
519  failedToRegisterConsumesMany(typeID);
520  }
521 
522  // This finds the indexes to all the ProductHolder's matching the type
523  ProductHolderIndexHelper::Matches matches =
525 
526  if (matches.numberOfMatches() == 0) {
527  maybeThrowMissingDictionaryException(typeID, false, preg_->missingDictionaries());
528  return;
529  }
530 
531  results.reserve(matches.numberOfMatches());
532 
533  // Loop over the ProductHolders. Add the products that are actually
534  // present into the results. This will also trigger delayed reading,
535  // on demand production, and check for deleted products as appropriate.
536 
537  // Over the years the code that uses getManyByType has grown to depend
538  // on the ordering of the results. The order originally was just an
539  // accident of how previous versions of the code were written, but
540  // here we have to go through some extra effort to preserve that ordering.
541 
542  // We build a list of holders that match a particular label and instance.
543  // When that list is complete we call findProducts, which loops over
544  // that list in reverse order of the ProcessHistory (starts with the
545  // most recent). Then we clear the list and repeat this until all the
546  // matching label and instance subsets have been dealt with.
547 
548  // Note that the function isFullyResolved returns true for the ProductHolders
549  // that are associated with an empty process name. Those are the ones that
550  // know how to search for the most recent process name matching
551  // a label and instance. We do not need these for getManyByType and
552  // skip them. In addition to skipping them, we make use of the fact
553  // that they mark the beginning of each subset of holders with the same
554  // label and instance. They tell us when to call findProducts.
555 
556  std::vector<ProductHolderBase const*> holders;
557 
558  for(unsigned int i = 0; i < matches.numberOfMatches(); ++i) {
559 
560  ProductHolderIndex index = matches.index(i);
561 
562  if(!matches.isFullyResolved(i)) {
563  if(!holders.empty()) {
564  // Process the ones with a particular module label and instance
565  findProducts(holders, typeID, results, mcc);
566  holders.clear();
567  }
568  } else {
569  ProductHolderBase const* productHolder = productHolders_.at(index).get();
570  assert(productHolder);
571  holders.push_back(productHolder);
572  }
573  }
574  // Do not miss the last subset of products
575  if(!holders.empty()) {
576  findProducts(holders, typeID, results, mcc);
577  }
578  return;
579  }
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
int i
Definition: DBlmapReader.cc:9
unsigned int ProductHolderIndex
#define unlikely(x)
Definition: Likely.h:21
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
BranchType const & branchType() const
Definition: Principal.h:165
ProductHolderCollection productHolders_
Definition: Principal.h:245
void findProducts(std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, ModuleCallingContext const *mcc) const
Definition: Principal.cc:582
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< std::string > const &missingDictionaries)
Definition: Principal.cc:38
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
Principal::ConstProductHolderPtr edm::Principal::getProductHolder ( BranchID const &  oid) const

Definition at line 429 of file Principal.cc.

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

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

429  {
430  ProductHolderIndex index = preg_->indexFrom(bid);
431  if(index == ProductHolderIndexInvalid){
432  return ConstProductHolderPtr();
433  }
434  return getProductHolderByIndex(index);
435  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
unsigned int ProductHolderIndex
ConstProductHolderPtr getProductHolderByIndex(ProductHolderIndex const &oid) const
Definition: Principal.cc:438
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
Principal::ConstProductHolderPtr edm::Principal::getProductHolderByIndex ( ProductHolderIndex const &  oid) const

Definition at line 438 of file Principal.cc.

References cmsHarvester::index, and productHolders_.

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

438  {
439 
440  ConstProductHolderPtr const phb = productHolders_[index].get();
441  return phb;
442  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
ProductHolderCollection productHolders_
Definition: Principal.h:245
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

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

740  {
741  ConstProductHolderPtr const phb = getProductHolder(bid);
742  if(phb == nullptr) {
744  }
745 
746  if(phb->onDemand()) {
748  if(not phb->resolveProduct(status,false,mcc) ) {
749  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
750  }
751  }
752  return *phb->provenance();
753  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:429
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:47
tuple status
Definition: ntuplemaker.py:245
bool edm::Principal::isComplete ( ) const
inline

Definition at line 193 of file Principal.h.

References isComplete_().

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

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

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

Definition at line 236 of file Principal.h.

Referenced by isComplete().

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

Definition at line 189 of file Principal.h.

References lookupProcessOrder_.

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

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

Definition at line 501 of file Principal.cc.

References productHolders_.

503  {
504  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_.at(index);
505  assert(0!=productHolder.get());
506  ProductHolderBase::ResolveStatus resolveStatus;
507  productHolder->resolveProduct(resolveStatus, skipCurrentProcess, mcc);
508  }
ProductHolderCollection productHolders_
Definition: Principal.h:245
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 145 of file Principal.h.

References processConfiguration_.

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

Definition at line 93 of file Principal.h.

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

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

Definition at line 149 of file Principal.h.

References productLookup_.

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

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

Definition at line 147 of file Principal.h.

References preg_.

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

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

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

806  {
807  bool willBePut = phb->putOrMergeProduct();
808  if(willBePut) {
809  checkUniquenessAndType(prod.get(), phb);
810  phb->putProduct(std::move(prod));
811  } else {
812  phb->checkType(*prod);
813  phb->mergeProduct(std::move(prod));
814  }
815  }
void checkUniquenessAndType(WrapperBase const *prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:792
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductProvenance prov,
ProductHolderBase productHolder 
)
protected

Definition at line 818 of file Principal.cc.

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

818  {
819  bool willBePut = phb->putOrMergeProduct();
820  if(willBePut) {
821  checkUniquenessAndType(prod.get(), phb);
822  phb->putProduct(std::move(prod), prov);
823  } else {
824  phb->checkType(*prod);
825  phb->mergeProduct(std::move(prod), prov);
826  }
827  }
void checkUniquenessAndType(WrapperBase const *prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:792
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::readFromSource ( ProductHolderBase const &  phb,
ModuleCallingContext const *  mcc 
) const
inline

Definition at line 182 of file Principal.h.

References readFromSource_().

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

182  {
183  readFromSource_(phb, mcc);
184  }
virtual void readFromSource_(ProductHolderBase const &phb, ModuleCallingContext const *mcc) const
Definition: Principal.h:234
virtual void edm::Principal::readFromSource_ ( ProductHolderBase const &  phb,
ModuleCallingContext const *  mcc 
) const
inlineprivatevirtual

Reimplemented in edm::EventPrincipal.

Definition at line 234 of file Principal.h.

Referenced by readFromSource().

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

Definition at line 773 of file Principal.cc.

References 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_().

773  {
774  for(auto const& prod : bids) {
775  ProductHolderIndex index= preg_->indexFrom(prod);
776  assert(index!=ProductHolderIndexInvalid);
777  ProductHolderIndex indexO = other.preg_->indexFrom(prod);
778  assert(indexO!=ProductHolderIndexInvalid);
779  productHolders_[index].swap(other.productHolders_[indexO]);
780  productHolders_[index]->setPrincipal(this);
781  }
782  reader_->mergeReaders(other.reader());
783  }
DelayedReader * reader_
Definition: Principal.h:257
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:24
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:249
ProductHolderCollection productHolders_
Definition: Principal.h:245
size_t edm::Principal::size ( void  ) const

Definition at line 238 of file Principal.cc.

References parseEventContent::prod.

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

238  {
239  size_t size = 0U;
240  for(auto const& prod : *this) {
241  if(prod->singleProduct() && // Not a NoProcessProductHolder
242  !prod->productUnavailable() &&
243  !prod->onDemand() &&
244  !prod->branchDescription().dropped()) {
245  ++size;
246  }
247  }
248  return size;
249  }
size_t size() const
Definition: Principal.cc:238
virtual bool edm::Principal::unscheduledFill ( std::string const &  moduleLabel,
ModuleCallingContext const *  mcc 
) const
pure virtual

Member Data Documentation

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

Definition at line 269 of file Principal.h.

Referenced by cacheIdentifier(), and fillPrincipal().

HistoryAppender* edm::Principal::historyAppender_
private

Definition at line 267 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 252 of file Principal.h.

Referenced by fillPrincipal(), and lookupProcessOrder().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

Referenced by fillPrincipal(), and processConfiguration().

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 240 of file Principal.h.

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

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

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

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

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

Definition at line 260 of file Principal.h.

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

DelayedReader* edm::Principal::reader_
private

Definition at line 257 of file Principal.h.

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