CMS 3D CMS Logo

BranchIDListHelper.cc
Go to the documentation of this file.
2 
5 
6 #include <cassert>
7 
8 namespace edm {
9 
11  : branchIDLists_(),
12  branchIDToIndexMap_(),
13  inputIndexToJobIndex_(),
14  producedBranchListIndex_(std::numeric_limits<BranchListIndex>::max()),
15  nAlreadyCopied_(0) {}
16 
18  //The BranchIDLists is a list of lists
19  // this routine compares bidlists to branchIDLists_ to see if a list
20  // in branchIDLists_ is already in bidlist and if it isn't we insert
21  // that new list into branchIDLists_
22  bool unchanged = true;
23  inputIndexToJobIndex_.clear();
24  inputIndexToJobIndex_.resize(bidlists.size());
25  for (auto it = bidlists.begin(), itEnd = bidlists.end(); it != itEnd; ++it) {
26  BranchListIndex oldBlix = it - bidlists.begin();
27  auto j = find_in_all(branchIDLists_, *it);
28  BranchListIndex blix = j - branchIDLists_.begin();
29  if (j == branchIDLists_.end()) {
30  branchIDLists_.push_back(*it);
31  for (BranchIDList::const_iterator i = it->begin(), iEnd = it->end(); i != iEnd; ++i) {
32  ProductIndex pix = i - it->begin();
33  branchIDToIndexMap_.insert(std::make_pair(BranchID(*i), std::make_pair(blix, pix)));
34  }
35  }
36  inputIndexToJobIndex_[oldBlix] = blix;
37  if (oldBlix != blix) {
38  unchanged = false;
39  }
40  }
41  return unchanged;
42  }
43 
45  inputIndexToJobIndex_.resize(bidlists.size());
46  for (auto it = bidlists.begin() + nAlreadyCopied_, itEnd = bidlists.end(); it != itEnd; ++it) {
47  BranchListIndex oldBlix = it - bidlists.begin();
48  BranchListIndex blix = branchIDLists_.size();
49  branchIDLists_.push_back(*it);
50  for (BranchIDList::const_iterator i = it->begin(), iEnd = it->end(); i != iEnd; ++i) {
51  ProductIndex pix = i - it->begin();
52  branchIDToIndexMap_.insert(std::make_pair(BranchID(*i), std::make_pair(blix, pix)));
53  }
54  inputIndexToJobIndex_[oldBlix] = blix;
55  }
56  nAlreadyCopied_ = bidlists.size();
57  }
58 
60  BranchIDList bidlist;
61  // Add entries for current process for ProductID to BranchID mapping.
62  for (ProductRegistry::ProductList::const_iterator it = preg.productList().begin(), itEnd = preg.productList().end();
63  it != itEnd;
64  ++it) {
65  //In the case of the alias, we always use the original branches BranchID
66  if (it->second.produced() and not it->second.isAlias()) {
67  if (it->second.branchType() == InEvent) {
68  bidlist.push_back(it->second.branchID().id());
69  }
70  }
71  }
72  if (!bidlist.empty()) {
73  BranchListIndex blix = branchIDLists_.size();
75  //preg.setProducedBranchListIndex(blix);
76  branchIDLists_.push_back(bidlist);
77  for (BranchIDList::const_iterator i = bidlist.begin(), iEnd = bidlist.end(); i != iEnd; ++i) {
78  ProductIndex pix = i - bidlist.begin();
79  branchIDToIndexMap_.insert(std::make_pair(BranchID(*i), std::make_pair(blix, pix)));
80  }
81  }
82  }
83 
84  bool BranchIDListHelper::fixBranchListIndexes(BranchListIndexes& indexes, bool assertOnFailure) const {
85  for (BranchListIndex& i : indexes) {
86  bool indexInRange = i < inputIndexToJobIndex_.size();
87  if (!indexInRange) {
88  if (assertOnFailure) {
89  assert(indexInRange);
90  }
91  return false;
92  }
94  }
95  return true;
96  }
97 } // namespace edm
unsigned short BranchListIndex
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
bool fixBranchListIndexes(BranchListIndexes &indexes, bool assertOnFailure=true) const
Called by sources to convert their read indexes into the indexes used by the job. ...
ProductList const & productList() const
void updateFromParent(BranchIDLists const &bidlists)
assert(be >=bs)
void updateFromRegistry(ProductRegistry const &reg)
BranchIDLists::size_type nAlreadyCopied_
std::vector< BranchListIndex > BranchListIndexes
BranchListIndex producedBranchListIndex_
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:26
BranchIDToIndexMap branchIDToIndexMap_
bool updateFromInput(BranchIDLists const &bidlists)
std::vector< BranchID::value_type > BranchIDList
Definition: BranchIDList.h:18
HLT enums.
unsigned short ProductIndex
Definition: ProductID.h:26
std::vector< BranchListIndex > inputIndexToJobIndex_
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118