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 <<
"The produced product " << previous.second <<
" is registered more than once.\n" 90 <<
"Please remove the redundant 'produces' call(s).\n";
94 <<
"The process name " << productDesc.
processName() <<
" was previously used for products in the input.\n" 95 <<
"This has caused branch name conflicts between input products and new products.\n" 96 <<
"Please modify the configuration file to use a distinct process name.\n" 97 <<
"Alternately, drop all input products using that process name and the\n" 98 <<
"descendants of those products.\n";
112 std::pair<ProductList::iterator, bool> ret =
129 assert(
combinable(iter->second, productDesc));
130 iter->second.merge(productDesc);
139 if(it->second.branchType() == brType) {
146 std::shared_ptr<ProductResolverIndexHelper const>
153 std::shared_ptr<ProductResolverIndexHelper>
164 if(initializeLookupInfo) {
172 std::set<TypeID>
const& elementTypesConsumed,
184 <<
"cannot modify the ProductRegistry because it is frozen\n";
192 <<
"cannot read the ProductRegistry because it is not yet frozen\n";
200 std::vector<std::string>
202 std::vector<std::string>
result;
206 result.push_back(product.second.branchName());
211 std::vector<BranchDescription const*>
213 std::vector<BranchDescription const*>
result;
217 result.push_back(&product.second);
224 for(
auto const& product : other) {
240 std::ostringstream differences;
242 ProductRegistry::ProductList::iterator j =
productList_.begin();
243 ProductRegistry::ProductList::iterator
s =
productList_.end();
244 ProductRegistry::ProductList::const_iterator
i = other.
productList().begin();
245 ProductRegistry::ProductList::const_iterator
e = other.
productList().end();
248 while(j != s || i != e) {
249 if(j != s && j->second.produced()) {
252 }
else if(j == s || (i != e && i->first < j->first)) {
253 if(i->second.present()) {
254 differences <<
"Branch '" << i->second.branchName() <<
"' is in file '" << fileName <<
"'\n";
255 differences <<
" but not in previous files.\n";
262 }
else if(i == e || (j != s && j->first < i->first)) {
264 differences <<
"Branch '" << j->second.branchName() <<
"' is in previous files\n";
265 differences <<
" but not in file '" << fileName <<
"'.\n";
271 j->second.merge(i->second);
279 return differences.str();
283 std::set<TypeID>
const* elementTypesConsumed,
286 std::map<TypeID, TypeID> containedTypeMap;
287 std::map<TypeID, std::vector<TypeWithDict> > containedTypeToBaseTypesMap;
289 std::vector<std::string> missingDictionaries;
290 std::vector<std::string> branchNamesForMissing;
291 std::vector<std::string> producedTypes;
296 auto const& desc = product.second;
300 if(desc.produced()) {
311 if (!desc.produced()) {
312 if (!
checkDictionary(missingDictionaries, desc.className(), desc.unwrappedType())) {
314 branchNamesForMissing.emplace_back(desc.branchName());
315 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
319 TypeID typeID(desc.unwrappedType().typeInfo());
321 auto iter = containedTypeMap.find(typeID);
322 bool alreadySawThisType = (iter != containedTypeMap.end());
324 if (!desc.produced() && !alreadySawThisType) {
325 if (!
checkDictionary(missingDictionaries, desc.wrappedName(), desc.wrappedType())) {
326 branchNamesForMissing.emplace_back(desc.branchName());
327 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
332 TypeID wrappedTypeID(desc.wrappedType().typeInfo());
335 if (alreadySawThisType) {
336 containedTypeID = iter->second;
340 bool hasContainedType = (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID());
342 std::vector<TypeWithDict>* baseTypesOfContainedType =
nullptr;
344 if (!alreadySawThisType) {
345 bool alreadyCheckedConstituents = desc.produced() && !desc.transient();
346 if (!alreadyCheckedConstituents && !desc.transient()) {
349 branchNamesForMissing.emplace_back(desc.branchName());
350 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
355 if (hasContainedType) {
356 auto iter = containedTypeToBaseTypesMap.find(containedTypeID);
357 if (iter == containedTypeToBaseTypesMap.end()) {
358 std::vector<TypeWithDict> baseTypes;
360 branchNamesForMissing.emplace_back(desc.branchName());
361 if (desc.produced()) {
362 producedTypes.emplace_back(desc.className() +
std::string(
" (produced in current process)"));
364 producedTypes.emplace_back(desc.className() +
std::string(
" (read from input)"));
368 iter = containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, baseTypes)).first;
370 baseTypesOfContainedType = &iter->second;
375 containedTypeMap.emplace(typeID, containedTypeID);
377 if (hasContainedType) {
378 auto iter = containedTypeToBaseTypesMap.find(containedTypeID);
379 if (iter != containedTypeToBaseTypesMap.end()) {
380 baseTypesOfContainedType = &iter->second;
385 if(productTypesConsumed !=
nullptr && !desc.produced()) {
386 bool mainTypeConsumed = (productTypesConsumed->find(typeID) != productTypesConsumed->end());
387 bool containedTypeConsumed = hasContainedType && (elementTypesConsumed->find(containedTypeID) != elementTypesConsumed->end());
388 if(hasContainedType && !containedTypeConsumed && baseTypesOfContainedType !=
nullptr) {
389 for(
TypeWithDict const& baseType : *baseTypesOfContainedType) {
390 if(elementTypesConsumed->find(
TypeID(baseType.typeInfo())) != elementTypesConsumed->end()) {
391 containedTypeConsumed =
true;
396 if(!containedTypeConsumed) {
397 if(mainTypeConsumed) {
402 if(hasContainedType) {
403 containedTypeID =
TypeID(
typeid(
void));
416 desc.moduleLabel().c_str(),
417 desc.productInstanceName().c_str(),
418 desc.processName().c_str(),
420 baseTypesOfContainedType);
425 if (!missingDictionaries.empty()) {
426 std::string context(
"Calling ProductRegistry::initializeLookupTables");
438 for(
auto const& product : productList_) {
439 auto const& desc = product.second;
450 std::set<TypeID>
const* elementTypesConsumed,
451 std::map<TypeID, TypeID>
const& containedTypeMap,
452 std::map<
TypeID, std::vector<TypeWithDict> >& containedTypeToBaseTypesMap) {
454 std::vector<std::string> missingDictionaries;
455 std::set<std::string> consumedTypesWithMissingDictionaries;
457 if (productTypesConsumed) {
461 for (
auto const& consumedTypeID : *productTypesConsumed) {
466 if (containedTypeMap.find(consumedTypeID) == containedTypeMap.end()) {
472 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
475 bool transient =
false;
476 TDictAttributeMap* wp = wrappedType.getClass()->GetAttributeMap();
477 if (wp && wp->HasKey(
"persistent") && !strcmp(wp->GetPropertyAsString(
"persistent"),
"false")) {
482 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
486 bool hasContainedType = (containedTypeID !=
TypeID(
typeid(
void)) && containedTypeID !=
TypeID());
487 if (hasContainedType) {
488 if (containedTypeToBaseTypesMap.find(containedTypeID) == containedTypeToBaseTypesMap.end()) {
489 std::vector<TypeWithDict> bases;
492 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
494 containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, bases));
499 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
504 if (!missingDictionaries.empty()) {
505 std::string context(
"Calling ProductRegistry::initializeLookupTables, checking dictionaries for consumed products");
510 if (elementTypesConsumed) {
511 missingDictionaries.clear();
512 consumedTypesWithMissingDictionaries.clear();
513 for (
auto const& consumedTypeID : *elementTypesConsumed) {
514 if (containedTypeToBaseTypesMap.find(consumedTypeID) == containedTypeToBaseTypesMap.end()) {
515 std::vector<TypeWithDict> bases;
518 consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
522 if (!missingDictionaries.empty()) {
523 std::string context(
"Calling ProductRegistry::initializeLookupTables, checking dictionaries for elements of products consumed using View");
536 <<
"The process name " << *processName <<
" was previously used for products in the input.\n" 537 <<
"Please modify the configuration file to use a distinct process name.\n" 538 <<
"Alternately, drop all input products using that process name and the\n" 539 <<
"descendants of those products.\n";
548 return itFind->second;
553 os << product.second <<
"\n-----\n";
edm::propagate_const< std::shared_ptr< ProductResolverIndexHelper > > lumiProductLookup_
void setProductProduced(BranchType branchType)
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)
boost::array< bool, NumBranchTypes > productProduced_
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)
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)