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 Referenceabstract

#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,
ProductHolderCollection::const_iterator > 
const_iterator
 
typedef ProductHolderBase const * ConstProductHolderPtr
 
typedef std::string ProcessName
 
typedef
ProcessHistory::const_iterator 
ProcessNameConstIterator
 
typedef std::vector
< std::shared_ptr
< ProductHolderBase > > 
ProductHolderCollection
 
typedef std::shared_ptr
< ProductHolderBase
SharedProductPtr
 
typedef
ProductHolderCollection::size_type 
size_type
 

Public Member Functions

void addAliasedProduct (std::shared_ptr< BranchDescription const > bd)
 
void addInputProduct (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)
 
void adjustIndexesAfterProductRegistryAddition ()
 
bool adjustToNewProductRegistry (ProductRegistry const &reg)
 
const_iterator begin () const
 
BranchType const & branchType () const
 
CacheIdentifier_t cacheIdentifier () const
 
void clearPrincipal ()
 
void deleteProduct (BranchID const &id)
 
const_iterator end () const
 
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
 
BasicHandle getByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, 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, ModuleCallingContext const *mcc) const
 
BasicHandle getByToken (KindOfType kindOfType, TypeID const &typeID, ProductHolderIndex index, bool skipCurrentProcess, bool &ambiguous, ModuleCallingContext const *mcc) const
 
OutputHandle getForOutput (BranchID const &bid, bool getProd, ModuleCallingContext const *mcc) const
 
void getManyByType (TypeID const &typeID, BasicHandleVec &results, EDConsumerBase const *consumes, ModuleCallingContext const *mcc) const
 
ConstProductHolderPtr getProductHolder (BranchID const &oid) const
 
ConstProductHolderPtr getProductHolderByIndex (ProductHolderIndex const &oid) const
 
Provenance getProvenance (BranchID const &bid, ModuleCallingContext const *mcc) const
 
bool isComplete () const
 
std::vector< unsigned int > const & lookupProcessOrder () const
 
void prefetch (ProductHolderIndex index, bool skipCurrentProcess, ModuleCallingContext const *mcc) const
 
 Principal (std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< ProductHolderIndexHelper const > productLookup, ProcessConfiguration const &pc, BranchType bt, HistoryAppender *historyAppender)
 
ProcessConfiguration const & processConfiguration () const
 
ProcessHistory const & processHistory () const
 
ProcessHistoryID const & processHistoryID () const
 
EDProductGetter const * prodGetter () const
 
ProductHolderIndexHelper const & productLookup () const
 
ProductRegistry const & productRegistry () const
 
DelayedReaderreader () const
 
void readFromSource (ProductHolderBase const &phb, ModuleCallingContext const *mcc) const
 
void recombine (Principal &other, std::vector< BranchID > const &bids)
 
size_t size () const
 
virtual bool unscheduledFill (std::string const &moduleLabel, ModuleCallingContext const *mcc) const =0
 
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::auto_ptr< ProductHolderBase > phb)
 
void addProductOrThrow (std::auto_ptr< ProductHolderBase > phb)
 
void checkUniquenessAndType (WrapperBase const *prod, ProductHolderBase const *productHolder) const
 
ProductHolderBasegetExistingProduct (BranchID const &branchID)
 
ProductHolderBasegetExistingProduct (ProductHolderBase const &phb)
 
void putOrMerge (std::unique_ptr< WrapperBase > prod, ProductHolderBase const *productHolder) const
 
void putOrMerge (std::unique_ptr< WrapperBase > prod, ProductProvenance &prov, ProductHolderBase *productHolder)
 

Private Member Functions

ProductData const * findProductByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, 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, ModuleCallingContext const *mcc) const
 
void findProducts (std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, 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
 
virtual void readFromSource_ (ProductHolderBase const &, ModuleCallingContext const *) const
 

Private Attributes

BranchType branchType_
 
CacheIdentifier_t cacheIdentifier_
 
HistoryAppenderhistoryAppender_
 
std::vector< unsigned int > lookupProcessOrder_
 
ProcessHistoryID orderProcessHistoryID_
 
std::shared_ptr
< ProductRegistry const > 
preg_
 
ProcessConfiguration const * processConfiguration_
 
ProcessHistoryID processHistoryID_
 
std::shared_ptr
< ProcessHistory const > 
processHistoryPtr_
 
ProductHolderCollection productHolders_
 
std::shared_ptr
< ProductHolderIndexHelper
const > 
productLookup_
 
std::set< void const * > productPtrs_
 
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 53 of file Principal.h.

Member Typedef Documentation

Definition at line 59 of file Principal.h.

typedef unsigned long edm::Principal::CacheIdentifier_t

Definition at line 168 of file Principal.h.

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

Definition at line 56 of file Principal.h.

Definition at line 58 of file Principal.h.

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

Definition at line 63 of file Principal.h.

Definition at line 57 of file Principal.h.

typedef std::vector<std::shared_ptr<ProductHolderBase> > edm::Principal::ProductHolderCollection

Definition at line 55 of file Principal.h.

Definition at line 62 of file Principal.h.

typedef ProductHolderCollection::size_type edm::Principal::size_type

Definition at line 60 of file Principal.h.

Constructor & Destructor Documentation

edm::Principal::Principal ( std::shared_ptr< ProductRegistry const >  reg,
std::shared_ptr< ProductHolderIndexHelper const >  productLookup,
ProcessConfiguration const &  pc,
BranchType  bt,
HistoryAppender historyAppender 
)

Definition at line 135 of file Principal.cc.

References addAliasedProduct(), addInputProduct(), addScheduledProduct(), addSourceProduct(), addUnscheduledProduct(), assert(), edm::ProductHolderIndexHelper::Range::begin(), edm::BranchDescription::branchType(), branchType_, edm::ProductHolderIndexHelper::Range::end(), spr::find(), i, edm::ProductHolderIndexHelper::IndexAndNames::index(), edm::InEvent, edm::BranchDescription::isAlias(), relval_steps::k, edm::BranchDescription::moduleLabel(), edm::BranchDescription::onDemand(), LaserDQM_cfg::process, parseEventContent::prod, edm::BranchDescription::produced(), edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup_, diffTwoXMLs::ranges, edm::source(), edm::ProductHolderIndexHelper::IndexAndNames::startInProcessNames(), and AlCaHLTBitMon_QueryRunRegistry::string.

139  :
140  EDProductGetter(),
144  productHolders_(reg->getNextIndexValue(bt), SharedProductPtr()),
145  preg_(reg),
148  reader_(),
149  productPtrs_(),
150  branchType_(bt),
151  historyAppender_(historyAppender),
153  {
154 
155  //Now that these have been set, we can create the list of Branches we need.
156  std::string const source("source");
157  ProductRegistry::ProductList const& prodsList = reg->productList();
158  // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
159  // So, the non-alias product holders must be created first.
160  // Therefore, on this first pass, skip current EDAliases.
161  bool hasAliases = false;
162  for(auto const& prod : prodsList) {
163  BranchDescription const& bd = prod.second;
164  if(bd.branchType() == branchType_) {
165  if(bd.isAlias()) {
166  hasAliases = true;
167  } else {
168  auto cbd = std::make_shared<BranchDescription const>(bd);
169  if(bd.produced()) {
170  if(bd.moduleLabel() == source) {
171  addSourceProduct(cbd);
172  } else if(bd.onDemand()) {
175  } else {
176  addScheduledProduct(cbd);
177  }
178  } else {
179  addInputProduct(cbd);
180  }
181  }
182  }
183  }
184  // Now process any EDAliases
185  if(hasAliases) {
186  for(auto const& prod : prodsList) {
187  BranchDescription const& bd = prod.second;
188  if(bd.isAlias() && bd.branchType() == branchType_) {
189  auto cbd = std::make_shared<BranchDescription const>(bd);
190  addAliasedProduct(cbd);
191  }
192  }
193  }
194 
195  // Now create the ProductHolders that search in reverse process
196  // order and are used for queries where the process name is the
197  // empty string
198  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
199  std::vector<ProductHolderIndex> matchingHolders(lookupProcessNames.size(), ProductHolderIndexInvalid);
200  std::vector<bool> ambiguous(lookupProcessNames.size(), false);
201  unsigned int beginElements = productLookup_->beginElements();
202  std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
203  std::vector<ProductHolderIndexHelper::Range> const& ranges = productLookup_->ranges();
204  std::vector<ProductHolderIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
205  std::vector<char> const& processNamesCharArray = productLookup_->processNames();
206 
207  if (!sortedTypeIDs.empty()) {
208  ProductHolderIndex productHolderIndex = ProductHolderIndexInvalid;
209  for(unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
210  ProductHolderIndexHelper::Range const& range = ranges.at(k);
211  for (unsigned int i = range.begin(); i < range.end(); ++i) {
212  ProductHolderIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
213  if (product.startInProcessNames() == 0) {
214  if (productHolderIndex != ProductHolderIndexInvalid) {
215  std::shared_ptr<ProductHolderBase> newHolder = std::make_shared<NoProcessProductHolder>(matchingHolders, ambiguous, this);
216  productHolders_.at(productHolderIndex) = newHolder;
217  matchingHolders.assign(lookupProcessNames.size(), ProductHolderIndexInvalid);
218  ambiguous.assign(lookupProcessNames.size(), false);
219  }
220  productHolderIndex = product.index();
221  } else {
222  std::string process(&processNamesCharArray.at(product.startInProcessNames()));
223  auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
224  assert(iter != lookupProcessNames.end());
225  ProductHolderIndex iMatchingIndex = product.index();
226  assert(iMatchingIndex != ProductHolderIndexInvalid);
227  if (iMatchingIndex == ProductHolderIndexAmbiguous) {
228  assert(k >= beginElements);
229  ambiguous.at(iter - lookupProcessNames.begin()) = true;
230  } else {
231  matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
232  }
233  }
234  }
235  }
236  std::shared_ptr<ProductHolderBase> newHolder = std::make_shared<NoProcessProductHolder>(matchingHolders, ambiguous, this);
237  productHolders_.at(productHolderIndex) = newHolder;
238  }
239  }
BranchType branchType_
Definition: Principal.h:267
int i
Definition: DBlmapReader.cc:9
DelayedReader * reader_
Definition: Principal.h:262
HistoryAppender * historyAppender_
Definition: Principal.h:272
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:62
static std::string const source("source")
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:243
std::map< BranchKey, BranchDescription > ProductList
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:131
ProcessHistoryID processHistoryID_
Definition: Principal.h:245
assert(m_qm.get())
unsigned int ProductHolderIndex
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:292
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:257
void addScheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:280
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:274
ProductHolderCollection productHolders_
Definition: Principal.h:250
void addSourceProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:286
std::set< void const * > productPtrs_
Definition: Principal.h:265
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:255
string ranges
Definition: diffTwoXMLs.py:78
PixelRecoRange< float > Range
void addUnscheduledProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:298
std::vector< std::string > const & lookupProcessNames() const
tuple process
Definition: LaserDQM_cfg.py:3
void addAliasedProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:304
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:247
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
edm::Principal::~Principal ( )
virtual

Definition at line 241 of file Principal.cc.

241  {
242  }

Member Function Documentation

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

Definition at line 304 of file Principal.cc.

References addProductOrThrow(), assert(), cmsHarvester::index, preg_, edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by Principal().

304  {
305  ProductHolderIndex index = preg_->indexFrom(bd->originalBranchID());
307 
308  std::auto_ptr<ProductHolderBase> phb(new AliasProductHolder(bd, dynamic_cast<ProducedProductHolder&>(*productHolders_[index])));
309  addProductOrThrow(phb);
310  }
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
ProductHolderCollection productHolders_
Definition: Principal.h:250
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:432
void edm::Principal::addInputProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 292 of file Principal.cc.

References addProductOrThrow().

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

292  {
293  std::auto_ptr<ProductHolderBase> phb(new InputProductHolder(bd, this));
294  addProductOrThrow(phb);
295  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:432
void edm::Principal::addProduct_ ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 418 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::ProductHolderIndexInvalid, and productHolders_.

Referenced by addProductOrThrow().

418  {
419  BranchDescription const& bd = productHolder->branchDescription();
420  assert (!bd.className().empty());
421  assert (!bd.friendlyClassName().empty());
422  assert (!bd.moduleLabel().empty());
423  assert (!bd.processName().empty());
424  SharedProductPtr phb(productHolder.release());
425 
426  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
428  productHolders_[index] = phb;
429  }
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:62
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
ProductHolderCollection productHolders_
Definition: Principal.h:250
void edm::Principal::addProductOrThrow ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 432 of file Principal.cc.

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

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

432  {
433  ProductHolderBase const* phb = getExistingProduct(*productHolder);
434  if(phb != nullptr) {
435  BranchDescription const& bd = productHolder->branchDescription();
436  throw Exception(errors::InsertFailure, "AlreadyPresent")
437  << "addProductOrThrow: Problem found while adding product, "
438  << "product already exists for ("
439  << bd.friendlyClassName() << ","
440  << bd.moduleLabel() << ","
441  << bd.productInstanceName() << ","
442  << bd.processName()
443  << ")\n";
444  }
445  addProduct_(productHolder);
446  }
void addProduct_(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:418
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:393
void edm::Principal::addScheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 280 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

280  {
281  std::auto_ptr<ProductHolderBase> phb(new ScheduledProductHolder(bd));
282  addProductOrThrow(phb);
283  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:432
void edm::Principal::addSourceProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 286 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

286  {
287  std::auto_ptr<ProductHolderBase> phb(new SourceProductHolder(bd));
288  addProductOrThrow(phb);
289  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:432
void edm::Principal::addUnscheduledProduct ( std::shared_ptr< BranchDescription const >  bd)

Definition at line 298 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

298  {
299  std::auto_ptr<ProductHolderBase> phb(new UnscheduledProductHolder(bd, this));
300  addProductOrThrow(phb);
301  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:432
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 863 of file Principal.cc.

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

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

863  {
864  if(preg_->getNextIndexValue(branchType_) != productHolders_.size()) {
865  productHolders_.resize(preg_->getNextIndexValue(branchType_));
866  for(auto const& prod : preg_->productList()) {
867  BranchDescription const& bd = prod.second;
868  if(bd.branchType() == branchType_) {
869  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
871  if(!productHolders_[index]) {
872  // no product holder. Must add one. The new entry must be an input product holder.
873  assert(!bd.produced());
874  auto cbd = std::make_shared<BranchDescription const>(bd);
875  addInputProduct(cbd);
876  }
877  }
878  }
879  }
880  assert(preg_->getNextIndexValue(branchType_) == productHolders_.size());
881  }
BranchType branchType_
Definition: Principal.h:267
assert(m_qm.get())
unsigned int ProductHolderIndex
void addInputProduct(std::shared_ptr< BranchDescription const > bd)
Definition: Principal.cc:292
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
ProductHolderCollection productHolders_
Definition: Principal.h:250
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

Definition at line 263 of file Principal.cc.

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

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

263  {
264  ProductRegistry::ProductList const& prodsList = reg.productList();
265  for(auto const& prod : prodsList) {
266  BranchDescription const& bd = prod.second;
267  if(!bd.produced() && (bd.branchType() == branchType_)) {
268  auto cbd = std::make_shared<BranchDescription const>(bd);
269  ProductHolderBase* phb = getExistingProduct(cbd->branchID());
270  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
271  return false;
272  }
273  phb->resetBranchDescription(cbd);
274  }
275  }
276  return true;
277  }
BranchType branchType_
Definition: Principal.h:267
std::map< BranchKey, BranchDescription > ProductList
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
Definition: ProductHolder.h:98
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:393
const_iterator edm::Principal::begin ( void  ) const
inline

Definition at line 157 of file Principal.h.

References productHolders_.

Referenced by edm::check(), edm::OutputModule::updateBranchParents(), edm::one::OutputModuleBase::updateBranchParents(), and edm::ProvenanceCheckerOutputModule::write().

157 {return boost::make_filter_iterator<FilledProductPtr>(productHolders_.begin(), productHolders_.end());}
ProductHolderCollection productHolders_
Definition: Principal.h:250
BranchType const& edm::Principal::branchType ( ) const
inline

Definition at line 165 of file Principal.h.

References branchType_.

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

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

Definition at line 169 of file Principal.h.

References cacheIdentifier_.

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

169 {return cacheIdentifier_;}
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:274
void edm::Principal::checkUniquenessAndType ( WrapperBase const *  prod,
ProductHolderBase const *  productHolder 
) const
protected

Definition at line 825 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::BranchDescription::branchName(), edm::ProductHolderBase::checkType(), productPtrs_, and edm::throwCorruptionException().

Referenced by edm::EventPrincipal::put(), edm::EventPrincipal::putOnRead(), putOrMerge(), and edm::EventPrincipal::readFromSource_().

825  {
826  if(prod == nullptr) return;
827  // These are defensive checks against things that should never happen, but have.
828  // Checks that the same physical product has not already been put into the event.
829  bool alreadyPresent = !productPtrs_.insert(prod).second;
830  if(alreadyPresent) {
831  phb->checkType(*prod);
832  throwCorruptionException("checkUniquenessAndType", phb->branchDescription().branchName());
833  }
834  // Checks that the real type of the product matches the branch.
835  phb->checkType(*prod);
836  }
static void throwCorruptionException(char const *where, std::string const &branchName)
Definition: Principal.cc:64
std::set< void const * > productPtrs_
Definition: Principal.h:265
void edm::Principal::clearPrincipal ( )

Definition at line 314 of file Principal.cc.

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

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

314  {
315  processHistoryPtr_.reset();
317  reader_ = nullptr;
318  for(auto const& prod : *this) {
319  prod->resetProductData();
320  }
321  productPtrs_.clear();
322  }
DelayedReader * reader_
Definition: Principal.h:262
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:243
ProcessHistoryID processHistoryID_
Definition: Principal.h:245
Hash< ProcessHistoryType > ProcessHistoryID
std::set< void const * > productPtrs_
Definition: Principal.h:265
void edm::Principal::deleteProduct ( BranchID const &  id)

Definition at line 325 of file Principal.cc.

References assert(), edm::ProductHolderBase::deleteProduct(), getExistingProduct(), edm::ProductHolderBase::product(), and productPtrs_.

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

325  {
326  ProductHolderBase* phb = getExistingProduct(id);
327  assert(nullptr != phb);
328  auto itFound = productPtrs_.find(phb->product());
329  if(itFound != productPtrs_.end()) {
330  productPtrs_.erase(itFound);
331  }
332  phb->deleteProduct();
333  }
assert(m_qm.get())
std::set< void const * > productPtrs_
Definition: Principal.h:265
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:393
const_iterator edm::Principal::end ( void  ) const
inline
void edm::Principal::fillPrincipal ( ProcessHistoryID const &  hist,
ProcessHistoryRegistry const &  phr,
DelayedReader reader 
)

Definition at line 337 of file Principal.cc.

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

339  {
340  //increment identifier here since clearPrincipal isn't called for Run/Lumi
342  if(reader) {
343  reader_ = reader;
344  }
345 
346  if (historyAppender_ && productRegistry().anyProductProduced()) {
349  processHistoryRegistry.getMapped(hist),
352  }
353  else {
354  std::shared_ptr<ProcessHistory const> inputProcessHistory;
355  if (hist.isValid()) {
356  //does not own the pointer
357  auto noDel =[](void const*){};
358  inputProcessHistory =
359  std::shared_ptr<ProcessHistory const>(processHistoryRegistry.getMapped(hist),noDel);
360  if (inputProcessHistory.get() == nullptr) {
362  << "Principal::fillPrincipal\n"
363  << "Input ProcessHistory not found in registry\n"
364  << "Contact a Framework developer\n";
365  }
366  } else {
367  //Since this is static we don't want it deleted
368  inputProcessHistory = std::shared_ptr<ProcessHistory const>(&s_emptyProcessHistory,[](void const*){});
369  }
371  processHistoryPtr_ = inputProcessHistory;
372  }
373 
375  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
376  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
377  unsigned int k = 0;
378  for (auto iter = processHistoryPtr_->rbegin(),
379  iEnd = processHistoryPtr_->rend();
380  iter != iEnd; ++iter) {
381  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
382  if (nameIter == lookupProcessNames.end()) {
383  continue;
384  }
385  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
386  ++k;
387  }
389  }
390  }
static ProcessHistory const s_emptyProcessHistory
Definition: Principal.cc:35
ProductRegistry const & productRegistry() const
Definition: Principal.h:147
DelayedReader * reader_
Definition: Principal.h:262
HistoryAppender * historyAppender_
Definition: Principal.h:272
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:243
static Principal::CacheIdentifier_t nextIdentifier()
Definition: Principal.cc:131
ProcessHistoryID processHistoryID_
Definition: Principal.h:245
std::shared_ptr< ProcessHistory const > appendToProcessHistory(ProcessHistoryID const &inputPHID, ProcessHistory const *inputProcessHistory, ProcessConfiguration const &pc)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:257
CacheIdentifier_t cacheIdentifier_
Definition: Principal.h:274
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:258
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:255
DelayedReader * reader() const
Definition: Principal.h:171
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:247
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumer,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 632 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, branchType(), edm::ELEMENT_TYPE, edm::ProductHolderIndexHelper::index(), cmsHarvester::index, edm::InputTag::indexFor(), edm::InputTag::instance(), edm::InputTag::label(), matches, edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::InputTag::process(), FSQHLTOfflineSource_cfi::processName, edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup(), productRegistry(), edm::EDConsumerBase::registeredToConsume(), edm::ProductHolderIndexHelper::relatedIndexes(), edm::throwAmbiguousException(), edm::InputTag::tryToCacheIndex(), unlikely, and edm::InputTag::willSkipCurrentProcess().

Referenced by findProductByTag(), and getByLabel().

636  {
637 
638  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
639 
640  ProductHolderIndex index = inputTag.indexFor(typeID, branchType(), &productRegistry());
641 
642  if (index == ProductHolderIndexInvalid) {
643 
644  char const* processName = inputTag.process().c_str();
645  if (skipCurrentProcess) {
646  processName = "\0";
647  }
648 
649  index = productLookup().index(kindOfType,
650  typeID,
651  inputTag.label().c_str(),
652  inputTag.instance().c_str(),
653  processName);
654 
655  if(index == ProductHolderIndexAmbiguous) {
656  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
657  } else if (index == ProductHolderIndexInvalid) {
658  ProductHolderIndexHelper::Matches matches =
659  productLookup().relatedIndexes(kindOfType, typeID);
660 
661  if (matches.numberOfMatches() == 0) {
662  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
663  }
664  return 0;
665  }
666  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
667  }
668  if(unlikely( consumer and (not consumer->registeredToConsume(index, skipCurrentProcess, branchType())))) {
669  failedToRegisterConsumes(kindOfType,typeID,inputTag.label(),inputTag.instance(),inputTag.process());
670  }
671 
672 
673  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
674 
675  ProductHolderBase::ResolveStatus resolveStatus;
676  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess, mcc);
677  if(resolveStatus == ProductHolderBase::Ambiguous) {
678  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
679  }
680  return productData;
681  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:147
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
ProductHolderIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
unsigned int ProductHolderIndex
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:100
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
BranchType const & branchType() const
Definition: Principal.h:165
ProductHolderCollection productHolders_
Definition: Principal.h:250
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< TypeID > const &missingDictionaries)
Definition: Principal.cc:39
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
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,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 684 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, branchType(), edm::ELEMENT_TYPE, edm::ProductHolderIndexHelper::index(), cmsHarvester::index, matches, edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup(), edm::EDConsumerBase::registeredToConsume(), edm::ProductHolderIndexHelper::relatedIndexes(), edm::throwAmbiguousException(), and unlikely.

690  {
691 
693  typeID,
694  label.c_str(),
695  instance.c_str(),
696  process.c_str());
697 
698  if(index == ProductHolderIndexAmbiguous) {
699  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
700  } else if (index == ProductHolderIndexInvalid) {
701  ProductHolderIndexHelper::Matches matches =
702  productLookup().relatedIndexes(kindOfType, typeID);
703 
704  if (matches.numberOfMatches() == 0) {
705  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
706  }
707  return 0;
708  }
709 
710  if(unlikely( consumer and (not consumer->registeredToConsume(index, false, branchType())))) {
711  failedToRegisterConsumes(kindOfType,typeID,label,instance,process);
712  }
713 
714  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
715 
716  ProductHolderBase::ResolveStatus resolveStatus;
717  ProductData const* productData = productHolder->resolveProduct(resolveStatus, false, mcc);
718  if(resolveStatus == ProductHolderBase::Ambiguous) {
719  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
720  }
721  return productData;
722  }
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
static PFTauRenderPlugin instance
ProductHolderIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
unsigned int ProductHolderIndex
static void throwAmbiguousException(const char *where, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:100
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
BranchType const & branchType() const
Definition: Principal.h:165
ProductHolderCollection productHolders_
Definition: Principal.h:250
tuple process
Definition: LaserDQM_cfg.py:3
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< TypeID > const &missingDictionaries)
Definition: Principal.cc:39
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 725 of file Principal.cc.

References findProductByLabel(), and edm::PRODUCT_TYPE.

Referenced by edm::getProductByTag().

725  {
726  ProductData const* productData =
728  typeID,
729  tag,
730  nullptr,
731  mcc);
732  return productData;
733  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, ModuleCallingContext const *mcc) const
Definition: Principal.cc:632
void edm::Principal::findProducts ( std::vector< ProductHolderBase const * > const &  holders,
TypeID const &  typeID,
BasicHandleVec results,
ModuleCallingContext const *  mcc 
) const
private

Definition at line 602 of file Principal.cc.

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

Referenced by getManyByType().

605  {
606 
607  for (auto iter = processHistoryPtr_->rbegin(),
608  iEnd = processHistoryPtr_->rend();
609  iter != iEnd; ++iter) {
610  std::string const& process = iter->processName();
611  for (auto productHolder : holders) {
612  BranchDescription const& bd = productHolder->branchDescription();
613  if (process == bd.processName()) {
614 
615  // Ignore aliases to avoid matching the same product multiple times.
616  if(bd.isAlias()) {
617  continue;
618  }
619 
620  ProductHolderBase::ResolveStatus resolveStatus;
621  ProductData const* productData = productHolder->resolveProduct(resolveStatus, false, mcc);
622  if(productData) {
623  // Skip product if not available.
624  results.emplace_back(*productData);
625  }
626  }
627  }
628  }
629  }
std::shared_ptr< ProcessHistory const > processHistoryPtr_
Definition: Principal.h:243
tuple process
Definition: LaserDQM_cfg.py:3
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 779 of file Principal.cc.

Referenced by edm::LuminosityBlock::getAllProvenance(), edm::Run::getAllProvenance(), edm::Event::getAllProvenance(), and edm::AsciiOutputModule::write().

779  {
780  provenances.clear();
781  for(auto const& productHolder : *this) {
782  if(productHolder->singleProduct() && productHolder->provenanceAvailable() && !productHolder->branchDescription().isAlias()) {
783  // We do not attempt to get the event/lumi/run status from the provenance,
784  // because the per event provenance may have been dropped.
785  if(productHolder->provenance()->product().present()) {
786  provenances.push_back(productHolder->provenance());
787  }
788  }
789  }
790  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag,
EDConsumerBase const *  consumes,
ModuleCallingContext const *  mcc 
) const

Definition at line 465 of file Principal.cc.

References findProductByLabel(), edm::InputTag::instance(), edm::InputTag::label(), edm::makeHandleExceptionFactory(), edm::makeNotFoundException(), edm::InputTag::process(), and query::result.

Referenced by edm::check(), edm::detail::NamedEventSelector::fill(), PileUpEventPrincipal::getByLabel(), edm::PrincipalGetAdapter::getByLabel_(), and edm::PrincipalGetAdapter::getMatchingSequenceByLabel_().

469  {
470 
471  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag, consumer, mcc);
472  if(result == 0) {
473  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
474  return makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process());
475  }));
476  }
477  return BasicHandle(*result);
478  }
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, ModuleCallingContext const *mcc) const
Definition: Principal.cc:632
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
tuple result
Definition: query.py:137
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:71
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
EDConsumerBase const *  consumes,
ModuleCallingContext const *  mcc 
) const

Definition at line 481 of file Principal.cc.

References findProductByLabel(), edm::makeHandleExceptionFactory(), edm::makeNotFoundException(), and query::result.

487  {
488 
489  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process,consumer, mcc);
490  if(result == 0) {
491  return BasicHandle(makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception> {
492  return makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
493  }));
494  }
495  return BasicHandle(*result);
496  }
static PFTauRenderPlugin instance
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumer, ModuleCallingContext const *mcc) const
Definition: Principal.cc:632
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
tuple result
Definition: query.py:137
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:71
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductHolderIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous,
ModuleCallingContext const *  mcc 
) const

Definition at line 499 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, assert(), cmsHarvester::index, edm::ProductHolderIndexInvalid, and productHolders_.

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

504  {
506  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
507  assert(0!=productHolder.get());
508  ProductHolderBase::ResolveStatus resolveStatus;
509  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess, mcc);
510  if(resolveStatus == ProductHolderBase::Ambiguous) {
511  ambiguous = true;
512  return BasicHandle();
513  }
514  if(productData == 0) {
515  return BasicHandle();
516  }
517  return BasicHandle(*productData);
518  }
assert(m_qm.get())
ProductHolderCollection productHolders_
Definition: Principal.h:250
ProductHolderBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 393 of file Principal.cc.

References assert(), cmsHarvester::index, preg_, edm::ProductHolderIndexInvalid, and productHolders_.

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

393  {
394  ProductHolderIndex index = preg_->indexFrom(branchID);
396  SharedProductPtr ptr = productHolders_.at(index);
397  return ptr.get();
398  }
std::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:62
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
ProductHolderCollection productHolders_
Definition: Principal.h:250
ProductHolderBase * edm::Principal::getExistingProduct ( ProductHolderBase const &  phb)
protected

Definition at line 401 of file Principal.cc.

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

401  {
402  ProductHolderBase* phb = getExistingProduct(productHolder.branchDescription().branchID());
403  if(nullptr != phb && BranchKey(productHolder.branchDescription()) != BranchKey(phb->branchDescription())) {
404  BranchDescription const& newProduct = phb->branchDescription();
405  BranchDescription const& existing = productHolder.branchDescription();
406  if(newProduct.branchName() != existing.branchName() && newProduct.branchID() == existing.branchID()) {
407  throw cms::Exception("HashCollision") << "Principal::getExistingProduct\n" <<
408  " Branch " << newProduct.branchName() << " has same branch ID as branch " << existing.branchName() << "\n" <<
409  "Workaround: change process name or product instance name of " << newProduct.branchName() << "\n";
410  } else {
411  assert(nullptr == phb || BranchKey(productHolder.branchDescription()) == BranchKey(phb->branchDescription()));
412  }
413  }
414  return phb;
415  }
assert(m_qm.get())
BranchDescription const & branchDescription() const
Definition: ProductHolder.h:90
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:393
OutputHandle edm::Principal::getForOutput ( BranchID const &  bid,
bool  getProd,
ModuleCallingContext const *  mcc 
) const

Definition at line 736 of file Principal.cc.

References getProductHolder(), edm::errors::LogicError, ntuplemaker::status, edm::throwProductDeletedException(), and edm::throwProductNotFoundException().

Referenced by edm::check(), edm::RootOutputFile::fillBranches(), edm::StreamSerializer::serializeEvent(), and edm::ProvenanceCheckerOutputModule::write().

737  {
738  ConstProductHolderPtr const phb = getProductHolder(bid);
739  if(phb == nullptr) {
741  }
742  if (phb->productWasDeleted()) {
743  throwProductDeletedException("getForOutput",phb->productType(),
744  phb->moduleLabel(),
745  phb->productInstanceName(),
746  phb->processName());
747  }
748  if(getProd) {
750  phb->resolveProduct(status,false,mcc);
751  }
752  if(!phb->provenance() || (!phb->product() && !phb->productProvenancePtr())) {
753  return OutputHandle();
754  }
755  return OutputHandle(phb->product(), &phb->branchDescription(), phb->productProvenancePtr());
756  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:449
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
static void throwProductDeletedException(ProductID const &pid, edm::EventPrincipal::ConstProductHolderPtr const phb)
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:57
tuple status
Definition: ntuplemaker.py:245
WrapperBase const * edm::Principal::getIt ( ProductID const &  ) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 806 of file Principal.cc.

References assert().

806  {
807  assert(nullptr);
808  return nullptr;
809  }
assert(m_qm.get())
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results,
EDConsumerBase const *  consumes,
ModuleCallingContext const *  mcc 
) const

Definition at line 531 of file Principal.cc.

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

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

534  {
535 
536  assert(results.empty());
537 
538  if(unlikely(consumer and (not consumer->registeredToConsumeMany(typeID,branchType())))) {
539  failedToRegisterConsumesMany(typeID);
540  }
541 
542  // This finds the indexes to all the ProductHolder's matching the type
543  ProductHolderIndexHelper::Matches matches =
545 
546  if (matches.numberOfMatches() == 0) {
547  maybeThrowMissingDictionaryException(typeID, false, preg_->missingDictionaries());
548  return;
549  }
550 
551  results.reserve(matches.numberOfMatches());
552 
553  // Loop over the ProductHolders. Add the products that are actually
554  // present into the results. This will also trigger delayed reading,
555  // on demand production, and check for deleted products as appropriate.
556 
557  // Over the years the code that uses getManyByType has grown to depend
558  // on the ordering of the results. The order originally was just an
559  // accident of how previous versions of the code were written, but
560  // here we have to go through some extra effort to preserve that ordering.
561 
562  // We build a list of holders that match a particular label and instance.
563  // When that list is complete we call findProducts, which loops over
564  // that list in reverse order of the ProcessHistory (starts with the
565  // most recent). Then we clear the list and repeat this until all the
566  // matching label and instance subsets have been dealt with.
567 
568  // Note that the function isFullyResolved returns true for the ProductHolders
569  // that are associated with an empty process name. Those are the ones that
570  // know how to search for the most recent process name matching
571  // a label and instance. We do not need these for getManyByType and
572  // skip them. In addition to skipping them, we make use of the fact
573  // that they mark the beginning of each subset of holders with the same
574  // label and instance. They tell us when to call findProducts.
575 
576  std::vector<ProductHolderBase const*> holders;
577 
578  for(unsigned int i = 0; i < matches.numberOfMatches(); ++i) {
579 
580  ProductHolderIndex index = matches.index(i);
581 
582  if(!matches.isFullyResolved(i)) {
583  if(!holders.empty()) {
584  // Process the ones with a particular module label and instance
585  findProducts(holders, typeID, results, mcc);
586  holders.clear();
587  }
588  } else {
589  ProductHolderBase const* productHolder = productHolders_.at(index).get();
590  assert(productHolder);
591  holders.push_back(productHolder);
592  }
593  }
594  // Do not miss the last subset of products
595  if(!holders.empty()) {
596  findProducts(holders, typeID, results, mcc);
597  }
598  return;
599  }
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
unsigned int ProductHolderIndex
#define unlikely(x)
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
BranchType const & branchType() const
Definition: Principal.h:165
ProductHolderCollection productHolders_
Definition: Principal.h:250
void findProducts(std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results, ModuleCallingContext const *mcc) const
Definition: Principal.cc:602
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< TypeID > const &missingDictionaries)
Definition: Principal.cc:39
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
Principal::ConstProductHolderPtr edm::Principal::getProductHolder ( BranchID const &  oid) const

Definition at line 449 of file Principal.cc.

References getProductHolderByIndex(), cmsHarvester::index, preg_, and edm::ProductHolderIndexInvalid.

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

449  {
450  ProductHolderIndex index = preg_->indexFrom(bid);
451  if(index == ProductHolderIndexInvalid){
452  return ConstProductHolderPtr();
453  }
454  return getProductHolderByIndex(index);
455  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
unsigned int ProductHolderIndex
ConstProductHolderPtr getProductHolderByIndex(ProductHolderIndex const &oid) const
Definition: Principal.cc:458
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
Principal::ConstProductHolderPtr edm::Principal::getProductHolderByIndex ( ProductHolderIndex const &  oid) const

Definition at line 458 of file Principal.cc.

References cmsHarvester::index, and productHolders_.

Referenced by edm::PrincipalGetAdapter::getBranchDescription(), getProductHolder(), and edm::NoProcessProductHolder::resolveProduct_().

458  {
459 
460  ConstProductHolderPtr const phb = productHolders_[index].get();
461  return phb;
462  }
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
ProductHolderCollection productHolders_
Definition: Principal.h:250
Provenance edm::Principal::getProvenance ( BranchID const &  bid,
ModuleCallingContext const *  mcc 
) const

Definition at line 759 of file Principal.cc.

References getProductHolder(), edm::errors::ProductNotFound, ntuplemaker::status, and edm::throwProductNotFoundException().

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

760  {
761  ConstProductHolderPtr const phb = getProductHolder(bid);
762  if(phb == nullptr) {
764  }
765 
766  if(phb->onDemand()) {
768  if(not phb->resolveProduct(status,false,mcc) ) {
769  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
770  }
771  }
772  return *phb->provenance();
773  }
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
Definition: Principal.cc:449
ProductHolderBase const * ConstProductHolderPtr
Definition: Principal.h:58
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:57
tuple status
Definition: ntuplemaker.py:245
WrapperBase const * edm::Principal::getThinnedProduct ( ProductID const &  ,
unsigned int &   
) const
overrideprivatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 812 of file Principal.cc.

References assert().

812  {
813  assert(nullptr);
814  return nullptr;
815  }
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 818 of file Principal.cc.

References assert().

820  {
821  assert(nullptr);
822  }
assert(m_qm.get())
bool edm::Principal::isComplete ( ) const
inline

Definition at line 193 of file Principal.h.

References isComplete_().

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

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

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

Definition at line 241 of file Principal.h.

Referenced by isComplete().

241 {return true;}
std::vector<unsigned int> const& edm::Principal::lookupProcessOrder ( ) const
inline

Definition at line 189 of file Principal.h.

References lookupProcessOrder_.

Referenced by edm::NoProcessProductHolder::resolveProduct_().

189 { return lookupProcessOrder_; }
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:257
void edm::Principal::prefetch ( ProductHolderIndex  index,
bool  skipCurrentProcess,
ModuleCallingContext const *  mcc 
) const

Definition at line 521 of file Principal.cc.

References assert(), and productHolders_.

523  {
524  std::shared_ptr<ProductHolderBase> const& productHolder = productHolders_.at(index);
525  assert(0!=productHolder.get());
526  ProductHolderBase::ResolveStatus resolveStatus;
527  productHolder->resolveProduct(resolveStatus, skipCurrentProcess, mcc);
528  }
assert(m_qm.get())
ProductHolderCollection productHolders_
Definition: Principal.h:250
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 145 of file Principal.h.

References processConfiguration_.

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

Definition at line 93 of file Principal.h.

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

93 {return this;}
ProductHolderIndexHelper const& edm::Principal::productLookup ( ) const
inline

Definition at line 149 of file Principal.h.

References productLookup_.

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

149 {return *productLookup_;}
std::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:255
ProductRegistry const& edm::Principal::productRegistry ( ) const
inline

Definition at line 147 of file Principal.h.

References preg_.

Referenced by fillPrincipal(), findProductByLabel(), edm::PrincipalGetAdapter::getBranchDescription(), edm::SubProcess::process(), and edm::ProvenanceCheckerOutputModule::write().

147 {return *preg_;}
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductHolderBase const *  productHolder 
) const
protected

Definition at line 839 of file Principal.cc.

References edm::ProductHolderBase::checkType(), checkUniquenessAndType(), edm::ProductHolderBase::mergeProduct(), edm::ProductHolderBase::putOrMergeProduct(), and edm::ProductHolderBase::putProduct().

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

839  {
840  bool willBePut = phb->putOrMergeProduct();
841  if(willBePut) {
842  checkUniquenessAndType(prod.get(), phb);
843  phb->putProduct(std::move(prod));
844  } else {
845  phb->checkType(*prod);
846  phb->mergeProduct(std::move(prod));
847  }
848  }
void checkUniquenessAndType(WrapperBase const *prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:825
void edm::Principal::putOrMerge ( std::unique_ptr< WrapperBase prod,
ProductProvenance prov,
ProductHolderBase productHolder 
)
protected

Definition at line 851 of file Principal.cc.

References edm::ProductHolderBase::checkType(), checkUniquenessAndType(), edm::ProductHolderBase::mergeProduct(), edm::ProductHolderBase::putOrMergeProduct(), and edm::ProductHolderBase::putProduct().

851  {
852  bool willBePut = phb->putOrMergeProduct();
853  if(willBePut) {
854  checkUniquenessAndType(prod.get(), phb);
855  phb->putProduct(std::move(prod), prov);
856  } else {
857  phb->checkType(*prod);
858  phb->mergeProduct(std::move(prod), prov);
859  }
860  }
void checkUniquenessAndType(WrapperBase const *prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:825
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::readFromSource ( ProductHolderBase const &  phb,
ModuleCallingContext const *  mcc 
) const
inline

Definition at line 182 of file Principal.h.

References readFromSource_().

Referenced by edm::InputProductHolder::resolveProduct_().

182  {
183  readFromSource_(phb, mcc);
184  }
virtual void readFromSource_(ProductHolderBase const &, ModuleCallingContext const *) const
Definition: Principal.h:239
virtual void edm::Principal::readFromSource_ ( ProductHolderBase const &  ,
ModuleCallingContext const *   
) const
inlineprivatevirtual

Reimplemented in edm::EventPrincipal.

Definition at line 239 of file Principal.h.

Referenced by readFromSource().

239 {}
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

Definition at line 793 of file Principal.cc.

References assert(), cmsHarvester::index, edm::DelayedReader::mergeReaders(), preg_, parseEventContent::prod, edm::ProductHolderIndexInvalid, productHolders_, reader(), and reader_.

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

793  {
794  for(auto const& prod : bids) {
795  ProductHolderIndex index= preg_->indexFrom(prod);
797  ProductHolderIndex indexO = other.preg_->indexFrom(prod);
799  productHolders_[index].swap(other.productHolders_[indexO]);
800  productHolders_[index]->setPrincipal(this);
801  }
802  reader_->mergeReaders(other.reader());
803  }
DelayedReader * reader_
Definition: Principal.h:262
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:24
assert(m_qm.get())
unsigned int ProductHolderIndex
std::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:254
ProductHolderCollection productHolders_
Definition: Principal.h:250
size_t edm::Principal::size ( void  ) const

Definition at line 248 of file Principal.cc.

References parseEventContent::prod.

Referenced by edm::SecSourceAnalyzer::getBranches(), edm::StreamerInputSource::read(), and edm::Event::size().

248  {
249  size_t size = 0U;
250  for(auto const& prod : *this) {
251  if(prod->singleProduct() && // Not a NoProcessProductHolder
252  !prod->productUnavailable() &&
253  !prod->onDemand() &&
254  !prod->branchDescription().dropped()) {
255  ++size;
256  }
257  }
258  return size;
259  }
size_t size() const
Definition: Principal.cc:248
virtual bool edm::Principal::unscheduledFill ( std::string const &  moduleLabel,
ModuleCallingContext const *  mcc 
) const
pure virtual

Member Data Documentation

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

Definition at line 274 of file Principal.h.

Referenced by cacheIdentifier(), and fillPrincipal().

HistoryAppender* edm::Principal::historyAppender_
private

Definition at line 272 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 257 of file Principal.h.

Referenced by fillPrincipal(), and lookupProcessOrder().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

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

Referenced by fillPrincipal(), and processConfiguration().

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 245 of file Principal.h.

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

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

Definition at line 243 of file Principal.h.

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

ProductHolderCollection edm::Principal::productHolders_
private
std::shared_ptr<ProductHolderIndexHelper const> edm::Principal::productLookup_
private

Definition at line 255 of file Principal.h.

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

std::set<void const*> edm::Principal::productPtrs_
mutableprivate

Definition at line 265 of file Principal.h.

Referenced by checkUniquenessAndType(), clearPrincipal(), and deleteProduct().

DelayedReader* edm::Principal::reader_
private

Definition at line 262 of file Principal.h.

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