Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DataFormats/Provenance/interface/ProductRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ namespace edm {
iter->second.merge(prod.second);
}
}
mergeProcessOrderFromAddInput(iReg.processOrder());
}

private:
Expand All @@ -206,6 +207,7 @@ namespace edm {

void checkForDuplicateProcessName(ProductDescription const& desc, std::string const* processName) const;
void updateProcessOrder(std::vector<std::string> const& processOrder);
void mergeProcessOrderFromAddInput(std::vector<std::string> const& processOrder);

void throwIfNotFrozen() const;
void throwIfFrozen() const;
Expand Down
14 changes: 6 additions & 8 deletions DataFormats/Provenance/interface/ProductResolverIndexHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ namespace edm {
char const* moduleLabel,
char const* instance) const;

// Return indexes for all groups that match the type.
Matches relatedIndexes(KindOfType kindOfType, TypeID const& typeID) const;

// This will throw if called after the object is frozen.
// The typeID must be for a type with a dictionary
// (the calling function is expected to check that)
Expand Down Expand Up @@ -196,15 +193,13 @@ namespace edm {
// Before the object is frozen the accessors above will
// fail to find a match. Once frozen, no more new entries
// can be added with insert.
void setFrozen(std::string_view processName);
void setFrozen(std::vector<std::string> const& orderedProcessNames);

/**The list of process names for data products associated to the ProductResolvers.
* If no products are associated with a process for this transition, the process name will not be in this list.
*/
std::vector<std::string> const& lookupProcessNames() const;

bool producesInCurrentProcess() const { return producesInCurrentProcess_; }

class Range {
public:
Range(unsigned int begin, unsigned int end) : begin_(begin), end_(end) {}
Expand Down Expand Up @@ -263,6 +258,10 @@ namespace edm {
// For debugging only
void print(std::ostream& os) const;

//ProcessName label used to denote the current process should be skipped
//used by all methods of this class that accept the process name
static constexpr char const* const skipCurrentProcessLabel() { return "#"; }

private:
// Next available value for a ProductResolverIndex. This just
// increments by one each time a new value is assigned.
Expand Down Expand Up @@ -335,6 +334,7 @@ namespace edm {
ProductResolverIndex index() const { return index_; }

void clearProcess() { process_.clear(); }
void setSkipCurrentProcess() { process_ = ProductResolverIndexHelper::skipCurrentProcessLabel(); }
void setIndex(ProductResolverIndex v) { index_ = v; }

bool operator<(Item const& right) const;
Expand All @@ -351,8 +351,6 @@ namespace edm {
edm::propagate_const<std::unique_ptr<std::set<Item>>> items_;

edm::propagate_const<std::unique_ptr<std::set<std::string>>> processItems_;

bool producesInCurrentProcess_{false};
};
} // namespace edm
#endif
32 changes: 27 additions & 5 deletions DataFormats/Provenance/src/ProductRegistry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,17 @@ namespace edm {
processingOrderMerge(processOrder, transient_.processOrder_);
}

void ProductRegistry::mergeProcessOrderFromAddInput(std::vector<std::string> const& processOrder) {
if (processOrder.empty())
return;
//see if the input already has the current process
if (not transient_.processOrder_.empty() and (transient_.processOrder_[0] != processOrder[0])) {
transient_.processOrder_.insert(transient_.processOrder_.end(), processOrder.begin(), processOrder.end());
} else {
updateProcessOrder(processOrder);
}
}

void ProductRegistry::setUnscheduledProducts(std::set<std::string> const& unscheduledLabels) {
throwIfFrozen();

Expand Down Expand Up @@ -250,9 +261,20 @@ namespace edm {
std::string ProductRegistry::merge(ProductRegistry const& other,
std::string const& fileName,
ProductDescription::MatchMode branchesMustMatch) {
if (branchesMustMatch == ProductDescription::FromInputToCurrent and transient_.processOrder_.size() == 1) {
transient_.processOrder_.insert(
transient_.processOrder_.end(), other.transient_.processOrder_.begin(), other.transient_.processOrder_.end());
if (branchesMustMatch == ProductDescription::FromInputToCurrent) {
if (processOrder().size() == 1 and not other.processOrder().empty() and
processOrder()[0] != other.processOrder()[0]) {
assert(transient_.processOrder_.size() == 1);
transient_.processOrder_.insert(transient_.processOrder_.end(),
other.transient_.processOrder_.begin(),
other.transient_.processOrder_.end());
} else {
//the current process must not change
assert(not processOrder().empty());
auto current = processOrder()[0];
processingOrderMerge(other.processOrder(), transient_.processOrder_);
assert(current == processOrder()[0]);
}
} else {
processingOrderMerge(other.processOrder(), transient_.processOrder_);
}
Expand Down Expand Up @@ -310,6 +332,7 @@ namespace edm {
std::vector<std::string> producedTypes;

transient_.branchIDToIndex_.clear();
assert(productList_.empty() or !processOrder().empty());

std::array<std::shared_ptr<ProductResolverIndexHelper>, NumBranchTypes> new_productLookups{
{std::make_shared<ProductResolverIndexHelper>(),
Expand Down Expand Up @@ -450,9 +473,8 @@ namespace edm {
throwMissingDictionariesException(missingDictionaries, context, producedTypes, branchNamesForMissing);
}

std::string_view processNameSV(processName ? std::string_view(*processName) : std::string_view());
for (auto& iterProductLookup : new_productLookups) {
iterProductLookup->setFrozen(processNameSV);
iterProductLookup->setFrozen(processOrder());
}
for (size_t i = 0; i < new_productLookups.size(); ++i) {
transient_.productLookups_[i] = std::move(new_productLookups[i]);
Expand Down
Loading