26 assert (pHistMap.empty() != pHistVector.empty());
27 for (ProcessHistoryVector::const_iterator
i = pHistVector.begin(),
e = pHistVector.end();
i !=
e; ++
i) {
28 pHistMap.insert(std::make_pair(
i->id(), *
i));
31 for (ProcessHistoryMap::const_iterator
i = pHistMap.begin(),
e = pHistMap.end();
i !=
e; ++
i) {
36 newHist.
emplace_back(it->processName(), newPsetID, it->releaseVersion(), it->passID());
40 pHistVector.push_back(std::move(newHist));
41 if (newphID != oldphID) {
45 assert(pHistVector.size() == pHistMap.size());
50 typedef std::set<OneHistory> Histories;
51 typedef std::pair<std::string, BranchID> Product;
52 typedef std::vector<Product> OrderedProducts;
54 explicit Sorter(Histories
const& histories) : histories_(histories) {}
55 bool operator()(Product
const&
a, Product
const&
b)
const;
56 Histories
const histories_;
58 bool Sorter::operator()(Product
const&
a, Product
const&
b)
const {
60 if (a.first == b.first)
return false;
61 bool mayBeTrue =
false;
62 for (Histories::const_iterator it = histories_.begin(), itEnd = histories_.end(); it != itEnd; ++it) {
63 OneHistory::const_iterator itA =
find_in_all(*it, a.first);
64 if (itA == it->end())
continue;
65 OneHistory::const_iterator itB =
find_in_all(*it, b.first);
66 if (itB == it->end())
continue;
80 procConfigVector.clear();
81 std::set<ProcessConfiguration> pcset;
82 for (
auto const& history : pHistVec) {
83 for (
auto const&
process : history) {
84 if (pcset.insert(
process).second) {
85 procConfigVector.push_back(
process);
92 fillListsAndIndexes(ProductRegistry& productRegistry,
94 std::shared_ptr<BranchIDLists const>& branchIDLists,
95 std::vector<BranchListIndex>& branchListIndexes) {
96 OrderedProducts orderedProducts;
97 std::set<std::string> processNamesThatProduced;
99 for (
auto& item : prodList) {
100 BranchDescription&
prod = item.second;
101 if (prod.branchType() ==
InEvent) {
103 processNamesThatProduced.insert(prod.processName());
104 orderedProducts.emplace_back(prod.processName(), prod.branchID());
107 assert (!orderedProducts.empty());
108 Histories processHistories;
110 for(ProcessHistoryMap::const_iterator it = pHistMap.begin(), itEnd = pHistMap.end(); it != itEnd; ++it) {
111 ProcessHistory
const& pHist = it->second;
112 OneHistory processHistory;
114 if (processNamesThatProduced.find(
i->processName()) != processNamesThatProduced.end()) {
115 processHistory.push_back(
i->processName());
118 max = (processHistory.size() > max ? processHistory.size() :
max);
119 assert(max <= processNamesThatProduced.size());
120 if (processHistory.size() > 1) {
121 processHistories.insert(processHistory);
130 for (OrderedProducts::const_iterator it = orderedProducts.begin(), itEnd = orderedProducts.end(); it != itEnd; ++it) {
131 if (it->first != processName) {
132 if (!processName.empty()) {
133 branchListIndexes.push_back(blix);
135 pv->push_back(std::move(*
p));
138 processName = it->first;
140 p->push_back(it->second.id());
142 branchListIndexes.push_back(blix);
143 pv->push_back(std::move(*
p));
144 branchIDLists.reset(
pv.release());
154 bool fullConversion) :
155 parameterSetIdConverter_(parameterSetIdConverter),
156 processHistoryIdConverter_(),
158 branchListIndexes_() {
160 fillProcessConfiguration(pHistVector, procConfigVector);
161 if (fullConversion) {
186 std::shared_ptr<BranchIDLists const>
std::vector< ProcessHistory > ProcessHistoryVector
collection_type::const_iterator const_iterator
std::vector< ProcessConfiguration > ProcessConfigurationVector
unsigned short BranchListIndex
ProcessHistoryIdConverter processHistoryIdConverter_
std::vector< BranchIDList > BranchIDLists
std::shared_ptr< BranchIDLists const > branchIDLists_
std::map< BranchKey, BranchDescription > ProductList
std::vector< std::string > StringVector
ProvenanceAdaptor(ProductRegistry &productRegistry, ProcessHistoryMap &pHistMap, ProcessHistoryVector &pHistVector, ProcessConfigurationVector &procConfigVector, ParameterSetIdConverter const ¶meterSetIdConverter, bool fullConversion)
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
void emplace_back(Args &&...args)
ParameterSetIdConverter parameterSetIdConverter_
std::vector< BranchListIndex > BranchListIndexes
std::vector< BranchListIndex > branchListIndexes_
std::shared_ptr< BranchIDLists const > branchIDLists() const
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
ParameterSetConverter::ParameterSetIdConverter ParameterSetIdConverter
void fixProcessHistory(ProcessHistoryMap &pHistMap, ProcessHistoryVector &pHistVector)
std::vector< BranchID::value_type > BranchIDList
ParameterSetID const & convertID(ParameterSetID const &oldID) const
ProcessHistoryID id() const
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
EventID const & max(EventID const &lh, EventID const &rh)
void branchListIndexes(BranchListIndexes &indexes) const