CMS 3D CMS Logo

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
edm::errors::LogicError
Definition: EDMException.h:37
edm::ProductProvenanceLookup::readProvenance
virtual std::unique_ptr< const std::set< ProductProvenance > > readProvenance() const =0
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProductProvenance::moveParentageID
ParentageID moveParentageID()
Definition: ProductProvenance.h:43
edm::ProductProvenanceLookup::parentProcessRetriever_
edm::propagate_const< ProductProvenanceLookup const * > parentProcessRetriever_
Definition: ProductProvenanceLookup.h:99
ProductRegistry.h
edm::BranchID::id
unsigned int id() const
Definition: BranchID.h:21
edm::ProductProvenanceLookup::entryInfoSet_
std::vector< ProducedProvenanceInfo > entryInfoSet_
Definition: ProductProvenanceLookup.h:97
edm::ProductProvenanceLookup::insertIntoSet
void insertIntoSet(ProductProvenance provenanceProduct) const
Definition: ProductProvenanceLookup.cc:42
edm::ProductRegistry
Definition: ProductRegistry.h:37
EDMException.h
edm::ProductProvenanceLookup::readEntryInfoSet_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
Definition: ProductProvenanceLookup.h:98
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
edm::ProductProvenance
Definition: ProductProvenance.h:24
edm::ProductProvenanceLookup::~ProductProvenanceLookup
virtual ~ProductProvenanceLookup()
Definition: ProductProvenanceLookup.cc:20
edm::BranchID
Definition: BranchID.h:14
ProductProvenanceLookup.h
edm::ProductProvenanceLookup::nextRetriever
virtual const ProductProvenanceLookup * nextRetriever() const =0
edm::ProductProvenance::branchID
BranchID const & branchID() const
Definition: ProductProvenance.h:38
edm::ProductProvenanceLookup::setupEntryInfoSet
void setupEntryInfoSet(edm::ProductRegistry const &)
Definition: ProductProvenanceLookup.cc:22
edm::InEvent
Definition: BranchType.h:11
b
double b
Definition: hdecay.h:118
edm::ProductProvenanceLookup::branchIDToProvenance
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
Definition: ProductProvenanceLookup.cc:59
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ProductProvenanceLookup::branchIDToProvenanceForProducedOnly
ProductProvenance const * branchIDToProvenanceForProducedOnly(BranchID const &bid) const
Definition: ProductProvenanceLookup.cc:95
edm::ProductProvenanceLookup::ProductProvenanceLookup
ProductProvenanceLookup()
Definition: ProductProvenanceLookup.cc:12
edm::ProductRegistry::productList
ProductList const & productList() const
Definition: ProductRegistry.h:76
Exception
Definition: hltDiff.cc:245
or
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::ProductProvenanceLookup::update
void update(edm::ProductRegistry const &)
Definition: ProductProvenanceLookup.cc:37