CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::Principal Class 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
< ProductResolverBase
SharedProductPtr
 
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
 
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 ()
 
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

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 56 of file Principal.h.

Member Typedef Documentation

Definition at line 63 of file Principal.h.

typedef unsigned long edm::Principal::CacheIdentifier_t

Definition at line 175 of file Principal.h.

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

Definition at line 59 of file Principal.h.

Definition at line 62 of file Principal.h.

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

Definition at line 60 of file Principal.h.

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

Definition at line 67 of file Principal.h.

Definition at line 61 of file Principal.h.

Definition at line 58 of file Principal.h.

Definition at line 66 of file Principal.h.

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

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

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

105  :
106  EDProductGetter(),
111  preg_(reg),
114  reader_(),
115  branchType_(bt),
116  historyAppender_(historyAppender),
118  {
119  productResolvers_.resize(reg->getNextIndexValue(bt));
120  //Now that these have been set, we can create the list of Branches we need.
121  std::string const source("source");
122  ProductRegistry::ProductList const& prodsList = reg->productList();
123  // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
124  // So, the non-alias product holders must be created first.
125  // Therefore, on this first pass, skip current EDAliases.
126  bool hasAliases = false;
127  for(auto const& prod : prodsList) {
128  BranchDescription const& bd = prod.second;
129  if(bd.branchType() == branchType_) {
130  if(isForPrimaryProcess or bd.processName() == pc.processName()) {
131  if(bd.isAlias()) {
132  hasAliases = true;
133  } else {
134  auto cbd = std::make_shared<BranchDescription const>(bd);
135  if(bd.produced()) {
136  if(bd.moduleLabel() == source) {
137  addSourceProduct(cbd);
138  } else if(bd.onDemand()) {
141  } else {
142  addScheduledProduct(cbd);
143  }
144  } else {
145  addInputProduct(cbd);
146  }
147  }
148  } else {
149  //We are in a SubProcess and this branch is from the parent
150  auto cbd =std::make_shared<BranchDescription const>(bd);
152  }
153  }
154  }
155  // Now process any EDAliases
156  if(hasAliases) {
157  for(auto const& prod : prodsList) {
158  BranchDescription const& bd = prod.second;
159  if(bd.isAlias() && bd.branchType() == branchType_) {
160  auto cbd = std::make_shared<BranchDescription const>(bd);
161  addAliasedProduct(cbd);
162  }
163  }
164  }
165 
166  // Now create the ProductResolvers that search in reverse process
167  // order and are used for queries where the process name is the
168  // empty string
169  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
170  std::vector<ProductResolverIndex> matchingHolders(lookupProcessNames.size(), ProductResolverIndexInvalid);
171  std::vector<bool> ambiguous(lookupProcessNames.size(), false);
172  unsigned int beginElements = productLookup_->beginElements();
173  std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
174  std::vector<ProductResolverIndexHelper::Range> const& ranges = productLookup_->ranges();
175  std::vector<ProductResolverIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
176  std::vector<char> const& processNamesCharArray = productLookup_->processNames();
177 
178  unsigned int numberOfMatches = 0;
180  if (!sortedTypeIDs.empty()) {
181  ProductResolverIndex productResolverIndex = ProductResolverIndexInvalid;
182  for(unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
183  ProductResolverIndexHelper::Range const& range = ranges.at(k);
184  for (unsigned int i = range.begin(); i < range.end(); ++i) {
185  ProductResolverIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
186  if (product.startInProcessNames() == 0) {
187  if (productResolverIndex != ProductResolverIndexInvalid) {
188  if ((numberOfMatches == 1) and
189  (lastMatchIndex != ProductResolverIndexAmbiguous)) {
190  //only one choice so use a special resolver
191  productResolvers_.at(productResolverIndex) = std::make_shared<SingleChoiceNoProcessProductResolver>(lastMatchIndex);
192  } else {
193  std::shared_ptr<ProductResolverBase> newHolder = std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous);
194  productResolvers_.at(productResolverIndex) = newHolder;
195  }
196  matchingHolders.assign(lookupProcessNames.size(), ProductResolverIndexInvalid);
197  ambiguous.assign(lookupProcessNames.size(), false);
198  numberOfMatches= 0;
199  lastMatchIndex = ProductResolverIndexInvalid;
200  }
201  productResolverIndex = product.index();
202  } else {
203  std::string process(&processNamesCharArray.at(product.startInProcessNames()));
204  auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
205  assert(iter != lookupProcessNames.end());
206  ProductResolverIndex iMatchingIndex = product.index();
207  lastMatchIndex = iMatchingIndex;
208  assert(iMatchingIndex != ProductResolverIndexInvalid);
209  ++numberOfMatches;
210  if (iMatchingIndex == ProductResolverIndexAmbiguous) {
211  assert(k >= beginElements);
212  ambiguous.at(iter - lookupProcessNames.begin()) = true;
213  } else {
214  matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
215  }
216  }
217  }
218  }
219  std::shared_ptr<ProductResolverBase> newHolder = std::make_shared<NoProcessProductResolver>(matchingHolders, ambiguous);
220  productResolvers_.at(productResolverIndex) = newHolder;
221  }
222  }
BranchType branchType_
Definition: Principal.h:280
int i
Definition: DBlmapReader.cc:9
DelayedReader * reader_
Definition: Principal.h:278
unsigned int ProductResolverIndex
static std::string const source("source")
ProductResolverCollection productResolvers_
Definition: Principal.h:266
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:259
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:96
ProcessHistoryID processHistoryID_
Definition: Principal.h:261
assert(m_qm.get())
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:275
edm::propagate_const< HistoryAppender * > historyAppender_
Definition: Principal.h:285
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:273
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:263
PixelRecoRange< float > Range
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:271
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:270
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:287
void addSourceProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:269
void addParentProcessProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:293
string ranges
Definition: diffTwoXMLs.py:78
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:280
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:147
tuple process
Definition: LaserDQM_cfg.py:3
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:285
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:263
std::vector< std::string > const & lookupProcessNames() const
edm::Principal::~Principal ( )
virtual

Definition at line 224 of file Principal.cc.

224  {
225  }

Member Function Documentation

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

Definition at line 285 of file Principal.cc.

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

Referenced by Principal().

285  {
286  ProductResolverIndex index = preg_->indexFrom(bd->originalBranchID());
288 
289  addProductOrThrow(std::make_unique<AliasProductResolver>(std::move(bd), dynamic_cast<ProducedProductResolver&>(*productResolvers_[index])));
290  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:266
assert(m_qm.get())
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:416
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:270
def move
Definition: eostools.py:510
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 275 of file Principal.cc.

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

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

275  {
276  addProductOrThrow(std::make_unique<InputProductResolver>(std::move(bd)));
277  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:416
def move
Definition: eostools.py:510
void edm::Principal::addParentProcessProduct ( 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<ParentProcessProductResolver>(std::move(bd)));
295  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:416
def move
Definition: eostools.py:510
void edm::Principal::addProduct_ ( std::unique_ptr< ProductResolverBase phb)
protected

Definition at line 402 of file Principal.cc.

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

Referenced by addProductOrThrow().

402  {
403  BranchDescription const& bd = productResolver->branchDescription();
404  assert (!bd.className().empty());
405  assert (!bd.friendlyClassName().empty());
406  assert (!bd.moduleLabel().empty());
407  assert (!bd.processName().empty());
408  SharedProductPtr phb(productResolver.release());
409 
410  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
412  productResolvers_[index] = phb;
413  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:266
std::shared_ptr< ProductResolverBase > SharedProductPtr
Definition: Principal.h:66
assert(m_qm.get())
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:270
void edm::Principal::addProductOrThrow ( std::unique_ptr< ProductResolverBase phb)
protected

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

416  {
417  ProductResolverBase const* phb = getExistingProduct(*productResolver);
418  if(phb != nullptr) {
419  BranchDescription const& bd = productResolver->branchDescription();
420  throw Exception(errors::InsertFailure, "AlreadyPresent")
421  << "addProductOrThrow: Problem found while adding product, "
422  << "product already exists for ("
423  << bd.friendlyClassName() << ","
424  << bd.moduleLabel() << ","
425  << bd.productInstanceName() << ","
426  << bd.processName()
427  << ")\n";
428  }
429  addProduct_(std::move(productResolver));
430  }
void addProduct_(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:402
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:373
def move
Definition: eostools.py:510
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 263 of file Principal.cc.

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

Referenced by Principal().

263  {
264  auto phb = std::make_unique<PuttableProductResolver>(std::move(bd));
266  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:416
def move
Definition: eostools.py:510
void edm::Principal::addSourceProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 269 of file Principal.cc.

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

Referenced by Principal().

269  {
270  auto phb = std::make_unique<PuttableProductResolver>(std::move(bd));
272  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:416
def move
Definition: eostools.py:510
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)
private

Definition at line 280 of file Principal.cc.

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

Referenced by Principal().

280  {
281  addProductOrThrow(std::make_unique<UnscheduledProductResolver>(std::move(bd)));
282  }
void addProductOrThrow(std::unique_ptr< ProductResolverBase > phb)
Definition: Principal.cc:416
def move
Definition: eostools.py:510
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 810 of file Principal.cc.

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

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

810  {
811  if(preg_->getNextIndexValue(branchType_) != productResolvers_.size()) {
812  productResolvers_.resize(preg_->getNextIndexValue(branchType_));
813  for(auto const& prod : preg_->productList()) {
814  BranchDescription const& bd = prod.second;
815  if(bd.branchType() == branchType_) {
816  ProductResolverIndex index = preg_->indexFrom(bd.branchID());
818  if(!productResolvers_[index]) {
819  // no product holder. Must add one. The new entry must be an input product holder.
820  assert(!bd.produced());
821  auto cbd = std::make_shared<BranchDescription const>(bd);
822  addInputProduct(cbd);
823  }
824  }
825  }
826  }
827  assert(preg_->getNextIndexValue(branchType_) == productResolvers_.size());
828  }
BranchType branchType_
Definition: Principal.h:280
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:266
assert(m_qm.get())
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:275
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:270
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

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

246  {
247  ProductRegistry::ProductList const& prodsList = reg.productList();
248  for(auto const& prod : prodsList) {
249  BranchDescription const& bd = prod.second;
250  if(!bd.produced() && (bd.branchType() == branchType_)) {
251  auto cbd = std::make_shared<BranchDescription const>(bd);
252  auto phb = getExistingProduct(cbd->branchID());
253  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
254  return false;
255  }
256  phb->resetBranchDescription(cbd);
257  }
258  }
259  return true;
260  }
BranchType branchType_
Definition: Principal.h:280
std::map< BranchKey, BranchDescription > ProductList
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:373
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
template<typename F >
void edm::Principal::applyToResolvers ( F  iFunc)
inlineprotected

Definition at line 211 of file Principal.h.

References productResolvers_.

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

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

Definition at line 159 of file Principal.h.

References productResolvers_.

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

Definition at line 162 of file Principal.h.

References productResolvers_.

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

Definition at line 172 of file Principal.h.

References branchType_.

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

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

Definition at line 176 of file Principal.h.

References cacheIdentifier_.

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

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

Definition at line 299 of file Principal.cc.

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

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

299  {
300  processHistoryPtr_.reset();
302  reader_ = nullptr;
303  for(auto& prod : *this) {
304  prod->resetProductData();
305  }
306  }
DelayedReader * reader_
Definition: Principal.h:278
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:259
ProcessHistoryID processHistoryID_
Definition: Principal.h:261
Hash< ProcessHistoryType > ProcessHistoryID
void edm::Principal::deleteProduct ( BranchID const &  id) const

Definition at line 309 of file Principal.cc.

References assert(), and getExistingProduct().

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

309  {
310  auto phb = getExistingProduct(id);
311  assert(nullptr != phb);
312  phb->unsafe_deleteProduct();
313  }
assert(m_qm.get())
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:373
const_iterator edm::Principal::end ( void  ) const
inline

Definition at line 160 of file Principal.h.

References productResolvers_.

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

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

Definition at line 163 of file Principal.h.

References productResolvers_.

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

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

Definition at line 317 of file Principal.cc.

References cacheIdentifier_, Exception, spr::find(), edm::ProcessHistoryRegistry::getMapped(), estimatePileup::hist, historyAppender_, edm::Hash< I >::isValid(), relval_2017::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().

319  {
320  //increment identifier here since clearPrincipal isn't called for Run/Lumi
322  if(reader) {
323  reader_ = reader;
324  }
325 
326  if (historyAppender_ && productRegistry().anyProductProduced()) {
328  historyAppender_->appendToProcessHistory(hist,
329  processHistoryRegistry.getMapped(hist),
332  }
333  else {
334  std::shared_ptr<ProcessHistory const> inputProcessHistory;
335  if (hist.isValid()) {
336  //does not own the pointer
337  auto noDel =[](void const*){};
338  inputProcessHistory =
339  std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist),noDel);
340  if (inputProcessHistory.get() == nullptr) {
342  << "Principal::fillPrincipal\n"
343  << "Input ProcessHistory not found in registry\n"
344  << "Contact a Framework developer\n";
345  }
346  } else {
347  //Since this is static we don't want it deleted
348  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory,[](void const*){});
349  }
351  processHistoryPtr_ = inputProcessHistory;
352  }
353 
355  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
356  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
357  unsigned int k = 0;
358  for (auto iter = processHistoryPtr_->rbegin(),
359  iEnd = processHistoryPtr_->rend();
360  iter != iEnd; ++iter) {
361  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
362  if (nameIter == lookupProcessNames.end()) {
363  continue;
364  }
365  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
366  ++k;
367  }
369  }
370  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:32
ProductRegistry const & productRegistry() const
Definition: Principal.h:145
DelayedReader * reader_
Definition: Principal.h:278
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:259
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:96
ProcessHistoryID processHistoryID_
Definition: Principal.h:261
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
edm::propagate_const< HistoryAppender * > historyAppender_
Definition: Principal.h:285
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:273
std::shared_ptr< ProductResolverIndexHelper const > productLookup_
Definition: Principal.h:271
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:287
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:274
DelayedReader * reader() const
Definition: Principal.h:178
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:263
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 619 of file Principal.cc.

References branchType(), edm::ProductResolverIndexHelper::index(), cmsHarvester::index, edm::InputTag::indexFor(), edm::InputTag::instance(), edm::InputTag::label(), edm::InputTag::process(), FSQHLTOfflineSource_cfi::processName, productLookup(), productRegistry(), edm::ProductResolverIndexAmbiguous, edm::ProductResolverIndexInvalid, productResolvers_, edm::EDConsumerBase::registeredToConsume(), dtDQMClient_cfg::resolution, edm::throwAmbiguousException(), edm::InputTag::tryToCacheIndex(), unlikely, and edm::InputTag::willSkipCurrentProcess().

Referenced by findProductByTag(), and getByLabel().

624  {
625 
626  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
627 
629 
630  if (index == ProductResolverIndexInvalid) {
631 
632  char const* processName = inputTag.process().c_str();
633  if (skipCurrentProcess) {
634  processName = "\0";
635  }
636 
637  index = productLookup().index(kindOfType,
638  typeID,
639  inputTag.label().c_str(),
640  inputTag.instance().c_str(),
641  processName);
642 
643  if(index == ProductResolverIndexAmbiguous) {
644  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
645  } else if (index == ProductResolverIndexInvalid) {
646  return 0;
647  }
648  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
649  }
650  if(unlikely( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
651  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),inputTag.process());
652  }
653 
654 
655  auto const& productResolver = productResolvers_[index];
656 
657  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
658  if(resolution.isAmbiguous()) {
659  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
660  }
661  return resolution.data();
662  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:145
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:266
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:60
#define unlikely(x)
BranchType const & branchType() const
Definition: Principal.h:172
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:147
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
EDConsumerBase const *  consumer,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 665 of file Principal.cc.

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

672  {
673 
675  typeID,
676  label.c_str(),
677  instance.c_str(),
678  process.c_str());
679 
680  if(index == ProductResolverIndexAmbiguous) {
681  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
682  } else if (index == ProductResolverIndexInvalid) {
683  return 0;
684  }
685 
686  if(unlikely( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
687  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
688  }
689 
690  auto const& productResolver = productResolvers_[index];
691 
692  auto resolution = productResolver->resolveProduct(*this, false, sra, mcc);
693  if(resolution.isAmbiguous()) {
694  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
695  }
696  return resolution.data();
697  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:266
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:60
#define unlikely(x)
BranchType const & branchType() const
Definition: Principal.h:172
ProductResolverIndexHelper const & productLookup() const
Definition: Principal.h:147
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
tuple process
Definition: LaserDQM_cfg.py:3
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 700 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

700  {
701  ProductData const* productData =
703  typeID,
704  tag,
705  nullptr,
706  nullptr,
707  mcc);
708  return productData;
709  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:619
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 589 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().

593  {
594 
595  for (auto iter = processHistoryPtr_->rbegin(),
596  iEnd = processHistoryPtr_->rend();
597  iter != iEnd; ++iter) {
598  std::string const& process = iter->processName();
599  for (auto productResolver : holders) {
600  BranchDescription const& bd = productResolver->branchDescription();
601  if (process == bd.processName()) {
602 
603  // Ignore aliases to avoid matching the same product multiple times.
604  if(bd.isAlias()) {
605  continue;
606  }
607 
608  ProductData const* productData = productResolver->resolveProduct(*this,false, sra, mcc).data();
609  if(productData) {
610  // Skip product if not available.
611  results.emplace_back(productData->wrapper(), &(productData->provenance()));
612  }
613  }
614  }
615  }
616  }
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:259
tuple results
Definition: mps_update.py:44
tuple process
Definition: LaserDQM_cfg.py:3
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 731 of file Principal.cc.

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

731  {
732  provenances.clear();
733  for(auto const& productResolver : *this) {
734  if(productResolver->singleProduct() && productResolver->provenanceAvailable() && !productResolver->branchDescription().isAlias()) {
735  // We do not attempt to get the event/lumi/run status from the provenance,
736  // because the per event provenance may have been dropped.
737  if(productResolver->provenance()->branchDescription().present()) {
738  provenances.push_back(productResolver->provenance());
739  }
740  }
741  }
742  }
void edm::Principal::getAllStableProvenance ( std::vector< StableProvenance const * > &  provenances) const

Definition at line 748 of file Principal.cc.

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

748  {
749  provenances.clear();
750  for(auto const& productResolver : *this) {
751  if(productResolver->singleProduct() && !productResolver->branchDescription().isAlias()) {
752  if(productResolver->stableProvenance()->branchDescription().present()) {
753  provenances.push_back(productResolver->stableProvenance());
754  }
755  }
756  }
757  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 449 of file Principal.cc.

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

Referenced by PileUpEventPrincipal::getByLabel(), edm::PrincipalGetAdapter::getByLabel_(), and edm::PrincipalGetAdapter::getMatchingSequenceByLabel_().

454  {
455 
456  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, sra, mcc);
457  if(result == 0) {
458  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
459  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process());
460  }));
461  }
462  return BasicHandle(result->wrapper(), &(result->provenance()));
463  }
tuple result
Definition: mps_fire.py:84
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:43
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:619
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 466 of file Principal.cc.

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

473  {
474 
475  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, sra, mcc);
476  if(result == 0) {
477  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
478  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
479  }));
480  }
481  return BasicHandle(result->wrapper(), &(result->provenance()));
482  }
static PFTauRenderPlugin instance
tuple result
Definition: mps_fire.py:84
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:43
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: Principal.cc:619
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductResolverIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 485 of file Principal.cc.

References assert(), cmsHarvester::index, edm::ProductResolverIndexInvalid, productResolvers_, and dtDQMClient_cfg::resolution.

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

491  {
493  auto& productResolver = productResolvers_[index];
494  assert(0!=productResolver.get());
495  auto resolution = productResolver->resolveProduct(*this, skipCurrentProcess, sra, mcc);
496  if(resolution.isAmbiguous()) {
497  ambiguous = true;
498  return BasicHandle();
499  }
500  auto productData = resolution.data();
501  if(productData == nullptr) {
502  return BasicHandle();
503  }
504  return BasicHandle(productData->wrapper(), &(productData->provenance()));
505  }
ProductResolverCollection productResolvers_
Definition: Principal.h:266
assert(m_qm.get())
ProductResolverBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 373 of file Principal.cc.

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

373  {
374  return const_cast<ProductResolverBase*>( const_cast<const Principal*>(this)->getExistingProduct(branchID));
375  }
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:373
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:100
ProductResolverBase const * edm::Principal::getExistingProduct ( BranchID const &  branchID) const
protected

Definition at line 378 of file Principal.cc.

References assert(), cmsHarvester::index, preg_, edm::ProductResolverIndexInvalid, and productResolvers_.

378  {
379  ProductResolverIndex index = preg_->indexFrom(branchID);
381  return productResolvers_.at(index).get();
382  }
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:266
assert(m_qm.get())
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:270
ProductResolverBase const * edm::Principal::getExistingProduct ( ProductResolverBase const &  phb) const
protected

Definition at line 385 of file Principal.cc.

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

385  {
386  auto phb = getExistingProduct(productResolver.branchDescription().branchID());
387  if(nullptr != phb && BranchKey(productResolver.branchDescription()) != BranchKey(phb->branchDescription())) {
388  BranchDescription const& newProduct = phb->branchDescription();
389  BranchDescription const& existing = productResolver.branchDescription();
390  if(newProduct.branchName() != existing.branchName() && newProduct.branchID() == existing.branchID()) {
391  throw cms::Exception("HashCollision") << "Principal::getExistingProduct\n" <<
392  " Branch " << newProduct.branchName() << " has same branch ID as branch " << existing.branchName() << "\n" <<
393  "Workaround: change process name or product instance name of " << newProduct.branchName() << "\n";
394  } else {
395  assert(nullptr == phb || BranchKey(productResolver.branchDescription()) == BranchKey(phb->branchDescription()));
396  }
397  }
398  return phb;
399  }
assert(m_qm.get())
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:373
BranchDescription const & branchDescription() const
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 772 of file Principal.cc.

References assert().

772  {
773  assert(false);
774  return nullptr;
775  }
assert(m_qm.get())
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results,
EDConsumerBase const *  consumes,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const

Definition at line 518 of file Principal.cc.

References assert(), branchType(), findProducts(), i, edm::ProductResolverIndexHelper::Matches::index(), cmsHarvester::index, edm::ProductResolverIndexHelper::Matches::isFullyResolved(), matches, edm::ProductResolverIndexHelper::Matches::numberOfMatches(), edm::PRODUCT_TYPE, productLookup(), productResolvers_, edm::EDConsumerBase::registeredToConsumeMany(), edm::ProductResolverIndexHelper::relatedIndexes(), and unlikely.

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

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

Definition at line 152 of file Principal.h.

References getProductResolver().

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

152  {
153  return const_cast<ProductResolverBase*>( const_cast<const Principal*>(this)->getProductResolver(oid));
154  }
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:100
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Definition: Principal.cc:433
Principal::ConstProductResolverPtr edm::Principal::getProductResolver ( BranchID const &  oid) const

Definition at line 433 of file Principal.cc.

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

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

433  {
434  ProductResolverIndex index = preg_->indexFrom(bid);
435  if(index == ProductResolverIndexInvalid){
436  return ConstProductResolverPtr();
437  }
438  return getProductResolverByIndex(index);
439  }
unsigned int ProductResolverIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:270
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:62
ConstProductResolverPtr getProductResolverByIndex(ProductResolverIndex const &oid) const
Definition: Principal.cc:442
Principal::ConstProductResolverPtr edm::Principal::getProductResolverByIndex ( ProductResolverIndex const &  oid) const
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

Definition at line 712 of file Principal.cc.

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

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

713  {
715  if(phb == nullptr) {
717  }
718 
719  if(phb->unscheduledWasNotRun()) {
720  if(not phb->resolveProduct(*this,false, nullptr, mcc).data() ) {
721  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
722  }
723  }
724  return *phb->provenance();
725  }
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:62
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
Definition: Principal.cc:433
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:36
WrapperBase const * edm::Principal::getThinnedProduct ( ProductID const &  ,
unsigned int &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 778 of file Principal.cc.

References assert().

778  {
779  assert(false);
780  return nullptr;
781  }
assert(m_qm.get())
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 784 of file Principal.cc.

References assert().

786  {
787  assert(false);
788  }
assert(m_qm.get())
bool edm::Principal::isComplete ( ) const
inline

Definition at line 194 of file Principal.h.

References isComplete_().

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

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

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

Definition at line 255 of file Principal.h.

Referenced by isComplete().

255 {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 508 of file Principal.cc.

References assert(), and productResolvers_.

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

511  {
512  auto const& productResolver = productResolvers_.at(index);
513  assert(0!=productResolver.get());
514  productResolver->prefetchAsync(task,*this, skipCurrentProcess,nullptr,mcc);
515  }
ProductResolverCollection productResolvers_
Definition: Principal.h:266
assert(m_qm.get())
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 143 of file Principal.h.

References processConfiguration_.

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

Definition at line 88 of file Principal.h.

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

88 {return this;}
ProductResolverIndexHelper const& edm::Principal::productLookup ( ) const
inline

Definition at line 147 of file Principal.h.

References productLookup_.

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

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

Definition at line 145 of file Principal.h.

References preg_.

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

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

Definition at line 796 of file Principal.cc.

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

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

796  {
797  if(edp.get() == nullptr) {
798  throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
799  << "put: Cannot put because unique_ptr to product is null."
800  << "\n";
801  }
802  auto phb = getExistingProduct(bd.branchID());
803  assert(phb);
804  // ProductResolver assumes ownership
805  putOrMerge(std::move(edp), phb);
806  }
assert(m_qm.get())
ProductResolverBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:373
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
Definition: Principal.cc:796
def move
Definition: eostools.py:510
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductResolverBase const *  productResolver 
) const
private

Definition at line 791 of file Principal.cc.

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

791  {
792  phb->putOrMergeProduct(std::move(prod));
793  }
def move
Definition: eostools.py:510
void edm::Principal::readAllFromSourceAndMergeImmediately ( )

Definition at line 831 of file Principal.cc.

References parseEventContent::prod, and reader().

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

831  {
832  if(not reader()) {return;}
833 
834  for(auto & prod : *this) {
835  prod->retrieveAndMerge(*this);
836  }
837  }
DelayedReader * reader() const
Definition: Principal.h:178
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

Definition at line 760 of file Principal.cc.

References assert(), edm::get_underlying_safe(), cmsHarvester::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_().

760  {
761  for(auto& prod : bids) {
762  ProductResolverIndex index= preg_->indexFrom(prod);
764  ProductResolverIndex indexO = other.preg_->indexFrom(prod);
766  get_underlying_safe(productResolvers_[index]).swap(get_underlying_safe(other.productResolvers_[indexO]));
767  }
768  reader_->mergeReaders(other.reader());
769  }
DelayedReader * reader_
Definition: Principal.h:278
unsigned int ProductResolverIndex
ProductResolverCollection productResolvers_
Definition: Principal.h:266
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:35
assert(m_qm.get())
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:270
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void edm::Principal::resetFailedFromThisProcess ( )

Definition at line 840 of file Principal.cc.

References parseEventContent::prod.

840  {
841  for( auto & prod : *this) {
842  prod->resetFailedFromThisProcess();
843  }
844  }
size_t edm::Principal::size ( void  ) const

Definition at line 231 of file Principal.cc.

References parseEventContent::prod.

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

231  {
232  size_t size = 0U;
233  for(auto const& prod : *this) {
234  if(prod->singleProduct() && // Not a NoProcessProductResolver
235  !prod->productUnavailable() &&
236  !prod->unscheduledWasNotRun() &&
237  !prod->branchDescription().dropped()) {
238  ++size;
239  }
240  }
241  return size;
242  }
size_t size() const
Definition: Principal.cc:231

Member Data Documentation

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

Definition at line 287 of file Principal.h.

Referenced by cacheIdentifier(), and fillPrincipal().

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

Definition at line 285 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 273 of file Principal.h.

Referenced by fillPrincipal(), and lookupProcessOrder().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

Referenced by fillPrincipal(), and processConfiguration().

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 261 of file Principal.h.

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

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

Definition at line 259 of file Principal.h.

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

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

Definition at line 271 of file Principal.h.

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

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

Definition at line 278 of file Principal.h.

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