CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DataFormats/Provenance/src/ProductIDToBranchID.cc

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------
00002   
00003 ProductIDToBranchID: Free functions to map between ProductIDs and BranchIDs
00004 
00005 ----------------------------------------------------------------------*/
00006 
00007 #include "DataFormats/Provenance/interface/ProductIDToBranchID.h"
00008 
00009 namespace edm {
00010 
00011   BranchID
00012   productIDToBranchID(ProductID const& pid, BranchIDLists const& lists, BranchListIndexes const& indexes) {
00013 
00014     if (pid.isValid()) {
00015       size_t procIndex = pid.processIndex()-1;
00016       if (procIndex < indexes.size()) {
00017         BranchListIndex blix = indexes[procIndex];
00018         if (blix < lists.size()) {
00019           BranchIDList const& blist = lists[blix];
00020           size_t prodIndex =pid.productIndex()-1;
00021           if (prodIndex<blist.size()) {
00022             BranchID::value_type bid = blist[prodIndex];
00023             return BranchID(bid);
00024           }
00025         }
00026       }
00027     }
00028     return BranchID();
00029   }
00030 }