Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*----------------------------------------------------------------------
  
ProductIDToBranchID: Free functions to map between ProductIDs and BranchIDs

----------------------------------------------------------------------*/

#include "DataFormats/Provenance/interface/ProductIDToBranchID.h"

namespace edm {

  BranchID productIDToBranchID(ProductID const& pid, BranchIDLists const& lists, BranchListIndexes const& indexes) {
    if (pid.isValid()) {
      size_t procIndex = pid.processIndex() - 1;
      if (procIndex < indexes.size()) {
        BranchListIndex blix = indexes[procIndex];
        if (blix < lists.size()) {
          BranchIDList const& blist = lists[blix];
          size_t prodIndex = pid.productIndex() - 1;
          if (prodIndex < blist.size()) {
            BranchID::value_type bid = blist[prodIndex];
            return BranchID(bid);
          }
        }
      }
    }
    return BranchID();
  }
}  // namespace edm