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> iResolvers)
23  : resolvers_{std::move(iResolvers)} {
24  //Deal with duplicates
25  std::set<eventsetup::EventSetupRecordKey> records;
26  for (auto const& p : resolvers_) {
27  records.insert(p.recordKey_);
28  }
29  for (auto const& k : records) {
30  usingRecordWithKey(k);
31  findingRecordWithKey(k);
32  }
33  }
34 
36  const IOVSyncValue& iSync,
37  ValidityInterval& oIOV) {
38  // Note that we manually invalidate the resolvers at the end of every call
39  // to test. And the beginning of the call to test is the only opportunity
40  // to reset this data, so we are not relying on the EventSetup system
41  // to manage invalidating the resolvers in EventSetupTestHelper. The only
42  // reasonable thing to do is return an interval for all time so the EventSetup
43  // system does not invalidate these resolvers when it shouldn't. There are two
44  // weaknesses to this:
45  //
46  // 1. If for the same record type there are ESProductResolvers both managed
47  // by this class and also others managed by the EventSetup, then
48  // at IOV boundaries for this record this will fail. The EventSetup
49  // will invalidate all the resolvers for the record after this class
50  // has set the ones it manages and they will stay invalid when they
51  // are needed.
52  //
53  // 2. TestProcessor does not support the special case where the different
54  // transitions executed in one call to test have different IOVs and different
55  // EventSetup data. That would be a pretty strange case, especially for a test.
56 
58  }
59 
61  const eventsetup::EventSetupRecordKey& iRecordKey, unsigned int iovIndex) {
62  KeyedResolversVector keyedResolversVector;
63  for (auto const& p : resolvers_) {
64  if (p.recordKey_ == iRecordKey) {
65  keyedResolversVector.emplace_back(p.dataKey_, p.resolver_);
66  }
67  }
68  return keyedResolversVector;
69  }
70 
71  std::shared_ptr<eventsetup::ESProductResolver> EventSetupTestHelper::getResolver(unsigned int iIndex) {
72  return resolvers_[iIndex].resolver_;
73  }
74 
76  for (auto const& p : resolvers_) {
77  p.resolver_->invalidate();
78  }
79  }
80 
81  } // namespace test
82 } // namespace edm
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
std::vector< ESProduceEntry > resolvers_
std::shared_ptr< eventsetup::ESProductResolver > getResolver(unsigned int index)
EventSetupTestHelper(std::vector< ESProduceEntry >)
std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >> KeyedResolversVector
HLT enums.
void setIntervalFor(const eventsetup::EventSetupRecordKey &, const IOVSyncValue &, ValidityInterval &) final
KeyedResolversVector registerResolvers(const eventsetup::EventSetupRecordKey &, unsigned int iovIndex) final
def move(src, dest)
Definition: eostools.py:511