22 #include "TDictAttributeMap.h" 41 anyProductProduced_(
false),
45 eventNextIndexValue_(0),
46 lumiNextIndexValue_(0),
47 runNextIndexValue_(0),
82 std::pair<ProductList::iterator, bool> ret =
86 if(previous.second.produced()) {
89 <<
"\nThe Framework requires a unique branch name for each product\n" 90 <<
"which consists of four parts: a friendly class name, module label,\n" 91 <<
"product instance name, and process name. A product has been\n" 92 <<
"registered with a duplicate branch name. The most common way\n" 93 <<
"to fix this error is to modify the product instance name in\n" 94 <<
"one of the offending 'produces' function calls. Another fix\n" 95 <<
"would be to delete one of them if they are for the same product.\n\n" 96 <<
" friendly class name = " << previous.second.friendlyClassName() <<
"\n" 97 <<
" module label = " << previous.second.moduleLabel() <<
"\n" 98 <<
" product instance name = " << previous.second.productInstanceName() <<
"\n" 99 <<
" process name = " << previous.second.processName() <<
"\n\n" 100 <<
"The following additional information is not used as part of\n" 101 <<
"the unique branch identifier.\n\n" 102 <<
" branch types = " << previous.second.branchType() <<
" " << productDesc.
branchType() <<
"\n" 103 <<
" class name = " << previous.second.fullClassName() <<
"\n\n" 104 <<
"Note that if the four parts of the branch name are the same,\n" 105 <<
"then this error will occur even if the branch types differ!\n\n";
109 <<
"The process name " << productDesc.
processName() <<
" was previously used for products in the input.\n" 110 <<
"This has caused branch name conflicts between input products and new products.\n" 111 <<
"Please modify the configuration file to use a distinct process name.\n" 112 <<
"Alternately, drop all input products using that process name and the\n" 113 <<
"descendants of those products.\n";
127 std::pair<ProductList::iterator, bool> ret =
144 assert(
combinable(iter->second, productDesc));
145 iter->second.merge(productDesc);
154 if(it->second.branchType() == brType) {
161 std::shared_ptr<ProductResolverIndexHelper const>
168 std::shared_ptr<ProductResolverIndexHelper>
179 if(initializeLookupInfo) {
187 std::set<TypeID>
const& elementTypesConsumed,
199 <<
"cannot modify the ProductRegistry because it is frozen\n";
207 <<
"cannot read the ProductRegistry because it is not yet frozen\n";
215 std::vector<std::string>
217 std::vector<std::string>
result;
221 result.push_back(product.second.branchName());
226 std::vector<BranchDescription const*>
228 std::vector<BranchDescription const*>
result;
232 result.push_back(&product.second);
239 for(
auto const& product : other) {
255 std::ostringstream differences;
257 ProductRegistry::ProductList::iterator j =
productList_.begin();
258 ProductRegistry::ProductList::iterator
s =
productList_.end();
259 ProductRegistry::ProductList::const_iterator
i = other.
productList().begin();
260 ProductRegistry::ProductList::const_iterator
e = other.
productList().end();
263 while(j != s || i != e) {
264 if(j != s && j->second.produced()) {
267 }
else if(j == s || (i != e && i->first < j->first)) {
268 if(i->second.present()) {
269 differences <<
"Branch '" << i->second.branchName() <<
"' is in file '" << fileName <<
"'\n";
270 differences <<
" but not in previous files.\n";
277 }
else if(i == e || (j != s && j->first < i->first)) {
279 differences <<
"Branch '" << j->second.branchName() <<
"' is in previous files\n";
280 differences <<
" but not in file '" << fileName <<
"'.\n";
286 j->second.merge(i->second);
294 return differences.str();
298 std::set<TypeID>
const* elementTypesConsumed,
301 std::map<TypeID, TypeID> containedTypeMap;
302 std::map<TypeID, std::vector<TypeWithDict> > containedTypeToBaseTypesMap;
304 std::vector<std::string> missingDictionaries;
305 std::vector<std::string> branchNamesForMissing;
306 std::vector<std::string> producedTypes;
311 auto const& desc = product.second;
315 if(desc.produced() && !desc.transient()) {
326 if (!desc.produced()) {
327 if (!
checkDictionary(missingDictionaries, desc.className(), desc.unwrappedType())) {
329 branchNamesForMissing.emplace_back(desc.branchName());
330 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
334 TypeID typeID(desc.unwrappedType().typeInfo());
336 auto iter = containedTypeMap.find(typeID);
337 bool alreadySawThisType = (iter != containedTypeMap.end());
339 if (!desc.produced() && !alreadySawThisType) {
340 if (!
checkDictionary(missingDictionaries, desc.wrappedName(), desc.wrappedType())) {
341 branchNamesForMissing.emplace_back(desc.branchName());
342 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
347 TypeID wrappedTypeID(desc.wrappedType().typeInfo());
350 if (alreadySawThisType) {
351 containedTypeID = iter->second;
355 bool hasContainedType = (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID());
357 std::vector<TypeWithDict>* baseTypesOfContainedType =
nullptr;
359 if (!alreadySawThisType) {
360 bool alreadyCheckedConstituents = desc.produced() && !desc.transient();
361 if (!alreadyCheckedConstituents && !desc.transient()) {
364 branchNamesForMissing.emplace_back(desc.branchName());
365 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
370 if (hasContainedType) {
371 auto iter = containedTypeToBaseTypesMap.find(containedTypeID);
372 if (iter == containedTypeToBaseTypesMap.end()) {
373 std::vector<TypeWithDict> baseTypes;
375 branchNamesForMissing.emplace_back(desc.branchName());
376 if (desc.produced()) {
377 producedTypes.emplace_back(desc.className() +
std::string(
" (produced in current process)"));
379 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
383 iter = containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, baseTypes)).first;
385 baseTypesOfContainedType = &iter->second;
390 containedTypeMap.emplace(typeID, containedTypeID);
392 if (hasContainedType) {
393 auto iter = containedTypeToBaseTypesMap.find(containedTypeID);
394 if (iter != containedTypeToBaseTypesMap.end()) {
395 baseTypesOfContainedType = &iter->second;
400 if(productTypesConsumed !=
nullptr && !desc.produced()) {
401 bool mainTypeConsumed = (productTypesConsumed->find(typeID) != productTypesConsumed->end());
402 bool containedTypeConsumed = hasContainedType && (elementTypesConsumed->find(containedTypeID) != elementTypesConsumed->end());
403 if(hasContainedType && !containedTypeConsumed && baseTypesOfContainedType !=
nullptr) {
404 for(
TypeWithDict const& baseType : *baseTypesOfContainedType) {
405 if(elementTypesConsumed->find(
TypeID(baseType.typeInfo())) != elementTypesConsumed->end()) {
406 containedTypeConsumed =
true;
411 if(!containedTypeConsumed) {
412 if(mainTypeConsumed) {
417 if(hasContainedType) {
418 containedTypeID =
TypeID(
typeid(
void));
431 desc.moduleLabel().c_str(),
432 desc.productInstanceName().c_str(),
433 desc.processName().c_str(),
435 baseTypesOfContainedType);
440 if (!missingDictionaries.empty()) {
441 std::string context(
"Calling ProductRegistry::initializeLookupTables");
453 for(
auto const& product : productList_) {
454 auto const& desc = product.second;
465 std::set<TypeID>
const* elementTypesConsumed,
466 std::map<TypeID, TypeID>
const& containedTypeMap,
467 std::map<
TypeID, std::vector<TypeWithDict> >& containedTypeToBaseTypesMap) {
469 std::vector<std::string> missingDictionaries;
470 std::set<std::string> consumedTypesWithMissingDictionaries;
472 if (productTypesConsumed) {
476 for (
auto const& consumedTypeID : *productTypesConsumed) {
481 if (containedTypeMap.find(consumedTypeID) == containedTypeMap.end()) {
487 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
490 bool transient =
false;
491 TDictAttributeMap* wp = wrappedType.getClass()->GetAttributeMap();
492 if (wp && wp->HasKey(
"persistent") && !strcmp(wp->GetPropertyAsString(
"persistent"),
"false")) {
497 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
501 bool hasContainedType = (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID());
502 if (hasContainedType) {
503 if (containedTypeToBaseTypesMap.find(containedTypeID) == containedTypeToBaseTypesMap.end()) {
504 std::vector<TypeWithDict> bases;
507 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
509 containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, bases));
514 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
519 if (!missingDictionaries.empty()) {
520 std::string context(
"Calling ProductRegistry::initializeLookupTables, checking dictionaries for consumed products");
525 if (elementTypesConsumed) {
526 missingDictionaries.clear();
527 consumedTypesWithMissingDictionaries.clear();
528 for (
auto const& consumedTypeID : *elementTypesConsumed) {
529 if (containedTypeToBaseTypesMap.find(consumedTypeID) == containedTypeToBaseTypesMap.end()) {
530 std::vector<TypeWithDict> bases;
533 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
537 if (!missingDictionaries.empty()) {
538 std::string context(
"Calling ProductRegistry::initializeLookupTables, checking dictionaries for elements of products consumed using View");
551 <<
"The process name " << *processName <<
" was previously used for products in the input.\n" 552 <<
"Please modify the configuration file to use a distinct process name.\n" 553 <<
"Alternately, drop all input products using that process name and the\n" 554 <<
"descendants of those products.\n";
563 return itFind->second;
568 os << product.second <<
"\n-----\n";
edm::propagate_const< std::shared_ptr< ProductResolverIndexHelper > > lumiProductLookup_
void setProductProduced(BranchType branchType)
BranchType const & branchType() const
void throwMissingDictionariesException(std::vector< std::string > &missingDictionaries, std::string const &context)
unsigned int ProductResolverIndex
void throwIfNotFrozen() const
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
std::vector< std::string > allBranchNames() const
std::map< BranchKey, BranchDescription > ProductList
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeWithDict > &baseTypes)
bool anyProducts(BranchType const brType) const
std::string const & processName() const
std::shared_ptr< ProductResolverIndexHelper const > lumiProductLookup() const
ProductList::size_type size() const
void addLabelAlias(BranchDescription const &productdesc, std::string const &labelAlias, std::string const &instanceAlias)
std::shared_ptr< ProductResolverIndexHelper const > eventProductLookup() const
virtual void addCalled(BranchDescription const &, bool iFromListener)
static TypeWithDict byName(std::string const &name)
ProductList const & productList() const
void initializeLookupTables(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
std::string const & moduleLabel() const
ProductResolverIndex eventNextIndexValue_
bool combinable(BranchDescription const &a, BranchDescription const &b)
bool checkDictionary(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
std::shared_ptr< ProductResolverIndexHelper const > runProductLookup() const
ProductResolverIndex lumiNextIndexValue_
void checkForDuplicateProcessName(BranchDescription const &desc, std::string const *processName) const
ProductResolverIndex & nextIndexValue(BranchType branchType)
bool checkClassDictionaries(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
std::vector< BranchDescription const * > allBranchDescriptions() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
BranchID const & branchID() const
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
void setFrozen(bool initializeLookupInfo=true)
void freezeIt(bool frozen=true)
void print(std::ostream &os) const
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
ProductResolverIndex runNextIndexValue_
std::string wrappedClassName(std::string const &iFullName)
std::vector< std::pair< std::string, std::string > > aliasToOriginal_
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
ProductResolverIndex const & getNextIndexValue(BranchType branchType) const
void throwIfFrozen() const
std::string const & className() const
void updateFromInput(ProductList const &other)
bool checkDictionaryOfWrappedType(std::vector< std::string > &missingDictionaries, TypeID const &unwrappedTypeID)
std::array< bool, NumBranchTypes > productProduced_
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)
edm::propagate_const< std::shared_ptr< ProductResolverIndexHelper > > eventProductLookup_
ProductResolverIndex indexFrom(BranchID const &iID) const
void addProduct(BranchDescription const &productdesc, bool iFromListener=false)
std::map< BranchID, ProductResolverIndex > branchIDToIndex_
edm::propagate_const< std::shared_ptr< ProductResolverIndexHelper > > runProductLookup_
def branchType(schema, name)
void copyProduct(BranchDescription const &productdesc)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)