CMS 3D CMS Logo

EventSetupImpl.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Module: EventSetup
5 //
6 // Description: <one line class summary>
7 //
8 // Implementation:
9 // <Notes on implementation>
10 //
11 // Author: Chris Jones
12 // Created: Thu Mar 24 16:27:10 EST 2005
13 //
14 
15 // system include files
16 #include <algorithm>
17 
18 // user include files
23 
24 namespace edm {
25 
27 
29 
31  const eventsetup::EventSetupRecordImpl* iRecord) {
32  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
33  if (lb == keysEnd_ || iKey != *lb) {
34  throw cms::Exception("LogicError") << "EventSetupImpl::insert Could not find key\n"
35  << "Should be impossible. Please contact Framework developer.\n";
36  }
37  auto index = std::distance(keysBegin_, lb);
38  recordImpls_[index] = iRecord;
39  }
40 
42  insertRecordImpl(iRecord.key(), &iRecord);
43  }
44 
45  std::optional<eventsetup::EventSetupRecordGeneric> EventSetupImpl::find(const eventsetup::EventSetupRecordKey& iKey,
46  unsigned int iTransitionID,
47  ESProxyIndex const* getTokenIndices) const {
48  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
49  if (lb == keysEnd_ || iKey != *lb) {
50  return std::nullopt;
51  }
52  auto index = std::distance(keysBegin_, lb);
53  if (recordImpls_[index] == nullptr) {
54  return std::nullopt;
55  }
56  return eventsetup::EventSetupRecordGeneric(recordImpls_[index], iTransitionID, getTokenIndices, this);
57  }
58 
60  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
61  if (lb == keysEnd_ || iKey != *lb) {
62  return nullptr;
63  }
64  auto index = std::distance(keysBegin_, lb);
65  return recordImpls_[index];
66  }
67 
70  return nullptr;
71  }
72  return recordImpls_[iKey.value()];
73  }
74 
75  void EventSetupImpl::fillAvailableRecordKeys(std::vector<eventsetup::EventSetupRecordKey>& oToFill) const {
76  oToFill.clear();
77  oToFill.reserve(recordImpls_.size());
78 
79  for (auto const& recordImpl : recordImpls_) {
80  if (recordImpl != nullptr) {
81  oToFill.push_back(recordImpl->key());
82  }
83  }
84  }
85 
87  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
88  return lb != keysEnd_ && iKey == *lb;
89  }
90 
92  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
93  if (lb != keysEnd_ && iKey == *lb) {
94  auto index = std::distance(keysBegin_, lb);
95  return recordImpls_[index] != nullptr;
96  }
97  return false;
98  }
99 
100  void EventSetupImpl::setKeyIters(std::vector<eventsetup::EventSetupRecordKey>::const_iterator const& keysBegin,
101  std::vector<eventsetup::EventSetupRecordKey>::const_iterator const& keysEnd) {
102  keysBegin_ = keysBegin;
103  keysEnd_ = keysEnd;
104  recordImpls_.resize(keysEnd_ - keysBegin_, nullptr);
105  }
106 
107 } // namespace edm
edm::EventSetupImpl::findImpl
eventsetup::EventSetupRecordImpl const * findImpl(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetupImpl.cc:59
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EventSetupImpl::fillAvailableRecordKeys
void fillAvailableRecordKeys(std::vector< eventsetup::EventSetupRecordKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all available records
Definition: EventSetupImpl.cc:75
edm::EventSetupImpl::find
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &, unsigned int iTransitionID, ESProxyIndex const *getTokenIndices) const
Definition: EventSetupImpl.cc:45
EventSetupImpl.h
edm::EventSetupImpl::validRecord
bool validRecord(eventsetup::EventSetupRecordKey const &iKey) const
Definition: EventSetupImpl.cc:91
edm::ESRecordIndex
Definition: ESIndices.h:80
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::ESProxyIndex
Definition: ESIndices.h:30
EventSetupRecord.h
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
edm::ESRecordIndex::value
constexpr Value_t value() const noexcept
Definition: ESIndices.h:95
edm::EventSetupImpl::keysEnd_
std::vector< eventsetup::EventSetupRecordKey >::const_iterator keysEnd_
Definition: EventSetupImpl.h:92
edm::eventsetup::EventSetupRecordImpl
Definition: EventSetupRecordImpl.h:76
edm::EventSetupImpl::setKeyIters
void setKeyIters(std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysBegin, std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysEnd)
Definition: EventSetupImpl.cc:100
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
edm::eventsetup::EventSetupRecordGeneric
Definition: EventSetupRecord.h:290
edm::eventsetup::EventSetupRecordImpl::key
EventSetupRecordKey const & key() const
Definition: EventSetupRecordImpl.h:102
edm::EventSetupImpl::~EventSetupImpl
~EventSetupImpl()
Definition: EventSetupImpl.cc:28
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::EventSetupImpl::insertRecordImpl
void insertRecordImpl(const eventsetup::EventSetupRecordKey &, const eventsetup::EventSetupRecordImpl *)
Definition: EventSetupImpl.cc:30
edm::EventSetupImpl::keysBegin_
std::vector< eventsetup::EventSetupRecordKey >::const_iterator keysBegin_
Definition: EventSetupImpl.h:91
edm::EventSetupImpl::recordIsProvidedByAModule
bool recordIsProvidedByAModule(eventsetup::EventSetupRecordKey const &) const
Definition: EventSetupImpl.cc:86
Exception
Definition: hltDiff.cc:246
Exception.h
edm::EventSetupImpl::recordImpls_
std::vector< eventsetup::EventSetupRecordImpl const * > recordImpls_
Definition: EventSetupImpl.h:93
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
EventSetupRecordKey.h
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
edm::EventSetupImpl::addRecordImpl
void addRecordImpl(const eventsetup::EventSetupRecordImpl &iRecord)
Definition: EventSetupImpl.cc:41
edm::EventSetupImpl::EventSetupImpl
EventSetupImpl()
Definition: EventSetupImpl.cc:26