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 ()
 
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 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 57 of file Principal.h.

Member Typedef Documentation

Definition at line 64 of file Principal.h.

typedef unsigned long edm::Principal::CacheIdentifier_t

Definition at line 179 of file Principal.h.

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

Definition at line 60 of file Principal.h.

Definition at line 63 of file Principal.h.

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

Definition at line 61 of file Principal.h.

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

Definition at line 68 of file Principal.h.

Definition at line 62 of file Principal.h.

Definition at line 59 of file Principal.h.

Definition at line 67 of file Principal.h.

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

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

References addAliasedProduct(), addInputProduct(), addParentProcessProduct(), addScheduledProduct(), addSourceProduct(), 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(), 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.

118  :
119  EDProductGetter(),
125  preg_(reg),
128  reader_(),
129  branchType_(bt),
130  historyAppender_(historyAppender),
132  {
133  productResolvers_.resize(reg->getNextIndexValue(bt));
134  //Now that these have been set, we can create the list of Branches we need.
135  std::string const source("source");
136  ProductRegistry::ProductList const& prodsList = reg->productList();
137  // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
138  // So, the non-alias product holders must be created first.
139  // Therefore, on this first pass, skip current EDAliases.
140  bool hasAliases = false;
141  for(auto const& prod : prodsList) {
142  BranchDescription const& bd = prod.second;
143  if(bd.branchType() == branchType_) {
144  if(isForPrimaryProcess or bd.processName() == pc.processName()) {
145  if(bd.isAlias()) {
146  hasAliases = true;
147  } else {
148  auto cbd = std::make_shared<BranchDescription const>(bd);
149  if(bd.produced()) {
150  if(bd.moduleLabel() == source) {
151  addSourceProduct(cbd);
152  } else if(bd.onDemand()) {
153  assert(branchType_ == InEvent);
155  } else {
156  addScheduledProduct(cbd);
157  }
158  } else {
159  addInputProduct(cbd);
160  }
161  }
162  } else {
163  //We are in a SubProcess and this branch is from the parent
164  auto cbd =std::make_shared<BranchDescription const>(bd);
166  }
167  }
168  }
169  // Now process any EDAliases
170  if(hasAliases) {
171  for(auto const& prod : prodsList) {
172  BranchDescription const& bd = prod.second;
173  if(bd.isAlias() && bd.branchType() == branchType_) {
174  auto cbd = std::make_shared<BranchDescription const>(bd);
175  addAliasedProduct(cbd);
176  }
177  }
178  }
179 
180  // Now create the ProductResolvers that search in reverse process
181  // order and are used for queries where the process name is the
182  // empty string
183  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
184  std::vector<ProductResolverIndex> matchingHolders(lookupProcessNames.size(), ProductResolverIndexInvalid);
185  std::vector<bool> ambiguous(lookupProcessNames.size(), false);
186  unsigned int beginElements = productLookup_->beginElements();
187  std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
188  std::vector<ProductResolverIndexHelper::Range> const& ranges = productLookup_->ranges();
189  std::vector<ProductResolverIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
190  std::vector<char> const& processNamesCharArray = productLookup_->processNames();
191 
192  unsigned int numberOfMatches = 0;
194  if (!sortedTypeIDs.empty()) {
195  ProductResolverIndex productResolverIndex = ProductResolverIndexInvalid;
196  for(unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
197  ProductResolverIndexHelper::Range const& range = ranges.at(k);
198  for (unsigned int i = range.begin(); i < range.end(); ++i) {
199  ProductResolverIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
200  if (product.startInProcessNames() == 0) {
201  if (productResolverIndex != ProductResolverIndexInvalid) {
202  if ((numberOfMatches == 1) and
203  (lastMatchIndex != ProductResolverIndexAmbiguous)) {
204  //only one choice so use a special resolver
205  productResolvers_.at(productResolverIndex) = std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
206  } else {
207  bool productMadeAtEnd = false;
208  //Need to know if the product from this processes is added at end of transition
209  for(unsigned int i=0; i< matchingHolders.size();++i) {
210  if( (not ambiguous[i]) and
211  ProductResolverIndexInvalid != matchingHolders[i] and
212  productResolvers_[matchingHolders[i]]->branchDescription().availableOnlyAtEndTransition()) {
213  productMadeAtEnd = true;
214  break;
215  }
216  }
217  std::shared_ptr<ProductResolverBase> newHolder = std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
218  productResolvers_.at(productResolverIndex) = newHolder;
219  }
220  matchingHolders.assign(lookupProcessNames.size(), ProductResolverIndexInvalid);
221  ambiguous.assign(lookupProcessNames.size(), false);
222  numberOfMatches= 0;
223  lastMatchIndex = ProductResolverIndexInvalid;
224  }
225  productResolverIndex = product.index();
226  } else {
227  std::string process(&processNamesCharArray.at(product.startInProcessNames()));
228  auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
229  assert(iter != lookupProcessNames.end());
230  ProductResolverIndex iMatchingIndex = product.index();
231  lastMatchIndex = iMatchingIndex;
232  assert(iMatchingIndex != ProductResolverIndexInvalid);
233  ++numberOfMatches;
234  if (iMatchingIndex == ProductResolverIndexAmbiguous) {
235  assert(k >= beginElements);
236  ambiguous.at(iter - lookupProcessNames.begin()) = true;
237  } else {
238  matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
239  }
240  }
241  }
242  }
243  //Need to know if the product from this processes is added at end of transition
244  bool productMadeAtEnd = false;
245  for(unsigned int i=0; i< matchingHolders.size();++i) {
246  if( (not ambiguous[i]) and
247  ProductResolverIndexInvalid != matchingHolders[i] and
248  productResolvers_[matchingHolders[i]]->branchDescription().availableOnlyAtEndTransition()) {
249  productMadeAtEnd = true;
250  break;
251  }
252  }
253  std::shared_ptr<ProductResolverBase> newHolder = std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous, productMadeAtEnd);
254  productResolvers_.at(productResolverIndex) = newHolder;
255  }
256  }
BranchType branchType_
Definition: Principal.h:277
DelayedReader * reader_
Definition: Principal.h:275
ProcessHistoryID processHistoryIDBeforeConfig_
Definition: Principal.h:258
unsigned int ProductResolverIndex
static std::string const source("source")
ProductResolverCollection productResolvers_
Definition: Principal.h:263
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:255
PixelRecoRange< float > Range
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:109
ProcessHistoryID processHistoryID_
Definition: Principal.h:257
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:309
edm::propagate_const< HistoryAppender * > historyAppender_
Definition: Principal.h:282
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:270
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:297
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:268
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:267
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:284
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:303
void addParentProcessProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:327
int k[5][pyjets_maxn]
string ranges
Definition: diffTwoXMLs.py:78
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:314
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:151
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:319
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:260
std::vector< std::string > const & lookupProcessNames() const
edm::Principal::~Principal ( )
override

Definition at line 258 of file Principal.cc.

258  {
259  }

Member Function Documentation

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

Definition at line 319 of file Principal.cc.

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

Referenced by Principal().

319  {
320  ProductResolverIndex index = preg_->indexFrom(bd->originalBranchID());
321  assert(index != ProductResolverIndexInvalid);
322 
323  addProductOrThrow(std::make_unique<AliasProductResolver>(std::move(bd), dynamic_cast<ProducedProductResolver&>(*productResolvers_[index])));
324  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:263
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:487
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:267
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 309 of file Principal.cc.

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

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

309  {
310  addProductOrThrow(std::make_unique<InputProductResolver>(std::move(bd)));
311  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:487
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addParentProcessProduct ( 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  addProductOrThrow(std::make_unique<ParentProcessProductResolver>(std::move(bd)));
329  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:487
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addProduct_ ( std::unique_ptr< ProductResolverBase phb)
protected

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

473  {
474  BranchDescription const& bd = productResolver->branchDescription();
475  assert (!bd.className().empty());
476  assert (!bd.friendlyClassName().empty());
477  assert (!bd.moduleLabel().empty());
478  assert (!bd.processName().empty());
479  SharedProductPtr phb(productResolver.release());
480 
481  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
482  assert(index != ProductResolverIndexInvalid);
483  productResolvers_[index] = phb;
484  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:263
std::shared_ptr< ProductResolverBase > SharedProductPtr
Definition: Principal.h:67
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:267
void edm::Principal::addProductOrThrow ( std::unique_ptr< ProductResolverBase phb)
protected

Definition at line 487 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(), and addUnscheduledProduct().

487  {
488  ProductResolverBase const* phb = getExistingProduct(*productResolver);
489  if(phb != nullptr) {
490  BranchDescription const& bd = productResolver->branchDescription();
491  throw Exception(errors::InsertFailure, "AlreadyPresent")
492  << "addProductOrThrow: Problem found while adding product, "
493  << "product already exists for ("
494  << bd.friendlyClassName() << ","
495  << bd.moduleLabel() << ","
496  << bd.productInstanceName() << ","
497  << bd.processName()
498  << ")\n";
499  }
500  addProduct_(std::move(productResolver));
501  }
void addProduct_(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:473
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:444
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 297 of file Principal.cc.

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

Referenced by Principal().

297  {
298  auto phb = std::make_unique<PuttableProductResolver>(std::move(bd));
300  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:487
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addSourceProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 303 of file Principal.cc.

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

Referenced by Principal().

303  {
304  auto phb = std::make_unique<PuttableProductResolver>(std::move(bd));
306  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:487
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 314 of file Principal.cc.

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

Referenced by Principal().

314  {
315  addProductOrThrow(std::make_unique<UnscheduledProductResolver>(std::move(bd)));
316  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:487
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

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

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

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

280  {
281  ProductRegistry::ProductList const& prodsList = reg.productList();
282  for(auto const& prod : prodsList) {
283  BranchDescription const& bd = prod.second;
284  if(!bd.produced() && (bd.branchType() == branchType_)) {
285  auto cbd = std::make_shared<BranchDescription const>(bd);
286  auto phb = getExistingProduct(cbd->branchID());
287  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
288  return false;
289  }
290  phb->resetBranchDescription(cbd);
291  }
292  }
293  return true;
294  }
BranchType branchType_
Definition: Principal.h:277
std::map< BranchKey, BranchDescription > ProductList
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:444
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
template<typename F >
void edm::Principal::applyToResolvers ( F  iFunc)
inlineprotected

Definition at line 209 of file Principal.h.

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

Referenced by setupUnscheduled().

209  {
210  for(auto& resolver: productResolvers_) {
211  iFunc(resolver.get());
212  }
213  }
ProductResolverCollection productResolvers_
Definition: Principal.h:263
const_iterator edm::Principal::begin ( void  ) const
inline

Definition at line 163 of file Principal.h.

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

Definition at line 166 of file Principal.h.

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

Definition at line 180 of file Principal.h.

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

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

Definition at line 333 of file Principal.cc.

References parseEventContent::prod, and reader_.

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

333  {
334  //We do not clear the product history information
335  // because it rarely changes and recalculating takes
336  // time.
337  reader_ = nullptr;
338  for(auto& prod : *this) {
339  prod->resetProductData();
340  }
341  }
DelayedReader * reader_
Definition: Principal.h:275
void edm::Principal::deleteProduct ( BranchID const &  id) const

Definition at line 344 of file Principal.cc.

References getExistingProduct().

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

344  {
345  auto phb = getExistingProduct(id);
346  assert(nullptr != phb);
347  phb->unsafe_deleteProduct();
348  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:444
const_iterator edm::Principal::end ( void  ) const
inline

Definition at line 164 of file Principal.h.

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

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

Definition at line 167 of file Principal.h.

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

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

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

362  {
363  //increment identifier here since clearPrincipal isn't called for Run/Lumi
365  if(reader) {
366  reader_ = reader;
367  }
368 
369  if (historyAppender_ && productRegistry().anyProductProduced()) {
371  processHistoryPtr_ =
372  historyAppender_->appendToProcessHistory(hist,
373  processHistoryRegistry. getMapped(hist),
375  processHistoryID_ = processHistoryPtr_->id();
377  }
378  }
379  else {
380  std::shared_ptr<ProcessHistory const> inputProcessHistory;
381  if( (not processHistoryPtr_) || (processHistoryIDBeforeConfig_ != hist) ) {
382  if (hist.isValid()) {
383  //does not own the pointer
384  auto noDel =[](void const*){};
385  inputProcessHistory =
386  std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist),noDel);
387  if (inputProcessHistory.get() == nullptr) {
389  << "Principal::fillPrincipal\n"
390  << "Input ProcessHistory not found in registry\n"
391  << "Contact a Framework developer\n";
392  }
393  } else {
394  //Since this is static we don't want it deleted
395  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory,[](void const*){});
396  //no need to do any ordering since it is empty
398  }
400  processHistoryPtr_ = inputProcessHistory;
402  }
403  }
404 
406  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
407  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
408  unsigned int k = 0;
409 
410  // We loop over processes in reverse order of the ProcessHistory.
411  // If any entries in the product lookup tables are associated with
412  // the process we add it to the vector of processes in the order
413  // the lookup should be performed. There is one exception though,
414  // We start with the current process even if it is not in the ProcessHistory.
415  // The current process might be needed but not be in the process
416  // history if all the products produced in the current process are
417  // transient.
418  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), processConfiguration_->processName());
419  if (nameIter != lookupProcessNames.end()) {
420  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
421  ++k;
422  }
423 
424  // We just looked for the current process so skip it if
425  // it is in the ProcessHistory.
426  auto iter = processHistoryPtr_->rbegin();
427  if (iter->processName() == processConfiguration_->processName()) {
428  ++iter;
429  }
430 
431  for (auto iEnd = processHistoryPtr_->rend(); iter != iEnd; ++iter) {
432  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
433  if (nameIter == lookupProcessNames.end()) {
434  continue;
435  }
436  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
437  ++k;
438  }
440  }
441  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:33
ProductRegistry const & productRegistry() const
Definition: Principal.h:149
DelayedReader * reader_
Definition: Principal.h:275
ProcessHistoryID processHistoryIDBeforeConfig_
Definition: Principal.h:258
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:255
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:109
ProcessHistoryID processHistoryID_
Definition: Principal.h:257
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:282
std::string const & processName() const
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:270
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:268
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:284
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:271
int k[5][pyjets_maxn]
DelayedReader * reader() const
Definition: Principal.h:182
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:260
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 692 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().

697  {
698 
699  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
700 
702 
703  if (index == ProductResolverIndexInvalid) {
704 
705  char const* processName = inputTag.process().c_str();
706  if (skipCurrentProcess) {
707  processName = "\0";
708  } else if (inputTag.process() == InputTag::kCurrentProcess) {
709  processName = processConfiguration_->processName().c_str();
710  }
711 
712  index = productLookup().index(kindOfType,
713  typeID,
714  inputTag.label().c_str(),
715  inputTag.instance().c_str(),
716  processName);
717 
718  if(index == ProductResolverIndexAmbiguous) {
719  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(),
721  } else if (index == ProductResolverIndexInvalid) {
722  return nullptr;
723  }
724  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
725  }
726  if(unlikely( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
727  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),
729  }
730 
731 
732  auto const& productResolver = productResolvers_[index];
733 
734  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
735  if(resolution.isAmbiguous()) {
736  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(),
738  }
739  return resolution.data();
740  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:149
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:263
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:73
std::string const & processName() const
#define unlikely(x)
BranchType const & branchType() const
Definition: Principal.h:176
static const std::string kCurrentProcess
Definition: InputTag.h:51
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:151
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:36
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:260
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 743 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.

750  {
751 
753  typeID,
754  label.c_str(),
755  instance.c_str(),
756  process.c_str());
757 
758  if(index == ProductResolverIndexAmbiguous) {
759  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
760  } else if (index == ProductResolverIndexInvalid) {
761  return nullptr;
762  }
763 
764  if(unlikely( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
765  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
766  }
767 
768  auto const& productResolver = productResolvers_[index];
769 
770  auto resolution = productResolver->resolveProduct(*this, false, sra, mcc);
771  if(resolution.isAmbiguous()) {
772  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
773  }
774  return resolution.data();
775  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:263
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:73
#define unlikely(x)
BranchType const & branchType() const
Definition: Principal.h:176
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:151
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 778 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

778  {
779  ProductData const* productData =
781  typeID,
782  tag,
783  nullptr,
784  nullptr,
785  mcc);
786  return productData;
787  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:692
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 662 of file Principal.cc.

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

Referenced by getManyByType().

666  {
667 
668  for (auto iter = processHistoryPtr_->rbegin(),
669  iEnd = processHistoryPtr_->rend();
670  iter != iEnd; ++iter) {
671  std::string const& process = iter->processName();
672  for (auto productResolver : holders) {
673  BranchDescription const& bd = productResolver->branchDescription();
674  if (process == bd.processName()) {
675 
676  // Ignore aliases to avoid matching the same product multiple times.
677  if(bd.isAlias()) {
678  continue;
679  }
680 
681  ProductData const* productData = productResolver->resolveProduct(*this,false, sra, mcc).data();
682  if(productData) {
683  // Skip product if not available.
684  results.emplace_back(productData->wrapper(), &(productData->provenance()));
685  }
686  }
687  }
688  }
689  }
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:255
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 809 of file Principal.cc.

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

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

Definition at line 826 of file Principal.cc.

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

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

Definition at line 520 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::PrincipalGetAdapter::getByLabel_(), and edm::PrincipalGetAdapter::getMatchingSequenceByLabel_().

525  {
526 
527  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, sra, mcc);
528  if(result == nullptr) {
529  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
530  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(),
532  }));
533  }
534  return BasicHandle(result->wrapper(), &(result->provenance()));
535  }
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:56
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:692
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:36
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:260
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 538 of file Principal.cc.

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

545  {
546 
547  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, sra, mcc);
548  if(result == nullptr) {
549  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
550  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
551  }));
552  }
553  return BasicHandle(result->wrapper(), &(result->provenance()));
554  }
static PFTauRenderPlugin instance
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:56
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:692
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductResolverIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 557 of file Principal.cc.

References edm::ProductResolverIndexInvalid, productResolvers_, and fftjetproducer_cfi::resolution.

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

563  {
565  auto& productResolver = productResolvers_[index];
566  assert(nullptr!=productResolver.get());
567  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
568  if(resolution.isAmbiguous()) {
569  ambiguous = true;
570  return BasicHandle();
571  }
572  auto productData = resolution.data();
573  if(productData == nullptr) {
574  return BasicHandle();
575  }
576  return BasicHandle(productData->wrapper(), &(productData->provenance()));
577  }
ProductResolverCollection productResolvers_
Definition: Principal.h:263
ProductResolverBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 444 of file Principal.cc.

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

444  {
445  return const_cast<ProductResolverBase*>( const_cast<const Principal*>(this)->getExistingProduct(branchID));
446  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:444
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:113
ProductResolverBase const * edm::Principal::getExistingProduct ( BranchID const &  branchID) const
protected

Definition at line 449 of file Principal.cc.

References preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

449  {
450  ProductResolverIndex index = preg_->indexFrom(branchID);
451  assert(index != ProductResolverIndexInvalid);
452  return productResolvers_.at(index).get();
453  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:263
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:267
ProductResolverBase const * edm::Principal::getExistingProduct ( ProductResolverBase const &  phb) const
protected

Definition at line 456 of file Principal.cc.

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

456  {
457  auto phb = getExistingProduct(productResolver.branchDescription().branchID());
458  if(nullptr != phb && BranchKey(productResolver.branchDescription()) != BranchKey(phb->branchDescription())) {
459  BranchDescription const& newProduct = phb->branchDescription();
460  BranchDescription const& existing = productResolver.branchDescription();
461  if(newProduct.branchName() != existing.branchName() && newProduct.branchID() == existing.branchID()) {
462  throw cms::Exception("HashCollision") << "Principal::getExistingProduct\n" <<
463  " Branch " << newProduct.branchName() << " has same branch ID as branch " << existing.branchName() << "\n" <<
464  "Workaround: change process name or product instance name of " << newProduct.branchName() << "\n";
465  } else {
466  assert(nullptr == phb || BranchKey(productResolver.branchDescription()) == BranchKey(phb->branchDescription()));
467  }
468  }
469  return phb;
470  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:444
BranchDescription const & branchDescription() const
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Definition at line 850 of file Principal.cc.

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

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

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

Definition at line 156 of file Principal.h.

References findQualityFiles::size.

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

156  {
157  return const_cast<ProductResolverBase*>( const_cast<const Principal*>(this)->getProductResolver(oid));
158  }
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:113
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Definition: Principal.cc:504
Principal::ConstProductResolverPtr edm::Principal::getProductResolver ( BranchID const &  oid) const

Definition at line 504 of file Principal.cc.

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

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

504  {
505  ProductResolverIndex index = preg_->indexFrom(bid);
506  if(index == ProductResolverIndexInvalid){
507  return ConstProductResolverPtr();
508  }
509  return getProductResolverByIndex(index);
510  }
unsigned int ProductResolverIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:267
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:63
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:513
Principal::ConstProductResolverPtr edm::Principal::getProductResolverByIndex ( ProductResolverIndex const &  oid) const
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

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

791  {
793  if(phb == nullptr) {
795  }
796 
797  if(phb->unscheduledWasNotRun()) {
798  if(not phb->resolveProduct(*this,false, nullptr, mcc).data() ) {
799  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
800  }
801  }
802  return *phb->provenance();
803  }
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:63
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Definition: Principal.cc:504
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:49
WrapperBase const * edm::Principal::getThinnedProduct ( ProductID const &  ,
unsigned int &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Definition at line 856 of file Principal.cc.

856  {
857  assert(false);
858  return nullptr;
859  }
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 580 of file Principal.cc.

References productResolvers_.

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

584  {
585  auto const& productResolver = productResolvers_.at(index);
586  assert(nullptr!=productResolver.get());
587  productResolver->prefetchAsync(task,*this, skipCurrentProcess,token, nullptr,mcc);
588  }
ProductResolverCollection productResolvers_
Definition: Principal.h:263
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 147 of file Principal.h.

147 {return *processConfiguration_;}
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:260
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 151 of file Principal.h.

References trackingPlots::other.

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

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

Definition at line 149 of file Principal.h.

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

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

Definition at line 874 of file Principal.cc.

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

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

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

Definition at line 869 of file Principal.cc.

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

869  {
870  phb->putOrMergeProduct(std::move(prod));
871  }
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::readAllFromSourceAndMergeImmediately ( )

Definition at line 909 of file Principal.cc.

References parseEventContent::prod, and reader().

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

909  {
910  if(not reader()) {return;}
911 
912  for(auto & prod : *this) {
913  prod->retrieveAndMerge(*this);
914  }
915  }
DelayedReader * reader() const
Definition: Principal.h:182
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

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

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

Definition at line 351 of file Principal.cc.

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

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

351  {
352  applyToResolvers([&iConfigure](ProductResolverBase* iResolver) {
353  iResolver->setupUnscheduled(iConfigure);
354  });
355  }
void applyToResolvers(F iFunc)
Definition: Principal.h:209
size_t edm::Principal::size ( void  ) const

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

265  {
266  size_t size = 0U;
267  for(auto const& prod : *this) {
268  if(prod->singleProduct() && // Not a NoProcessProductResolver
269  !prod->productUnavailable() &&
270  !prod->unscheduledWasNotRun() &&
271  !prod->branchDescription().dropped()) {
272  ++size;
273  }
274  }
275  return size;
276  }
size_t size() const
Definition: Principal.cc:265

Member Data Documentation

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

Definition at line 284 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 282 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 270 of file Principal.h.

Referenced by fillPrincipal().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

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

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 257 of file Principal.h.

Referenced by fillPrincipal().

ProcessHistoryID edm::Principal::processHistoryIDBeforeConfig_
private

Definition at line 258 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 255 of file Principal.h.

Referenced by fillPrincipal(), and findProducts().

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

Definition at line 268 of file Principal.h.

Referenced by fillPrincipal(), and Principal().

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

Definition at line 275 of file Principal.h.

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