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 
6 
7 namespace edm {
8 
10  branchIDToIndexMap_(),
11  branchListIndexMapper_() {}
12 
13  bool
14  BranchIDListHelper:: updateFromInput(BranchIDLists const& bidlists, std::string const& fileName) {
15  bool unchanged = true;
18  BranchIDToIndexMap& branchIDToIndexMap = breg.extra().branchIDToIndexMap_;
19  BranchListIndexMapper& branchListIndexMapper = breg.extra().branchListIndexMapper_;
20  branchListIndexMapper.clear();
21  typedef BranchIDLists::const_iterator Iter;
23  for(Iter it = bidlists.begin(), itEnd = bidlists.end(); it != itEnd; ++it) {
24  BranchListIndex oldBlix = it - bidlists.begin();
25  RegIter j = find_in_all(bdata, *it);
26  BranchListIndex blix = j - bdata.begin();
27  if(j == bdata.end()) {
28  breg.insertMapped(*it);
29  for(BranchIDList::const_iterator i = it->begin(), iEnd = it->end(); i != iEnd; ++i) {
30  ProductIndex pix = i - it->begin();
31  branchIDToIndexMap.insert(std::make_pair(*i, std::make_pair(blix, pix)));
32  }
33  }
34  branchListIndexMapper.insert(std::make_pair(oldBlix, blix));
35  if(oldBlix != blix) {
36  unchanged = false;
37  }
38  }
39  return unchanged;
40  }
41 
42  void
44  BranchIDList bidlist;
45  // Add entries for current process for ProductID to BranchID mapping.
46  for(ProductRegistry::ProductList::const_iterator it = preg.productList().begin(), itEnd = preg.productList().end();
47  it != itEnd; ++it) {
48  if(it->second.produced()) {
49  if(it->second.branchType() == InEvent) {
50  bidlist.push_back(it->second.branchID().id());
51  }
52  }
53  }
55  BranchIDToIndexMap& branchIDToIndexMap = breg.extra().branchIDToIndexMap_;
56  if(!bidlist.empty()) {
57  BranchListIndex blix = breg.data().size();
58  preg.setProducedBranchListIndex(blix);
59  breg.insertMapped(bidlist);
60  for(BranchIDList::const_iterator i = bidlist.begin(), iEnd = bidlist.end(); i != iEnd; ++i) {
61  ProductIndex pix = i - bidlist.begin();
62  branchIDToIndexMap.insert(std::make_pair(*i, std::make_pair(blix, pix)));
63  }
64  }
65  }
66 
67  void
70  BranchListIndexMapper& branchListIndexMapper = breg.extra().branchListIndexMapper_;
71  for(BranchListIndexes::iterator i = indexes.begin(), e = indexes.end(); i != e; ++i) {
72  *i = branchListIndexMapper[*i];
73  }
74  }
75 
76  void
79  breg.data().clear();
80  breg.extra().branchIDToIndexMap_.clear();
81  breg.extra().branchListIndexMapper_.clear();
82  }
83 }
int i
Definition: DBlmapReader.cc:9
unsigned short BranchListIndex
BranchIDToIndexMap const & branchIDToIndexMap() const
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
static bool updateFromInput(BranchIDLists const &bidlists, std::string const &fileName)
collection_type::const_iterator const_iterator
static void fixBranchListIndexes(BranchListIndexes &indexes)
ProductList const & productList() const
void setProducedBranchListIndex(BranchListIndex blix) const
std::vector< BranchListIndex > BranchListIndexes
int j
Definition: DBlmapReader.cc:9
std::multimap< BranchID, IndexPair > BranchIDToIndexMap
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:32
std::vector< BranchID::value_type > BranchIDList
Definition: BranchIDList.h:18
static void updateRegistries(ProductRegistry const &reg)
author Stefano ARGIRO author Bill Tanenbaum
std::map< BranchListIndex, BranchListIndex > BranchListIndexMapper
static ThreadSafeIndexedRegistry * instance()
collection_type & data()
Provide access to the contained collection.
unsigned short ProductIndex
Definition: ProductID.h:26