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 
68  void EventSetupImpl::fillAvailableRecordKeys(std::vector<eventsetup::EventSetupRecordKey>& oToFill) const {
69  oToFill.clear();
70  oToFill.reserve(recordImpls_.size());
71 
72  for (auto const& recordImpl : recordImpls_) {
73  if (recordImpl != nullptr) {
74  oToFill.push_back(recordImpl->key());
75  }
76  }
77  }
78 
80  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
81  return lb != keysEnd_ && iKey == *lb;
82  }
83 
85  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
86  if (lb != keysEnd_ && iKey == *lb) {
87  auto index = std::distance(keysBegin_, lb);
88  return recordImpls_[index] != nullptr;
89  }
90  return false;
91  }
92 
93  void EventSetupImpl::setKeyIters(std::vector<eventsetup::EventSetupRecordKey>::const_iterator const& keysBegin,
94  std::vector<eventsetup::EventSetupRecordKey>::const_iterator const& keysEnd) {
95  keysBegin_ = keysBegin;
96  keysEnd_ = keysEnd;
97  recordImpls_.resize(keysEnd_ - keysBegin_, nullptr);
98  }
99 
100 } // 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:68
edm::EventSetupImpl::find
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &, unsigned int iTransitionID, ESProxyIndex const *getTokenIndices) const
Definition: EventSetupImpl.cc:45
EventSetupImpl.h
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
edm::EventSetupImpl::validRecord
bool validRecord(eventsetup::EventSetupRecordKey const &iKey) const
Definition: EventSetupImpl.cc:84
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::ESProxyIndex
Definition: ESIndices.h:29
EventSetupRecord.h
edm::EventSetupImpl::keysEnd_
std::vector< eventsetup::EventSetupRecordKey >::const_iterator keysEnd_
Definition: EventSetupImpl.h:86
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
edm::eventsetup::EventSetupRecordImpl
Definition: EventSetupRecordImpl.h:73
edm::EventSetupImpl::setKeyIters
void setKeyIters(std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysBegin, std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysEnd)
Definition: EventSetupImpl.cc:93
edm::eventsetup::EventSetupRecordGeneric
Definition: EventSetupRecord.h:283
edm::eventsetup::EventSetupRecordImpl::key
EventSetupRecordKey const & key() const
Definition: EventSetupRecordImpl.h:99
edm::EventSetupImpl::~EventSetupImpl
~EventSetupImpl()
Definition: EventSetupImpl.cc:28
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:85
edm::EventSetupImpl::recordIsProvidedByAModule
bool recordIsProvidedByAModule(eventsetup::EventSetupRecordKey const &) const
Definition: EventSetupImpl.cc:79
Exception
Definition: hltDiff.cc:246
Exception.h
edm::EventSetupImpl::recordImpls_
std::vector< eventsetup::EventSetupRecordImpl const * > recordImpls_
Definition: EventSetupImpl.h:87
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
EventSetupRecordKey.h
edm::EventSetupImpl::addRecordImpl
void addRecordImpl(const eventsetup::EventSetupRecordImpl &iRecord)
Definition: EventSetupImpl.cc:41
edm::EventSetupImpl::EventSetupImpl
EventSetupImpl()
Definition: EventSetupImpl.cc:26