CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  {}
16 
17  bool
19  //The BranchIDLists is a list of lists
20  // this routine compares bidlists to branchIDLists_ to see if a list
21  // in branchIDLists_ is already in bidlist and if it isn't we insert
22  // that new list into branchIDLists_
23  bool unchanged = true;
24  inputIndexToJobIndex_.clear();
25  inputIndexToJobIndex_.resize(bidlists.size());
26  for(auto it = bidlists.begin(), itEnd = bidlists.end(); it != itEnd; ++it) {
27  BranchListIndex oldBlix = it - bidlists.begin();
28  auto j = find_in_all(branchIDLists_, *it);
29  BranchListIndex blix = j - branchIDLists_.begin();
30  if(j == branchIDLists_.end()) {
31  branchIDLists_.push_back(*it);
32  for(BranchIDList::const_iterator i = it->begin(), iEnd = it->end(); i != iEnd; ++i) {
33  ProductIndex pix = i - it->begin();
34  branchIDToIndexMap_.insert(std::make_pair(BranchID(*i), std::make_pair(blix, pix)));
35  }
36  }
37  inputIndexToJobIndex_[oldBlix]=blix;
38  if(oldBlix != blix) {
39  unchanged = false;
40  }
41  }
42  return unchanged;
43  }
44 
45  void
47  BranchIDList bidlist;
48  // Add entries for current process for ProductID to BranchID mapping.
49  for(ProductRegistry::ProductList::const_iterator it = preg.productList().begin(), itEnd = preg.productList().end();
50  it != itEnd; ++it) {
51  if(it->second.produced()) {
52  if(it->second.branchType() == InEvent) {
53  bidlist.push_back(it->second.branchID().id());
54  }
55  }
56  }
57  if(!bidlist.empty()) {
58  BranchListIndex blix = branchIDLists_.size();
60  //preg.setProducedBranchListIndex(blix);
61  branchIDLists_.push_back(bidlist);
62  for(BranchIDList::const_iterator i = bidlist.begin(), iEnd = bidlist.end(); i != iEnd; ++i) {
63  ProductIndex pix = i - bidlist.begin();
64  branchIDToIndexMap_.insert(std::make_pair(BranchID(*i), std::make_pair(blix, pix)));
65  }
66  }
67  }
68 
69  void
71  for(BranchListIndex& i : indexes) {
72  assert(i<inputIndexToJobIndex_.size());
74  }
75  }
76 }
int i
Definition: DBlmapReader.cc:9
unsigned short BranchListIndex
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void updateFromRegistry(ProductRegistry const &reg)
ProductList const & productList() const
std::vector< BranchListIndex > BranchListIndexes
BranchListIndex producedBranchListIndex_
int j
Definition: DBlmapReader.cc:9
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:32
BranchIDToIndexMap branchIDToIndexMap_
bool updateFromInput(BranchIDLists const &bidlists)
void fixBranchListIndexes(BranchListIndexes &indexes) const
Called by sources to convert their read indexes into the indexes used by the job. ...
std::vector< BranchID::value_type > BranchIDList
Definition: BranchIDList.h:18
unsigned short ProductIndex
Definition: ProductID.h:26
preg
Definition: Schedule.cc:362
std::vector< BranchListIndex > inputIndexToJobIndex_
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:137