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 addFromInput (edm::ProductRegistry const &)
 
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< TypeID >> 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< TypeID >> &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 36 of file ProductRegistry.h.

Member Typedef Documentation

◆ ConstProductList

Definition at line 49 of file ProductRegistry.h.

◆ ProductList

Definition at line 38 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 47 of file ProductRegistry.h.

47 {}

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 addFromInput(), 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< TypeID >> const &  containedTypeToBaseTypesMap 
)
private

Definition at line 480 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables().

483  {
484  Transients::AliasToOriginalVector elementAliases;
485  for (auto& item : transient_.aliasToOriginal_) {
486  auto iterContainedType = containedTypeMap.find(std::get<Transients::kType>(item));
487  if (iterContainedType == containedTypeMap.end()) {
489  ex << "containedTypeMap did not contain " << std::get<Transients::kType>(item).className()
490  << " that is used in EDAlias " << std::get<Transients::kModuleLabel>(item)
491  << ".\nThis should not happen, contact framework developers";
492  ex.addContext("Calling ProductRegistry::initializeLookupTables()");
493  throw ex;
494  }
495  auto const& containedTypeID = iterContainedType->second;
496  bool const hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
497  if (not hasContainedType) {
498  continue;
499  }
500 
501  if (elementTypesConsumed->find(containedTypeID) != elementTypesConsumed->end()) {
502  elementAliases.emplace_back(ELEMENT_TYPE,
503  containedTypeID,
504  std::get<Transients::kModuleLabel>(item),
505  std::get<Transients::kProductInstanceName>(item),
506  std::get<Transients::kAliasForModuleLabel>(item));
507  }
508 
509  auto iterBaseTypes = containedTypeToBaseTypesMap.find(containedTypeID);
510  if (iterBaseTypes == containedTypeToBaseTypesMap.end()) {
511  continue;
512  }
513  for (TypeID const& baseTypeID : iterBaseTypes->second) {
514  if (elementTypesConsumed->find(baseTypeID) != elementTypesConsumed->end()) {
515  elementAliases.emplace_back(ELEMENT_TYPE,
516  baseTypeID,
517  std::get<Transients::kModuleLabel>(item),
518  std::get<Transients::kProductInstanceName>(item),
519  std::get<Transients::kAliasForModuleLabel>(item));
520  }
521  }
522  }
524  std::make_move_iterator(elementAliases.begin()),
525  std::make_move_iterator(elementAliases.end()));
526  }
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

◆ addFromInput()

void edm::ProductRegistry::addFromInput ( edm::ProductRegistry const &  other)

Definition at line 221 of file ProductRegistry.cc.

References addCalled(), cms::cuda::assert(), edm::combinable(), trackingPlots::other, dumpMFGeometry_cfg::prod, productList_, and throwIfFrozen().

221  {
222  throwIfFrozen();
223  for (auto const& prod : other.productList_) {
224  ProductList::iterator iter = productList_.find(prod.first);
225  if (iter == productList_.end()) {
226  productList_.insert(std::make_pair(prod.first, prod.second));
227  addCalled(prod.second, false);
228  } else {
229  assert(combinable(iter->second, prod.second));
230  iter->second.merge(prod.second);
231  }
232  }
233  }
assert(be >=bs)
virtual void addCalled(BranchDescription const &, bool iFromListener)
bool combinable(BranchDescription const &a, BranchDescription const &b)
void throwIfFrozen() const

◆ 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)
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 627 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, transient_, and mkLumiAveragedPlots::tuple.

630  {
631  auto aliasFields = [](auto const& item) {
632  return std::tie(std::get<Transients::kKind>(item),
633  std::get<Transients::kType>(item),
634  std::get<Transients::kModuleLabel>(item),
635  std::get<Transients::kProductInstanceName>(item));
636  };
637  auto const target = std::tuple(kindOfType, type, moduleLabel, productInstanceName);
638  auto found =
641  target,
642  [aliasFields](auto const& item, auto const& target) { return aliasFields(item) < target; });
643  std::vector<std::string> ret;
644  for (; found != transient_.aliasToOriginal_.end() and aliasFields(*found) == target; ++found) {
645  ret.emplace_back(std::get<Transients::kAliasForModuleLabel>(*found));
646  }
647  return ret;
648  }
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 ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, 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 102 of file ProductRegistry.h.

References productList_.

Referenced by edm::ProducerBase< edm::global::EDProducer, Args... >::registerProducts(), edm::stream::EDAnalyzerBase::registerProductsAndCallbacks(), edm::one::EDAnalyzerBase::registerProductsAndCallbacks(), edm::global::EDAnalyzerBase::registerProductsAndCallbacks(), edm::limited::EDAnalyzerBase::registerProductsAndCallbacks(), and edm::core::OutputModuleCore::registerProductsAndCallbacks().

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

◆ 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< TypeID >> &  containedTypeToBaseTypesMap 
)
private

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

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

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

Referenced by initializeLookupTables().

609  {
610  if (processName && !desc.produced() && (*processName == desc.processName())) {
611  throw Exception(errors::Configuration, "Duplicate Process Name.\n")
612  << "The process name " << *processName << " was previously used for products in the input.\n"
613  << "Please modify the configuration file to use a distinct process name.\n"
614  << "Alternately, drop all input products using that process name and the\n"
615  << "descendants of those products.\n";
616  }
617  }

◆ 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(), edmtest::PutOrMergeTestSource::registerProducts(), 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 656 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables(), and merge().

656  {
657  return transient_.nextIndexValues_[branchType];
658  }
std::array< ProductResolverIndex, NumBranchTypes > nextIndexValues_

◆ indexFrom()

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

Definition at line 619 of file ProductRegistry.cc.

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

619  {
620  std::map<BranchID, ProductResolverIndex>::const_iterator itFind = transient_.branchIDToIndex_.find(iID);
621  if (itFind == transient_.branchIDToIndex_.end()) {
623  }
624  return itFind->second;
625  }
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 310 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().

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

266  {
267  std::ostringstream differences;
268 
269  ProductRegistry::ProductList::iterator j = productList_.begin();
270  ProductRegistry::ProductList::iterator s = productList_.end();
271  ProductRegistry::ProductList::const_iterator i = other.productList().begin();
272  ProductRegistry::ProductList::const_iterator e = other.productList().end();
273 
274  // Loop over entries in the main product registry.
275  while (j != s || i != e) {
276  if (j != s && j->second.produced()) {
277  // Ignore branches just produced (i.e. not in input file).
278  ++j;
279  } else if (j == s || (i != e && i->first < j->first)) {
280  if (i->second.present()) {
281  differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n";
282  differences << " but not in previous files.\n";
283  } else {
284  productList_.insert(*i);
285  transient_.branchIDToIndex_[i->second.branchID()] = getNextIndexValue(i->second.branchType());
286  ++nextIndexValue(i->second.branchType());
287  }
288  ++i;
289  } else if (i == e || (j != s && j->first < i->first)) {
290  if (j->second.present() &&
291  (branchesMustMatch == BranchDescription::Strict || j->second.branchType() == InProcess)) {
292  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
293  differences << " but not in file '" << fileName << "'.\n";
294  }
295  ++j;
296  } else {
297  std::string difs = match(j->second, i->second, fileName);
298  if (difs.empty()) {
299  j->second.merge(i->second);
300  } else {
301  differences << difs;
302  }
303  ++i;
304  ++j;
305  }
306  }
307  return differences.str();
308  }
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 660 of file ProductRegistry.cc.

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

Referenced by initializeLookupTables(), and merge().

660  {
661  return transient_.nextIndexValues_[branchType];
662  }
std::array< ProductResolverIndex, NumBranchTypes > nextIndexValues_

◆ print()

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

Definition at line 650 of file ProductRegistry.cc.

References productList_.

650  {
651  for (auto const& product : productList_) {
652  os << product.second << "\n-----\n";
653  }
654  }

◆ 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 125 of file ProductRegistry.h.

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

125 { 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 edm::Schedule::finishSetup(), 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 235 of file ProductRegistry.cc.

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

Referenced by edm::Schedule::finishSetup(), and edm::SecondaryEventProvider::SecondaryEventProvider().

235  {
236  throwIfFrozen();
237 
238  bool hasAliases = false;
239  std::vector<BranchID> onDemandIDs;
240  for (auto& prod : productList_) {
241  if (prod.second.produced() && prod.second.branchType() == InEvent &&
242  unscheduledLabels.end() != unscheduledLabels.find(prod.second.moduleLabel())) {
243  prod.second.setOnDemand(true);
244  onDemandIDs.push_back(prod.second.branchID());
245  }
246  if (prod.second.produced() && prod.second.isAlias()) {
247  hasAliases = true;
248  }
249  }
250 
251  // Need to loop over EDAliases to set their on-demand flag based on the pointed-to branch
252  if (hasAliases) {
253  std::sort(onDemandIDs.begin(), onDemandIDs.end());
254  for (auto& prod : productList_) {
255  if (prod.second.isAlias()) {
256  if (std::binary_search(onDemandIDs.begin(), onDemandIDs.end(), prod.second.aliasForBranchID())) {
257  prod.second.setOnDemand(true);
258  }
259  }
260  }
261  }
262  }
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 addFromInput(), 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