CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProductProvenanceLookup.cc
Go to the documentation of this file.
4 
5 #include <algorithm>
6 
7 /*
8  ProductProvenanceLookup
9 */
10 
11 namespace edm {
13  : entryInfoSet_(), readEntryInfoSet_(), parentProcessRetriever_(nullptr) {}
14 
16  : entryInfoSet_(), readEntryInfoSet_(), parentProcessRetriever_(nullptr) {
17  setupEntryInfoSet(iReg);
18  }
19 
21 
23  std::set<BranchID> ids;
24  for (auto const& p : iReg.productList()) {
25  if (p.second.branchType() == edm::InEvent) {
26  if (p.second.produced() or p.second.isProvenanceSetOnRead()) {
27  ids.insert(p.second.branchID());
28  }
29  }
30  }
31  entryInfoSet_.reserve(ids.size());
32  for (auto const& b : ids) {
33  entryInfoSet_.emplace_back(b);
34  }
35  }
36 
38  entryInfoSet_.clear();
39  setupEntryInfoSet(iReg);
40  }
41 
43  //NOTE:do not read provenance here because we only need the full
44  // provenance when someone tries to access it not when doing the insert
45  // doing the delay saves 20% of time when doing an analysis job
46  //readProvenance();
47  auto itFound =
49  entryInfoSet_.end(),
50  entryInfo.branchID(),
51  [](auto const& iEntry, edm::BranchID const& iValue) { return iEntry.branchID() < iValue; });
52  if UNLIKELY (itFound == entryInfoSet_.end() or itFound->branchID() != entryInfo.branchID()) {
53  throw edm::Exception(edm::errors::LogicError) << "ProductProvenanceLookup::insertIntoSet passed a BranchID "
54  << entryInfo.branchID().id() << " that has not been pre-registered";
55  }
56  itFound->threadsafe_set(entryInfo.moveParentageID());
57  }
58 
60  auto itFound = std::lower_bound(
61  entryInfoSet_.begin(), entryInfoSet_.end(), bid, [](auto const& iEntry, edm::BranchID const& iValue) {
62  return iEntry.branchID() < iValue;
63  });
64  if (itFound != entryInfoSet_.end() and itFound->branchID() == bid) {
65  if (auto p = itFound->productProvenance()) {
66  return p;
67  }
68  }
70  return parentProcessRetriever_->branchIDToProvenance(bid);
71  }
72  //check in source
73  if (nullptr == readEntryInfoSet_.load()) {
74  auto readProv = readProvenance();
75  std::set<ProductProvenance> const* expected = nullptr;
76  if (readEntryInfoSet_.compare_exchange_strong(expected, readProv.get())) {
77  readProv.release();
78  }
79  }
80  auto ptr = readEntryInfoSet_.load();
81  if (ptr) {
82  ProductProvenance ei(bid);
83  auto itRead = ptr->find(ei);
84  if (itRead != ptr->end()) {
85  return &*itRead;
86  }
87  }
88  auto nr = nextRetriever();
89  if (nr) {
90  return nr->branchIDToProvenance(bid);
91  }
92  return nullptr;
93  }
94 
96  auto itFound = std::lower_bound(
97  entryInfoSet_.begin(), entryInfoSet_.end(), bid, [](auto const& iEntry, edm::BranchID const& iValue) {
98  return iEntry.branchID() < iValue;
99  });
100  if (itFound != entryInfoSet_.end() and itFound->branchID() == bid) {
101  if (auto p = itFound->productProvenance()) {
102  return p;
103  }
104  }
106  return parentProcessRetriever_->branchIDToProvenanceForProducedOnly(bid);
107  }
108  auto nr = nextRetriever();
109  if (nr) {
110  return nr->branchIDToProvenanceForProducedOnly(bid);
111  }
112  return nullptr;
113  }
114 
115 } // namespace edm
ProductProvenance const * branchIDToProvenanceForProducedOnly(BranchID const &bid) const
BranchID const & branchID() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ParentageID moveParentageID()
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
unsigned int id() const
Definition: BranchID.h:21
ProductList const & productList() const
virtual std::unique_ptr< const std::set< ProductProvenance > > readProvenance() const =0
void update(edm::ProductRegistry const &)
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
virtual const ProductProvenanceLookup * nextRetriever() const =0
void insertIntoSet(ProductProvenance provenanceProduct) const
double b
Definition: hdecay.h:118
edm::propagate_const< ProductProvenanceLookup const * > parentProcessRetriever_
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
#define UNLIKELY(x)
Definition: Likely.h:21
std::vector< ProducedProvenanceInfo > entryInfoSet_
void setupEntryInfoSet(edm::ProductRegistry const &)