CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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
12  productIDToBranchID(ProductID const& pid, BranchIDLists const& lists, BranchListIndexes const& indexes) {
13  if (!pid.isValid()) {
14  return BranchID();
15  }
16  BranchID::value_type bid = 0;
17  try {
18  BranchListIndex blix = indexes.at(pid.processIndex()-1);
19  BranchIDList const& blist = lists.at(blix);
20  bid = blist.at(pid.productIndex()-1);
21  }
22  catch (std::exception) {
23  return BranchID();
24  }
25  return BranchID(bid);
26  }
27 }
unsigned short BranchListIndex
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
ProcessIndex productIndex() const
Definition: ProductID.h:38
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:36
ProcessIndex processIndex() const
Definition: ProductID.h:37