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 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 180 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 114 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.

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

Definition at line 265 of file Principal.cc.

265  {
266  }

Member Function Documentation

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

Definition at line 326 of file Principal.cc.

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

Referenced by Principal().

326  {
327  ProductResolverIndex index = preg_->indexFrom(bd->originalBranchID());
328  assert(index != ProductResolverIndexInvalid);
329 
330  addProductOrThrow(std::make_unique<AliasProductResolver>(std::move(bd), dynamic_cast<ProducedProductResolver&>(*productResolvers_[index])));
331  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:264
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:494
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:268
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 316 of file Principal.cc.

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

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

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

Definition at line 334 of file Principal.cc.

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

Referenced by Principal().

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

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

480  {
481  BranchDescription const& bd = productResolver->branchDescription();
482  assert (!bd.className().empty());
483  assert (!bd.friendlyClassName().empty());
484  assert (!bd.moduleLabel().empty());
485  assert (!bd.processName().empty());
486  SharedProductPtr phb(productResolver.release());
487 
488  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
489  assert(index != ProductResolverIndexInvalid);
490  productResolvers_[index] = phb;
491  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:264
std::shared_ptr< ProductResolverBase > SharedProductPtr
Definition: Principal.h:68
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:268
void edm::Principal::addProductOrThrow ( std::unique_ptr< ProductResolverBase phb)
protected

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

494  {
495  ProductResolverBase const* phb = getExistingProduct(*productResolver);
496  if(phb != nullptr) {
497  BranchDescription const& bd = productResolver->branchDescription();
498  throw Exception(errors::InsertFailure, "AlreadyPresent")
499  << "addProductOrThrow: Problem found while adding product, "
500  << "product already exists for ("
501  << bd.friendlyClassName() << ","
502  << bd.moduleLabel() << ","
503  << bd.productInstanceName() << ","
504  << bd.processName()
505  << ")\n";
506  }
507  addProduct_(std::move(productResolver));
508  }
void addProduct_(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:480
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:451
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 304 of file Principal.cc.

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

Referenced by Principal().

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

Definition at line 310 of file Principal.cc.

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

Referenced by Principal().

310  {
311  auto phb = std::make_unique<PuttableProductResolver>(std::move(bd));
313  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:494
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 321 of file Principal.cc.

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

Referenced by Principal().

321  {
322  addProductOrThrow(std::make_unique<UnscheduledProductResolver>(std::move(bd)));
323  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:494
def move(src, dest)
Definition: eostools.py:511
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

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

895  {
896  if(preg_->getNextIndexValue(branchType_) != productResolvers_.size()) {
897  productResolvers_.resize(preg_->getNextIndexValue(branchType_));
898  for(auto const& prod : preg_->productList()) {
899  BranchDescription const& bd = prod.second;
900  if(bd.branchType() == branchType_) {
901  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
902  assert(index != ProductResolverIndexInvalid);
903  if(!productResolvers_[index]) {
904  // no product holder. Must add one. The new entry must be an input product holder.
905  assert(!bd.produced());
906  auto cbd = std::make_shared<BranchDescription const>(bd);
907  addInputProduct(cbd);
908  }
909  }
910  }
911  }
912  assert(preg_->getNextIndexValue(branchType_) == productResolvers_.size());
913  }
BranchType branchType_
Definition: Principal.h:278
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:264
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:316
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:268
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

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

287  {
288  ProductRegistry::ProductList const& prodsList = reg.productList();
289  for(auto const& prod : prodsList) {
290  BranchDescription const& bd = prod.second;
291  if(!bd.produced() && (bd.branchType() == branchType_)) {
292  auto cbd = std::make_shared<BranchDescription const>(bd);
293  auto phb = getExistingProduct(cbd->branchID());
294  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
295  return false;
296  }
297  phb->resetBranchDescription(cbd);
298  }
299  }
300  return true;
301  }
BranchType branchType_
Definition: Principal.h:278
std::map< BranchKey, BranchDescription > ProductList
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:451
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
template<typename F >
void edm::Principal::applyToResolvers ( F  iFunc)
inlineprotected

Definition at line 210 of file Principal.h.

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

Referenced by setupUnscheduled().

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

Definition at line 164 of file Principal.h.

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

Definition at line 167 of file Principal.h.

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

Definition at line 181 of file Principal.h.

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

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

Definition at line 340 of file Principal.cc.

References parseEventContent::prod, and reader_.

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

340  {
341  //We do not clear the product history information
342  // because it rarely changes and recalculating takes
343  // time.
344  reader_ = nullptr;
345  for(auto& prod : *this) {
346  prod->resetProductData();
347  }
348  }
DelayedReader * reader_
Definition: Principal.h:276
void edm::Principal::deleteProduct ( BranchID const &  id) const

Definition at line 351 of file Principal.cc.

References getExistingProduct().

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

351  {
352  auto phb = getExistingProduct(id);
353  assert(nullptr != phb);
354  phb->unsafe_deleteProduct();
355  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:451
const_iterator edm::Principal::end ( void  ) const
inline

Definition at line 165 of file Principal.h.

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

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

Definition at line 168 of file Principal.h.

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

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

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

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

704  {
705 
706  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
707 
709 
710  if (index == ProductResolverIndexInvalid) {
711 
712  char const* processName = inputTag.process().c_str();
713  if (skipCurrentProcess) {
714  processName = "\0";
715  } else if (inputTag.process() == InputTag::kCurrentProcess) {
716  processName = processConfiguration_->processName().c_str();
717  }
718 
719  index = productLookup().index(kindOfType,
720  typeID,
721  inputTag.label().c_str(),
722  inputTag.instance().c_str(),
723  processName);
724 
725  if(index == ProductResolverIndexAmbiguous) {
726  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(),
728  } else if (index == ProductResolverIndexInvalid) {
729  return nullptr;
730  }
731  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
732  }
733  if(UNLIKELY( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
734  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),
736  }
737 
738 
739  auto const& productResolver = productResolvers_[index];
740 
741  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
742  if(resolution.isAmbiguous()) {
743  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(),
745  }
746  return resolution.data();
747  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:150
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:264
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:74
std::string const & processName() const
BranchType const & branchType() const
Definition: Principal.h:177
static const std::string kCurrentProcess
Definition: InputTag.h:51
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:152
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:37
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:261
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
#define UNLIKELY(x)
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 750 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.

757  {
758 
760  typeID,
761  label.c_str(),
762  instance.c_str(),
763  process.c_str());
764 
765  if(index == ProductResolverIndexAmbiguous) {
766  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
767  } else if (index == ProductResolverIndexInvalid) {
768  return nullptr;
769  }
770 
771  if(UNLIKELY( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
772  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
773  }
774 
775  auto const& productResolver = productResolvers_[index];
776 
777  auto resolution = productResolver->resolveProduct(*this, false, sra, mcc);
778  if(resolution.isAmbiguous()) {
779  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
780  }
781  return resolution.data();
782  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:264
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:74
BranchType const & branchType() const
Definition: Principal.h:177
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:152
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
#define UNLIKELY(x)
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 785 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

785  {
786  ProductData const* productData =
788  typeID,
789  tag,
790  nullptr,
791  nullptr,
792  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:699
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 669 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().

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

Definition at line 816 of file Principal.cc.

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

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

Definition at line 833 of file Principal.cc.

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

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

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

532  {
533 
534  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, sra, mcc);
535  if(result == nullptr) {
536  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
537  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(),
539  }));
540  }
541  return BasicHandle(result->wrapper(), &(result->provenance()));
542  }
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:57
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:699
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:37
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:261
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 545 of file Principal.cc.

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

552  {
553 
554  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, sra, mcc);
555  if(result == nullptr) {
556  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
557  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
558  }));
559  }
560  return BasicHandle(result->wrapper(), &(result->provenance()));
561  }
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:57
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:699
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductResolverIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 564 of file Principal.cc.

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

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

570  {
572  auto& productResolver = productResolvers_[index];
573  assert(nullptr!=productResolver.get());
574  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
575  if(resolution.isAmbiguous()) {
576  ambiguous = true;
577  return BasicHandle();
578  }
579  auto productData = resolution.data();
580  if(productData == nullptr) {
581  return BasicHandle();
582  }
583  return BasicHandle(productData->wrapper(), &(productData->provenance()));
584  }
ProductResolverCollection productResolvers_
Definition: Principal.h:264
ProductResolverBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 451 of file Principal.cc.

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

451  {
452  return const_cast<ProductResolverBase*>( const_cast<const Principal*>(this)->getExistingProduct(branchID));
453  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:451
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:114
ProductResolverBase const * edm::Principal::getExistingProduct ( BranchID const &  branchID) const
protected

Definition at line 456 of file Principal.cc.

References preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

456  {
457  ProductResolverIndex index = preg_->indexFrom(branchID);
458  assert(index != ProductResolverIndexInvalid);
459  return productResolvers_.at(index).get();
460  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:264
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:268
ProductResolverBase const * edm::Principal::getExistingProduct ( ProductResolverBase const &  phb) const
protected

Definition at line 463 of file Principal.cc.

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

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

Implements edm::EDProductGetter.

Definition at line 857 of file Principal.cc.

857  {
858  assert(false);
859  return nullptr;
860  }
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

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

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

Definition at line 157 of file Principal.h.

References findQualityFiles::size.

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

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

Definition at line 511 of file Principal.cc.

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

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

511  {
512  ProductResolverIndex index = preg_->indexFrom(bid);
513  if(index == ProductResolverIndexInvalid){
514  return ConstProductResolverPtr();
515  }
516  return getProductResolverByIndex(index);
517  }
unsigned int ProductResolverIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:268
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:64
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:520
Principal::ConstProductResolverPtr edm::Principal::getProductResolverByIndex ( ProductResolverIndex const &  oid) const
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

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

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

Implements edm::EDProductGetter.

Definition at line 863 of file Principal.cc.

863  {
864  assert(false);
865  return nullptr;
866  }
void edm::Principal::getThinnedProducts ( ProductID const &  ,
std::vector< WrapperBase const * > &  ,
std::vector< unsigned int > &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Definition at line 869 of file Principal.cc.

871  {
872  assert(false);
873  }
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 587 of file Principal.cc.

References productResolvers_.

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

591  {
592  auto const& productResolver = productResolvers_.at(index);
593  assert(nullptr!=productResolver.get());
594  productResolver->prefetchAsync(task,*this, skipCurrentProcess,token, nullptr,mcc);
595  }
ProductResolverCollection productResolvers_
Definition: Principal.h:264
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 148 of file Principal.h.

148 {return *processConfiguration_;}
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:261
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 152 of file Principal.h.

References trackingPlots::other.

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

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

Definition at line 150 of file Principal.h.

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

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

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

881  {
882  if(edp.get() == nullptr) {
883  throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
884  << "put: Cannot put because unique_ptr to product is null."
885  << "\n";
886  }
887  auto phb = getExistingProduct(bd.branchID());
888  assert(phb);
889  // ProductResolver assumes ownership
890  putOrMerge(std::move(edp), phb);
891  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:451
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
Definition: Principal.cc:881
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 876 of file Principal.cc.

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

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

Definition at line 916 of file Principal.cc.

References parseEventContent::prod, and reader().

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

916  {
917  if(not reader()) {return;}
918 
919  for(auto & prod : *this) {
920  prod->retrieveAndMerge(*this, mergeableRunProductMetadata);
921  }
922  }
DelayedReader * reader() const
Definition: Principal.h:183
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

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

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

Definition at line 358 of file Principal.cc.

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

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

358  {
359  applyToResolvers([&iConfigure](ProductResolverBase* iResolver) {
360  iResolver->setupUnscheduled(iConfigure);
361  });
362  }
void applyToResolvers(F iFunc)
Definition: Principal.h:210
size_t edm::Principal::size ( void  ) const

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

272  {
273  size_t size = 0U;
274  for(auto const& prod : *this) {
275  if(prod->singleProduct() && // Not a NoProcessProductResolver
276  !prod->productUnavailable() &&
277  !prod->unscheduledWasNotRun() &&
278  !prod->branchDescription().dropped()) {
279  ++size;
280  }
281  }
282  return size;
283  }
size_t size() const
Definition: Principal.cc:272

Member Data Documentation

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

Definition at line 285 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 283 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 271 of file Principal.h.

Referenced by fillPrincipal().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

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

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 258 of file Principal.h.

Referenced by fillPrincipal().

ProcessHistoryID edm::Principal::processHistoryIDBeforeConfig_
private

Definition at line 259 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 256 of file Principal.h.

Referenced by fillPrincipal(), and findProducts().

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

Definition at line 269 of file Principal.h.

Referenced by fillPrincipal(), and Principal().

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

Definition at line 276 of file Principal.h.

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