Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:03

0001 #include "DataFormats/Provenance/interface/BranchChildren.h"
0002 
0003 #include "DataFormats/Provenance/interface/BranchDescription.h"
0004 
0005 namespace edm {
0006   void BranchChildren::append_(map_t const& lookup,
0007                                BranchID item,
0008                                BranchIDSet& itemSet,
0009                                std::map<BranchID, BranchID> const& droppedToKeptAlias) const {
0010     auto const iter = lookup.find(item);
0011     if (iter != lookup.end()) {
0012       BranchIDSet const& branchIDs = iter->second;
0013       for (BranchID const& branchID : branchIDs) {
0014         auto it = droppedToKeptAlias.find(branchID);
0015         // Insert the BranchID of the children into the set of descendants.
0016         // If the insert succeeds, append recursively.
0017         if (it == droppedToKeptAlias.end()) {
0018           // Normal case. Not an EDAlias.
0019           if (itemSet.insert(branchID).second) {
0020             append_(lookup, branchID, itemSet, droppedToKeptAlias);
0021           }
0022         } else {
0023           // In this case, we want to put the EDAlias in the
0024           // set of things to drop because that is what really
0025           // needs to be dropped, but the recursive search in
0026           // the lookup map must continue with the original BranchID
0027           // because that is what the lookup map contains.
0028           if (itemSet.insert(it->second).second) {
0029             append_(lookup, branchID, itemSet, droppedToKeptAlias);
0030           }
0031         }
0032       }
0033     }
0034   }
0035 
0036   void BranchChildren::clear() { childLookup_.clear(); }
0037 
0038   void BranchChildren::insertEmpty(BranchID parent) { childLookup_.insert(std::make_pair(parent, BranchIDSet())); }
0039 
0040   void BranchChildren::insertChild(BranchID parent, BranchID child) { childLookup_[parent].insert(child); }
0041 
0042   void BranchChildren::appendToDescendants(BranchDescription const& parent,
0043                                            BranchIDSet& descendants,
0044                                            std::map<BranchID, BranchID> const& droppedToKeptAlias) const {
0045     descendants.insert(parent.branchID());
0046     // A little tricky here. The child lookup map is filled with the
0047     // BranchID of the original product even if there was an EDAlias
0048     // and the EDAlias was saved and the original branch dropped.
0049     append_(childLookup_, parent.originalBranchID(), descendants, droppedToKeptAlias);
0050   }
0051 }  // namespace edm