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< ProductResolverIndexHelper const > productLookup (BranchType branchType) const
 
std::shared_ptr< ProductResolverIndexHelperproductLookup (BranchType branchType)
 
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

author Stefano ARGIRO 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.

References freezeIt().

65  freezeIt(toBeFrozen);
66  }
ProductList const & productList() const
void freezeIt(bool frozen=true)

◆ ~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.

Referenced by addLabelAlias(), and addProduct().

187 {}

◆ 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 466 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables().

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

◆ addLabelAlias()

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

Definition at line 108 of file ProductRegistry.cc.

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

Referenced by edm::detail::processEDAliases().

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  }
ret
prodAgent to be discontinued
assert(be >=bs)
AliasToOriginalVector aliasToOriginal_
virtual void addCalled(BranchDescription const &, bool iFromListener)
deep_tau::DeepTauBase::BasicDiscriminator bd
Definition: DeepTauId.cc:808
void throwIfFrozen() const

◆ addProduct()

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

Definition at line 68 of file ProductRegistry.cc.

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

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  }
ret
prodAgent to be discontinued
assert(be >=bs)
virtual void addCalled(BranchDescription const &, bool iFromListener)
void throwIfFrozen() const

◆ 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 614 of file ProductRegistry.cc.

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

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

◆ allBranchDescriptions()

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

Definition at line 199 of file ProductRegistry.cc.

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

Referenced by edm::RootFile::dropOnInputAndReorder(), edm::SubProcess::selectProducts(), edm::core::OutputModuleCore::selectProducts(), and edm::PrincipalGetAdapter::throwUnregisteredPutException().

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  }
ProductList const & productList() const
ProductList::size_type size() const

◆ allBranchNames()

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

Definition at line 189 of file ProductRegistry.cc.

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

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  }
ProductList const & productList() const
ProductList::size_type size() const

◆ anyProductProduced()

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

◆ anyProducts()

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

Definition at line 135 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

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  }
void throwIfNotFrozen() const

◆ callForEachBranch()

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

Definition at line 100 of file ProductRegistry.h.

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

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  }

◆ 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 515 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables().

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

◆ checkForDuplicateProcessName()

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

Definition at line 595 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables().

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

◆ copyProduct()

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

Definition at line 122 of file ProductRegistry.cc.

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

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  }
assert(be >=bs)
bool combinable(BranchDescription const &a, BranchDescription const &b)
void throwIfFrozen() const

◆ freezeIt()

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

◆ frozen()

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

◆ getNextIndexValue()

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

Definition at line 643 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables(), and merge().

643  {
644  return transient_.nextIndexValues_[branchType];
645  }
std::array< ProductResolverIndex, NumBranchTypes > nextIndexValues_

◆ indexFrom()

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

Definition at line 606 of file ProductRegistry.cc.

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

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

◆ initializeLookupTables()

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

Definition at line 296 of file ProductRegistry.cc.

References addElementTypesForAliases(), edm::ProductRegistry::Transients::branchIDToIndex_, edm::checkClassDictionaries(), checkDictionariesOfConsumedTypes(), edm::checkDictionary(), edm::checkDictionaryOfWrappedType(), checkForDuplicateProcessName(), visDQMUpload::context, 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().

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

◆ initializeTransients()

void edm::ProductRegistry::initializeTransients ( )
inline

◆ 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.

References edm::ProductRegistry::Transients::branchIDToIndex_, MillePedeFileConverter_cfg::e, MillePedeFileConverter_cfg::fileName, getNextIndexValue(), mps_fire::i, edm::InProcess, 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().

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() &&
277  (branchesMustMatch == BranchDescription::Strict || j->second.branchType() == InProcess)) {
278  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
279  differences << " but not in file '" << fileName << "'.\n";
280  }
281  ++j;
282  } else {
283  std::string difs = match(j->second, i->second, fileName);
284  if (difs.empty()) {
285  j->second.merge(i->second);
286  } else {
287  differences << difs;
288  }
289  ++i;
290  ++j;
291  }
292  }
293  return differences.str();
294  }
ProductResolverIndex & nextIndexValue(BranchType branchType)
ProductResolverIndex const & getNextIndexValue(BranchType branchType) const
std::map< BranchID, ProductResolverIndex > branchIDToIndex_
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)

◆ nextIndexValue()

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

Definition at line 647 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables(), and merge().

647  {
648  return transient_.nextIndexValues_[branchType];
649  }
std::array< ProductResolverIndex, NumBranchTypes > nextIndexValues_

◆ print()

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

Definition at line 637 of file ProductRegistry.cc.

References productList_.

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

◆ productList()

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

◆ productListUpdator()

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

◆ productLookup() [1/2]

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

Definition at line 145 of file ProductRegistry.cc.

References edm::get_underlying_safe(), edm::ProductRegistry::Transients::productLookups_, and transient_.

Referenced by edm::WorkerManager::beginJob(), edm::Schedule::changeModule(), initializeLookupTables(), and edm::EDConsumerBase::modulesWhoseProductsAreConsumed().

145  {
146  return get_underlying_safe(transient_.productLookups_[branchType]);
147  }
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::array< edm::propagate_const< std::shared_ptr< ProductResolverIndexHelper > >, NumBranchTypes > productLookups_

◆ productLookup() [2/2]

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

Definition at line 149 of file ProductRegistry.cc.

References edm::get_underlying_safe(), edm::ProductRegistry::Transients::productLookups_, and transient_.

149  {
150  return get_underlying_safe(transient_.productLookups_[branchType]);
151  }
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::array< edm::propagate_const< std::shared_ptr< ProductResolverIndexHelper > >, NumBranchTypes > productLookups_

◆ productProduced()

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

Definition at line 121 of file ProductRegistry.h.

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

121 { return transient_.productProduced_[branchType]; }
std::array< bool, NumBranchTypes > productProduced_

◆ setFrozen() [1/2]

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

Definition at line 153 of file ProductRegistry.cc.

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

Referenced by fwlite::internal::BranchMapReaderStrategyV8::updateFile(), fwlite::internal::BranchMapReaderStrategyV11::updateFile(), fwlite::internal::BranchMapReaderStrategyV17::updateFile(), and fwlite::internal::BranchMapReaderStrategyV1::updateMap().

153  {
154  if (frozen())
155  return;
156  freezeIt();
157  if (initializeLookupInfo) {
158  initializeLookupTables(nullptr, nullptr, nullptr);
159  }
161  }
AliasToOriginalVector aliasToOriginal_
void initializeLookupTables(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
void freezeIt(bool frozen=true)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92

◆ 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.

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

165  {
166  if (frozen())
167  return;
168  freezeIt();
169  initializeLookupTables(&productTypesConsumed, &elementTypesConsumed, &processName);
171  }
AliasToOriginalVector aliasToOriginal_
void initializeLookupTables(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
void freezeIt(bool frozen=true)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92

◆ 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.

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

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

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  }
void throwIfFrozen() const

◆ 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.

References Exception, and frozen().

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

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

◆ throwIfNotFrozen()

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

Definition at line 180 of file ProductRegistry.cc.

References Exception, and frozen().

Referenced by anyProducts().

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

◆ 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.

References copyProduct(), and trackingPlots::other.

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

Member Data Documentation

◆ productList_

ProductList edm::ProductRegistry::productList_
private

◆ transient_

Transients edm::ProductRegistry::transient_
private