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)
 
bool atEndTransition () const
 
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
 
bool isComplete () const
 
std::vector< unsigned int > const & lookupProcessOrder () const
 
void prefetchAsync (WaitingTask *waitTask, ProductResolverIndex index, bool skipCurrentProcess, 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 resetFailedFromThisProcess ()
 
void setAtEndTransition (bool iAtEnd)
 
void setupUnscheduled (UnscheduledConfigurator const &)
 
size_t size () const
 
virtual ~Principal ()
 
- Public Member Functions inherited from edm::EDProductGetter
 EDProductGetter ()
 
 EDProductGetter (EDProductGetter const &)=delete
 
EDProductGetter const & operator= (EDProductGetter const &)=delete
 
unsigned int transitionIndex () const
 
virtual ~EDProductGetter ()
 

Protected Member Functions

void addProduct_ (std::unique_ptr< 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
 
virtual WrapperBase const * getIt (ProductID const &) const override
 
virtual WrapperBase const * getThinnedProduct (ProductID const &, unsigned int &) const override
 
virtual void getThinnedProducts (ProductID const &, std::vector< WrapperBase const * > &, std::vector< unsigned int > &) const override
 
virtual bool isComplete_ () const
 
void putOrMerge (std::unique_ptr< WrapperBase > prod, ProductResolverBase const *productResolver) const
 

Private Attributes

bool atEndTransition_
 
BranchType branchType_
 
CacheIdentifier_t cacheIdentifier_
 
edm::propagate_const< HistoryAppender * > historyAppender_
 
std::vector< unsigned int > lookupProcessOrder_
 
ProcessHistoryID orderProcessHistoryID_
 
std::shared_ptr< ProductRegistry const > preg_
 
ProcessConfiguration const * processConfiguration_
 
ProcessHistoryID processHistoryID_
 
std::shared_ptr< ProcessHistory const > processHistoryPtr_
 
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 181 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 112 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.

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

Definition at line 237 of file Principal.cc.

237  {
238  }

Member Function Documentation

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

Definition at line 298 of file Principal.cc.

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

Referenced by Principal().

298  {
299  ProductResolverIndex index = preg_->indexFrom(bd->originalBranchID());
300  assert(index != ProductResolverIndexInvalid);
301 
302  addProductOrThrow(std::make_unique<AliasProductResolver>(std::move(bd), dynamic_cast<ProducedProductResolver&>(*productResolvers_[index])));
303  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:272
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:443
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:276
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 288 of file Principal.cc.

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

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

288  {
289  addProductOrThrow(std::make_unique<InputProductResolver>(std::move(bd)));
290  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:443
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addParentProcessProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 306 of file Principal.cc.

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

Referenced by Principal().

306  {
307  addProductOrThrow(std::make_unique<ParentProcessProductResolver>(std::move(bd)));
308  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:443
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::addProduct_ ( std::unique_ptr< ProductResolverBase phb)
protected

Definition at line 429 of file Principal.cc.

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

Referenced by addProductOrThrow().

429  {
430  BranchDescription const& bd = productResolver->branchDescription();
431  assert (!bd.className().empty());
432  assert (!bd.friendlyClassName().empty());
433  assert (!bd.moduleLabel().empty());
434  assert (!bd.processName().empty());
435  SharedProductPtr phb(productResolver.release());
436 
437  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
438  assert(index != ProductResolverIndexInvalid);
439  productResolvers_[index] = phb;
440  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:272
std::shared_ptr< ProductResolverBase > SharedProductPtr
Definition: Principal.h:67
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:276
void edm::Principal::addProductOrThrow ( std::unique_ptr< ProductResolverBase phb)
protected

Definition at line 443 of file Principal.cc.

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

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

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

Definition at line 276 of file Principal.cc.

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

Referenced by Principal().

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

Definition at line 282 of file Principal.cc.

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

Referenced by Principal().

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

Definition at line 293 of file Principal.cc.

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

Referenced by Principal().

293  {
294  addProductOrThrow(std::make_unique<UnscheduledProductResolver>(std::move(bd)));
295  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:443
def move(src, dest)
Definition: eostools.py:510
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 843 of file Principal.cc.

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

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

843  {
844  if(preg_->getNextIndexValue(branchType_) != productResolvers_.size()) {
845  productResolvers_.resize(preg_->getNextIndexValue(branchType_));
846  for(auto const& prod : preg_->productList()) {
847  BranchDescription const& bd = prod.second;
848  if(bd.branchType() == branchType_) {
849  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
850  assert(index != ProductResolverIndexInvalid);
851  if(!productResolvers_[index]) {
852  // no product holder. Must add one. The new entry must be an input product holder.
853  assert(!bd.produced());
854  auto cbd = std::make_shared<BranchDescription const>(bd);
855  addInputProduct(cbd);
856  }
857  }
858  }
859  }
860  assert(preg_->getNextIndexValue(branchType_) == productResolvers_.size());
861  }
BranchType branchType_
Definition: Principal.h:286
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:272
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:288
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:276
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

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

259  {
260  ProductRegistry::ProductList const& prodsList = reg.productList();
261  for(auto const& prod : prodsList) {
262  BranchDescription const& bd = prod.second;
263  if(!bd.produced() && (bd.branchType() == branchType_)) {
264  auto cbd = std::make_shared<BranchDescription const>(bd);
265  auto phb = getExistingProduct(cbd->branchID());
266  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
267  return false;
268  }
269  phb->resetBranchDescription(cbd);
270  }
271  }
272  return true;
273  }
BranchType branchType_
Definition: Principal.h:286
std::map< BranchKey, BranchDescription > ProductList
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
template<typename F >
void edm::Principal::applyToResolvers ( F  iFunc)
inlineprotected

Definition at line 217 of file Principal.h.

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

Referenced by setupUnscheduled().

217  {
218  for(auto& resolver: productResolvers_) {
219  iFunc(resolver.get());
220  }
221  }
ProductResolverCollection productResolvers_
Definition: Principal.h:272
bool edm::Principal::atEndTransition ( ) const
inline
const_iterator edm::Principal::begin ( void  ) const
inline

Definition at line 165 of file Principal.h.

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

Definition at line 168 of file Principal.h.

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

Definition at line 182 of file Principal.h.

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

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

Definition at line 312 of file Principal.cc.

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

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

312  {
313  processHistoryPtr_.reset();
315  reader_ = nullptr;
316  for(auto& prod : *this) {
317  prod->resetProductData();
318  }
319  }
DelayedReader * reader_
Definition: Principal.h:284
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:265
ProcessHistoryID processHistoryID_
Definition: Principal.h:267
Hash< ProcessHistoryType > ProcessHistoryID
void edm::Principal::deleteProduct ( BranchID const &  id) const

Definition at line 327 of file Principal.cc.

References getExistingProduct().

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

327  {
328  auto phb = getExistingProduct(id);
329  assert(nullptr != phb);
330  phb->unsafe_deleteProduct();
331  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
const_iterator edm::Principal::end ( void  ) const
inline

Definition at line 166 of file Principal.h.

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

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

Definition at line 169 of file Principal.h.

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

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

Definition at line 343 of file Principal.cc.

References atEndTransition_, 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_, processHistoryPtr_, productLookup_, productRegistry(), reader(), reader_, and edm::s_emptyProcessHistory.

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

345  {
346  //increment identifier here since clearPrincipal isn't called for Run/Lumi
348  atEndTransition_=false;
349  if(reader) {
350  reader_ = reader;
351  }
352 
353  if (historyAppender_ && productRegistry().anyProductProduced()) {
355  historyAppender_->appendToProcessHistory(hist,
356  processHistoryRegistry.getMapped(hist),
359  }
360  else {
361  std::shared_ptr<ProcessHistory const> inputProcessHistory;
362  if (hist.isValid()) {
363  //does not own the pointer
364  auto noDel =[](void const*){};
365  inputProcessHistory =
366  std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist),noDel);
367  if (inputProcessHistory.get() == nullptr) {
369  << "Principal::fillPrincipal\n"
370  << "Input ProcessHistory not found in registry\n"
371  << "Contact a Framework developer\n";
372  }
373  } else {
374  //Since this is static we don't want it deleted
375  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory,[](void const*){});
376  }
378  processHistoryPtr_ = inputProcessHistory;
379  }
380 
382  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
383  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
384  unsigned int k = 0;
385  for (auto iter = processHistoryPtr_->rbegin(),
386  iEnd = processHistoryPtr_->rend();
387  iter != iEnd; ++iter) {
388  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
389  if (nameIter == lookupProcessNames.end()) {
390  continue;
391  }
392  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
393  ++k;
394  }
396  }
397  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:32
ProductRegistry const & productRegistry() const
Definition: Principal.h:151
DelayedReader * reader_
Definition: Principal.h:284
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:265
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:108
ProcessHistoryID processHistoryID_
Definition: Principal.h:267
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:291
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:279
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:277
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:293
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:280
int k[5][pyjets_maxn]
DelayedReader * reader() const
Definition: Principal.h:184
bool atEndTransition_
Definition: Principal.h:295
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:269
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 647 of file Principal.cc.

References edm::appendCurrentProcessIfAlias(), branchType(), edm::ProductResolverIndexHelper::index(), diffTreeTool::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().

652  {
653 
654  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
655 
657 
658  if (index == ProductResolverIndexInvalid) {
659 
660  char const* processName = inputTag.process().c_str();
661  if (skipCurrentProcess) {
662  processName = "\0";
663  } else if (inputTag.process() == InputTag::kCurrentProcess) {
664  processName = processConfiguration_->processName().c_str();
665  }
666 
667  index = productLookup().index(kindOfType,
668  typeID,
669  inputTag.label().c_str(),
670  inputTag.instance().c_str(),
671  processName);
672 
673  if(index == ProductResolverIndexAmbiguous) {
674  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(),
676  } else if (index == ProductResolverIndexInvalid) {
677  return 0;
678  }
679  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
680  }
681  if(unlikely( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
682  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),
684  }
685 
686 
687  auto const& productResolver = productResolvers_[index];
688 
689  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
690  if(resolution.isAmbiguous()) {
691  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(),
693  }
694  return resolution.data();
695  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:151
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:272
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:72
std::string const & processName() const
#define unlikely(x)
BranchType const & branchType() const
Definition: Principal.h:178
static const std::string kCurrentProcess
Definition: InputTag.h:51
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:153
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:35
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:269
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 698 of file Principal.cc.

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

705  {
706 
708  typeID,
709  label.c_str(),
710  instance.c_str(),
711  process.c_str());
712 
713  if(index == ProductResolverIndexAmbiguous) {
714  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
715  } else if (index == ProductResolverIndexInvalid) {
716  return 0;
717  }
718 
719  if(unlikely( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
720  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
721  }
722 
723  auto const& productResolver = productResolvers_[index];
724 
725  auto resolution = productResolver->resolveProduct(*this, false, sra, mcc);
726  if(resolution.isAmbiguous()) {
727  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
728  }
729  return resolution.data();
730  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:272
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:72
#define unlikely(x)
BranchType const & branchType() const
Definition: Principal.h:178
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:153
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 733 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

733  {
734  ProductData const* productData =
736  typeID,
737  tag,
738  nullptr,
739  nullptr,
740  mcc);
741  return productData;
742  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:647
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 617 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().

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

Definition at line 764 of file Principal.cc.

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

764  {
765  provenances.clear();
766  for(auto const& productResolver : *this) {
767  if(productResolver->singleProduct() && productResolver->provenanceAvailable() && !productResolver->branchDescription().isAlias()) {
768  // We do not attempt to get the event/lumi/run status from the provenance,
769  // because the per event provenance may have been dropped.
770  if(productResolver->provenance()->branchDescription().present()) {
771  provenances.push_back(productResolver->provenance());
772  }
773  }
774  }
775  }
void edm::Principal::getAllStableProvenance ( std::vector< StableProvenance const * > &  provenances) const

Definition at line 781 of file Principal.cc.

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

781  {
782  provenances.clear();
783  for(auto const& productResolver : *this) {
784  if(productResolver->singleProduct() && !productResolver->branchDescription().isAlias()) {
785  if(productResolver->stableProvenance()->branchDescription().present()) {
786  provenances.push_back(productResolver->stableProvenance());
787  }
788  }
789  }
790  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 476 of file Principal.cc.

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

481  {
482 
483  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, sra, mcc);
484  if(result == 0) {
485  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
486  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(),
488  }));
489  }
490  return BasicHandle(result->wrapper(), &(result->provenance()));
491  }
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:55
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:647
static std::string appendCurrentProcessIfAlias(std::string const &processFromInputTag, std::string const &currentProcess)
Definition: Principal.cc:35
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:269
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 494 of file Principal.cc.

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

501  {
502 
503  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, sra, mcc);
504  if(result == 0) {
505  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
506  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
507  }));
508  }
509  return BasicHandle(result->wrapper(), &(result->provenance()));
510  }
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:55
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:647
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductResolverIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 513 of file Principal.cc.

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

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

519  {
521  auto& productResolver = productResolvers_[index];
522  assert(0!=productResolver.get());
523  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
524  if(resolution.isAmbiguous()) {
525  ambiguous = true;
526  return BasicHandle();
527  }
528  auto productData = resolution.data();
529  if(productData == nullptr) {
530  return BasicHandle();
531  }
532  return BasicHandle(productData->wrapper(), &(productData->provenance()));
533  }
ProductResolverCollection productResolvers_
Definition: Principal.h:272
ProductResolverBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 400 of file Principal.cc.

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

400  {
401  return const_cast<ProductResolverBase*>( const_cast<const Principal*>(this)->getExistingProduct(branchID));
402  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
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:112
ProductResolverBase const * edm::Principal::getExistingProduct ( BranchID const &  branchID) const
protected

Definition at line 405 of file Principal.cc.

References diffTreeTool::index, preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

405  {
406  ProductResolverIndex index = preg_->indexFrom(branchID);
407  assert(index != ProductResolverIndexInvalid);
408  return productResolvers_.at(index).get();
409  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:272
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:276
ProductResolverBase const * edm::Principal::getExistingProduct ( ProductResolverBase const &  phb) const
protected

Definition at line 412 of file Principal.cc.

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

412  {
413  auto phb = getExistingProduct(productResolver.branchDescription().branchID());
414  if(nullptr != phb && BranchKey(productResolver.branchDescription()) != BranchKey(phb->branchDescription())) {
415  BranchDescription const& newProduct = phb->branchDescription();
416  BranchDescription const& existing = productResolver.branchDescription();
417  if(newProduct.branchName() != existing.branchName() && newProduct.branchID() == existing.branchID()) {
418  throw cms::Exception("HashCollision") << "Principal::getExistingProduct\n" <<
419  " Branch " << newProduct.branchName() << " has same branch ID as branch " << existing.branchName() << "\n" <<
420  "Workaround: change process name or product instance name of " << newProduct.branchName() << "\n";
421  } else {
422  assert(nullptr == phb || BranchKey(productResolver.branchDescription()) == BranchKey(phb->branchDescription()));
423  }
424  }
425  return phb;
426  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
BranchDescription const & branchDescription() const
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 805 of file Principal.cc.

805  {
806  assert(false);
807  return nullptr;
808  }
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 546 of file Principal.cc.

References branchType(), findProducts(), mps_fire::i, edm::ProductResolverIndexHelper::Matches::index(), diffTreeTool::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_().

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

Definition at line 158 of file Principal.h.

References findQualityFiles::size.

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

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

Definition at line 460 of file Principal.cc.

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

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

460  {
461  ProductResolverIndex index = preg_->indexFrom(bid);
462  if(index == ProductResolverIndexInvalid){
463  return ConstProductResolverPtr();
464  }
465  return getProductResolverByIndex(index);
466  }
unsigned int ProductResolverIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:276
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:63
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:469
Principal::ConstProductResolverPtr edm::Principal::getProductResolverByIndex ( ProductResolverIndex const &  oid) const
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

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

746  {
748  if(phb == nullptr) {
750  }
751 
752  if(phb->unscheduledWasNotRun()) {
753  if(not phb->resolveProduct(*this,false, nullptr, mcc).data() ) {
754  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
755  }
756  }
757  return *phb->provenance();
758  }
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:63
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Definition: Principal.cc:460
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:48
WrapperBase const * edm::Principal::getThinnedProduct ( ProductID const &  ,
unsigned int &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 811 of file Principal.cc.

811  {
812  assert(false);
813  return nullptr;
814  }
void edm::Principal::getThinnedProducts ( ProductID const &  ,
std::vector< WrapperBase const * > &  ,
std::vector< unsigned int > &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 817 of file Principal.cc.

819  {
820  assert(false);
821  }
bool edm::Principal::isComplete ( ) const
inline

Definition at line 200 of file Principal.h.

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

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

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

Definition at line 261 of file Principal.h.

References parseEventContent::prod.

261 {return true;}
std::vector<unsigned int> const& edm::Principal::lookupProcessOrder ( ) const
inline
void edm::Principal::prefetchAsync ( WaitingTask waitTask,
ProductResolverIndex  index,
bool  skipCurrentProcess,
ModuleCallingContext const *  mcc 
) const

Definition at line 536 of file Principal.cc.

References productResolvers_.

Referenced by edm::Worker::prefetchAsync().

539  {
540  auto const& productResolver = productResolvers_.at(index);
541  assert(0!=productResolver.get());
542  productResolver->prefetchAsync(task,*this, skipCurrentProcess,nullptr,mcc);
543  }
ProductResolverCollection productResolvers_
Definition: Principal.h:272
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 149 of file Principal.h.

149 {return *processConfiguration_;}
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:269
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 153 of file Principal.h.

References trackingPlots::other.

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

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

Definition at line 151 of file Principal.h.

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

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

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

829  {
830  if(edp.get() == nullptr) {
831  throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
832  << "put: Cannot put because unique_ptr to product is null."
833  << "\n";
834  }
835  auto phb = getExistingProduct(bd.branchID());
836  assert(phb);
837  // ProductResolver assumes ownership
838  putOrMerge(std::move(edp), phb);
839  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:400
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
Definition: Principal.cc:829
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 824 of file Principal.cc.

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

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

Definition at line 864 of file Principal.cc.

References parseEventContent::prod, and reader().

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

864  {
865  if(not reader()) {return;}
866 
867  for(auto & prod : *this) {
868  prod->retrieveAndMerge(*this);
869  }
870  }
DelayedReader * reader() const
Definition: Principal.h:184
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

Definition at line 793 of file Principal.cc.

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

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

793  {
794  for(auto& prod : bids) {
795  ProductResolverIndex index= preg_->indexFrom(prod);
796  assert(index!=ProductResolverIndexInvalid);
797  ProductResolverIndex indexO = other.preg_->indexFrom(prod);
798  assert(indexO!=ProductResolverIndexInvalid);
799  get_underlying_safe(productResolvers_[index]).swap(get_underlying_safe(other.productResolvers_[indexO]));
800  }
801  reader_->mergeReaders(other.reader());
802  }
DelayedReader * reader_
Definition: Principal.h:284
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:272
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:35
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:276
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void edm::Principal::resetFailedFromThisProcess ( )

Definition at line 873 of file Principal.cc.

References parseEventContent::prod.

873  {
874  for( auto & prod : *this) {
875  prod->resetFailedFromThisProcess();
876  }
877  }
void edm::Principal::setAtEndTransition ( bool  iAtEnd)
void edm::Principal::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)

Definition at line 334 of file Principal.cc.

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

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

334  {
335  applyToResolvers([&iConfigure](ProductResolverBase* iResolver) {
336  iResolver->setupUnscheduled(iConfigure);
337  });
338  }
void applyToResolvers(F iFunc)
Definition: Principal.h:217
size_t edm::Principal::size ( void  ) const

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

244  {
245  size_t size = 0U;
246  for(auto const& prod : *this) {
247  if(prod->singleProduct() && // Not a NoProcessProductResolver
248  !prod->productUnavailable() &&
249  !prod->unscheduledWasNotRun() &&
250  !prod->branchDescription().dropped()) {
251  ++size;
252  }
253  }
254  return size;
255  }
size_t size() const
Definition: Principal.cc:244

Member Data Documentation

bool edm::Principal::atEndTransition_
private

Definition at line 295 of file Principal.h.

Referenced by fillPrincipal(), and setAtEndTransition().

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

Definition at line 293 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 291 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 279 of file Principal.h.

Referenced by fillPrincipal().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

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

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 267 of file Principal.h.

Referenced by clearPrincipal(), and fillPrincipal().

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

Definition at line 265 of file Principal.h.

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

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

Definition at line 277 of file Principal.h.

Referenced by fillPrincipal(), and Principal().

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

Definition at line 284 of file Principal.h.

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