CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProductIDToBranchID.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 
3 ProductIDToBranchID: Free functions to map between ProductIDs and BranchIDs
4 
5 ----------------------------------------------------------------------*/
6 
8 
9 namespace edm {
10 
11  BranchID productIDToBranchID(ProductID const& pid, BranchIDLists const& lists, BranchListIndexes const& indexes) {
12  if (pid.isValid()) {
13  size_t procIndex = pid.processIndex() - 1;
14  if (procIndex < indexes.size()) {
15  BranchListIndex blix = indexes[procIndex];
16  if (blix < lists.size()) {
17  BranchIDList const& blist = lists[blix];
18  size_t prodIndex = pid.productIndex() - 1;
19  if (prodIndex < blist.size()) {
20  BranchID::value_type bid = blist[prodIndex];
21  return BranchID(bid);
22  }
23  }
24  }
25  }
26  return BranchID();
27  }
28 } // namespace edm
unsigned short BranchListIndex
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
ProcessIndex productIndex() const
Definition: ProductID.h:34
std::vector< BranchListIndex > BranchListIndexes
BranchID productIDToBranchID(ProductID const &pid, BranchIDLists const &lists, BranchListIndexes const &indexes)
unsigned int value_type
Definition: BranchID.h:16
std::vector< BranchID::value_type > BranchIDList
Definition: BranchIDList.h:18
bool isValid() const
Definition: ProductID.h:32
ProcessIndex processIndex() const
Definition: ProductID.h:33