CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::ProductRegistry Class Reference

#include <ProductRegistry.h>

Inheritance diagram for edm::ProductRegistry:
edm::SignallingProductRegistry

Classes

struct  Transients
 

Public Types

typedef std::map< BranchKey, BranchDescription const > ConstProductList
 
typedef std::map< BranchKey, BranchDescriptionProductList
 

Public Member Functions

void addLabelAlias (BranchDescription const &productdesc, std::string const &labelAlias, std::string const &instanceAlias)
 
void addProduct (BranchDescription const &productdesc, bool iFromListener=false)
 
std::vector< std::string > aliasToModules (KindOfType kindOfType, TypeID const &type, std::string_view moduleLabel, std::string_view productInstanceName) const
 
std::vector< BranchDescription const * > allBranchDescriptions () const
 
std::vector< std::string > allBranchNames () const
 
bool anyProductProduced () const
 
bool anyProducts (BranchType const brType) const
 
template<typename T >
void callForEachBranch (T const &iFunc)
 
void copyProduct (BranchDescription const &productdesc)
 
bool frozen () const
 
ProductResolverIndex const & getNextIndexValue (BranchType branchType) const
 
ProductResolverIndex indexFrom (BranchID const &iID) const
 
void initializeTransients ()
 
std::string merge (ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
 
void print (std::ostream &os) const
 
ProductList const & productList () const
 
ProductListproductListUpdator ()
 
std::shared_ptr< ProductResolverIndexHelperproductLookup (BranchType branchType)
 
std::shared_ptr< ProductResolverIndexHelper const > productLookup (BranchType branchType) const
 
bool productProduced (BranchType branchType) const
 
 ProductRegistry ()
 
 ProductRegistry (ProductList const &productList, bool toBeFrozen=true)
 
void setFrozen (bool initializeLookupInfo=true)
 
void setFrozen (std::set< TypeID > const &productTypesConsumed, std::set< TypeID > const &elementTypesConsumed, std::string const &processName)
 
void setUnscheduledProducts (std::set< std::string > const &unscheduledLabels)
 
ProductList::size_type size () const
 
void updateFromInput (ProductList const &other)
 
void updateFromInput (std::vector< BranchDescription > const &other)
 
virtual ~ProductRegistry ()
 

Private Member Functions

virtual void addCalled (BranchDescription const &, bool iFromListener)
 
void addElementTypesForAliases (std::set< TypeID > const *elementTypesConsumed, std::map< TypeID, TypeID > const &containedTypeMap, std::map< TypeID, std::vector< TypeWithDict >> const &containedTypeToBaseTypesMap)
 
void checkDictionariesOfConsumedTypes (std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::map< TypeID, TypeID > const &containedTypeMap, std::map< TypeID, std::vector< TypeWithDict >> &containedTypeToBaseTypesMap)
 
void checkForDuplicateProcessName (BranchDescription const &desc, std::string const *processName) const
 
void freezeIt (bool frozen=true)
 
void initializeLookupTables (std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
 
ProductResolverIndexnextIndexValue (BranchType branchType)
 
void setProductProduced (BranchType branchType)
 
void throwIfFrozen () const
 
void throwIfNotFrozen () const
 

Private Attributes

ProductList productList_
 
Transients transient_
 

Detailed Description

\original author Stefano ARGIRO \current author Bill Tanenbaum

Date
19 Jul 2005

Definition at line 37 of file ProductRegistry.h.

Member Typedef Documentation

◆ ConstProductList

Definition at line 50 of file ProductRegistry.h.

◆ ProductList

Definition at line 39 of file ProductRegistry.h.

Constructor & Destructor Documentation

◆ ProductRegistry() [1/2]

edm::ProductRegistry::ProductRegistry ( )

Definition at line 32 of file ProductRegistry.cc.

32 : productList_(), transient_() {}

◆ ProductRegistry() [2/2]

edm::ProductRegistry::ProductRegistry ( ProductList const &  productList,
bool  toBeFrozen = true 
)
explicit

Definition at line 63 of file ProductRegistry.cc.

65  freezeIt(toBeFrozen);
66  }

References freezeIt().

◆ ~ProductRegistry()

virtual edm::ProductRegistry::~ProductRegistry ( )
inlinevirtual

Definition at line 48 of file ProductRegistry.h.

48 {}

Member Function Documentation

◆ addCalled()

void edm::ProductRegistry::addCalled ( BranchDescription const &  ,
bool  iFromListener 
)
privatevirtual

Reimplemented in edm::SignallingProductRegistry.

Definition at line 187 of file ProductRegistry.cc.

187 {}

Referenced by addLabelAlias(), and addProduct().

◆ addElementTypesForAliases()

void edm::ProductRegistry::addElementTypesForAliases ( std::set< TypeID > const *  elementTypesConsumed,
std::map< TypeID, TypeID > const &  containedTypeMap,
std::map< TypeID, std::vector< TypeWithDict >> const &  containedTypeToBaseTypesMap 
)
private

Definition at line 465 of file ProductRegistry.cc.

468  {
469  Transients::AliasToOriginalVector elementAliases;
470  for (auto& item : transient_.aliasToOriginal_) {
471  auto iterContainedType = containedTypeMap.find(std::get<Transients::kType>(item));
472  if (iterContainedType == containedTypeMap.end()) {
474  ex << "containedTypeMap did not contain " << std::get<Transients::kType>(item).className()
475  << " that is used in EDAlias " << std::get<Transients::kModuleLabel>(item)
476  << ".\nThis should not happen, contact framework developers";
477  ex.addContext("Calling ProductRegistry::initializeLookupTables()");
478  throw ex;
479  }
480  auto const& containedTypeID = iterContainedType->second;
481  bool const hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
482  if (not hasContainedType) {
483  continue;
484  }
485 
486  if (elementTypesConsumed->find(containedTypeID) != elementTypesConsumed->end()) {
487  elementAliases.emplace_back(ELEMENT_TYPE,
488  containedTypeID,
489  std::get<Transients::kModuleLabel>(item),
490  std::get<Transients::kProductInstanceName>(item),
491  std::get<Transients::kAliasForModuleLabel>(item));
492  }
493 
494  auto iterBaseTypes = containedTypeToBaseTypesMap.find(containedTypeID);
495  if (iterBaseTypes == containedTypeToBaseTypesMap.end()) {
496  continue;
497  }
498  for (TypeWithDict const& baseType : iterBaseTypes->second) {
499  TypeID baseTypeID(baseType.typeInfo());
500  if (elementTypesConsumed->find(baseTypeID) != elementTypesConsumed->end()) {
501  elementAliases.emplace_back(ELEMENT_TYPE,
502  baseTypeID,
503  std::get<Transients::kModuleLabel>(item),
504  std::get<Transients::kProductInstanceName>(item),
505  std::get<Transients::kAliasForModuleLabel>(item));
506  }
507  }
508  }
510  std::make_move_iterator(elementAliases.begin()),
511  std::make_move_iterator(elementAliases.end()));
512  }

References cms::Exception::addContext(), edm::ProductRegistry::Transients::aliasToOriginal_, edm::ELEMENT_TYPE, B2GTnPMonitor_cfi::item, edm::errors::LogicError, transient_, and edm::TypeWithDict::typeInfo().

Referenced by initializeLookupTables().

◆ addLabelAlias()

void edm::ProductRegistry::addLabelAlias ( BranchDescription const &  productdesc,
std::string const &  labelAlias,
std::string const &  instanceAlias 
)

Definition at line 108 of file ProductRegistry.cc.

110  {
111  assert(productDesc.produced());
112  assert(productDesc.branchID().isValid());
113  throwIfFrozen();
114  BranchDescription bd(productDesc, labelAlias, instanceAlias);
115  std::pair<ProductList::iterator, bool> ret = productList_.insert(std::make_pair(BranchKey(bd), bd));
116  assert(ret.second);
117  transient_.aliasToOriginal_.emplace_back(
118  PRODUCT_TYPE, productDesc.unwrappedTypeID(), labelAlias, instanceAlias, productDesc.moduleLabel());
119  addCalled(bd, false);
120  }

References addCalled(), edm::ProductRegistry::Transients::aliasToOriginal_, cms::cuda::assert(), edm::BranchDescription::branchID(), edm::BranchID::isValid(), edm::BranchDescription::moduleLabel(), edm::BranchDescription::produced(), edm::PRODUCT_TYPE, productList_, runTheMatrix::ret, throwIfFrozen(), transient_, and edm::BranchDescription::unwrappedTypeID().

◆ addProduct()

void edm::ProductRegistry::addProduct ( BranchDescription const &  productdesc,
bool  iFromListener = false 
)

Definition at line 68 of file ProductRegistry.cc.

68  {
69  assert(productDesc.produced());
70  throwIfFrozen();
71  std::pair<ProductList::iterator, bool> ret =
72  productList_.insert(std::make_pair(BranchKey(productDesc), productDesc));
73  if (!ret.second) {
74  auto const& previous = *productList_.find(BranchKey(productDesc));
75  if (previous.second.produced()) {
76  // Duplicate registration in current process
77  throw Exception(errors::LogicError, "Duplicate Product Identifier")
78  << "\nThe Framework requires a unique branch name for each product\n"
79  << "which consists of four parts: a friendly class name, module label,\n"
80  << "product instance name, and process name. A product has been\n"
81  << "registered with a duplicate branch name. The most common way\n"
82  << "to fix this error is to modify the product instance name in\n"
83  << "one of the offending 'produces' function calls. Another fix\n"
84  << "would be to delete one of them if they are for the same product.\n\n"
85  << " friendly class name = " << previous.second.friendlyClassName() << "\n"
86  << " module label = " << previous.second.moduleLabel() << "\n"
87  << " product instance name = " << previous.second.productInstanceName() << "\n"
88  << " process name = " << previous.second.processName() << "\n\n"
89  << "The following additional information is not used as part of\n"
90  << "the unique branch identifier.\n\n"
91  << " branch types = " << previous.second.branchType() << " " << productDesc.branchType() << "\n"
92  << " class name = " << previous.second.fullClassName() << "\n\n"
93  << "Note that if the four parts of the branch name are the same,\n"
94  << "then this error will occur even if the branch types differ!\n\n";
95  } else {
96  // Duplicate registration in previous process
97  throw Exception(errors::Configuration, "Duplicate Process Name.\n")
98  << "The process name " << productDesc.processName() << " was previously used for products in the input.\n"
99  << "This has caused branch name conflicts between input products and new products.\n"
100  << "Please modify the configuration file to use a distinct process name.\n"
101  << "Alternately, drop all input products using that process name and the\n"
102  << "descendants of those products.\n";
103  }
104  }
105  addCalled(productDesc, fromListener);
106  }

References addCalled(), cms::cuda::assert(), edm::BranchDescription::branchType(), edm::errors::Configuration, Exception, edm::errors::LogicError, callgraph::previous, edm::BranchDescription::processName(), edm::BranchDescription::produced(), productList_, runTheMatrix::ret, and throwIfFrozen().

Referenced by edm::ProductRegistryHelper::addToRegistry().

◆ aliasToModules()

std::vector< std::string > edm::ProductRegistry::aliasToModules ( KindOfType  kindOfType,
TypeID const &  type,
std::string_view  moduleLabel,
std::string_view  productInstanceName 
) const

Definition at line 613 of file ProductRegistry.cc.

616  {
617  auto aliasFields = [](auto const& item) {
618  return std::tie(std::get<Transients::kKind>(item),
619  std::get<Transients::kType>(item),
620  std::get<Transients::kModuleLabel>(item),
621  std::get<Transients::kProductInstanceName>(item));
622  };
623  auto const target = std::tuple(kindOfType, type, moduleLabel, productInstanceName);
624  auto found =
627  target,
628  [aliasFields](auto const& item, auto const& target) { return aliasFields(item) < target; });
629  std::vector<std::string> ret;
630  for (; found != transient_.aliasToOriginal_.end() and aliasFields(*found) == target; ++found) {
631  ret.emplace_back(std::get<Transients::kAliasForModuleLabel>(*found));
632  }
633  return ret;
634  }

References edm::ProductRegistry::Transients::aliasToOriginal_, newFWLiteAna::found, B2GTnPMonitor_cfi::item, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, HerwigMaxPtPartonFilter_cfi::moduleLabel, runTheMatrix::ret, filterCSVwithJSON::target, and transient_.

◆ allBranchDescriptions()

std::vector< BranchDescription const * > edm::ProductRegistry::allBranchDescriptions ( ) const

Definition at line 199 of file ProductRegistry.cc.

199  {
200  std::vector<BranchDescription const*> result;
201  result.reserve(productList().size());
202 
203  for (auto const& product : productList()) {
204  result.push_back(&product.second);
205  }
206  return result;
207  }

References productList(), mps_fire::result, and size().

Referenced by edm::RootFile::dropOnInput(), edm::SubProcess::selectProducts(), edm::global::OutputModuleBase::selectProducts(), edm::limited::OutputModuleBase::selectProducts(), edm::one::OutputModuleBase::selectProducts(), and edm::PrincipalGetAdapter::throwUnregisteredPutException().

◆ allBranchNames()

std::vector< std::string > edm::ProductRegistry::allBranchNames ( ) const

Definition at line 189 of file ProductRegistry.cc.

189  {
190  std::vector<std::string> result;
191  result.reserve(productList().size());
192 
193  for (auto const& product : productList()) {
194  result.push_back(product.second.branchName());
195  }
196  return result;
197  }

References productList(), mps_fire::result, and size().

◆ anyProductProduced()

bool edm::ProductRegistry::anyProductProduced ( ) const
inline

◆ anyProducts()

bool edm::ProductRegistry::anyProducts ( BranchType const  brType) const

Definition at line 135 of file ProductRegistry.cc.

135  {
137  for (ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end(); it != itEnd; ++it) {
138  if (it->second.branchType() == brType) {
139  return true;
140  }
141  }
142  return false;
143  }

References productList_, and throwIfNotFrozen().

◆ callForEachBranch()

template<typename T >
void edm::ProductRegistry::callForEachBranch ( T const &  iFunc)
inline

Definition at line 100 of file ProductRegistry.h.

100  {
101  //NOTE: If implementation changes from a map, need to check that iterators are still valid
102  // after an insert with the new container, else need to copy the container and iterate over the copy
103  for (ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(), itEntryEnd = productList_.end();
104  itEntry != itEntryEnd;
105  ++itEntry) {
106  iFunc(itEntry->second);
107  }
108  }

References productList_.

Referenced by edm::ProducerBase::registerProducts(), edm::stream::EDAnalyzerBase::registerProductsAndCallbacks(), edm::EDAnalyzer::registerProductsAndCallbacks(), edm::one::EDAnalyzerBase::registerProductsAndCallbacks(), edm::global::EDAnalyzerBase::registerProductsAndCallbacks(), and edm::limited::EDAnalyzerBase::registerProductsAndCallbacks().

◆ checkDictionariesOfConsumedTypes()

void edm::ProductRegistry::checkDictionariesOfConsumedTypes ( std::set< TypeID > const *  productTypesConsumed,
std::set< TypeID > const *  elementTypesConsumed,
std::map< TypeID, TypeID > const &  containedTypeMap,
std::map< TypeID, std::vector< TypeWithDict >> &  containedTypeToBaseTypesMap 
)
private

Definition at line 514 of file ProductRegistry.cc.

518  {
519  std::vector<std::string> missingDictionaries;
520  std::set<std::string> consumedTypesWithMissingDictionaries;
521 
522  if (productTypesConsumed) {
523  // Check dictionaries for all classes declared to be consumed
524  for (auto const& consumedTypeID : *productTypesConsumed) {
525  // We use the containedTypeMap to see which types have already
526  // had their dictionaries checked. We do not waste time rechecking
527  // those dictionaries.
528  if (containedTypeMap.find(consumedTypeID) == containedTypeMap.end()) {
529  std::string wrappedName = wrappedClassName(consumedTypeID.className());
530  TypeWithDict wrappedType = TypeWithDict::byName(wrappedName);
531  if (!checkDictionary(missingDictionaries, wrappedName, wrappedType)) {
532  checkDictionary(missingDictionaries, consumedTypeID);
533  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
534  continue;
535  }
536  bool transient = false;
537  TDictAttributeMap* wp = wrappedType.getClass()->GetAttributeMap();
538  if (wp && wp->HasKey("persistent") && !strcmp(wp->GetPropertyAsString("persistent"), "false")) {
539  transient = true;
540  }
541  if (transient) {
542  if (!checkDictionary(missingDictionaries, consumedTypeID)) {
543  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
544  }
545 
547  TypeID(wrappedType.typeInfo()), consumedTypeID.className());
548  bool hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
549  if (hasContainedType) {
550  if (containedTypeToBaseTypesMap.find(containedTypeID) == containedTypeToBaseTypesMap.end()) {
551  std::vector<TypeWithDict> bases;
552  // Run this to check for missing dictionaries, bases is not really used
553  if (!public_base_classes(missingDictionaries, containedTypeID, bases)) {
554  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
555  }
556  containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, bases));
557  }
558  }
559  } else {
560  if (!checkClassDictionaries(missingDictionaries, wrappedName, wrappedType)) {
561  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
562  }
563  }
564  }
565  }
566  if (!missingDictionaries.empty()) {
567  std::string context(
568  "Calling ProductRegistry::initializeLookupTables, checking dictionaries for consumed products");
569  throwMissingDictionariesException(missingDictionaries, context, consumedTypesWithMissingDictionaries, false);
570  }
571  }
572 
573  if (elementTypesConsumed) {
574  missingDictionaries.clear();
575  consumedTypesWithMissingDictionaries.clear();
576  for (auto const& consumedTypeID : *elementTypesConsumed) {
577  if (containedTypeToBaseTypesMap.find(consumedTypeID) == containedTypeToBaseTypesMap.end()) {
578  std::vector<TypeWithDict> bases;
579  // Run this to check for missing dictionaries, bases is not really used
580  if (!public_base_classes(missingDictionaries, consumedTypeID, bases)) {
581  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
582  }
583  }
584  }
585  if (!missingDictionaries.empty()) {
586  std::string context(
587  "Calling ProductRegistry::initializeLookupTables, checking dictionaries for elements of products consumed "
588  "using View");
589  throwMissingDictionariesException(missingDictionaries, context, consumedTypesWithMissingDictionaries, true);
590  }
591  }
592  }

References edm::TypeWithDict::byName(), edm::checkClassDictionaries(), edm::checkDictionary(), edm::TypeID::className(), edm::productholderindexhelper::getContainedTypeFromWrapper(), edm::public_base_classes(), AlCaHLTBitMon_QueryRunRegistry::string, edm::throwMissingDictionariesException(), pfClustersFromHGC3DClusters_cfi::wp, and edm::wrappedClassName().

Referenced by initializeLookupTables().

◆ checkForDuplicateProcessName()

void edm::ProductRegistry::checkForDuplicateProcessName ( BranchDescription const &  desc,
std::string const *  processName 
) const
private

Definition at line 594 of file ProductRegistry.cc.

595  {
596  if (processName && !desc.produced() && (*processName == desc.processName())) {
597  throw Exception(errors::Configuration, "Duplicate Process Name.\n")
598  << "The process name " << *processName << " was previously used for products in the input.\n"
599  << "Please modify the configuration file to use a distinct process name.\n"
600  << "Alternately, drop all input products using that process name and the\n"
601  << "descendants of those products.\n";
602  }
603  }

References edm::errors::Configuration, submitPVResolutionJobs::desc, Exception, and SimL1EmulatorRepack_CalouGT_cff::processName.

Referenced by initializeLookupTables().

◆ copyProduct()

void edm::ProductRegistry::copyProduct ( BranchDescription const &  productdesc)

Definition at line 122 of file ProductRegistry.cc.

122  {
123  assert(!productDesc.produced());
124  throwIfFrozen();
125  BranchKey k = BranchKey(productDesc);
126  ProductList::iterator iter = productList_.find(k);
127  if (iter == productList_.end()) {
128  productList_.insert(std::make_pair(k, productDesc));
129  } else {
130  assert(combinable(iter->second, productDesc));
131  iter->second.merge(productDesc);
132  }
133  }

References cms::cuda::assert(), edm::combinable(), dqmdumpme::k, edm::BranchDescription::produced(), productList_, and throwIfFrozen().

Referenced by edm::DaqProvenanceHelper::daqInit(), edm::LHEProvenanceHelper::LHEProvenanceHelper(), edm::RootFile::RootFile(), and updateFromInput().

◆ freezeIt()

void edm::ProductRegistry::freezeIt ( bool  frozen = true)
inlineprivate

Definition at line 168 of file ProductRegistry.h.

References frozen(), edm::ProductRegistry::Transients::frozen_, and transient_.

Referenced by ProductRegistry(), and setFrozen().

◆ frozen()

bool edm::ProductRegistry::frozen ( ) const
inline

◆ getNextIndexValue()

ProductResolverIndex const & edm::ProductRegistry::getNextIndexValue ( BranchType  branchType) const

Definition at line 642 of file ProductRegistry.cc.

642  {
643  return transient_.nextIndexValues_[branchType];
644  }

References edm::ProductRegistry::Transients::nextIndexValues_, and transient_.

Referenced by initializeLookupTables(), and merge().

◆ indexFrom()

ProductResolverIndex edm::ProductRegistry::indexFrom ( BranchID const &  iID) const

Definition at line 605 of file ProductRegistry.cc.

605  {
606  std::map<BranchID, ProductResolverIndex>::const_iterator itFind = transient_.branchIDToIndex_.find(iID);
607  if (itFind == transient_.branchIDToIndex_.end()) {
609  }
610  return itFind->second;
611  }

References edm::ProductRegistry::Transients::branchIDToIndex_, edm::ProductResolverIndexInvalid, and transient_.

◆ initializeLookupTables()

void edm::ProductRegistry::initializeLookupTables ( std::set< TypeID > const *  productTypesConsumed,
std::set< TypeID > const *  elementTypesConsumed,
std::string const *  processName 
)
private

Definition at line 295 of file ProductRegistry.cc.

297  {
298  std::map<TypeID, TypeID> containedTypeMap;
299  std::map<TypeID, std::vector<TypeWithDict>> containedTypeToBaseTypesMap;
300 
301  std::vector<std::string> missingDictionaries;
302  std::vector<std::string> branchNamesForMissing;
303  std::vector<std::string> producedTypes;
304 
306 
307  for (auto const& product : productList_) {
308  auto const& desc = product.second;
309 
311 
312  if (desc.produced() && !desc.transient()) {
313  setProductProduced(desc.branchType());
314  }
315 
316  //only do the following if the data is supposed to be available in the event
317  if (desc.present()) {
318  // Check dictionaries (we already checked for the produced ones earlier somewhere else).
319  // We have to have the dictionaries to properly setup the lookup tables for support of
320  // Views. Also we need them to determine which present products are declared to be
321  // consumed in the case where the consumed type is a View<T>.
322  if (!desc.produced()) {
323  if (!checkDictionary(missingDictionaries, desc.className(), desc.unwrappedType())) {
324  checkDictionaryOfWrappedType(missingDictionaries, desc.className());
325  branchNamesForMissing.emplace_back(desc.branchName());
326  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
327  continue;
328  }
329  }
330  TypeID typeID(desc.unwrappedType().typeInfo());
331 
332  auto iterContainedType = containedTypeMap.find(typeID);
333  bool alreadySawThisType = (iterContainedType != containedTypeMap.end());
334 
335  if (!desc.produced() && !alreadySawThisType) {
336  if (!checkDictionary(missingDictionaries, desc.wrappedName(), desc.wrappedType())) {
337  branchNamesForMissing.emplace_back(desc.branchName());
338  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
339  continue;
340  }
341  }
342 
343  TypeID wrappedTypeID(desc.wrappedType().typeInfo());
344 
345  TypeID containedTypeID;
346  if (alreadySawThisType) {
347  containedTypeID = iterContainedType->second;
348  } else {
349  containedTypeID = productholderindexhelper::getContainedTypeFromWrapper(wrappedTypeID, typeID.className());
350  }
351  bool hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
352 
353  std::vector<TypeWithDict>* baseTypesOfContainedType = nullptr;
354 
355  if (!alreadySawThisType) {
356  bool alreadyCheckedConstituents = desc.produced() && !desc.transient();
357  if (!alreadyCheckedConstituents && !desc.transient()) {
358  // This checks dictionaries of the wrapped class and all its constituent classes
359  if (!checkClassDictionaries(missingDictionaries, desc.wrappedName(), desc.wrappedType())) {
360  branchNamesForMissing.emplace_back(desc.branchName());
361  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
362  continue;
363  }
364  }
365 
366  if (hasContainedType) {
367  auto iterBaseTypes = containedTypeToBaseTypesMap.find(containedTypeID);
368  if (iterBaseTypes == containedTypeToBaseTypesMap.end()) {
369  std::vector<TypeWithDict> baseTypes;
370  if (!public_base_classes(missingDictionaries, containedTypeID, baseTypes)) {
371  branchNamesForMissing.emplace_back(desc.branchName());
372  if (desc.produced()) {
373  producedTypes.emplace_back(desc.className() + std::string(" (produced in current process)"));
374  } else {
375  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
376  }
377  continue;
378  }
379  iterBaseTypes = containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, baseTypes)).first;
380  }
381  baseTypesOfContainedType = &iterBaseTypes->second;
382  }
383 
384  // Do this after the dictionary checks of constituents so the list of branch names for missing types
385  // is complete
386  containedTypeMap.emplace(typeID, containedTypeID);
387  } else {
388  if (hasContainedType) {
389  auto iterBaseTypes = containedTypeToBaseTypesMap.find(containedTypeID);
390  if (iterBaseTypes != containedTypeToBaseTypesMap.end()) {
391  baseTypesOfContainedType = &iterBaseTypes->second;
392  }
393  }
394  }
395 
396  if (productTypesConsumed != nullptr && !desc.produced()) {
397  bool mainTypeConsumed = (productTypesConsumed->find(typeID) != productTypesConsumed->end());
398  bool containedTypeConsumed =
399  hasContainedType && (elementTypesConsumed->find(containedTypeID) != elementTypesConsumed->end());
400  if (hasContainedType && !containedTypeConsumed && baseTypesOfContainedType != nullptr) {
401  for (TypeWithDict const& baseType : *baseTypesOfContainedType) {
402  if (elementTypesConsumed->find(TypeID(baseType.typeInfo())) != elementTypesConsumed->end()) {
403  containedTypeConsumed = true;
404  break;
405  }
406  }
407  }
408  if (!containedTypeConsumed) {
409  if (mainTypeConsumed) {
410  // The main type is consumed, but either
411  // there is no contained type, or if there is,
412  // neither it nor any of its base classes are consumed.
413  // Set the contained type, if there is one, to void,
414  if (hasContainedType) {
415  containedTypeID = TypeID(typeid(void));
416  }
417  } else {
418  // The main type is not consumed, and either
419  // there is no contained type, or if there is,
420  // neither it nor any of its base classes are consumed.
421  // Don't insert anything in the lookup tables.
422  continue;
423  }
424  }
425  }
427  ->insert(typeID,
428  desc.moduleLabel().c_str(),
429  desc.productInstanceName().c_str(),
430  desc.processName().c_str(),
431  containedTypeID,
432  baseTypesOfContainedType);
433 
434  transient_.branchIDToIndex_[desc.branchID()] = index;
435  }
436  }
437  if (!missingDictionaries.empty()) {
438  std::string context("Calling ProductRegistry::initializeLookupTables");
439  throwMissingDictionariesException(missingDictionaries, context, producedTypes, branchNamesForMissing);
440  }
441 
442  for (auto& iterProductLookup : transient_.productLookups_) {
443  iterProductLookup->setFrozen();
444  }
445 
446  unsigned int indexIntoNextIndexValue = 0;
447  for (auto const& iterProductLookup : transient_.productLookups_) {
448  transient_.nextIndexValues_[indexIntoNextIndexValue] = iterProductLookup->nextIndexValue();
449  ++indexIntoNextIndexValue;
450  }
451 
452  for (auto const& product : productList_) {
453  auto const& desc = product.second;
454  if (transient_.branchIDToIndex_.find(desc.branchID()) == transient_.branchIDToIndex_.end()) {
455  transient_.branchIDToIndex_[desc.branchID()] = getNextIndexValue(desc.branchType());
456  ++nextIndexValue(desc.branchType());
457  }
458  }
460  productTypesConsumed, elementTypesConsumed, containedTypeMap, containedTypeToBaseTypesMap);
461 
462  addElementTypesForAliases(elementTypesConsumed, containedTypeMap, containedTypeToBaseTypesMap);
463  }

References addElementTypesForAliases(), edm::ProductRegistry::Transients::branchIDToIndex_, edm::checkClassDictionaries(), checkDictionariesOfConsumedTypes(), edm::checkDictionary(), edm::checkDictionaryOfWrappedType(), checkForDuplicateProcessName(), submitPVResolutionJobs::desc, edm::productholderindexhelper::getContainedTypeFromWrapper(), getNextIndexValue(), edm::eventsetup::heterocontainer::insert(), nextIndexValue(), edm::ProductRegistry::Transients::nextIndexValues_, SimL1EmulatorRepack_CalouGT_cff::processName, productList_, productLookup(), edm::ProductRegistry::Transients::productLookups_, edm::public_base_classes(), setProductProduced(), AlCaHLTBitMon_QueryRunRegistry::string, edm::throwMissingDictionariesException(), and transient_.

Referenced by setFrozen().

◆ initializeTransients()

void edm::ProductRegistry::initializeTransients ( )
inline

Definition at line 138 of file ProductRegistry.h.

138 { transient_.reset(); }

References edm::ProductRegistry::Transients::reset(), and transient_.

◆ merge()

std::string edm::ProductRegistry::merge ( ProductRegistry const &  other,
std::string const &  fileName,
BranchDescription::MatchMode  branchesMustMatch = BranchDescription::Permissive 
)

Definition at line 250 of file ProductRegistry.cc.

252  {
253  std::ostringstream differences;
254 
255  ProductRegistry::ProductList::iterator j = productList_.begin();
256  ProductRegistry::ProductList::iterator s = productList_.end();
257  ProductRegistry::ProductList::const_iterator i = other.productList().begin();
258  ProductRegistry::ProductList::const_iterator e = other.productList().end();
259 
260  // Loop over entries in the main product registry.
261  while (j != s || i != e) {
262  if (j != s && j->second.produced()) {
263  // Ignore branches just produced (i.e. not in input file).
264  ++j;
265  } else if (j == s || (i != e && i->first < j->first)) {
266  if (i->second.present()) {
267  differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n";
268  differences << " but not in previous files.\n";
269  } else {
270  productList_.insert(*i);
271  transient_.branchIDToIndex_[i->second.branchID()] = getNextIndexValue(i->second.branchType());
272  ++nextIndexValue(i->second.branchType());
273  }
274  ++i;
275  } else if (i == e || (j != s && j->first < i->first)) {
276  if (j->second.present() && branchesMustMatch == BranchDescription::Strict) {
277  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
278  differences << " but not in file '" << fileName << "'.\n";
279  }
280  ++j;
281  } else {
282  std::string difs = match(j->second, i->second, fileName);
283  if (difs.empty()) {
284  j->second.merge(i->second);
285  } else {
286  differences << difs;
287  }
288  ++i;
289  ++j;
290  }
291  }
292  return differences.str();
293  }

References edm::ProductRegistry::Transients::branchIDToIndex_, MillePedeFileConverter_cfg::e, MillePedeFileConverter_cfg::fileName, getNextIndexValue(), mps_fire::i, dqmiolumiharvest::j, edm::match(), nextIndexValue(), trackingPlots::other, productList_, alignCSCRings::s, edm::BranchDescription::Strict, AlCaHLTBitMon_QueryRunRegistry::string, and transient_.

Referenced by edm::StreamerInputSource::mergeIntoRegistry(), edm::RootPrimaryFileSequence::nextFile(), and edm::RootPrimaryFileSequence::previousFile().

◆ nextIndexValue()

ProductResolverIndex & edm::ProductRegistry::nextIndexValue ( BranchType  branchType)
private

Definition at line 646 of file ProductRegistry.cc.

646  {
647  return transient_.nextIndexValues_[branchType];
648  }

References edm::ProductRegistry::Transients::nextIndexValues_, and transient_.

Referenced by initializeLookupTables(), and merge().

◆ print()

void edm::ProductRegistry::print ( std::ostream &  os) const

Definition at line 636 of file ProductRegistry.cc.

636  {
637  for (auto const& product : productList_) {
638  os << product.second << "\n-----\n";
639  }
640  }

References productList_.

◆ productList()

ProductList const& edm::ProductRegistry::productList ( ) const
inline

◆ productListUpdator()

ProductList& edm::ProductRegistry::productListUpdator ( )
inline

◆ productLookup() [1/2]

std::shared_ptr< ProductResolverIndexHelper > edm::ProductRegistry::productLookup ( BranchType  branchType)

◆ productLookup() [2/2]

std::shared_ptr< ProductResolverIndexHelper const > edm::ProductRegistry::productLookup ( BranchType  branchType) const

◆ productProduced()

bool edm::ProductRegistry::productProduced ( BranchType  branchType) const
inline

Definition at line 121 of file ProductRegistry.h.

121 { return transient_.productProduced_[branchType]; }

References edm::ProductRegistry::Transients::productProduced_, and transient_.

◆ setFrozen() [1/2]

void edm::ProductRegistry::setFrozen ( bool  initializeLookupInfo = true)

◆ setFrozen() [2/2]

void edm::ProductRegistry::setFrozen ( std::set< TypeID > const &  productTypesConsumed,
std::set< TypeID > const &  elementTypesConsumed,
std::string const &  processName 
)

Definition at line 163 of file ProductRegistry.cc.

165  {
166  if (frozen())
167  return;
168  freezeIt();
169  initializeLookupTables(&productTypesConsumed, &elementTypesConsumed, &processName);
171  }

References edm::ProductRegistry::Transients::aliasToOriginal_, freezeIt(), frozen(), initializeLookupTables(), SimL1EmulatorRepack_CalouGT_cff::processName, edm::sort_all(), and transient_.

◆ setProductProduced()

void edm::ProductRegistry::setProductProduced ( BranchType  branchType)
inlineprivate

◆ setUnscheduledProducts()

void edm::ProductRegistry::setUnscheduledProducts ( std::set< std::string > const &  unscheduledLabels)

Definition at line 221 of file ProductRegistry.cc.

221  {
222  throwIfFrozen();
223 
224  bool hasAliases = false;
225  std::vector<BranchID> onDemandIDs;
226  for (auto& prod : productList_) {
227  if (prod.second.produced() && prod.second.branchType() == InEvent &&
228  unscheduledLabels.end() != unscheduledLabels.find(prod.second.moduleLabel())) {
229  prod.second.setOnDemand(true);
230  onDemandIDs.push_back(prod.second.branchID());
231  }
232  if (prod.second.produced() && prod.second.isAlias()) {
233  hasAliases = true;
234  }
235  }
236 
237  // Need to loop over EDAliases to set their on-demand flag based on the pointed-to branch
238  if (hasAliases) {
239  std::sort(onDemandIDs.begin(), onDemandIDs.end());
240  for (auto& prod : productList_) {
241  if (prod.second.isAlias()) {
242  if (std::binary_search(onDemandIDs.begin(), onDemandIDs.end(), prod.second.aliasForBranchID())) {
243  prod.second.setOnDemand(true);
244  }
245  }
246  }
247  }
248  }

References edm::InEvent, dumpMFGeometry_cfg::prod, productList_, jetUpdater_cfi::sort, and throwIfFrozen().

Referenced by edm::SecondaryEventProvider::SecondaryEventProvider().

◆ size()

ProductList::size_type edm::ProductRegistry::size ( void  ) const
inline

◆ throwIfFrozen()

void edm::ProductRegistry::throwIfFrozen ( ) const
private

Definition at line 173 of file ProductRegistry.cc.

173  {
174  if (frozen()) {
175  throw cms::Exception("ProductRegistry", "throwIfFrozen")
176  << "cannot modify the ProductRegistry because it is frozen\n";
177  }
178  }

References Exception, and frozen().

Referenced by addLabelAlias(), addProduct(), copyProduct(), productListUpdator(), and setUnscheduledProducts().

◆ throwIfNotFrozen()

void edm::ProductRegistry::throwIfNotFrozen ( ) const
private

Definition at line 180 of file ProductRegistry.cc.

180  {
181  if (!frozen()) {
182  throw cms::Exception("ProductRegistry", "throwIfNotFrozen")
183  << "cannot read the ProductRegistry because it is not yet frozen\n";
184  }
185  }

References Exception, and frozen().

Referenced by anyProducts().

◆ updateFromInput() [1/2]

void edm::ProductRegistry::updateFromInput ( ProductList const &  other)

◆ updateFromInput() [2/2]

void edm::ProductRegistry::updateFromInput ( std::vector< BranchDescription > const &  other)

Definition at line 215 of file ProductRegistry.cc.

215  {
216  for (BranchDescription const& branchDescription : other) {
217  copyProduct(branchDescription);
218  }
219  }

References copyProduct(), and trackingPlots::other.

Member Data Documentation

◆ productList_

ProductList edm::ProductRegistry::productList_
private

◆ transient_

Transients edm::ProductRegistry::transient_
private
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
edm::ProductRegistry::Transients::productProduced_
std::array< bool, NumBranchTypes > productProduced_
Definition: ProductRegistry.h:148
edm::TypeWithDict::byName
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
edm::ProductRegistry::checkDictionariesOfConsumedTypes
void checkDictionariesOfConsumedTypes(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::map< TypeID, TypeID > const &containedTypeMap, std::map< TypeID, std::vector< TypeWithDict >> &containedTypeToBaseTypesMap)
Definition: ProductRegistry.cc:514
edm::ProductResolverIndex
unsigned int ProductResolverIndex
Definition: ProductResolverIndex.h:8
mps_fire.i
i
Definition: mps_fire.py:428
edm::ProductRegistry::Transients::frozen_
bool frozen_
Definition: ProductRegistry.h:146
edm::throwMissingDictionariesException
void throwMissingDictionariesException(std::vector< std::string > &missingDictionaries, std::string const &context)
Definition: DictionaryTools.cc:193
edm::ProductRegistry::transient_
Transients transient_
Definition: ProductRegistry.h:191
edm::PRODUCT_TYPE
Definition: ProductKindOfType.h:5
edm::ProductRegistry::Transients::productLookups_
std::array< edm::propagate_const< std::shared_ptr< ProductResolverIndexHelper > >, NumBranchTypes > productLookups_
Definition: ProductRegistry.h:151
edm::sort_all
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
bd
deep_tau::DeepTauBase::BasicDiscriminator bd
Definition: DeepTauId.cc:1082
edm::errors::LogicError
Definition: EDMException.h:37
pfClustersFromHGC3DClusters_cfi.wp
wp
Definition: pfClustersFromHGC3DClusters_cfi.py:20
edm::ProductRegistry::size
ProductList::size_type size() const
Definition: ProductRegistry.h:109
deep_tau::DeepTauBase::BasicDiscriminator
BasicDiscriminator
Definition: DeepTauBase.h:115
edm::ProductRegistry::checkForDuplicateProcessName
void checkForDuplicateProcessName(BranchDescription const &desc, std::string const *processName) const
Definition: ProductRegistry.cc:594
callgraph.previous
previous
Definition: callgraph.py:62
cms::cuda::assert
assert(be >=bs)
edm::ProductRegistry::productLookup
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
Definition: ProductRegistry.cc:145
edm::ProductRegistry::Transients::nextIndexValues_
std::array< ProductResolverIndex, NumBranchTypes > nextIndexValues_
Definition: ProductRegistry.h:153
edm::combinable
bool combinable(BranchDescription const &a, BranchDescription const &b)
Definition: BranchDescription.cc:340
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
edm::ProductRegistry::getNextIndexValue
ProductResolverIndex const & getNextIndexValue(BranchType branchType) const
Definition: ProductRegistry.cc:642
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
edm::BranchDescription::Strict
Definition: BranchDescription.h:36
edm::checkDictionaryOfWrappedType
bool checkDictionaryOfWrappedType(std::vector< std::string > &missingDictionaries, TypeID const &unwrappedTypeID)
Definition: DictionaryTools.cc:80
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::productholderindexhelper::getContainedTypeFromWrapper
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
Definition: ProductResolverIndexHelper.cc:19
edm::checkClassDictionaries
bool checkClassDictionaries(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
Definition: DictionaryTools.cc:102
edm::Exception
Definition: EDMException.h:77
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::ProductRegistry::Transients::aliasToOriginal_
AliasToOriginalVector aliasToOriginal_
Definition: ProductRegistry.h:159
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
trackingPlots.other
other
Definition: trackingPlots.py:1460
edm::InEvent
Definition: BranchType.h:11
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::ProductRegistry::throwIfFrozen
void throwIfFrozen() const
Definition: ProductRegistry.cc:173
edm::ProductRegistry::throwIfNotFrozen
void throwIfNotFrozen() const
Definition: ProductRegistry.cc:180
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ProductRegistry::copyProduct
void copyProduct(BranchDescription const &productdesc)
Definition: ProductRegistry.cc:122
edm::ProductRegistry::Transients::branchIDToIndex_
std::map< BranchID, ProductResolverIndex > branchIDToIndex_
Definition: ProductRegistry.h:155
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
edm::ProductRegistry::Transients::reset
void reset()
Definition: ProductRegistry.cc:48
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
edm::ProductResolverIndexInvalid
Definition: ProductResolverIndex.h:16
edm::ProductRegistry::Transients::AliasToOriginalVector
std::vector< std::tuple< KindOfType, TypeID, std::string, std::string, std::string > > AliasToOriginalVector
Definition: ProductRegistry.h:158
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::wrappedClassName
std::string wrappedClassName(std::string const &iFullName)
Definition: WrappedClassName.cc:4
edm::ProductRegistry::productList_
ProductList productList_
Definition: ProductRegistry.h:190
edm::ProductRegistry::setProductProduced
void setProductProduced(BranchType branchType)
Definition: ProductRegistry.h:163
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
edm::ProductRegistry::initializeLookupTables
void initializeLookupTables(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
Definition: ProductRegistry.cc:295
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::ProductRegistry::productList
ProductList const & productList() const
Definition: ProductRegistry.h:76
edm::match
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
Definition: BranchDescription.cc:351
edm::public_base_classes
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeWithDict > &baseTypes)
Definition: DictionaryTools.cc:319
edm::ELEMENT_TYPE
Definition: ProductKindOfType.h:5
edm::ProductRegistry::addCalled
virtual void addCalled(BranchDescription const &, bool iFromListener)
Definition: ProductRegistry.cc:187
Exception
Definition: hltDiff.cc:245
edm::eventsetup::heterocontainer::insert
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
edm::ProductRegistry::frozen
bool frozen() const
Definition: ProductRegistry.h:140
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
edm::checkDictionary
bool checkDictionary(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
Definition: DictionaryTools.cc:67
mps_fire.result
result
Definition: mps_fire.py:311
edm::ProductRegistry::nextIndexValue
ProductResolverIndex & nextIndexValue(BranchType branchType)
Definition: ProductRegistry.cc:646
edm::ProductRegistry::addElementTypesForAliases
void addElementTypesForAliases(std::set< TypeID > const *elementTypesConsumed, std::map< TypeID, TypeID > const &containedTypeMap, std::map< TypeID, std::vector< TypeWithDict >> const &containedTypeToBaseTypesMap)
Definition: ProductRegistry.cc:465
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::ProductRegistry::freezeIt
void freezeIt(bool frozen=true)
Definition: ProductRegistry.h:168
edm::errors::Configuration
Definition: EDMException.h:36
edm::ProductRegistry::Transients::anyProductProduced_
bool anyProductProduced_
Definition: ProductRegistry.h:149
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37