CMS 3D CMS Logo

EventSetupTestHelper.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/TestProcessor
4 // Class : EventSetupTestHelper
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: root
10 // Created: Tue, 08 May 2018 18:33:15 GMT
11 //
12 
13 // system include files
14 
15 // user include files
18 
19 namespace edm {
20  namespace test {
21 
22  EventSetupTestHelper::EventSetupTestHelper(std::vector<ESProduceEntry> iProxies) : proxies_{std::move(iProxies)} {
23  //Deal with duplicates
24  std::set<eventsetup::EventSetupRecordKey> records;
25  for (auto const& p : proxies_) {
26  records.insert(p.recordKey_);
27  }
28  for (auto const& k : records) {
29  usingRecordWithKey(k);
30  findingRecordWithKey(k);
31  }
32  }
33 
35  const IOVSyncValue& iSync,
36  ValidityInterval& oIOV) {
37  // Note that we manually invalidate the proxies at the end of every call
38  // to test. And the beginning of the call to test is the only opportunity
39  // to reset this data, so we are not relying on the EventSetup system
40  // to manage invalidating the proxies in EventSetupTestHelper. The only
41  // reasonable thing to do is return an interval for all time so the EventSetup
42  // system does not invalidate these proxies when it shouldn't. There are two
43  // weaknesses to this:
44  //
45  // 1. If for the same record type there are DataProxies both managed
46  // by this class and also others managed by the EventSetup, then
47  // at IOV boundaries for this record this will fail. The EventSetup
48  // will invalidate all the proxies for the record after this class
49  // has set the ones it manages and they will stay invalid when they
50  // are needed.
51  //
52  // 2. TestProcessor does not support the special case where the different
53  // transitions executed in one call to test have different IOVs and different
54  // EventSetup data. That would be a pretty strange case, especially for a test.
55 
57  }
58 
60  const eventsetup::EventSetupRecordKey& iRecordKey, unsigned int iovIndex) {
61  KeyedProxiesVector keyedProxiesVector;
62  for (auto const& p : proxies_) {
63  if (p.recordKey_ == iRecordKey) {
64  keyedProxiesVector.emplace_back(p.dataKey_, p.proxy_);
65  }
66  }
67  return keyedProxiesVector;
68  }
69 
70  std::shared_ptr<eventsetup::DataProxy> EventSetupTestHelper::getProxy(unsigned int iIndex) {
71  return proxies_[iIndex].proxy_;
72  }
73 
75  for (auto const& p : proxies_) {
76  p.proxy_->invalidate();
77  }
78  }
79 
80  } // namespace test
81 } // namespace edm
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ValidityInterval
Definition: ValidityInterval.h:28
edm::test::EventSetupTestHelper::setIntervalFor
void setIntervalFor(const eventsetup::EventSetupRecordKey &, const IOVSyncValue &, ValidityInterval &) final
Definition: EventSetupTestHelper.cc:34
DataProxy.h
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
test
Definition: SmallWORMDict.h:13
edm::test::EventSetupTestHelper::resetAllProxies
void resetAllProxies()
Definition: EventSetupTestHelper.cc:74
edm::test::EventSetupTestHelper::EventSetupTestHelper
EventSetupTestHelper(std::vector< ESProduceEntry >)
Definition: EventSetupTestHelper.cc:22
edm::test::EventSetupTestHelper::proxies_
std::vector< ESProduceEntry > proxies_
Definition: EventSetupTestHelper.h:51
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
edm::eventsetup::DataProxyProvider::KeyedProxiesVector
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >> KeyedProxiesVector
Definition: DataProxyProvider.h:196
edm::test::EventSetupTestHelper::registerProxies
KeyedProxiesVector registerProxies(const eventsetup::EventSetupRecordKey &, unsigned int iovIndex) final
Definition: EventSetupTestHelper.cc:59
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::test::EventSetupTestHelper::getProxy
std::shared_ptr< eventsetup::DataProxy > getProxy(unsigned int index)
Definition: EventSetupTestHelper.cc:70
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
EventSetupTestHelper.h