CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::Principal Class Reference

#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, ProductResolverCollection::const_iterator > const_iterator
 
typedef ProductResolverBase const * ConstProductResolverPtr
 
typedef boost::filter_iterator< FilledProductPtr, ProductResolverCollection::iterator > iterator
 
typedef std::string ProcessName
 
typedef ProcessHistory::const_iterator ProcessNameConstIterator
 
typedef std::vector< propagate_const< std::shared_ptr< ProductResolverBase > > > ProductResolverCollection
 
typedef std::shared_ptr< ProductResolverBaseSharedProductPtr
 
typedef ProductResolverCollection::size_type size_type
 

Public Member Functions

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
 
void getAllStableProvenance (std::vector< StableProvenance 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, ProductResolverIndex index, bool skipCurrentProcess, bool &ambiguous, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void getManyByType (TypeID const &typeID, BasicHandleVec &results, EDConsumerBase const *consumes, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
ProductResolverBasegetModifiableProductResolver (BranchID const &oid)
 
ConstProductResolverPtr getProductResolver (BranchID const &oid) const
 
ConstProductResolverPtr getProductResolverByIndex (ProductResolverIndex const &oid) const
 
Provenance getProvenance (BranchID const &bid, ModuleCallingContext const *mcc) const
 
std::vector< unsigned int > const & lookupProcessOrder () const
 
void prefetchAsync (WaitingTask *waitTask, ProductResolverIndex index, bool skipCurrentProcess, ServiceToken const &token, ModuleCallingContext const *mcc) const
 
 Principal (std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductResolverIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender, bool isForPrimaryProcess=true)
 
ProcessConfiguration const & processConfiguration () const
 
ProcessHistory const & processHistory () const
 
ProcessHistoryID const & processHistoryID () const
 
EDProductGetter const * prodGetter () const
 
ProductResolverIndexHelper const & productLookup () const
 
ProductRegistry const & productRegistry () const
 
void readAllFromSourceAndMergeImmediately (MergeableRunProductMetadata const *mergeableRunProductMetadata=0)
 
DelayedReaderreader () const
 
void recombine (Principal &other, std::vector< BranchID > const &bids)
 
void setupUnscheduled (UnscheduledConfigurator const &)
 
size_t size () const
 
 ~Principal () override
 
- 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< ProductResolverBase > phb)
 
void addProductOrThrow (std::unique_ptr< ProductResolverBase > phb)
 
template<typename F >
void applyToResolvers (F iFunc)
 
ProductResolverBasegetExistingProduct (BranchID const &branchID)
 
ProductResolverBase const * getExistingProduct (BranchID const &branchID) const
 
ProductResolverBase const * getExistingProduct (ProductResolverBase const &phb) const
 
void putOrMerge (BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
 

Private Member Functions

void addAliasedProduct (std::shared_ptr< BranchDescription const > bd)
 
void addInputProduct (std::shared_ptr< BranchDescription const > bd)
 
void addParentProcessProduct (std::shared_ptr< BranchDescription const > bd)
 
void addScheduledProduct (std::shared_ptr< BranchDescription const > bd)
 
void addSourceProduct (std::shared_ptr< BranchDescription const > bd)
 
void addSwitchAliasProduct (std::shared_ptr< BranchDescription const > bd)
 
void addSwitchProducerProduct (std::shared_ptr< BranchDescription const > bd)
 
void addUnscheduledProduct (std::shared_ptr< BranchDescription const > bd)
 
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< ProductResolverBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
WrapperBase const * getIt (ProductID const &) const override
 
WrapperBase const * getThinnedProduct (ProductID const &, unsigned int &) const override
 
void getThinnedProducts (ProductID const &, std::vector< WrapperBase const * > &, std::vector< unsigned int > &) const override
 
void putOrMerge (std::unique_ptr< WrapperBase > prod, ProductResolverBase const *productResolver) const
 

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_
 
ProcessHistoryID processHistoryIDBeforeConfig_
 
std::shared_ptr< ProcessHistory const > processHistoryPtr_
 
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
 
ProductResolverCollection productResolvers_
 
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 58 of file Principal.h.

Member Typedef Documentation

Definition at line 65 of file Principal.h.

typedef unsigned long edm::Principal::CacheIdentifier_t

Definition at line 183 of file Principal.h.

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

Definition at line 61 of file Principal.h.

Definition at line 64 of file Principal.h.

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

Definition at line 62 of file Principal.h.

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

Definition at line 69 of file Principal.h.

Definition at line 63 of file Principal.h.

Definition at line 60 of file Principal.h.

Definition at line 68 of file Principal.h.

typedef ProductResolverCollection::size_type edm::Principal::size_type

Definition at line 66 of file Principal.h.

Constructor & Destructor Documentation

edm::Principal::Principal ( std::shared_ptr< ProductRegistry const >  reg,
std::shared_ptr< ProductResolverIndexHelper const >  productLookup,
ProcessConfiguration const &  pc,
BranchType  bt,
HistoryAppender historyAppender,
bool  isForPrimaryProcess = true 
)

Definition at line 122 of file Principal.cc.

References addAliasedProduct(), addInputProduct(), addParentProcessProduct(), addScheduledProduct(), addSourceProduct(), addSwitchAliasProduct(), addSwitchProducerProduct(), addUnscheduledProduct(), edm::ProductResolverIndexHelper::Range::begin(), edm::BranchDescription::branchType(), branchType_, edm::ProductResolverIndexHelper::Range::end(), spr::find(), mps_fire::i, edm::ProductResolverIndexHelper::IndexAndNames::index(), edm::InEvent, edm::BranchDescription::isAlias(), edm::BranchDescription::isSwitchAlias(), gen::k, edm::BranchDescription::moduleLabel(), edm::BranchDescription::onDemand(), or, LaserDQM_cfg::process, edm::ProcessConfiguration::processName(), edm::BranchDescription::processName(), parseEventContent::prod, edm::BranchDescription::produced(), productLookup_, edm::ProductResolverIndexAmbiguous, edm::ProductResolverIndexInvalid, productResolvers_, diffTwoXMLs::ranges, edm::source(), edm::ProductResolverIndexHelper::IndexAndNames::startInProcessNames(), and AlCaHLTBitMon_QueryRunRegistry::string.

128  : EDProductGetter(),
134  preg_(reg),
137  reader_(),
138  branchType_(bt),
139  historyAppender_(historyAppender),
141  productResolvers_.resize(reg->getNextIndexValue(bt));
142  //Now that these have been set, we can create the list of Branches we need.
143  std::string const source("source");
144  ProductRegistry::ProductList const& prodsList = reg->productList();
145  // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
146  // So, the non-alias product holders must be created first.
147  // Therefore, on this first pass, skip current EDAliases.
148  bool hasAliases = false;
149  bool hasSwitchAliases = false;
150  for (auto const& prod : prodsList) {
151  BranchDescription const& bd = prod.second;
152  if (bd.branchType() == branchType_) {
153  if (isForPrimaryProcess or bd.processName() == pc.processName()) {
154  if (bd.isAlias()) {
155  hasAliases = true;
156  } else if (bd.isSwitchAlias()) {
157  hasSwitchAliases = true;
158  } else {
159  auto cbd = std::make_shared<BranchDescription const>(bd);
160  if (bd.produced()) {
161  if (bd.moduleLabel() == source) {
162  addSourceProduct(cbd);
163  } else if (bd.onDemand()) {
164  assert(branchType_ == InEvent);
166  } else {
167  addScheduledProduct(cbd);
168  }
169  } else {
170  addInputProduct(cbd);
171  }
172  }
173  } else {
174  //We are in a SubProcess and this branch is from the parent
175  auto cbd = std::make_shared<BranchDescription const>(bd);
177  }
178  }
179  }
180  // Now process any EDAliases
181  if (hasAliases) {
182  for (auto const& prod : prodsList) {
183  BranchDescription const& bd = prod.second;
184  if (bd.isAlias() && bd.branchType() == branchType_) {
185  addAliasedProduct(std::make_shared<BranchDescription const>(bd));
186  }
187  }
188  }
189  // Finally process any SwitchProducer aliases
190  if (hasSwitchAliases) {
191  for (auto const& prod : prodsList) {
192  BranchDescription const& bd = prod.second;
193  if (bd.isSwitchAlias() && bd.branchType() == branchType_) {
194  assert(branchType_ == InEvent);
195  auto cbd = std::make_shared<BranchDescription const>(bd);
196  // Need different implementation for SwitchProducers not
197  // in any Path (onDemand) and for those in a Path in order
198  // to prevent the switch-aliased-for EDProducers from
199  // being run when the SwitchProducer is in a Path after a
200  // failing EDFilter.
201  if (bd.onDemand()) {
203  } else {
205  }
206  }
207  }
208  }
209 
210  // Now create the ProductResolvers that search in reverse process
211  // order and are used for queries where the process name is the
212  // empty string
213  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
214  std::vector<ProductResolverIndex> matchingHolders(lookupProcessNames.size(), ProductResolverIndexInvalid);
215  std::vector<bool> ambiguous(lookupProcessNames.size(), false);
216  unsigned int beginElements = productLookup_->beginElements();
217  std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
218  std::vector<ProductResolverIndexHelper::Range> const& ranges = productLookup_->ranges();
219  std::vector<ProductResolverIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
220  std::vector<char> const& processNamesCharArray = productLookup_->processNames();
221 
222  unsigned int numberOfMatches = 0;
224  if (!sortedTypeIDs.empty()) {
225  ProductResolverIndex productResolverIndex = ProductResolverIndexInvalid;
226  for (unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
227  ProductResolverIndexHelper::Range const& range = ranges.at(k);
228  for (unsigned int i = range.begin(); i < range.end(); ++i) {
229  ProductResolverIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
230  if (product.startInProcessNames() == 0) {
231  if (productResolverIndex != ProductResolverIndexInvalid) {
232  if ((numberOfMatches == 1) and (lastMatchIndex != ProductResolverIndexAmbiguous)) {
233  //only one choice so use a special resolver
234  productResolvers_.at(productResolverIndex) =
235  std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
236  } else {
237  bool productMadeAtEnd = false;
238  //Need to know if the product from this processes is added at end of transition
239  for (unsigned int i = 0; i < matchingHolders.size(); ++i) {
240  if ((not ambiguous[i]) and ProductResolverIndexInvalid != matchingHolders[i] and
241  productResolvers_[matchingHolders[i]]->branchDescription().availableOnlyAtEndTransition()) {
242  productMadeAtEnd = true;
243  break;
244  }
245  }
246  std::shared_ptr<ProductResolverBase> newHolder =
247  std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
248  productResolvers_.at(productResolverIndex) = newHolder;
249  }
250  matchingHolders.assign(lookupProcessNames.size(), ProductResolverIndexInvalid);
251  ambiguous.assign(lookupProcessNames.size(), false);
252  numberOfMatches = 0;
253  lastMatchIndex = ProductResolverIndexInvalid;
254  }
255  productResolverIndex = product.index();
256  } else {
257  std::string process(&processNamesCharArray.at(product.startInProcessNames()));
258  auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
259  assert(iter != lookupProcessNames.end());
260  ProductResolverIndex iMatchingIndex = product.index();
261  lastMatchIndex = iMatchingIndex;
262  assert(iMatchingIndex != ProductResolverIndexInvalid);
263  ++numberOfMatches;
264  if (iMatchingIndex == ProductResolverIndexAmbiguous) {
265  assert(k >= beginElements);
266  ambiguous.at(iter - lookupProcessNames.begin()) = true;
267  } else {
268  matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
269  }
270  }
271  }
272  }
273  //Need to know if the product from this processes is added at end of transition
274  if ((numberOfMatches == 1) and (lastMatchIndex != ProductResolverIndexAmbiguous)) {
275  //only one choice so use a special resolver
276  productResolvers_.at(productResolverIndex) =
277  std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
278  } else {
279  bool productMadeAtEnd = false;
280  for (unsigned int i = 0; i < matchingHolders.size(); ++i) {
281  if ((not ambiguous[i]) and ProductResolverIndexInvalid != matchingHolders[i] and
282  productResolvers_[matchingHolders[i]]->branchDescription().availableOnlyAtEndTransition()) {
283  productMadeAtEnd = true;
284  break;
285  }
286  }
287  std::shared_ptr<ProductResolverBase> newHolder =
288  std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
289  productResolvers_.at(productResolverIndex) = newHolder;
290  }
291  }
292  }
BranchType branchType_
Definition: Principal.h:282
DelayedReader * reader_
Definition: Principal.h:280
ProcessHistoryID processHistoryIDBeforeConfig_
Definition: Principal.h:263
unsigned int ProductResolverIndex
static std::string const source("source")
ProductResolverCollection productResolvers_
Definition: Principal.h:268
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:260
PixelRecoRange< float > Range
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:118
ProcessHistoryID processHistoryID_
Definition: Principal.h:262
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:337
edm::propagate_const< HistoryAppender * > historyAppender_
Definition: Principal.h:287
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:275
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:327
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:273
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:289
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void addSourceProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:332
void addParentProcessProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:369
int k[5][pyjets_maxn]
string ranges
Definition: diffTwoXMLs.py:79
void addSwitchAliasProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:361
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:341
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:148
void addSwitchProducerProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:353
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:345
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:265
std::vector< std::string > const & lookupProcessNames() const
edm::Principal::~Principal ( )
override

Definition at line 294 of file Principal.cc.

294 {}

Member Function Documentation

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

Definition at line 345 of file Principal.cc.

References addProductOrThrow(), eostools::move(), preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

Referenced by Principal().

345  {
346  ProductResolverIndex index = preg_->indexFrom(bd->originalBranchID());
347  assert(index != ProductResolverIndexInvalid);
348 
349  addProductOrThrow(std::make_unique<AliasProductResolver>(
350  std::move(bd), dynamic_cast<DataManagingOrAliasProductResolver&>(*productResolvers_[index])));
351  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 337 of file Principal.cc.

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

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

337  {
338  addProductOrThrow(std::make_unique<InputProductResolver>(std::move(bd)));
339  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addParentProcessProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 369 of file Principal.cc.

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

Referenced by Principal().

369  {
370  addProductOrThrow(std::make_unique<ParentProcessProductResolver>(std::move(bd)));
371  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addProduct_ ( std::unique_ptr< ProductResolverBase phb)
protected

Definition at line 502 of file Principal.cc.

References edm::BranchDescription::branchID(), edm::BranchDescription::className(), edm::BranchDescription::friendlyClassName(), edm::BranchDescription::moduleLabel(), preg_, edm::BranchDescription::processName(), edm::ProductResolverIndexInvalid, and productResolvers_.

Referenced by addProductOrThrow().

502  {
503  BranchDescription const& bd = productResolver->branchDescription();
504  assert(!bd.className().empty());
505  assert(!bd.friendlyClassName().empty());
506  assert(!bd.moduleLabel().empty());
507  assert(!bd.processName().empty());
508  SharedProductPtr phb(productResolver.release());
509 
510  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
511  assert(index != ProductResolverIndexInvalid);
512  productResolvers_[index] = phb;
513  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
std::shared_ptr< ProductResolverBase > SharedProductPtr
Definition: Principal.h:68
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
void edm::Principal::addProductOrThrow ( std::unique_ptr< ProductResolverBase phb)
protected

Definition at line 515 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(), addParentProcessProduct(), addScheduledProduct(), addSourceProduct(), addSwitchAliasProduct(), addSwitchProducerProduct(), and addUnscheduledProduct().

515  {
516  ProductResolverBase const* phb = getExistingProduct(*productResolver);
517  if (phb != nullptr) {
518  BranchDescription const& bd = productResolver->branchDescription();
519  throw Exception(errors::InsertFailure, "AlreadyPresent")
520  << "addProductOrThrow: Problem found while adding product, "
521  << "product already exists for (" << bd.friendlyClassName() << "," << bd.moduleLabel() << ","
522  << bd.productInstanceName() << "," << bd.processName() << ")\n";
523  }
524  addProduct_(std::move(productResolver));
525  }
void addProduct_(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:502
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:474
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 327 of file Principal.cc.

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

Referenced by Principal().

327  {
328  auto phb = std::make_unique<PuttableProductResolver>(std::move(bd));
330  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addSourceProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 332 of file Principal.cc.

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

Referenced by Principal().

332  {
333  auto phb = std::make_unique<PuttableProductResolver>(std::move(bd));
335  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addSwitchAliasProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 361 of file Principal.cc.

References addProductOrThrow(), eostools::move(), preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

Referenced by Principal().

361  {
362  ProductResolverIndex index = preg_->indexFrom(bd->switchAliasForBranchID());
363  assert(index != ProductResolverIndexInvalid);
364 
365  addProductOrThrow(std::make_unique<SwitchAliasProductResolver>(
366  std::move(bd), dynamic_cast<DataManagingOrAliasProductResolver&>(*productResolvers_[index])));
367  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addSwitchProducerProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 353 of file Principal.cc.

References addProductOrThrow(), eostools::move(), preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

Referenced by Principal().

353  {
354  ProductResolverIndex index = preg_->indexFrom(bd->switchAliasForBranchID());
355  assert(index != ProductResolverIndexInvalid);
356 
357  addProductOrThrow(std::make_unique<SwitchProducerProductResolver>(
358  std::move(bd), dynamic_cast<DataManagingOrAliasProductResolver&>(*productResolvers_[index])));
359  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 341 of file Principal.cc.

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

Referenced by Principal().

341  {
342  addProductOrThrow(std::make_unique<UnscheduledProductResolver>(std::move(bd)));
343  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:515
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 884 of file Principal.cc.

References addInputProduct(), edm::BranchDescription::branchID(), edm::BranchDescription::branchType(), branchType_, preg_, parseEventContent::prod, edm::BranchDescription::produced(), edm::ProductResolverIndexInvalid, and productResolvers_.

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

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

Definition at line 311 of file Principal.cc.

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

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

311  {
312  ProductRegistry::ProductList const& prodsList = reg.productList();
313  for (auto const& prod : prodsList) {
314  BranchDescription const& bd = prod.second;
315  if (!bd.produced() && (bd.branchType() == branchType_)) {
316  auto cbd = std::make_shared<BranchDescription const>(bd);
317  auto phb = getExistingProduct(cbd->branchID());
318  if (phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
319  return false;
320  }
321  phb->resetBranchDescription(cbd);
322  }
323  }
324  return true;
325  }
BranchType branchType_
Definition: Principal.h:282
std::map< BranchKey, BranchDescription > ProductList
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:474
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
template<typename F >
void edm::Principal::applyToResolvers ( F  iFunc)
inlineprotected

Definition at line 214 of file Principal.h.

References edm::getThinnedProduct(), parseEventContent::prod, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by setupUnscheduled().

214  {
215  for (auto& resolver : productResolvers_) {
216  iFunc(resolver.get());
217  }
218  }
ProductResolverCollection productResolvers_
Definition: Principal.h:268
const_iterator edm::Principal::begin ( void  ) const
inline

Definition at line 160 of file Principal.h.

160  {
161  return boost::make_filter_iterator<FilledProductPtr>(productResolvers_.begin(), productResolvers_.end());
162  }
ProductResolverCollection productResolvers_
Definition: Principal.h:268
iterator edm::Principal::begin ( void  )
inline

Definition at line 167 of file Principal.h.

167  {
168  return boost::make_filter_iterator<FilledProductPtr>(productResolvers_.begin(), productResolvers_.end());
169  }
ProductResolverCollection productResolvers_
Definition: Principal.h:268
BranchType const& edm::Principal::branchType ( ) const
inline
CacheIdentifier_t edm::Principal::cacheIdentifier ( ) const
inline

Definition at line 184 of file Principal.h.

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

184 { return cacheIdentifier_; }
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:289
void edm::Principal::clearPrincipal ( )

Definition at line 374 of file Principal.cc.

References parseEventContent::prod, and reader_.

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

374  {
375  //We do not clear the product history information
376  // because it rarely changes and recalculating takes
377  // time.
378  reader_ = nullptr;
379  for (auto& prod : *this) {
380  prod->resetProductData();
381  }
382  }
DelayedReader * reader_
Definition: Principal.h:280
void edm::Principal::deleteProduct ( BranchID const &  id) const

Definition at line 384 of file Principal.cc.

References getExistingProduct().

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

384  {
385  auto phb = getExistingProduct(id);
386  assert(nullptr != phb);
387  phb->unsafe_deleteProduct();
388  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:474
const_iterator edm::Principal::end ( void  ) const
inline

Definition at line 163 of file Principal.h.

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

163  {
164  return boost::make_filter_iterator<FilledProductPtr>(productResolvers_.end(), productResolvers_.end());
165  }
ProductResolverCollection productResolvers_
Definition: Principal.h:268
iterator edm::Principal::end ( void  )
inline

Definition at line 170 of file Principal.h.

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

170  {
171  return boost::make_filter_iterator<FilledProductPtr>(productResolvers_.end(), productResolvers_.end());
172  }
ProductResolverCollection productResolvers_
Definition: Principal.h:268
void edm::Principal::fillPrincipal ( ProcessHistoryID const &  hist,
ProcessHistoryRegistry const &  phr,
DelayedReader reader 
)

Definition at line 395 of file Principal.cc.

References cacheIdentifier_, Exception, spr::find(), edm::ProcessHistoryRegistry::getMapped(), create_public_lumi_plots::hist, historyAppender_, edm::Hash< I >::isValid(), gen::k, edm::errors::LogicError, lookupProcessOrder_, edm::nextIdentifier(), orderProcessHistoryID_, processConfiguration_, processHistoryID_, processHistoryIDBeforeConfig_, processHistoryPtr_, edm::ProcessConfiguration::processName(), productLookup_, productRegistry(), reader(), reader_, and edm::s_emptyProcessHistory.

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

397  {
398  //increment identifier here since clearPrincipal isn't called for Run/Lumi
400  if (reader) {
401  reader_ = reader;
402  }
403 
404  if (historyAppender_ && productRegistry().anyProductProduced()) {
406  processHistoryPtr_ = historyAppender_->appendToProcessHistory(
407  hist, processHistoryRegistry.getMapped(hist), *processConfiguration_);
408  processHistoryID_ = processHistoryPtr_->id();
410  }
411  } else {
412  std::shared_ptr<ProcessHistory const> inputProcessHistory;
413  if ((not processHistoryPtr_) || (processHistoryIDBeforeConfig_ != hist)) {
414  if (hist.isValid()) {
415  //does not own the pointer
416  auto noDel = [](void const*) {};
417  inputProcessHistory = std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist), noDel);
418  if (inputProcessHistory.get() == nullptr) {
419  throw Exception(errors::LogicError) << "Principal::fillPrincipal\n"
420  << "Input ProcessHistory not found in registry\n"
421  << "Contact a Framework developer\n";
422  }
423  } else {
424  //Since this is static we don't want it deleted
425  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory, [](void const*) {});
426  //no need to do any ordering since it is empty
428  }
430  processHistoryPtr_ = inputProcessHistory;
432  }
433  }
434 
436  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
437  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
438  unsigned int k = 0;
439 
440  // We loop over processes in reverse order of the ProcessHistory.
441  // If any entries in the product lookup tables are associated with
442  // the process we add it to the vector of processes in the order
443  // the lookup should be performed. There is one exception though,
444  // We start with the current process even if it is not in the ProcessHistory.
445  // The current process might be needed but not be in the process
446  // history if all the products produced in the current process are
447  // transient.
448  auto nameIter =
449  std::find(lookupProcessNames.begin(), lookupProcessNames.end(), processConfiguration_->processName());
450  if (nameIter != lookupProcessNames.end()) {
451  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
452  ++k;
453  }
454 
455  // We just looked for the current process so skip it if
456  // it is in the ProcessHistory.
457  auto iter = processHistoryPtr_->rbegin();
458  if (iter->processName() == processConfiguration_->processName()) {
459  ++iter;
460  }
461 
462  for (auto iEnd = processHistoryPtr_->rend(); iter != iEnd; ++iter) {
463  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
464  if (nameIter == lookupProcessNames.end()) {
465  continue;
466  }
467  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
468  ++k;
469  }
471  }
472  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:34
ProductRegistry const & productRegistry() const
Definition: Principal.h:146
DelayedReader * reader_
Definition: Principal.h:280
ProcessHistoryID processHistoryIDBeforeConfig_
Definition: Principal.h:263
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:260
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:118
ProcessHistoryID processHistoryID_
Definition: Principal.h:262
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
edm::propagate_const< HistoryAppender * > historyAppender_
Definition: Principal.h:287
std::string const & processName() const
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:275
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:273
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:289
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:276
int k[5][pyjets_maxn]
DelayedReader * reader() const
Definition: Principal.h:186
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:265
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 706 of file Principal.cc.

References edm::appendCurrentProcessIfAlias(), branchType(), edm::ProductResolverIndexHelper::index(), edm::InputTag::indexFor(), edm::InputTag::instance(), edm::InputTag::kCurrentProcess, edm::InputTag::label(), edm::InputTag::process(), processConfiguration_, modifiedElectrons_cfi::processName, edm::ProcessConfiguration::processName(), productLookup(), productRegistry(), edm::ProductResolverIndexAmbiguous, edm::ProductResolverIndexInvalid, productResolvers_, edm::EDConsumerBase::registeredToConsume(), fftjetproducer_cfi::resolution, edm::throwAmbiguousException(), edm::InputTag::tryToCacheIndex(), UNLIKELY, and edm::InputTag::willSkipCurrentProcess().

Referenced by findProductByTag(), and getByLabel().

711  {
712  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
713 
715 
716  if (index == ProductResolverIndexInvalid) {
717  char const* processName = inputTag.process().c_str();
718  if (skipCurrentProcess) {
719  processName = "\0";
720  } else if (inputTag.process() == InputTag::kCurrentProcess) {
721  processName = processConfiguration_->processName().c_str();
722  }
723 
724  index =
725  productLookup().index(kindOfType, typeID, inputTag.label().c_str(), inputTag.instance().c_str(), processName);
726 
727  if (index == ProductResolverIndexAmbiguous) {
728  throwAmbiguousException("findProductByLabel",
729  typeID,
730  inputTag.label(),
731  inputTag.instance(),
733  } else if (index == ProductResolverIndexInvalid) {
734  return nullptr;
735  }
736  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
737  }
738  if (UNLIKELY(consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
739  failedToRegisterConsumes(kindOfType,
740  typeID,
741  inputTag.label(),
742  inputTag.instance(),
744  }
745 
746  auto const& productResolver = productResolvers_[index];
747 
748  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
749  if (resolution.isAmbiguous()) {
750  throwAmbiguousException("findProductByLabel",
751  typeID,
752  inputTag.label(),
753  inputTag.instance(),
755  }
756  return resolution.data();
757  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:146
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:77
std::string const & processName() const
BranchType const & branchType() const
Definition: Principal.h:180
static const std::string kCurrentProcess
Definition: InputTag.h:54
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:148
#define UNLIKELY(x)
Definition: Likely.h:21
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:36
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:265
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
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 759 of file Principal.cc.

References branchType(), edm::ProductResolverIndexHelper::index(), productLookup(), edm::ProductResolverIndexAmbiguous, edm::ProductResolverIndexInvalid, productResolvers_, edm::EDConsumerBase::registeredToConsume(), fftjetproducer_cfi::resolution, edm::throwAmbiguousException(), and UNLIKELY.

766  {
768  productLookup().index(kindOfType, typeID, label.c_str(), instance.c_str(), process.c_str());
769 
770  if (index == ProductResolverIndexAmbiguous) {
771  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
772  } else if (index == ProductResolverIndexInvalid) {
773  return nullptr;
774  }
775 
776  if (UNLIKELY(consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
777  failedToRegisterConsumes(kindOfType, typeID, label, instance, process);
778  }
779 
780  auto const& productResolver = productResolvers_[index];
781 
782  auto resolution = productResolver->resolveProduct(*this, false, sra, mcc);
783  if (resolution.isAmbiguous()) {
784  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
785  }
786  return resolution.data();
787  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
static PFTauRenderPlugin instance
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:77
char const * label
BranchType const & branchType() const
Definition: Principal.h:180
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:148
#define UNLIKELY(x)
Definition: Likely.h:21
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 789 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

791  {
792  ProductData const* productData = findProductByLabel(PRODUCT_TYPE, typeID, tag, nullptr, nullptr, mcc);
793  return productData;
794  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:706
void edm::Principal::findProducts ( std::vector< ProductResolverBase const * > const &  holders,
TypeID const &  typeID,
BasicHandleVec results,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 681 of file Principal.cc.

References edm::BranchDescription::isAnyAlias(), LaserDQM_cfg::process, processHistoryPtr_, edm::BranchDescription::processName(), edm::ProductData::provenance(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::ProductData::wrapper().

Referenced by getManyByType().

685  {
686  for (auto iter = processHistoryPtr_->rbegin(), iEnd = processHistoryPtr_->rend(); iter != iEnd; ++iter) {
687  std::string const& process = iter->processName();
688  for (auto productResolver : holders) {
689  BranchDescription const& bd = productResolver->branchDescription();
690  if (process == bd.processName()) {
691  // Ignore aliases to avoid matching the same product multiple times.
692  if (bd.isAnyAlias()) {
693  continue;
694  }
695 
696  ProductData const* productData = productResolver->resolveProduct(*this, false, sra, mcc).data();
697  if (productData) {
698  // Skip product if not available.
699  results.emplace_back(productData->wrapper(), &(productData->provenance()));
700  }
701  }
702  }
703  }
704  }
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:260
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 813 of file Principal.cc.

Referenced by edm::OccurrenceForOutput::getAllProvenance(), and edm::Event::getAllProvenance().

813  {
814  provenances.clear();
815  for (auto const& productResolver : *this) {
816  if (productResolver->singleProduct() && productResolver->provenanceAvailable() &&
817  !productResolver->branchDescription().isAnyAlias()) {
818  // We do not attempt to get the event/lumi/run status from the provenance,
819  // because the per event provenance may have been dropped.
820  if (productResolver->provenance()->branchDescription().present()) {
821  provenances.push_back(productResolver->provenance());
822  }
823  }
824  }
825  }
void edm::Principal::getAllStableProvenance ( std::vector< StableProvenance const * > &  provenances) const

Definition at line 830 of file Principal.cc.

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

830  {
831  provenances.clear();
832  for (auto const& productResolver : *this) {
833  if (productResolver->singleProduct() && !productResolver->branchDescription().isAnyAlias()) {
834  if (productResolver->stableProvenance()->branchDescription().present()) {
835  provenances.push_back(productResolver->stableProvenance());
836  }
837  }
838  }
839  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 540 of file Principal.cc.

References edm::appendCurrentProcessIfAlias(), findProductByLabel(), edm::InputTag::instance(), edm::InputTag::label(), edm::makeHandleExceptionFactory(), edm::makeNotFoundException(), edm::InputTag::process(), processConfiguration_, edm::ProcessConfiguration::processName(), edm::ProductData::provenance(), mps_fire::result, and edm::ProductData::wrapper().

Referenced by edm::test::Event::get(), edm::PrincipalGetAdapter::getByLabel_(), and edm::PrincipalGetAdapter::getMatchingSequenceByLabel_().

545  {
546  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, sra, mcc);
547  if (result == nullptr) {
548  return BasicHandle(makeHandleExceptionFactory([=]() -> std::shared_ptr<cms::Exception> {
549  return makeNotFoundException(
550  "getByLabel",
551  kindOfType,
552  typeID,
553  inputTag.label(),
554  inputTag.instance(),
556  }));
557  }
558  return BasicHandle(result->wrapper(), &(result->provenance()));
559  }
std::string const & processName() const
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:53
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:706
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:36
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:265
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 561 of file Principal.cc.

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

568  {
569  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process, consumer, sra, mcc);
570  if (result == nullptr) {
571  return BasicHandle(makeHandleExceptionFactory([=]() -> std::shared_ptr<cms::Exception> {
572  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
573  }));
574  }
575  return BasicHandle(result->wrapper(), &(result->provenance()));
576  }
static PFTauRenderPlugin instance
char const * label
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:53
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:706
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductResolverIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 578 of file Principal.cc.

References edm::BasicHandle::makeInvalid(), edm::ProductResolverIndexInvalid, productResolvers_, and fftjetproducer_cfi::resolution.

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

584  {
586  auto& productResolver = productResolvers_[index];
587  assert(nullptr != productResolver.get());
588  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
589  if (resolution.isAmbiguous()) {
590  ambiguous = true;
591  //The caller is looking explicitly for this case
592  // and uses the extra data at the caller to setup the exception
593  return BasicHandle::makeInvalid();
594  }
595  auto productData = resolution.data();
596  if (productData == nullptr) {
597  //The caller is looking explicitly for this case
598  // and uses the extra data at the caller to setup the exception
599  return BasicHandle::makeInvalid();
600  }
601  return BasicHandle(productData->wrapper(), &(productData->provenance()));
602  }
ProductResolverCollection productResolvers_
Definition: Principal.h:268
static BasicHandle makeInvalid()
Definition: BasicHandle.h:112
ProductResolverBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 474 of file Principal.cc.

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

474  {
475  return const_cast<ProductResolverBase*>(const_cast<const Principal*>(this)->getExistingProduct(branchID));
476  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:474
Principal(std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductResolverIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender, bool isForPrimaryProcess=true)
Definition: Principal.cc:122
ProductResolverBase const * edm::Principal::getExistingProduct ( BranchID const &  branchID) const
protected

Definition at line 478 of file Principal.cc.

References preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

478  {
479  ProductResolverIndex index = preg_->indexFrom(branchID);
480  assert(index != ProductResolverIndexInvalid);
481  return productResolvers_.at(index).get();
482  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
ProductResolverBase const * edm::Principal::getExistingProduct ( ProductResolverBase const &  phb) const
protected

Definition at line 484 of file Principal.cc.

References edm::ProductResolverBase::branchDescription(), edm::BranchDescription::branchID(), edm::BranchDescription::branchName(), Exception, and getExistingProduct().

484  {
485  auto phb = getExistingProduct(productResolver.branchDescription().branchID());
486  if (nullptr != phb && BranchKey(productResolver.branchDescription()) != BranchKey(phb->branchDescription())) {
487  BranchDescription const& newProduct = phb->branchDescription();
488  BranchDescription const& existing = productResolver.branchDescription();
489  if (newProduct.branchName() != existing.branchName() && newProduct.branchID() == existing.branchID()) {
490  throw cms::Exception("HashCollision")
491  << "Principal::getExistingProduct\n"
492  << " Branch " << newProduct.branchName() << " has same branch ID as branch " << existing.branchName()
493  << "\n"
494  << "Workaround: change process name or product instance name of " << newProduct.branchName() << "\n";
495  } else {
496  assert(nullptr == phb || BranchKey(productResolver.branchDescription()) == BranchKey(phb->branchDescription()));
497  }
498  }
499  return phb;
500  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:474
BranchDescription const & branchDescription() const
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Definition at line 852 of file Principal.cc.

852  {
853  assert(false);
854  return nullptr;
855  }
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 614 of file Principal.cc.

References branchType(), findProducts(), mps_fire::i, edm::ProductResolverIndexHelper::Matches::index(), edm::ProductResolverIndexHelper::Matches::isFullyResolved(), patRefSel_triggerMatching_cfi::matches, edm::ProductResolverIndexHelper::Matches::numberOfMatches(), edm::PRODUCT_TYPE, productLookup(), productResolvers_, edm::EDConsumerBase::registeredToConsumeMany(), edm::ProductResolverIndexHelper::relatedIndexes(), and UNLIKELY.

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

618  {
619  assert(results.empty());
620 
621  if (UNLIKELY(consumer and (not consumer->registeredToConsumeMany(typeID, branchType())))) {
622  failedToRegisterConsumesMany(typeID);
623  }
624 
625  // This finds the indexes to all the ProductResolver's matching the type
626  ProductResolverIndexHelper::Matches matches = productLookup().relatedIndexes(PRODUCT_TYPE, typeID);
627 
628  if (matches.numberOfMatches() == 0) {
629  return;
630  }
631 
632  results.reserve(matches.numberOfMatches());
633 
634  // Loop over the ProductResolvers. Add the products that are actually
635  // present into the results. This will also trigger delayed reading,
636  // on demand production, and check for deleted products as appropriate.
637 
638  // Over the years the code that uses getManyByType has grown to depend
639  // on the ordering of the results. The order originally was just an
640  // accident of how previous versions of the code were written, but
641  // here we have to go through some extra effort to preserve that ordering.
642 
643  // We build a list of holders that match a particular label and instance.
644  // When that list is complete we call findProducts, which loops over
645  // that list in reverse order of the ProcessHistory (starts with the
646  // most recent). Then we clear the list and repeat this until all the
647  // matching label and instance subsets have been dealt with.
648 
649  // Note that the function isFullyResolved returns true for the ProductResolvers
650  // that are associated with an empty process name. Those are the ones that
651  // know how to search for the most recent process name matching
652  // a label and instance. We do not need these for getManyByType and
653  // skip them. In addition to skipping them, we make use of the fact
654  // that they mark the beginning of each subset of holders with the same
655  // label and instance. They tell us when to call findProducts.
656 
657  std::vector<ProductResolverBase const*> holders;
658 
659  for (unsigned int i = 0; i < matches.numberOfMatches(); ++i) {
660  ProductResolverIndex index = matches.index(i);
661 
662  if (!matches.isFullyResolved(i)) {
663  if (!holders.empty()) {
664  // Process the ones with a particular module label and instance
665  findProducts(holders, typeID, results, sra, mcc);
666  holders.clear();
667  }
668  } else {
669  ProductResolverBase const* productResolver = productResolvers_.at(index).get();
670  assert(productResolver);
671  holders.push_back(productResolver);
672  }
673  }
674  // Do not miss the last subset of products
675  if (!holders.empty()) {
676  findProducts(holders, typeID, results, sra, mcc);
677  }
678  return;
679  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
BranchType const & branchType() const
Definition: Principal.h:180
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:148
void findProducts(std::vector< ProductResolverBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:681
#define UNLIKELY(x)
Definition: Likely.h:21
ProductResolverBase* edm::Principal::getModifiableProductResolver ( BranchID const &  oid)
inline

Definition at line 153 of file Principal.h.

References findQualityFiles::size.

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

153  {
154  return const_cast<ProductResolverBase*>(const_cast<const Principal*>(this)->getProductResolver(oid));
155  }
Principal(std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductResolverIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender, bool isForPrimaryProcess=true)
Definition: Principal.cc:122
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Definition: Principal.cc:527
Principal::ConstProductResolverPtr edm::Principal::getProductResolver ( BranchID const &  oid) const

Definition at line 527 of file Principal.cc.

References getProductResolverByIndex(), preg_, and edm::ProductResolverIndexInvalid.

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

527  {
528  ProductResolverIndex index = preg_->indexFrom(bid);
529  if (index == ProductResolverIndexInvalid) {
530  return ConstProductResolverPtr();
531  }
532  return getProductResolverByIndex(index);
533  }
unsigned int ProductResolverIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:64
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:535
Principal::ConstProductResolverPtr edm::Principal::getProductResolverByIndex ( ProductResolverIndex const &  oid) const
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

Definition at line 796 of file Principal.cc.

References getProductResolver(), edm::errors::ProductNotFound, and edm::throwProductNotFoundException().

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

796  {
798  if (phb == nullptr) {
800  }
801 
802  if (phb->unscheduledWasNotRun()) {
803  if (not phb->resolveProduct(*this, false, nullptr, mcc).data()) {
804  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
805  }
806  }
807  return *phb->provenance();
808  }
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:64
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Definition: Principal.cc:527
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:48
WrapperBase const * edm::Principal::getThinnedProduct ( ProductID const &  ,
unsigned int &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Definition at line 857 of file Principal.cc.

857  {
858  assert(false);
859  return nullptr;
860  }
void edm::Principal::getThinnedProducts ( ProductID const &  ,
std::vector< WrapperBase const * > &  ,
std::vector< unsigned int > &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Definition at line 862 of file Principal.cc.

864  {
865  assert(false);
866  }
std::vector<unsigned int> const& edm::Principal::lookupProcessOrder ( ) const
inline
void edm::Principal::prefetchAsync ( WaitingTask waitTask,
ProductResolverIndex  index,
bool  skipCurrentProcess,
ServiceToken const &  token,
ModuleCallingContext const *  mcc 
) const

Definition at line 604 of file Principal.cc.

References productResolvers_.

Referenced by edm::Worker::prefetchAsync(), and edm::Worker::prePrefetchSelectionAsync().

608  {
609  auto const& productResolver = productResolvers_.at(index);
610  assert(nullptr != productResolver.get());
611  productResolver->prefetchAsync(task, *this, skipCurrentProcess, token, nullptr, mcc);
612  }
ProductResolverCollection productResolvers_
Definition: Principal.h:268
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 144 of file Principal.h.

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

Definition at line 148 of file Principal.h.

References trackingPlots::other.

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

148 { return *productLookup_; }
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:273
ProductRegistry const& edm::Principal::productRegistry ( ) const
inline

Definition at line 146 of file Principal.h.

Referenced by fillPrincipal(), findProductByLabel(), edm::SubProcess::processAsync(), and edm::PrincipalGetAdapter::throwUnregisteredPutException().

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

Definition at line 872 of file Principal.cc.

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

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

872  {
873  if (edp.get() == nullptr) {
874  throw edm::Exception(edm::errors::InsertFailure, "Null Pointer")
875  << "put: Cannot put because unique_ptr to product is null."
876  << "\n";
877  }
878  auto phb = getExistingProduct(bd.branchID());
879  assert(phb);
880  // ProductResolver assumes ownership
881  putOrMerge(std::move(edp), phb);
882  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:474
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
Definition: Principal.cc:872
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductResolverBase const *  productResolver 
) const
private

Definition at line 868 of file Principal.cc.

References eostools::move(), and edm::ProductResolverBase::putOrMergeProduct().

868  {
869  phb->putOrMergeProduct(std::move(prod));
870  }
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::readAllFromSourceAndMergeImmediately ( MergeableRunProductMetadata const *  mergeableRunProductMetadata = 0)

Definition at line 904 of file Principal.cc.

References parseEventContent::prod, and reader().

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

904  {
905  if (not reader()) {
906  return;
907  }
908 
909  for (auto& prod : *this) {
910  prod->retrieveAndMerge(*this, mergeableRunProductMetadata);
911  }
912  }
DelayedReader * reader() const
Definition: Principal.h:186
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

Definition at line 841 of file Principal.cc.

References edm::get_underlying_safe(), edm::DelayedReader::mergeReaders(), preg_, parseEventContent::prod, edm::ProductResolverIndexInvalid, productResolvers_, reader(), and reader_.

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

841  {
842  for (auto& prod : bids) {
843  ProductResolverIndex index = preg_->indexFrom(prod);
844  assert(index != ProductResolverIndexInvalid);
845  ProductResolverIndex indexO = other.preg_->indexFrom(prod);
846  assert(indexO != ProductResolverIndexInvalid);
847  get_underlying_safe(productResolvers_[index]).swap(get_underlying_safe(other.productResolvers_[indexO]));
848  }
849  reader_->mergeReaders(other.reader());
850  }
DelayedReader * reader_
Definition: Principal.h:280
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:268
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:36
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:272
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void edm::Principal::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)

Definition at line 390 of file Principal.cc.

References applyToResolvers(), and edm::ProductResolverBase::setupUnscheduled().

Referenced by edm::WorkerManager::setupOnDemandSystem().

390  {
391  applyToResolvers([&iConfigure](ProductResolverBase* iResolver) { iResolver->setupUnscheduled(iConfigure); });
392  }
void applyToResolvers(F iFunc)
Definition: Principal.h:214
size_t edm::Principal::size ( void  ) const

Definition at line 299 of file Principal.cc.

References parseEventContent::prod, and mitigatedMETSequence_cff::U.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), edm::SecSourceAnalyzer::getBranches(), edm::StreamerInputSource::read(), edm::OccurrenceForOutput::size(), and edm::Event::size().

299  {
300  size_t size = 0U;
301  for (auto const& prod : *this) {
302  if (prod->singleProduct() && // Not a NoProcessProductResolver
303  !prod->productUnavailable() && !prod->unscheduledWasNotRun() && !prod->branchDescription().dropped()) {
304  ++size;
305  }
306  }
307  return size;
308  }
size_t size() const
Definition: Principal.cc:299

Member Data Documentation

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

Definition at line 289 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 287 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 275 of file Principal.h.

Referenced by fillPrincipal().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

Referenced by fillPrincipal(), findProductByLabel(), and getByLabel().

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 262 of file Principal.h.

Referenced by fillPrincipal().

ProcessHistoryID edm::Principal::processHistoryIDBeforeConfig_
private

Definition at line 263 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 260 of file Principal.h.

Referenced by fillPrincipal(), and findProducts().

std::shared_ptr<ProductResolverIndexHelper const> edm::Principal::productLookup_
private

Definition at line 273 of file Principal.h.

Referenced by fillPrincipal(), and Principal().

ProductResolverCollection edm::Principal::productResolvers_
private
DelayedReader* edm::Principal::reader_
private

Definition at line 280 of file Principal.h.

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