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 | Static 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 boost::filter_iterator
< FilledProductPtr,
ProductHolderCollection::const_iterator > 
const_iterator
 
typedef ProductHolderBase const * ConstProductPtr
 
typedef std::string ProcessName
 
typedef
ProcessHistory::const_iterator 
ProcessNameConstIterator
 
typedef std::vector
< boost::shared_ptr
< ProductHolderBase > > 
ProductHolderCollection
 
typedef boost::shared_ptr
< ProductHolderBase
SharedProductPtr
 
typedef
ProductHolderCollection::size_type 
size_type
 

Public Member Functions

void addAliasedProduct (boost::shared_ptr< ConstBranchDescription > bd)
 
void addInputProduct (boost::shared_ptr< ConstBranchDescription > bd)
 
void addScheduledProduct (boost::shared_ptr< ConstBranchDescription > bd)
 
void addSourceProduct (boost::shared_ptr< ConstBranchDescription > bd)
 
void addUnscheduledProduct (boost::shared_ptr< ConstBranchDescription > bd)
 
void adjustIndexesAfterProductRegistryAddition ()
 
bool adjustToNewProductRegistry (ProductRegistry const &reg)
 
const_iterator begin () const
 
BranchType const & branchType () const
 
void clearPrincipal ()
 
void deleteProduct (BranchID const &id)
 
const_iterator end () const
 
void fillPrincipal (ProcessHistoryID const &hist, DelayedReader *reader)
 
ProductData const * findProductByTag (TypeID const &typeID, InputTag const &tag) const
 
void getAllProvenance (std::vector< Provenance const * > &provenances) const
 
BasicHandle getByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
 
BasicHandle getByLabel (KindOfType kindOfType, TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process) const
 
BasicHandle getByToken (KindOfType kindOfType, TypeID const &typeID, ProductHolderIndex index, bool skipCurrentProcess, bool &ambiguous) const
 
OutputHandle getForOutput (BranchID const &bid, bool getProd) const
 
void getManyByType (TypeID const &typeID, BasicHandleVec &results) const
 
ConstProductPtr getProductByIndex (ProductHolderIndex const &oid, bool resolveProd, bool fillOnDemand) const
 
ConstProductPtr getProductHolder (BranchID const &oid, bool resolveProd, bool fillOnDemand) const
 
Provenance getProvenance (BranchID const &bid) const
 
bool isComplete () const
 
std::vector< unsigned int > const & lookupProcessOrder () const
 
 Principal (boost::shared_ptr< ProductRegistry const > reg, boost::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 recombine (Principal &other, std::vector< BranchID > const &bids)
 
void resolveProduct (ProductHolderBase const &phb, bool fillOnDemand) const
 
size_t size () const
 
virtual bool unscheduledFill (std::string const &moduleLabel) const =0
 
virtual ~Principal ()
 
- Public Member Functions inherited from edm::EDProductGetter
 EDProductGetter ()
 
virtual ~EDProductGetter ()
 

Protected Member Functions

void addProduct_ (std::auto_ptr< ProductHolderBase > phb)
 
void addProductOrThrow (std::auto_ptr< ProductHolderBase > phb)
 
void checkUniquenessAndType (WrapperOwningHolder const &prod, ProductHolderBase const *productHolder) const
 
ProductHolderBasegetExistingProduct (BranchID const &branchID)
 
ProductHolderBasegetExistingProduct (ProductHolderBase const &phb)
 
void putOrMerge (WrapperOwningHolder const &prod, ProductHolderBase const *productHolder) const
 
void putOrMerge (WrapperOwningHolder const &prod, ProductProvenance &prov, ProductHolderBase *productHolder)
 

Private Member Functions

ProductData const * findProductByLabel (KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
 
ProductData const * findProductByLabel (KindOfType kindOfType, TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process) const
 
void findProducts (std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results) const
 
virtual WrapperHolder getIt (ProductID const &) const
 
virtual bool isComplete_ () const
 
virtual void resolveProduct_ (ProductHolderBase const &, bool) const
 

Private Attributes

BranchType branchType_
 
HistoryAppenderhistoryAppender_
 
std::vector< unsigned int > lookupProcessOrder_
 
ProcessHistoryID orderProcessHistoryID_
 
boost::shared_ptr
< ProductRegistry const > 
preg_
 
ProcessConfiguration const * processConfiguration_
 
ProcessHistoryID processHistoryID_
 
ProcessHistory const * processHistoryPtr_
 
ProductHolderCollection productHolders_
 
boost::shared_ptr
< ProductHolderIndexHelper
const > 
productLookup_
 
std::set< void const * > productPtrs_
 
DelayedReaderreader_
 

Static Private Attributes

static const ProcessHistory emptyProcessHistory_
 

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

Member Typedef Documentation

Definition at line 58 of file Principal.h.

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

Definition at line 55 of file Principal.h.

Definition at line 57 of file Principal.h.

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

Definition at line 62 of file Principal.h.

Definition at line 56 of file Principal.h.

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

Definition at line 54 of file Principal.h.

Definition at line 61 of file Principal.h.

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

Definition at line 59 of file Principal.h.

Constructor & Destructor Documentation

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

Definition at line 103 of file Principal.cc.

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

107  :
108  EDProductGetter(),
109  processHistoryPtr_(nullptr),
112  productHolders_(reg->getNextIndexValue(bt), SharedProductPtr()),
113  preg_(reg),
116  reader_(),
117  productPtrs_(),
118  branchType_(bt),
119  historyAppender_(historyAppender) {
120 
121  //Now that these have been set, we can create the list of Branches we need.
122  std::string const source("source");
123  ProductRegistry::ProductList const& prodsList = reg->productList();
124  // The constructor of an alias product holder takes as an argument the product holder for which it is an alias.
125  // So, the non-alias product holders must be created first.
126  // Therefore, on this first pass, skip current EDAliases.
127  bool hasAliases = false;
128  for(auto const& prod : prodsList) {
129  BranchDescription const& bd = prod.second;
130  if(bd.branchType() == branchType_) {
131  if(bd.isAlias()) {
132  hasAliases = true;
133  } else {
134  boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
135  if(bd.produced()) {
136  if(bd.moduleLabel() == source) {
137  addSourceProduct(cbd);
138  } else if(bd.onDemand()) {
139  assert(branchType_ == InEvent);
141  } else {
142  addScheduledProduct(cbd);
143  }
144  } else {
145  addInputProduct(cbd);
146  }
147  }
148  }
149  }
150  // Now process any EDAliases
151  if(hasAliases) {
152  for(auto const& prod : prodsList) {
153  BranchDescription const& bd = prod.second;
154  if(bd.isAlias() && bd.branchType() == branchType_) {
155  boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
156  addAliasedProduct(cbd);
157  }
158  }
159  }
160 
161  // Now create the ProductHolders that search in reverse process
162  // order and are used for queries where the process name is the
163  // empty string
164  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
165  std::vector<ProductHolderIndex> matchingHolders(lookupProcessNames.size(), ProductHolderIndexInvalid);
166  std::vector<bool> ambiguous(lookupProcessNames.size(), false);
167  unsigned int beginElements = productLookup_->beginElements();
168  std::vector<TypeID> const& sortedTypeIDs = productLookup_->sortedTypeIDs();
169  std::vector<ProductHolderIndexHelper::Range> const& ranges = productLookup_->ranges();
170  std::vector<ProductHolderIndexHelper::IndexAndNames> const& indexAndNames = productLookup_->indexAndNames();
171  std::vector<char> const& processNamesCharArray = productLookup_->processNames();
172 
173  if (!sortedTypeIDs.empty()) {
174  ProductHolderIndex productHolderIndex = ProductHolderIndexInvalid;
175  for(unsigned int k = 0, kEnd = sortedTypeIDs.size(); k < kEnd; ++k) {
176  ProductHolderIndexHelper::Range const& range = ranges.at(k);
177  for (unsigned int i = range.begin(); i < range.end(); ++i) {
178  ProductHolderIndexHelper::IndexAndNames const& product = indexAndNames.at(i);
179  if (product.startInProcessNames() == 0) {
180  if (productHolderIndex != ProductHolderIndexInvalid) {
181  boost::shared_ptr<ProductHolderBase> newHolder(new NoProcessProductHolder(matchingHolders, ambiguous, this));
182  productHolders_.at(productHolderIndex) = newHolder;
183  matchingHolders.assign(lookupProcessNames.size(), ProductHolderIndexInvalid);
184  ambiguous.assign(lookupProcessNames.size(), false);
185  }
186  productHolderIndex = product.index();
187  } else {
188  std::string process(&processNamesCharArray.at(product.startInProcessNames()));
189  auto iter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), process);
190  assert(iter != lookupProcessNames.end());
191  ProductHolderIndex iMatchingIndex = product.index();
192  assert(iMatchingIndex != ProductHolderIndexInvalid);
193  if (iMatchingIndex == ProductHolderIndexAmbiguous) {
194  assert(k >= beginElements);
195  ambiguous.at(iter - lookupProcessNames.begin()) = true;
196  } else {
197  matchingHolders.at(iter - lookupProcessNames.begin()) = iMatchingIndex;
198  }
199  }
200  }
201  }
202  boost::shared_ptr<ProductHolderBase> newHolder(new NoProcessProductHolder(matchingHolders, ambiguous, this));
203  productHolders_.at(productHolderIndex) = newHolder;
204  }
205  }
BranchType branchType_
Definition: Principal.h:242
int i
Definition: DBlmapReader.cc:9
DelayedReader * reader_
Definition: Principal.h:237
void addUnscheduledProduct(boost::shared_ptr< ConstBranchDescription > bd)
Definition: Principal.cc:264
HistoryAppender * historyAppender_
Definition: Principal.h:247
std::map< BranchKey, BranchDescription > ProductList
ProcessHistoryID processHistoryID_
Definition: Principal.h:220
void addScheduledProduct(boost::shared_ptr< ConstBranchDescription > bd)
Definition: Principal.cc:246
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
ProcessHistory const * processHistoryPtr_
Definition: Principal.h:218
unsigned int ProductHolderIndex
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
boost::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:61
void addInputProduct(boost::shared_ptr< ConstBranchDescription > bd)
Definition: Principal.cc:258
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:232
boost::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:230
ProductHolderCollection productHolders_
Definition: Principal.h:225
void addAliasedProduct(boost::shared_ptr< ConstBranchDescription > bd)
Definition: Principal.cc:270
std::set< void const * > productPtrs_
Definition: Principal.h:240
int k[5][pyjets_maxn]
string ranges
Definition: diffTwoXMLs.py:78
PixelRecoRange< float > Range
std::vector< std::string > const & lookupProcessNames() const
void addSourceProduct(boost::shared_ptr< ConstBranchDescription > bd)
Definition: Principal.cc:252
tuple process
Definition: LaserDQM_cfg.py:3
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:222
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:137
edm::Principal::~Principal ( )
virtual

Definition at line 207 of file Principal.cc.

207  {
208  }

Member Function Documentation

void edm::Principal::addAliasedProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 270 of file Principal.cc.

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

Referenced by Principal().

270  {
271  ProductHolderIndex index = preg_->indexFrom(bd->originalBranchID());
272  assert(index != ProductHolderIndexInvalid);
273 
274  std::auto_ptr<ProductHolderBase> phb(new AliasProductHolder(bd, dynamic_cast<ProducedProductHolder&>(*productHolders_[index])));
275  addProductOrThrow(phb);
276  }
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
unsigned int ProductHolderIndex
ProductHolderCollection productHolders_
Definition: Principal.h:225
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:382
void edm::Principal::addInputProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 258 of file Principal.cc.

References addProductOrThrow().

Referenced by adjustIndexesAfterProductRegistryAddition(), and Principal().

258  {
259  std::auto_ptr<ProductHolderBase> phb(new InputProductHolder(bd, this));
260  addProductOrThrow(phb);
261  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:382
void edm::Principal::addProduct_ ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 368 of file Principal.cc.

References edm::ConstBranchDescription::branchID(), edm::ConstBranchDescription::className(), edm::ConstBranchDescription::friendlyClassName(), getHLTprescales::index, edm::ConstBranchDescription::moduleLabel(), preg_, edm::ConstBranchDescription::processName(), edm::ProductHolderIndexInvalid, and productHolders_.

Referenced by addProductOrThrow().

368  {
369  ConstBranchDescription const& bd = productHolder->branchDescription();
370  assert (!bd.className().empty());
371  assert (!bd.friendlyClassName().empty());
372  assert (!bd.moduleLabel().empty());
373  assert (!bd.processName().empty());
374  SharedProductPtr phb(productHolder);
375 
376  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
377  assert(index != ProductHolderIndexInvalid);
378  productHolders_[index] = phb;
379  }
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
unsigned int ProductHolderIndex
boost::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:61
ProductHolderCollection productHolders_
Definition: Principal.h:225
void edm::Principal::addProductOrThrow ( std::auto_ptr< ProductHolderBase phb)
protected

Definition at line 382 of file Principal.cc.

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

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

382  {
383  ProductHolderBase const* phb = getExistingProduct(*productHolder);
384  if(phb != nullptr) {
385  ConstBranchDescription const& bd = productHolder->branchDescription();
386  throw Exception(errors::InsertFailure, "AlreadyPresent")
387  << "addProductOrThrow: Problem found while adding product, "
388  << "product already exists for ("
389  << bd.friendlyClassName() << ","
390  << bd.moduleLabel() << ","
391  << bd.productInstanceName() << ","
392  << bd.processName()
393  << ")\n";
394  }
395  addProduct_(productHolder);
396  }
void addProduct_(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:368
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:353
void edm::Principal::addScheduledProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 246 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

246  {
247  std::auto_ptr<ProductHolderBase> phb(new ScheduledProductHolder(bd));
248  addProductOrThrow(phb);
249  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:382
void edm::Principal::addSourceProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 252 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

252  {
253  std::auto_ptr<ProductHolderBase> phb(new SourceProductHolder(bd));
254  addProductOrThrow(phb);
255  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:382
void edm::Principal::addUnscheduledProduct ( boost::shared_ptr< ConstBranchDescription bd)

Definition at line 264 of file Principal.cc.

References addProductOrThrow().

Referenced by Principal().

264  {
265  std::auto_ptr<ProductHolderBase> phb(new UnscheduledProductHolder(bd, this));
266  addProductOrThrow(phb);
267  }
void addProductOrThrow(std::auto_ptr< ProductHolderBase > phb)
Definition: Principal.cc:382
void edm::Principal::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 785 of file Principal.cc.

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

Referenced by edm::StreamerInputSource::read().

785  {
786  if(preg_->getNextIndexValue(branchType_) != productHolders_.size()) {
787  productHolders_.resize(preg_->getNextIndexValue(branchType_));
788  for(auto const& prod : preg_->productList()) {
789  BranchDescription const& bd = prod.second;
790  if(bd.branchType() == branchType_) {
791  ProductHolderIndex index = preg_->indexFrom(bd.branchID());
792  assert(index != ProductHolderIndexInvalid);
793  if(!productHolders_[index]) {
794  // no product holder. Must add one. The new entry must be an input product holder.
795  assert(!bd.produced());
796  boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
797  addInputProduct(cbd);
798  }
799  }
800  }
801  }
802  assert(preg_->getNextIndexValue(branchType_) == productHolders_.size());
803  }
BranchType branchType_
Definition: Principal.h:242
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
unsigned int ProductHolderIndex
void addInputProduct(boost::shared_ptr< ConstBranchDescription > bd)
Definition: Principal.cc:258
ProductHolderCollection productHolders_
Definition: Principal.h:225
bool edm::Principal::adjustToNewProductRegistry ( ProductRegistry const &  reg)

Definition at line 229 of file Principal.cc.

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

Referenced by edm::StreamerInputSource::read().

229  {
230  ProductRegistry::ProductList const& prodsList = reg.productList();
231  for(auto const& prod : prodsList) {
232  BranchDescription const& bd = prod.second;
233  if(!bd.produced() && (bd.branchType() == branchType_)) {
234  boost::shared_ptr<ConstBranchDescription> cbd(new ConstBranchDescription(bd));
235  ProductHolderBase* phb = getExistingProduct(cbd->branchID());
236  if(phb == nullptr || phb->branchDescription().branchName() != cbd->branchName()) {
237  return false;
238  }
239  phb->resetBranchDescription(cbd);
240  }
241  }
242  return true;
243  }
BranchType branchType_
Definition: Principal.h:242
std::map< BranchKey, BranchDescription > ProductList
void resetBranchDescription(boost::shared_ptr< ConstBranchDescription > bd)
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:353
const_iterator edm::Principal::begin ( void  ) const
inline
BranchType const& edm::Principal::branchType ( ) const
inline

Definition at line 152 of file Principal.h.

References branchType_.

Referenced by findProductByLabel().

152 {return branchType_;}
BranchType branchType_
Definition: Principal.h:242
void edm::Principal::checkUniquenessAndType ( WrapperOwningHolder const &  prod,
ProductHolderBase const *  productHolder 
) const
protected

Definition at line 746 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::ConstBranchDescription::branchName(), edm::ProductHolderBase::checkType(), edm::WrapperHolder::isValid(), parseEventContent::prod, productPtrs_, reset(), edm::second(), edm::throwCorruptionException(), and edm::WrapperHolder::wrapper().

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

746  {
747  if(!prod.isValid()) return;
748  // These are defensive checks against things that should never happen, but have.
749  // Checks that the same physical product has not already been put into the event.
750  bool alreadyPresent = !productPtrs_.insert(prod.wrapper()).second;
751  if(alreadyPresent) {
752  phb->checkType(prod);
753  const_cast<WrapperOwningHolder&>(prod).reset();
754  throwCorruptionException("checkUniquenessAndType", phb->branchDescription().branchName());
755  }
756  // Checks that the real type of the product matches the branch.
757  phb->checkType(prod);
758  }
static void throwCorruptionException(char const *where, std::string const &branchName)
Definition: Principal.cc:48
U second(std::pair< T, U > const &p)
std::set< void const * > productPtrs_
Definition: Principal.h:240
void reset(double vett[256])
Definition: TPedValues.cc:11
void edm::Principal::clearPrincipal ( )

Definition at line 280 of file Principal.cc.

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

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

280  {
281  processHistoryPtr_ = 0;
283  reader_ = 0;
284  for(auto const& prod : *this) {
285  prod->resetProductData();
286  }
287  productPtrs_.clear();
288  }
DelayedReader * reader_
Definition: Principal.h:237
ProcessHistoryID processHistoryID_
Definition: Principal.h:220
ProcessHistory const * processHistoryPtr_
Definition: Principal.h:218
Hash< ProcessHistoryType > ProcessHistoryID
std::set< void const * > productPtrs_
Definition: Principal.h:240
void edm::Principal::deleteProduct ( BranchID const &  id)

Definition at line 291 of file Principal.cc.

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

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

291  {
292  ProductHolderBase* phb = getExistingProduct(id);
293  assert(nullptr != phb);
294  auto itFound = productPtrs_.find(phb->product().get());
295  if(itFound != productPtrs_.end()) {
296  productPtrs_.erase(itFound);
297  }
298  phb->deleteProduct();
299  }
std::set< void const * > productPtrs_
Definition: Principal.h:240
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:353
const_iterator edm::Principal::end ( void  ) const
inline
void edm::Principal::fillPrincipal ( ProcessHistoryID const &  hist,
DelayedReader reader 
)

Definition at line 303 of file Principal.cc.

References edm::HistoryAppender::appendToProcessHistory(), emptyProcessHistory_, edm::hlt::Exception, spr::find(), edm::detail::ThreadSafeRegistry< KEY, T, E >::getMapped(), estimatePileup::hist, historyAppender_, edm::CachedHistory::inputProcessHistory(), edm::detail::ThreadSafeRegistry< KEY, T, E >::instance(), edm::Hash< I >::isValid(), gen::k, edm::errors::LogicError, lookupProcessOrder_, orderProcessHistoryID_, processConfiguration_, edm::CachedHistory::processHistory(), edm::CachedHistory::processHistoryID(), processHistoryID_, processHistoryPtr_, productLookup_, productRegistry(), edm::ProcessHistory::rbegin(), reader(), reader_, PhysicsTools::registry, and edm::ProcessHistory::rend().

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

303  {
304  if(reader) {
305  reader_ = reader;
306  }
307 
308  ProcessHistory const* inputProcessHistory = 0;
309  if (historyAppender_ && productRegistry().anyProductProduced()) {
310  CachedHistory const& cachedHistory =
313  processHistoryPtr_ = cachedHistory.processHistory();
314  processHistoryID_ = cachedHistory.processHistoryID();
315  inputProcessHistory = cachedHistory.inputProcessHistory();
316  }
317  else {
318  if (hist.isValid()) {
320  inputProcessHistory = registry->getMapped(hist);
321  if (inputProcessHistory == 0) {
323  << "Principal::fillPrincipal\n"
324  << "Input ProcessHistory not found in registry\n"
325  << "Contact a Framework developer\n";
326  }
327  } else {
328  inputProcessHistory = &emptyProcessHistory_;
329  }
331  processHistoryPtr_ = inputProcessHistory;
332  }
333 
335  std::vector<std::string> const& lookupProcessNames = productLookup_->lookupProcessNames();
336  lookupProcessOrder_.assign(lookupProcessNames.size(), 0);
337  unsigned int k = 0;
338  for (auto iter = processHistoryPtr_->rbegin(),
339  iEnd = processHistoryPtr_->rend();
340  iter != iEnd; ++iter) {
341  auto nameIter = std::find(lookupProcessNames.begin(), lookupProcessNames.end(), iter->processName());
342  if (nameIter == lookupProcessNames.end()) {
343  continue;
344  }
345  lookupProcessOrder_.at(k) = nameIter - lookupProcessNames.begin();
346  ++k;
347  }
349  }
350  }
const_reverse_iterator rbegin() const
ProductRegistry const & productRegistry() const
Definition: Principal.h:135
DelayedReader * reader_
Definition: Principal.h:237
static const ProcessHistory emptyProcessHistory_
Definition: Principal.h:249
HistoryAppender * historyAppender_
Definition: Principal.h:247
static ThreadSafeRegistry * instance()
ProcessHistoryID processHistoryID_
Definition: Principal.h:220
CachedHistory const & appendToProcessHistory(ProcessHistoryID const &inputPHID, ProcessConfiguration const &pc)
ProcessHistory const * processHistoryPtr_
Definition: Principal.h:218
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
edm::detail::ThreadSafeRegistry< edm::ProcessHistoryID, edm::ProcessHistory, edm::FullHistoryToReducedHistoryMap > ProcessHistoryRegistry
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:232
const_reverse_iterator rend() const
boost::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:230
ProcessHistoryID orderProcessHistoryID_
Definition: Principal.h:233
int k[5][pyjets_maxn]
DelayedReader * reader() const
Definition: Principal.h:154
static Interceptor::Registry registry("Interceptor")
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:222
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag 
) const
private

Definition at line 581 of file Principal.cc.

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

Referenced by findProductByTag(), and getByLabel().

583  {
584 
585  bool skipCurrentProcess = inputTag.willSkipCurrentProcess();
586 
587  ProductHolderIndex index = inputTag.indexFor(typeID, branchType(), &productRegistry());
588 
589  if (index == ProductHolderIndexInvalid) {
590 
591  char const* processName = inputTag.process().c_str();
592  if (skipCurrentProcess) {
593  processName = "\0";
594  }
595 
596  index = productLookup().index(kindOfType,
597  typeID,
598  inputTag.label().c_str(),
599  inputTag.instance().c_str(),
600  processName);
601 
602  if(index == ProductHolderIndexAmbiguous) {
603  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
604  } else if (index == ProductHolderIndexInvalid) {
605  ProductHolderIndexHelper::Matches matches =
606  productLookup().relatedIndexes(kindOfType, typeID);
607 
608  if (matches.numberOfMatches() == 0) {
609  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
610  }
611  return 0;
612  }
613  inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
614  }
615 
616  boost::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
617 
618  ProductHolderBase::ResolveStatus resolveStatus;
619  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess);
620  if(resolveStatus == ProductHolderBase::Ambiguous) {
621  throwAmbiguousException("findProductByLabel", typeID, inputTag.label(), inputTag.instance(), inputTag.process());
622  }
623  return productData;
624  }
ProductRegistry const & productRegistry() const
Definition: Principal.h:135
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
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
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:84
BranchType const & branchType() const
Definition: Principal.h:152
ProductHolderCollection productHolders_
Definition: Principal.h:225
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< std::string > const &missingDictionaries)
Definition: Principal.cc:32
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:137
ProductData const * edm::Principal::findProductByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process 
) const
private

Definition at line 627 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, edm::ELEMENT_TYPE, getHLTprescales::index, edm::ProductHolderIndexHelper::index(), edm::maybeThrowMissingDictionaryException(), edm::ProductHolderIndexHelper::Matches::numberOfMatches(), preg_, edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, productHolders_, productLookup(), edm::ProductHolderIndexHelper::relatedIndexes(), and edm::throwAmbiguousException().

631  {
632 
634  typeID,
635  label.c_str(),
636  instance.c_str(),
637  process.c_str());
638 
639  if(index == ProductHolderIndexAmbiguous) {
640  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
641  } else if (index == ProductHolderIndexInvalid) {
642  ProductHolderIndexHelper::Matches matches =
643  productLookup().relatedIndexes(kindOfType, typeID);
644 
645  if (matches.numberOfMatches() == 0) {
646  maybeThrowMissingDictionaryException(typeID, kindOfType == ELEMENT_TYPE, preg_->missingDictionaries());
647  }
648  return 0;
649  }
650  boost::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
651 
652  ProductHolderBase::ResolveStatus resolveStatus;
653  ProductData const* productData = productHolder->resolveProduct(resolveStatus, false);
654  if(resolveStatus == ProductHolderBase::Ambiguous) {
655  throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
656  }
657  return productData;
658  }
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
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
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:84
ProductHolderCollection productHolders_
Definition: Principal.h:225
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< std::string > const &missingDictionaries)
Definition: Principal.cc:32
tuple process
Definition: LaserDQM_cfg.py:3
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:137
ProductData const * edm::Principal::findProductByTag ( TypeID const &  typeID,
InputTag const &  tag 
) const

Definition at line 661 of file Principal.cc.

References findProductByLabel(), edm::PRODUCT_TYPE, and edm::throwNotFoundException().

Referenced by edm::getProductByTag().

661  {
662  ProductData const* productData =
664  typeID,
665  tag);
666  if(productData == nullptr) {
667  throwNotFoundException("findProductByTag", typeID, tag);
668  }
669  return productData;
670  }
static void throwNotFoundException(char const *where, TypeID const &productType, InputTag const &tag)
Definition: Principal.cc:97
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
Definition: Principal.cc:581
void edm::Principal::findProducts ( std::vector< ProductHolderBase const * > const &  holders,
TypeID const &  typeID,
BasicHandleVec results 
) const
private

Definition at line 537 of file Principal.cc.

References edm::ConstBranchDescription::isAlias(), edm::ConstBranchDescription::moduleLabel(), LaserDQM_cfg::process, processHistoryPtr_, edm::ConstBranchDescription::processName(), edm::ConstBranchDescription::productInstanceName(), edm::ProcessHistory::rbegin(), edm::ProcessHistory::rend(), resolveProduct(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::throwProductDeletedException().

Referenced by getManyByType().

539  {
540 
541  for (auto iter = processHistoryPtr_->rbegin(),
542  iEnd = processHistoryPtr_->rend();
543  iter != iEnd; ++iter) {
544  std::string const& process = iter->processName();
545  for (auto productHolder : holders) {
546  ConstBranchDescription const& bd = productHolder->branchDescription();
547  if (process == bd.processName()) {
548 
549  // Ignore aliases to avoid matching the same product multiple times.
550  if(bd.isAlias()) {
551  continue;
552  }
553 
554  //NOTE sometimes 'productHolder->productUnavailable()' is true if was already deleted
555  if(productHolder->productWasDeleted()) {
556  throwProductDeletedException("findProducts",
557  typeID,
558  bd.moduleLabel(),
559  bd.productInstanceName(),
560  bd.processName());
561  }
562 
563  // Skip product if not available.
564  if(!productHolder->productUnavailable()) {
565 
566  this->resolveProduct(*productHolder, true);
567  // If the product is a dummy filler, product holder will now be marked unavailable.
568  // Unscheduled execution can fail to produce the EDProduct so check
569  if(productHolder->product() && !productHolder->productUnavailable() && !productHolder->onDemand()) {
570  // Found a good match, save it
571  BasicHandle bh(productHolder->productData());
572  results.push_back(bh);
573  }
574  }
575  }
576  }
577  }
578  }
const_reverse_iterator rbegin() const
void resolveProduct(ProductHolderBase const &phb, bool fillOnDemand) const
Definition: Principal.h:167
static void throwProductDeletedException(ProductID const &pid, edm::EventPrincipal::ConstProductPtr const phb)
ProcessHistory const * processHistoryPtr_
Definition: Principal.h:218
const_reverse_iterator rend() const
tuple process
Definition: LaserDQM_cfg.py:3
void edm::Principal::getAllProvenance ( std::vector< Provenance const * > &  provenances) const

Definition at line 713 of file Principal.cc.

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

713  {
714  provenances.clear();
715  for(auto const& productHolder : *this) {
716  if(productHolder->singleProduct() && productHolder->provenanceAvailable() && !productHolder->branchDescription().isAlias()) {
717  // We do not attempt to get the event/lumi/run status from the provenance,
718  // because the per event provenance may have been dropped.
719  if(productHolder->provenance()->product().present()) {
720  provenances.push_back(productHolder->provenance());
721  }
722  }
723  }
724  }
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
InputTag const &  inputTag 
) const

Definition at line 421 of file Principal.cc.

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

Referenced by edm::check(), and PileUpEventPrincipal::getByLabel().

423  {
424 
425  ProductData const* result = findProductByLabel(kindOfType, typeID, inputTag);
426  if(result == 0) {
427  boost::shared_ptr<cms::Exception> whyFailed =
428  makeNotFoundException("getByLabel", kindOfType, typeID, inputTag.label(), inputTag.instance(), inputTag.process());
429  return BasicHandle(whyFailed);
430  }
431  return BasicHandle(*result);
432  }
tuple result
Definition: query.py:137
static boost::shared_ptr< cms::Exception > makeNotFoundException(char const *where, KindOfType kindOfType, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:55
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
Definition: Principal.cc:581
BasicHandle edm::Principal::getByLabel ( KindOfType  kindOfType,
TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process 
) const

Definition at line 435 of file Principal.cc.

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

439  {
440 
441  ProductData const* result = findProductByLabel(kindOfType, typeID, label, instance, process);
442  if(result == 0) {
443  boost::shared_ptr<cms::Exception> whyFailed =
444  makeNotFoundException("getByLabel", kindOfType, typeID, label, instance, process);
445  return BasicHandle(whyFailed);
446  }
447  return BasicHandle(*result);
448  }
static PFTauRenderPlugin instance
tuple result
Definition: query.py:137
static boost::shared_ptr< cms::Exception > makeNotFoundException(char const *where, KindOfType kindOfType, TypeID const &productType, std::string const &label, std::string const &instance, std::string const &process)
Definition: Principal.cc:55
ProductData const * findProductByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
Definition: Principal.cc:581
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle edm::Principal::getByToken ( KindOfType  kindOfType,
TypeID const &  typeID,
ProductHolderIndex  index,
bool  skipCurrentProcess,
bool &  ambiguous 
) const

Definition at line 451 of file Principal.cc.

References edm::ProductHolderBase::Ambiguous, getHLTprescales::index, edm::ProductHolderIndexInvalid, and productHolders_.

455  {
457  boost::shared_ptr<ProductHolderBase> const& productHolder = productHolders_[index];
458  assert(0!=productHolder.get());
459  ProductHolderBase::ResolveStatus resolveStatus;
460  ProductData const* productData = productHolder->resolveProduct(resolveStatus, skipCurrentProcess);
461  if(resolveStatus == ProductHolderBase::Ambiguous) {
462  ambiguous = true;
463  return BasicHandle();
464  }
465  if(productData == 0) {
466  return BasicHandle();
467  }
468  return BasicHandle(*productData);
469  }
ProductHolderCollection productHolders_
Definition: Principal.h:225
ProductHolderBase * edm::Principal::getExistingProduct ( BranchID const &  branchID)
protected

Definition at line 353 of file Principal.cc.

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

353  {
354  ProductHolderIndex index = preg_->indexFrom(branchID);
355  assert(index != ProductHolderIndexInvalid);
356  SharedProductPtr ptr = productHolders_.at(index);
357  return ptr.get();
358  }
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
unsigned int ProductHolderIndex
boost::shared_ptr< ProductHolderBase > SharedProductPtr
Definition: Principal.h:61
ProductHolderCollection productHolders_
Definition: Principal.h:225
ProductHolderBase * edm::Principal::getExistingProduct ( ProductHolderBase const &  phb)
protected

Definition at line 361 of file Principal.cc.

References edm::ProductHolderBase::branchDescription(), edm::ConstBranchDescription::branchID(), and getExistingProduct().

361  {
362  ProductHolderBase* phb = getExistingProduct(productHolder.branchDescription().branchID());
363  assert(nullptr == phb || BranchKey(productHolder.branchDescription()) == BranchKey(phb->branchDescription()));
364  return phb;
365  }
ProductHolderBase * getExistingProduct(BranchID const &branchID)
Definition: Principal.cc:353
OutputHandle edm::Principal::getForOutput ( BranchID const &  bid,
bool  getProd 
) const

Definition at line 673 of file Principal.cc.

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

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

673  {
674  ConstProductPtr const phb = getProductHolder(bid, getProd, true);
675  if(phb == nullptr) {
677  }
678  if (phb->productWasDeleted()) {
679  throwProductDeletedException("getForOutput",phb->productType(),
680  phb->moduleLabel(),
681  phb->productInstanceName(),
682  phb->processName());
683  }
684  if(!phb->provenance() || (!phb->product() && !phb->productProvenancePtr())) {
685  return OutputHandle();
686  }
687  return OutputHandle(WrapperHolder(phb->product().get(), phb->productData().getInterface()), &phb->branchDescription(), phb->productProvenancePtr());
688  }
static void throwProductDeletedException(ProductID const &pid, edm::EventPrincipal::ConstProductPtr const phb)
ConstProductPtr getProductHolder(BranchID const &oid, bool resolveProd, bool fillOnDemand) const
Definition: Principal.cc:399
ProductHolderBase const * ConstProductPtr
Definition: Principal.h:57
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:41
WrapperHolder edm::Principal::getIt ( ProductID const &  ) const
privatevirtual

Implements edm::EDProductGetter.

Reimplemented in edm::EventPrincipal.

Definition at line 740 of file Principal.cc.

740  {
741  assert(nullptr);
742  return WrapperHolder();
743  }
void edm::Principal::getManyByType ( TypeID const &  typeID,
BasicHandleVec results 
) const

Definition at line 472 of file Principal.cc.

References findProducts(), i, getHLTprescales::index, edm::maybeThrowMissingDictionaryException(), preg_, edm::PRODUCT_TYPE, productHolders_, productLookup(), and edm::ProductHolderIndexHelper::relatedIndexes().

473  {
474 
475  assert(results.empty());
476 
477  // This finds the indexes to all the ProductHolder's matching the type
478  ProductHolderIndexHelper::Matches matches =
480 
481  if (matches.numberOfMatches() == 0) {
482  maybeThrowMissingDictionaryException(typeID, false, preg_->missingDictionaries());
483  return;
484  }
485 
486  results.reserve(matches.numberOfMatches());
487 
488  // Loop over the ProductHolders. Add the products that are actually
489  // present into the results. This will also trigger delayed reading,
490  // on demand production, and check for deleted products as appropriate.
491 
492  // Over the years the code that uses getManyByType has grown to depend
493  // on the ordering of the results. The order originally was just an
494  // accident of how previous versions of the code were written, but
495  // here we have to go through some extra effort to preserve that ordering.
496 
497  // We build a list of holders that match a particular label and instance.
498  // When that list is complete we call findProducts, which loops over
499  // that list in reverse order of the ProcessHistory (starts with the
500  // most recent). Then we clear the list and repeat this until all the
501  // matching label and instance subsets have been dealt with.
502 
503  // Note that the function isFullyResolved returns true for the ProductHolders
504  // that are associated with an empty process name. Those are the ones that
505  // know how to search for the most recent process name matching
506  // a label and instance. We do not need these for getManyByType and
507  // skip them. In addition to skipping them, we make use of the fact
508  // that they mark the beginning of each subset of holders with the same
509  // label and instance. They tell us when to call findProducts.
510 
511  std::vector<ProductHolderBase const*> holders;
512 
513  for(unsigned int i = 0; i < matches.numberOfMatches(); ++i) {
514 
515  ProductHolderIndex index = matches.index(i);
516 
517  if(!matches.isFullyResolved(i)) {
518  if(!holders.empty()) {
519  // Process the ones with a particular module label and instance
520  findProducts(holders, typeID, results);
521  holders.clear();
522  }
523  } else {
524  ProductHolderBase const* productHolder = productHolders_.at(index).get();
525  assert(productHolder);
526  holders.push_back(productHolder);
527  }
528  }
529  // Do not miss the last subset of products
530  if(!holders.empty()) {
531  findProducts(holders, typeID, results);
532  }
533  return;
534  }
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
int i
Definition: DBlmapReader.cc:9
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
unsigned int ProductHolderIndex
void findProducts(std::vector< ProductHolderBase const * > const &holders, TypeID const &typeID, BasicHandleVec &results) const
Definition: Principal.cc:537
ProductHolderCollection productHolders_
Definition: Principal.h:225
static void maybeThrowMissingDictionaryException(TypeID const &productType, bool isElement, std::vector< std::string > const &missingDictionaries)
Definition: Principal.cc:32
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:137
Principal::ConstProductPtr edm::Principal::getProductByIndex ( ProductHolderIndex const &  oid,
bool  resolveProd,
bool  fillOnDemand 
) const

Definition at line 408 of file Principal.cc.

References getHLTprescales::index, productHolders_, and resolveProduct().

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

408  {
409 
410  ConstProductPtr const phb = productHolders_[index].get();
411  if(nullptr == phb) {
412  return phb;
413  }
414  if(resolveProd && !phb->productUnavailable()) {
415  this->resolveProduct(*phb, fillOnDemand);
416  }
417  return phb;
418  }
void resolveProduct(ProductHolderBase const &phb, bool fillOnDemand) const
Definition: Principal.h:167
ProductHolderCollection productHolders_
Definition: Principal.h:225
ProductHolderBase const * ConstProductPtr
Definition: Principal.h:57
Principal::ConstProductPtr edm::Principal::getProductHolder ( BranchID const &  oid,
bool  resolveProd,
bool  fillOnDemand 
) const

Definition at line 399 of file Principal.cc.

References getProductByIndex(), getHLTprescales::index, preg_, and edm::ProductHolderIndexInvalid.

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

399  {
400  ProductHolderIndex index = preg_->indexFrom(bid);
401  if(index == ProductHolderIndexInvalid){
402  return ConstProductPtr();
403  }
404  return getProductByIndex(index, resolveProd, fillOnDemand);
405  }
ConstProductPtr getProductByIndex(ProductHolderIndex const &oid, bool resolveProd, bool fillOnDemand) const
Definition: Principal.cc:408
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
unsigned int ProductHolderIndex
ProductHolderBase const * ConstProductPtr
Definition: Principal.h:57
Provenance edm::Principal::getProvenance ( BranchID const &  bid) const

Definition at line 691 of file Principal.cc.

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

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

691  {
692  ConstProductPtr const phb = getProductHolder(bid, false, true);
693  if(phb == nullptr) {
695  }
696 
697  if(phb->onDemand()) {
698  unscheduledFill(phb->branchDescription().moduleLabel());
699  }
700  // We already tried to produce the unscheduled products above
701  // If they still are not there, then throw
702  if(phb->onDemand()) {
703  throwProductNotFoundException("getProvenance(onDemand)", errors::ProductNotFound, bid);
704  }
705 
706  return *phb->provenance();
707  }
ConstProductPtr getProductHolder(BranchID const &oid, bool resolveProd, bool fillOnDemand) const
Definition: Principal.cc:399
ProductHolderBase const * ConstProductPtr
Definition: Principal.h:57
virtual bool unscheduledFill(std::string const &moduleLabel) const =0
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:41
bool edm::Principal::isComplete ( ) const
inline

Definition at line 177 of file Principal.h.

References isComplete_().

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

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

Definition at line 216 of file Principal.h.

Referenced by isComplete().

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

Definition at line 171 of file Principal.h.

References lookupProcessOrder_.

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

171 { return lookupProcessOrder_; }
std::vector< unsigned int > lookupProcessOrder_
Definition: Principal.h:232
ProcessConfiguration const& edm::Principal::processConfiguration ( ) const
inline

Definition at line 133 of file Principal.h.

References processConfiguration_.

133 {return *processConfiguration_;}
ProcessConfiguration const * processConfiguration_
Definition: Principal.h:222
ProcessHistory const& edm::Principal::processHistory ( ) const
inline

Definition at line 125 of file Principal.h.

References processHistoryPtr_.

Referenced by edm::StreamSerializer::serializeEvent(), and edm::AsciiOutputModule::write().

125  {
126  return *processHistoryPtr_;
127  }
ProcessHistory const * processHistoryPtr_
Definition: Principal.h:218
ProcessHistoryID const& edm::Principal::processHistoryID ( ) const
inline
EDProductGetter const* edm::Principal::prodGetter ( ) const
inline

Definition at line 92 of file Principal.h.

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

Definition at line 137 of file Principal.h.

References productLookup_.

Referenced by findProductByLabel(), and getManyByType().

137 {return *productLookup_;}
boost::shared_ptr< ProductHolderIndexHelper const > productLookup_
Definition: Principal.h:230
ProductRegistry const& edm::Principal::productRegistry ( ) const
inline

Definition at line 135 of file Principal.h.

References preg_.

Referenced by edm::EventPrincipal::fillEventPrincipal(), fillPrincipal(), findProductByLabel(), edm::ProvenanceCheckerOutputModule::write(), and edm::SubProcess::write().

135 {return *preg_;}
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
void edm::Principal::putOrMerge ( WrapperOwningHolder const &  prod,
ProductHolderBase const *  productHolder 
) const
protected

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

761  {
762  bool willBePut = phb->putOrMergeProduct();
763  if(willBePut) {
765  phb->putProduct(prod);
766  } else {
767  phb->checkType(prod);
768  phb->mergeProduct(prod);
769  }
770  }
void checkUniquenessAndType(WrapperOwningHolder const &prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:746
void edm::Principal::putOrMerge ( WrapperOwningHolder const &  prod,
ProductProvenance prov,
ProductHolderBase productHolder 
)
protected

Definition at line 773 of file Principal.cc.

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

773  {
774  bool willBePut = phb->putOrMergeProduct();
775  if(willBePut) {
777  phb->putProduct(prod, prov);
778  } else {
779  phb->checkType(prod);
780  phb->mergeProduct(prod, prov);
781  }
782  }
void checkUniquenessAndType(WrapperOwningHolder const &prod, ProductHolderBase const *productHolder) const
Definition: Principal.cc:746
DelayedReader* edm::Principal::reader ( ) const
inline
void edm::Principal::recombine ( Principal other,
std::vector< BranchID > const &  bids 
)

Definition at line 727 of file Principal.cc.

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

Referenced by edm::PoolSource::readEvent_().

727  {
728  for(auto const& prod : bids) {
729  ProductHolderIndex index= preg_->indexFrom(prod);
730  assert(index!=ProductHolderIndexInvalid);
731  ProductHolderIndex indexO = other.preg_->indexFrom(prod);
732  assert(indexO!=ProductHolderIndexInvalid);
733  productHolders_[index].swap(other.productHolders_[indexO]);
734  productHolders_[index]->setPrincipal(this);
735  }
736  reader_->mergeReaders(other.reader());
737  }
DelayedReader * reader_
Definition: Principal.h:237
void mergeReaders(DelayedReader *other)
Definition: DelayedReader.h:25
boost::shared_ptr< ProductRegistry const > preg_
Definition: Principal.h:229
unsigned int ProductHolderIndex
ProductHolderCollection productHolders_
Definition: Principal.h:225
void edm::Principal::resolveProduct ( ProductHolderBase const &  phb,
bool  fillOnDemand 
) const
inline

Definition at line 167 of file Principal.h.

References resolveProduct_().

Referenced by findProducts(), getProductByIndex(), and edm::InputProductHolder::resolveProduct_().

167 {resolveProduct_(phb, fillOnDemand);}
virtual void resolveProduct_(ProductHolderBase const &, bool) const
Definition: Principal.h:214
virtual void edm::Principal::resolveProduct_ ( ProductHolderBase const &  ,
bool   
) const
inlineprivatevirtual

Reimplemented in edm::EventPrincipal.

Definition at line 214 of file Principal.h.

Referenced by resolveProduct().

214 {}
size_t edm::Principal::size ( void  ) const

Definition at line 214 of file Principal.cc.

References parseEventContent::prod.

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

214  {
215  size_t size = 0U;
216  for(auto const& prod : *this) {
217  if(prod->singleProduct() && // Not a NoProcessProductHolder
218  !prod->productUnavailable() &&
219  !prod->onDemand() &&
220  !prod->branchDescription().dropped()) {
221  ++size;
222  }
223  }
224  return size;
225  }
size_t size() const
Definition: Principal.cc:214
virtual bool edm::Principal::unscheduledFill ( std::string const &  moduleLabel) const
pure virtual

Member Data Documentation

BranchType edm::Principal::branchType_
private
ProcessHistory const edm::Principal::emptyProcessHistory_
staticprivate

Definition at line 249 of file Principal.h.

Referenced by fillPrincipal().

HistoryAppender* edm::Principal::historyAppender_
private

Definition at line 247 of file Principal.h.

Referenced by fillPrincipal().

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

Definition at line 232 of file Principal.h.

Referenced by fillPrincipal(), and lookupProcessOrder().

ProcessHistoryID edm::Principal::orderProcessHistoryID_
private

Definition at line 233 of file Principal.h.

Referenced by fillPrincipal().

boost::shared_ptr<ProductRegistry const> edm::Principal::preg_
private
ProcessConfiguration const* edm::Principal::processConfiguration_
private

Definition at line 222 of file Principal.h.

Referenced by fillPrincipal(), and processConfiguration().

ProcessHistoryID edm::Principal::processHistoryID_
private

Definition at line 220 of file Principal.h.

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

ProcessHistory const* edm::Principal::processHistoryPtr_
private

Definition at line 218 of file Principal.h.

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

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

Definition at line 230 of file Principal.h.

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

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

Definition at line 240 of file Principal.h.

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

DelayedReader* edm::Principal::reader_
private

Definition at line 237 of file Principal.h.

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