File indexing completed on 2024-04-06 12:12:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "FWCore/Framework/test/DummyRecord.h"
0011 #include "FWCore/Framework/test/Dummy2Record.h"
0012 #include "FWCore/Framework/test/DepRecord.h"
0013 #include "FWCore/Framework/test/DepOn2Record.h"
0014 #include "FWCore/Framework/test/DummyFinder.h"
0015 #include "FWCore/Framework/test/DummyData.h"
0016 #include "FWCore/Framework/test/DummyESProductResolverProvider.h"
0017 #include "FWCore/Framework/interface/DependentRecordIntervalFinder.h"
0018 #include "FWCore/Framework/interface/EventSetupImpl.h"
0019 #include "FWCore/Framework/interface/EventSetupProvider.h"
0020 #include "FWCore/Framework/interface/EventSetup.h"
0021 #include "FWCore/Framework/interface/ESProductResolverProvider.h"
0022 #include "FWCore/Framework/interface/ESProductResolverTemplate.h"
0023 #include "FWCore/Framework/interface/ESRecordsToProductResolverIndices.h"
0024 #include "FWCore/Framework/interface/EDConsumerBase.h"
0025 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0026 #include "FWCore/Framework/interface/EventSetupRecordProvider.h"
0027 #include "FWCore/Framework/src/SynchronousEventSetupsController.h"
0028 #include "FWCore/Framework/interface/NoRecordException.h"
0029 #include "FWCore/Framework/test/print_eventsetup_record_dependencies.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0032 #include "FWCore/ServiceRegistry/interface/ESParentContext.h"
0033 #include "FWCore/Utilities/interface/propagate_const.h"
0034 #include "FWCore/Concurrency/interface/ThreadsController.h"
0035 #include "FWCore/Concurrency/interface/FinalWaitingTask.h"
0036
0037 #include "cppunit/extensions/HelperMacros.h"
0038
0039 #include <memory>
0040 #include <string>
0041 #include <vector>
0042 #include <cstring>
0043
0044 using namespace edm::eventsetup;
0045
0046 namespace {
0047 edm::ParameterSet createDummyPset() {
0048 edm::ParameterSet pset;
0049 std::vector<std::string> emptyVStrings;
0050 pset.addParameter<std::vector<std::string>>("@all_esprefers", emptyVStrings);
0051 pset.addParameter<std::vector<std::string>>("@all_essources", emptyVStrings);
0052 pset.addParameter<std::vector<std::string>>("@all_esmodules", emptyVStrings);
0053 return pset;
0054 }
0055 }
0056
0057 class testdependentrecord : public CppUnit::TestFixture {
0058 CPPUNIT_TEST_SUITE(testdependentrecord);
0059
0060 CPPUNIT_TEST(dependentConstructorTest);
0061 CPPUNIT_TEST(dependentFinder1Test);
0062 CPPUNIT_TEST(dependentFinder2Test);
0063 CPPUNIT_TEST(testIncomparibleIOVAlgorithm);
0064 CPPUNIT_TEST(testInvalidIOVAlgorithm);
0065 CPPUNIT_TEST(testInvalidIOVFirstTime);
0066 CPPUNIT_TEST(testInvalidIOVFirstEventID);
0067 CPPUNIT_TEST(timeAndRunTest);
0068 CPPUNIT_TEST(dependentSetproviderTest);
0069 CPPUNIT_TEST(getTest);
0070 CPPUNIT_TEST(getDataWithESGetTokenTest);
0071 CPPUNIT_TEST(getHandleWithESGetTokenTest);
0072 CPPUNIT_TEST(getTransientHandleWithESGetTokenTest);
0073 CPPUNIT_TEST(oneOfTwoRecordTest);
0074 CPPUNIT_TEST(resetTest);
0075 CPPUNIT_TEST(alternateFinderTest);
0076 CPPUNIT_TEST(invalidRecordTest);
0077 CPPUNIT_TEST(extendIOVTest);
0078
0079 CPPUNIT_TEST_SUITE_END();
0080
0081 public:
0082 void setUp() { m_scheduler = std::make_unique<edm::ThreadsController>(1); }
0083 void tearDown() {}
0084
0085 void dependentConstructorTest();
0086 void dependentFinder1Test();
0087 void dependentFinder2Test();
0088 void testIncomparibleIOVAlgorithm();
0089 void testInvalidIOVAlgorithm();
0090 void testInvalidIOVFirstTime();
0091 void testInvalidIOVFirstEventID();
0092 void timeAndRunTest();
0093 void dependentSetproviderTest();
0094 void getTest();
0095 void getDataWithESGetTokenTest();
0096 void getHandleWithESGetTokenTest();
0097 void getTransientHandleWithESGetTokenTest();
0098 void oneOfTwoRecordTest();
0099 void resetTest();
0100 void alternateFinderTest();
0101 void invalidRecordTest();
0102 void extendIOVTest();
0103
0104 private:
0105 edm::propagate_const<std::unique_ptr<edm::ThreadsController>> m_scheduler;
0106
0107 };
0108
0109
0110 CPPUNIT_TEST_SUITE_REGISTRATION(testdependentrecord);
0111
0112
0113
0114
0115
0116
0117
0118
0119 namespace {
0120
0121 edm::ActivityRegistry activityRegistry;
0122
0123 class DummyESProductResolverProvider : public edm::eventsetup::ESProductResolverProvider {
0124 public:
0125 DummyESProductResolverProvider() { usingRecord<DummyRecord>(); }
0126
0127 protected:
0128 KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int ) override {
0129 return KeyedResolversVector();
0130 }
0131 };
0132
0133 class DepRecordResolverProvider : public edm::eventsetup::ESProductResolverProvider {
0134 public:
0135 DepRecordResolverProvider() { usingRecord<DepRecord>(); }
0136
0137 protected:
0138 KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int ) override {
0139 return KeyedResolversVector();
0140 }
0141 };
0142
0143 class WorkingDepRecordResolver
0144 : public edm::eventsetup::ESProductResolverTemplate<DepRecord, edm::eventsetup::test::DummyData> {
0145 public:
0146 WorkingDepRecordResolver(const edm::eventsetup::test::DummyData* iDummy) : data_(iDummy) {}
0147
0148 protected:
0149 const value_type* make(const record_type&, const DataKey&) final { return data_; }
0150 void const* getAfterPrefetchImpl() const final { return data_; }
0151
0152 private:
0153 const edm::eventsetup::test::DummyData* data_;
0154 };
0155
0156 class DepRecordResolverProviderWithData : public edm::eventsetup::ESProductResolverProvider {
0157 public:
0158 DepRecordResolverProviderWithData(const edm::eventsetup::test::DummyData& iData = edm::eventsetup::test::DummyData())
0159 : dummy_(iData) {
0160 usingRecord<DepRecord>();
0161 }
0162
0163 protected:
0164 KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int ) override {
0165 KeyedResolversVector keyedResolversVector;
0166 std::shared_ptr<WorkingDepRecordResolver> pResolver = std::make_shared<WorkingDepRecordResolver>(&dummy_);
0167 edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<edm::eventsetup::test::DummyData>(), "");
0168 keyedResolversVector.emplace_back(dataKey, pResolver);
0169 return keyedResolversVector;
0170 }
0171
0172 private:
0173 edm::eventsetup::test::DummyData dummy_;
0174 };
0175
0176 class DepOn2RecordResolverProvider : public edm::eventsetup::ESProductResolverProvider {
0177 public:
0178 DepOn2RecordResolverProvider() { usingRecord<DepOn2Record>(); }
0179
0180 protected:
0181 KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int ) override {
0182 return KeyedResolversVector();
0183 }
0184 };
0185
0186 class DepRecordFinder : public edm::EventSetupRecordIntervalFinder {
0187 public:
0188 DepRecordFinder() : edm::EventSetupRecordIntervalFinder(), interval_() { this->findingRecord<DepRecord>(); }
0189
0190 void setInterval(const edm::ValidityInterval& iInterval) { interval_ = iInterval; }
0191
0192 protected:
0193 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0194 const edm::IOVSyncValue& iTime,
0195 edm::ValidityInterval& iInterval) override {
0196 if (interval_.validFor(iTime)) {
0197 iInterval = interval_;
0198 } else {
0199 if (interval_.last() == edm::IOVSyncValue::invalidIOVSyncValue() &&
0200 interval_.first() != edm::IOVSyncValue::invalidIOVSyncValue() && interval_.first() <= iTime) {
0201 iInterval = interval_;
0202 } else {
0203 iInterval = edm::ValidityInterval();
0204 }
0205 }
0206 }
0207
0208 private:
0209 edm::ValidityInterval interval_;
0210 };
0211
0212 class Dummy2RecordFinder : public edm::EventSetupRecordIntervalFinder {
0213 public:
0214 Dummy2RecordFinder() : edm::EventSetupRecordIntervalFinder(), interval_() { this->findingRecord<Dummy2Record>(); }
0215
0216 void setInterval(const edm::ValidityInterval& iInterval) { interval_ = iInterval; }
0217
0218 protected:
0219 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0220 const edm::IOVSyncValue& iTime,
0221 edm::ValidityInterval& iInterval) override {
0222 if (interval_.validFor(iTime)) {
0223 iInterval = interval_;
0224 } else {
0225 if (interval_.last() == edm::IOVSyncValue::invalidIOVSyncValue() &&
0226 interval_.first() != edm::IOVSyncValue::invalidIOVSyncValue() && interval_.first() <= iTime) {
0227 iInterval = interval_;
0228 } else {
0229 iInterval = edm::ValidityInterval();
0230 }
0231 }
0232 }
0233
0234 private:
0235 edm::ValidityInterval interval_;
0236 };
0237 }
0238
0239 using namespace edm::eventsetup;
0240 void testdependentrecord::dependentConstructorTest() {
0241 EventSetupRecordProvider depProvider(DepRecord::keyForClass(), &activityRegistry);
0242
0243 CPPUNIT_ASSERT(1 == depProvider.dependentRecords().size());
0244 CPPUNIT_ASSERT(*(depProvider.dependentRecords().begin()) == DummyRecord::keyForClass());
0245
0246 edm::print_eventsetup_record_dependencies<DepRecord>(std::cout);
0247 }
0248
0249 void testdependentrecord::dependentFinder1Test() {
0250 auto dummyProvider = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0251 const edm::EventID eID_1(1, 1, 1);
0252 const edm::IOVSyncValue sync_1(eID_1);
0253 const edm::EventID eID_3(1, 1, 3);
0254 const edm::ValidityInterval definedInterval(sync_1, edm::IOVSyncValue(eID_3));
0255 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
0256 dummyFinder->setInterval(definedInterval);
0257 dummyProvider->addFinder(dummyFinder);
0258
0259 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
0260 DependentRecordIntervalFinder finder(depRecordKey);
0261 finder.addProviderWeAreDependentOn(dummyProvider);
0262
0263 CPPUNIT_ASSERT(definedInterval == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 2))));
0264
0265 dummyFinder->setInterval(edm::ValidityInterval::invalidInterval());
0266 dummyProvider->initializeForNewSyncValue();
0267 CPPUNIT_ASSERT(edm::ValidityInterval::invalidInterval() ==
0268 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 4))));
0269
0270 const edm::EventID eID_5(1, 1, 5);
0271 const edm::IOVSyncValue sync_5(eID_5);
0272 const edm::ValidityInterval unknownedEndInterval(sync_5, edm::IOVSyncValue::invalidIOVSyncValue());
0273 dummyFinder->setInterval(unknownedEndInterval);
0274
0275 dummyProvider->initializeForNewSyncValue();
0276 CPPUNIT_ASSERT(unknownedEndInterval ==
0277 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 5))));
0278 }
0279
0280 void testdependentrecord::dependentFinder2Test() {
0281 auto dummyProvider1 = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0282
0283 const edm::EventID eID_1(1, 1, 1);
0284 const edm::IOVSyncValue sync_1(eID_1);
0285 const edm::ValidityInterval definedInterval1(sync_1, edm::IOVSyncValue(edm::EventID(1, 1, 5)));
0286 dummyProvider1->setValidityInterval_forTesting(definedInterval1);
0287
0288 auto dummyProvider2 = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0289
0290 const edm::EventID eID_2(1, 1, 2);
0291 const edm::IOVSyncValue sync_2(eID_2);
0292 const edm::ValidityInterval definedInterval2(sync_2, edm::IOVSyncValue(edm::EventID(1, 1, 6)));
0293 dummyProvider2->setValidityInterval_forTesting(definedInterval2);
0294
0295 const edm::ValidityInterval overlapInterval(std::max(definedInterval1.first(), definedInterval2.first()),
0296 std::min(definedInterval1.last(), definedInterval2.last()));
0297
0298 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
0299
0300 DependentRecordIntervalFinder finder(depRecordKey);
0301 finder.addProviderWeAreDependentOn(dummyProvider1);
0302 finder.addProviderWeAreDependentOn(dummyProvider2);
0303
0304 CPPUNIT_ASSERT(overlapInterval == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 4))));
0305 }
0306
0307 void testdependentrecord::testIncomparibleIOVAlgorithm() {
0308 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
0309 DependentRecordIntervalFinder finder(depRecordKey);
0310
0311
0312 auto dummyProviderEventID = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0313 auto dummyProviderTime = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0314
0315 finder.addProviderWeAreDependentOn(dummyProviderEventID);
0316 finder.addProviderWeAreDependentOn(dummyProviderTime);
0317
0318 {
0319 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 1, 1)),
0320 edm::IOVSyncValue(edm::EventID(1, 1, 5)));
0321 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0322
0323 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(1)), edm::IOVSyncValue(edm::Timestamp(6)));
0324 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0325
0326 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336 CPPUNIT_ASSERT(expectedIOV ==
0337 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 4), edm::Timestamp(3))));
0338
0339
0340
0341
0342
0343 dummyProviderEventID->initializeForNewSyncValue();
0344 dummyProviderTime->initializeForNewSyncValue();
0345 CPPUNIT_ASSERT(expectedIOV ==
0346 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 4), edm::Timestamp(4))));
0347
0348
0349 dummyProviderEventID->initializeForNewSyncValue();
0350 dummyProviderTime->initializeForNewSyncValue();
0351 CPPUNIT_ASSERT(expectedIOV ==
0352 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 2), edm::Timestamp(3))));
0353
0354
0355 dummyProviderEventID->initializeForNewSyncValue();
0356 dummyProviderTime->initializeForNewSyncValue();
0357 CPPUNIT_ASSERT(expectedIOV ==
0358 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 1), edm::Timestamp(2))));
0359 }
0360 {
0361
0362
0363
0364 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 1, 6)),
0365 edm::IOVSyncValue(edm::EventID(1, 1, 10)));
0366 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0367
0368 const edm::ValidityInterval expectedIOV(iovEventID.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0369
0370
0371
0372 dummyProviderTime->initializeForNewSyncValue();
0373 CPPUNIT_ASSERT(expectedIOV ==
0374 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 6), edm::Timestamp(5))));
0375 }
0376 {
0377
0378 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(7)), edm::IOVSyncValue(edm::Timestamp(10)));
0379 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0380
0381 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0382
0383 dummyProviderEventID->initializeForNewSyncValue();
0384 CPPUNIT_ASSERT(expectedIOV ==
0385 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 7), edm::Timestamp(7))));
0386 }
0387
0388 {
0389 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 2, 11)),
0390 edm::IOVSyncValue(edm::EventID(1, 3, 20)));
0391 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0392
0393 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(1ULL << 32)),
0394 edm::IOVSyncValue(edm::Timestamp(5ULL << 32)));
0395 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0396
0397 const edm::ValidityInterval expectedIOV(iovEventID.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0398 CPPUNIT_ASSERT(
0399 expectedIOV ==
0400 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 2, 12), edm::Timestamp(3ULL << 32))));
0401 }
0402
0403 {
0404 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 3, 21)),
0405 edm::IOVSyncValue(edm::EventID(1, 10, 40)));
0406 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0407
0408 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(7ULL << 32)),
0409 edm::IOVSyncValue(edm::Timestamp(10ULL << 32)));
0410 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0411
0412 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0413 CPPUNIT_ASSERT(
0414 expectedIOV ==
0415 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 4, 30), edm::Timestamp(8ULL << 32))));
0416 }
0417
0418 {
0419 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 11, 41)),
0420 edm::IOVSyncValue(edm::EventID(1, 20, 60)));
0421 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0422
0423 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(11ULL << 32)),
0424 edm::IOVSyncValue(edm::Timestamp(100ULL << 32)));
0425 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0426
0427 const edm::ValidityInterval expectedIOV(iovEventID.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0428 CPPUNIT_ASSERT(
0429 expectedIOV ==
0430 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 12, 50), edm::Timestamp(70ULL << 32))));
0431 }
0432
0433
0434 {
0435 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(2, 1, 0)),
0436 edm::IOVSyncValue(edm::EventID(6, 0, 0)));
0437 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0438
0439 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(200ULL << 32)),
0440 edm::IOVSyncValue(edm::Timestamp(500ULL << 32)));
0441 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0442
0443 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0444 CPPUNIT_ASSERT(
0445 expectedIOV ==
0446 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(4, 12, 50), edm::Timestamp(400ULL << 32))));
0447 }
0448 {
0449 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 1, 6)),
0450 edm::IOVSyncValue(edm::EventID(1, 1, 10)));
0451 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0452
0453 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(7)), edm::IOVSyncValue(edm::Timestamp(10)));
0454 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0455
0456 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0457 CPPUNIT_ASSERT(expectedIOV ==
0458 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 7), edm::Timestamp(7))));
0459 }
0460 }
0461
0462 void testdependentrecord::testInvalidIOVAlgorithm() {
0463 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
0464 DependentRecordIntervalFinder finder(depRecordKey);
0465
0466 auto dummyProviderEventID = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0467 auto dummyProviderTime = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0468
0469 finder.addProviderWeAreDependentOn(dummyProviderEventID);
0470 finder.addProviderWeAreDependentOn(dummyProviderTime);
0471
0472 {
0473 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 1, 6)),
0474 edm::IOVSyncValue(edm::EventID(1, 1, 10)));
0475 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0476
0477 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(7)), edm::IOVSyncValue(edm::Timestamp(10)));
0478 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0479
0480 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0481 CPPUNIT_ASSERT(expectedIOV ==
0482 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 7), edm::Timestamp(7))));
0483 }
0484
0485
0486 const edm::ValidityInterval invalid(edm::IOVSyncValue::invalidIOVSyncValue(),
0487 edm::IOVSyncValue::invalidIOVSyncValue());
0488 {
0489 dummyProviderEventID->setValidityInterval_forTesting(invalid);
0490 dummyProviderTime->initializeForNewSyncValue();
0491 const edm::ValidityInterval expectedIOV(edm::IOVSyncValue(edm::Timestamp(7)),
0492 edm::IOVSyncValue::invalidIOVSyncValue());
0493 CPPUNIT_ASSERT(expectedIOV ==
0494 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 11), edm::Timestamp(8))));
0495 }
0496 {
0497 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 1, 12)),
0498 edm::IOVSyncValue(edm::EventID(1, 1, 20)));
0499 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0500 dummyProviderTime->setValidityInterval_forTesting(invalid);
0501 const edm::ValidityInterval expectedIOV(iovEventID.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0502 CPPUNIT_ASSERT(expectedIOV ==
0503 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 13), edm::Timestamp(11))));
0504 }
0505 {
0506 dummyProviderEventID->setValidityInterval_forTesting(invalid);
0507 dummyProviderTime->setValidityInterval_forTesting(invalid);
0508
0509 dummyProviderEventID->initializeForNewSyncValue();
0510 CPPUNIT_ASSERT(invalid ==
0511 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 13), edm::Timestamp(11))));
0512 }
0513 }
0514
0515 void testdependentrecord::testInvalidIOVFirstTime() {
0516 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
0517 DependentRecordIntervalFinder finder(depRecordKey);
0518
0519 auto dummyProviderEventID = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0520 auto dummyProviderTime = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0521
0522 finder.addProviderWeAreDependentOn(dummyProviderEventID);
0523 finder.addProviderWeAreDependentOn(dummyProviderTime);
0524
0525 const edm::ValidityInterval invalid(edm::IOVSyncValue::invalidIOVSyncValue(),
0526 edm::IOVSyncValue::invalidIOVSyncValue());
0527 {
0528
0529
0530 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 1, 1)),
0531 edm::IOVSyncValue(edm::EventID(1, 1, 6)));
0532 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0533
0534 dummyProviderTime->setValidityInterval_forTesting(invalid);
0535
0536 const edm::ValidityInterval expectedIOV(iovEventID.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0537
0538 CPPUNIT_ASSERT(expectedIOV ==
0539 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 4), edm::Timestamp(1))));
0540 }
0541 {
0542 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(2)), edm::IOVSyncValue(edm::Timestamp(6)));
0543 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0544
0545 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0546
0547 dummyProviderEventID->initializeForNewSyncValue();
0548 CPPUNIT_ASSERT(expectedIOV ==
0549 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 5), edm::Timestamp(3))));
0550 }
0551 }
0552
0553 void testdependentrecord::testInvalidIOVFirstEventID() {
0554 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
0555 DependentRecordIntervalFinder finder(depRecordKey);
0556
0557 auto dummyProviderEventID = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0558 auto dummyProviderTime = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0559
0560 finder.addProviderWeAreDependentOn(dummyProviderEventID);
0561 finder.addProviderWeAreDependentOn(dummyProviderTime);
0562
0563 const edm::ValidityInterval invalid(edm::IOVSyncValue::invalidIOVSyncValue(),
0564 edm::IOVSyncValue::invalidIOVSyncValue());
0565 {
0566
0567
0568 dummyProviderEventID->setValidityInterval_forTesting(invalid);
0569
0570 const edm::ValidityInterval iovTime(edm::IOVSyncValue(edm::Timestamp(1)), edm::IOVSyncValue(edm::Timestamp(6)));
0571 dummyProviderTime->setValidityInterval_forTesting(iovTime);
0572
0573 const edm::ValidityInterval expectedIOV(iovTime.first(), edm::IOVSyncValue::invalidIOVSyncValue());
0574
0575 CPPUNIT_ASSERT(expectedIOV ==
0576 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 4), edm::Timestamp(3))));
0577 }
0578 {
0579 const edm::ValidityInterval iovEventID(edm::IOVSyncValue(edm::EventID(1, 1, 5)),
0580 edm::IOVSyncValue(edm::EventID(1, 1, 10)));
0581 dummyProviderEventID->setValidityInterval_forTesting(iovEventID);
0582
0583 const edm::ValidityInterval expectedIOV(edm::IOVSyncValue(edm::Timestamp(1)),
0584 edm::IOVSyncValue::invalidIOVSyncValue());
0585 dummyProviderTime->initializeForNewSyncValue();
0586 CPPUNIT_ASSERT(expectedIOV ==
0587 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 5), edm::Timestamp(4))));
0588 }
0589 }
0590
0591 void testdependentrecord::timeAndRunTest() {
0592 edm::ParameterSet pset = createDummyPset();
0593 {
0594 SynchronousEventSetupsController controller;
0595 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
0596
0597 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> dummyProv =
0598 std::make_shared<DummyESProductResolverProvider>();
0599 provider.add(dummyProv);
0600
0601 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
0602 dummyFinder->setInterval(
0603 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 5))));
0604 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
0605
0606 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> depProv =
0607 std::make_shared<DepOn2RecordResolverProvider>();
0608 provider.add(depProv);
0609
0610 std::shared_ptr<Dummy2RecordFinder> dummy2Finder = std::make_shared<Dummy2RecordFinder>();
0611 dummy2Finder->setInterval(
0612 edm::ValidityInterval(edm::IOVSyncValue(edm::Timestamp(1)), edm::IOVSyncValue(edm::Timestamp(5))));
0613 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummy2Finder));
0614
0615 {
0616 edm::ESParentContext parentC;
0617 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1), edm::Timestamp(1)));
0618 const edm::EventSetup eventSetup1(provider.eventSetupImpl(), 0, nullptr, parentC);
0619 long long id1 = eventSetup1.get<DepOn2Record>().cacheIdentifier();
0620
0621 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1), edm::Timestamp(2)));
0622 const edm::EventSetup eventSetup2(provider.eventSetupImpl(), 0, nullptr, parentC);
0623 long long id2 = eventSetup2.get<DepOn2Record>().cacheIdentifier();
0624 CPPUNIT_ASSERT(id1 == id2);
0625
0626 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 2), edm::Timestamp(2)));
0627 const edm::EventSetup eventSetup3(provider.eventSetupImpl(), 0, nullptr, parentC);
0628 long long id3 = eventSetup3.get<DepOn2Record>().cacheIdentifier();
0629 CPPUNIT_ASSERT(id1 == id3);
0630
0631 dummy2Finder->setInterval(
0632 edm::ValidityInterval(edm::IOVSyncValue(edm::Timestamp(6)), edm::IOVSyncValue(edm::Timestamp(10))));
0633
0634 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 4), edm::Timestamp(7)));
0635 const edm::EventSetup eventSetup4(provider.eventSetupImpl(), 0, nullptr, parentC);
0636 long long id4 = eventSetup4.get<DepOn2Record>().cacheIdentifier();
0637 CPPUNIT_ASSERT(id1 != id4);
0638
0639 dummyFinder->setInterval(
0640 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 6)), edm::IOVSyncValue(edm::EventID(1, 1, 10))));
0641
0642 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 7), edm::Timestamp(8)));
0643 const edm::EventSetup eventSetup5(provider.eventSetupImpl(), 0, nullptr, parentC);
0644 long long id5 = eventSetup5.get<DepOn2Record>().cacheIdentifier();
0645 CPPUNIT_ASSERT(id4 != id5);
0646 }
0647 }
0648
0649 {
0650
0651
0652 SynchronousEventSetupsController controller;
0653 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
0654
0655 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> dummyProv =
0656 std::make_shared<DummyESProductResolverProvider>();
0657 provider.add(dummyProv);
0658
0659 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
0660 dummyFinder->setInterval(
0661 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue::invalidIOVSyncValue()));
0662 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
0663
0664 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> depProv =
0665 std::make_shared<DepOn2RecordResolverProvider>();
0666 provider.add(depProv);
0667
0668 std::shared_ptr<Dummy2RecordFinder> dummy2Finder = std::make_shared<Dummy2RecordFinder>();
0669 dummy2Finder->setInterval(
0670 edm::ValidityInterval(edm::IOVSyncValue(edm::Timestamp(1)), edm::IOVSyncValue::invalidIOVSyncValue()));
0671 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummy2Finder));
0672 {
0673 edm::ESParentContext parentC;
0674 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1), edm::Timestamp(1)));
0675 const edm::EventSetup eventSetup1(provider.eventSetupImpl(), 0, nullptr, parentC);
0676 long long id1 = eventSetup1.get<DepOn2Record>().cacheIdentifier();
0677
0678 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1), edm::Timestamp(2)));
0679 const edm::EventSetup eventSetup2(provider.eventSetupImpl(), 0, nullptr, parentC);
0680 long long id2 = eventSetup2.get<DepOn2Record>().cacheIdentifier();
0681 CPPUNIT_ASSERT(id1 == id2);
0682
0683 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 2), edm::Timestamp(2)));
0684 const edm::EventSetup eventSetup3(provider.eventSetupImpl(), 0, nullptr, parentC);
0685 long long id3 = eventSetup3.get<DepOn2Record>().cacheIdentifier();
0686 CPPUNIT_ASSERT(id1 == id3);
0687
0688 dummy2Finder->setInterval(
0689 edm::ValidityInterval(edm::IOVSyncValue(edm::Timestamp(6)), edm::IOVSyncValue::invalidIOVSyncValue()));
0690 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 4), edm::Timestamp(7)));
0691 const edm::EventSetup eventSetup4(provider.eventSetupImpl(), 0, nullptr, parentC);
0692 long long id4 = eventSetup4.get<DepOn2Record>().cacheIdentifier();
0693 CPPUNIT_ASSERT(id1 != id4);
0694
0695 dummyFinder->setInterval(
0696 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 6)), edm::IOVSyncValue::invalidIOVSyncValue()));
0697 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 7), edm::Timestamp(8)));
0698 const edm::EventSetup eventSetup5(provider.eventSetupImpl(), 0, nullptr, parentC);
0699 long long id5 = eventSetup5.get<DepOn2Record>().cacheIdentifier();
0700 CPPUNIT_ASSERT(id4 != id5);
0701 }
0702 }
0703 }
0704
0705 void testdependentrecord::dependentSetproviderTest() {
0706 auto depProvider = std::make_unique<EventSetupRecordProvider>(DepRecord::keyForClass(), &activityRegistry);
0707
0708 auto dummyProvider = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
0709
0710 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
0711 dummyFinder->setInterval(
0712 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 3))));
0713 dummyProvider->addFinder(dummyFinder);
0714
0715 CPPUNIT_ASSERT(*(depProvider->dependentRecords().begin()) == dummyProvider->key());
0716
0717 std::vector<std::shared_ptr<EventSetupRecordProvider>> providers;
0718 providers.push_back(dummyProvider);
0719 depProvider->setDependentProviders(providers);
0720 }
0721
0722 void testdependentrecord::getTest() {
0723 SynchronousEventSetupsController controller;
0724 edm::ParameterSet pset = createDummyPset();
0725 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
0726
0727 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> dummyProv =
0728 std::make_shared<DummyESProductResolverProvider>();
0729 provider.add(dummyProv);
0730
0731 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
0732 dummyFinder->setInterval(
0733 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 3))));
0734 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
0735
0736 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> depProv = std::make_shared<DepRecordResolverProvider>();
0737 provider.add(depProv);
0738 edm::ESParentContext parentC;
0739 {
0740 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1)));
0741 const edm::EventSetup eventSetup1(provider.eventSetupImpl(), 0, nullptr, parentC);
0742 const DepRecord& depRecord = eventSetup1.get<DepRecord>();
0743
0744 depRecord.getRecord<DummyRecord>();
0745
0746 auto dr = depRecord.tryToGetRecord<DummyRecord>();
0747 CPPUNIT_ASSERT(dr.has_value());
0748 }
0749 {
0750 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 4)));
0751 const edm::EventSetup eventSetup2(provider.eventSetupImpl(), 0, nullptr, parentC);
0752 CPPUNIT_ASSERT_THROW(eventSetup2.get<DepRecord>(), edm::eventsetup::NoRecordException<DepRecord>);
0753 }
0754 }
0755
0756 namespace {
0757 template <typename RECORD>
0758 struct DummyDataConsumer : public edm::EDConsumerBase {
0759 explicit DummyDataConsumer(edm::ESInputTag const& iTag)
0760 : m_token{esConsumes<edm::eventsetup::test::DummyData, RECORD>(iTag)} {}
0761
0762 void prefetch(edm::EventSetupImpl const& iImpl) const {
0763 auto const& recs = this->esGetTokenRecordIndicesVector(edm::Transition::Event);
0764 auto const& proxies = this->esGetTokenIndicesVector(edm::Transition::Event);
0765 for (size_t i = 0; i != proxies.size(); ++i) {
0766 auto rec = iImpl.findImpl(recs[i]);
0767 if (rec) {
0768 oneapi::tbb::task_group group;
0769 edm::FinalWaitingTask waitTask{group};
0770 edm::ServiceToken token;
0771 rec->prefetchAsync(
0772 edm::WaitingTaskHolder(group, &waitTask), proxies[i], &iImpl, token, edm::ESParentContext{});
0773 waitTask.wait();
0774 }
0775 }
0776 }
0777 edm::ESGetToken<edm::eventsetup::test::DummyData, RECORD> m_token;
0778 };
0779
0780 template <typename RECORD1, typename RECORD2>
0781 struct DummyDataConsumer2 : public edm::EDConsumerBase {
0782 explicit DummyDataConsumer2(edm::ESInputTag const& iTag1, edm::ESInputTag const& iTag2)
0783 : m_token1{esConsumes<edm::eventsetup::test::DummyData, RECORD1>(iTag1)},
0784 m_token2{esConsumes<edm::eventsetup::test::DummyData, RECORD2>(iTag2)} {}
0785
0786 void prefetch(edm::EventSetupImpl const& iImpl) const {
0787 auto const& recs = this->esGetTokenRecordIndicesVector(edm::Transition::Event);
0788 auto const& proxies = this->esGetTokenIndicesVector(edm::Transition::Event);
0789 for (size_t i = 0; i != proxies.size(); ++i) {
0790 auto rec = iImpl.findImpl(recs[i]);
0791 if (rec) {
0792 oneapi::tbb::task_group group;
0793 edm::FinalWaitingTask waitTask{group};
0794 edm::ServiceToken token;
0795 rec->prefetchAsync(
0796 edm::WaitingTaskHolder(group, &waitTask), proxies[i], &iImpl, token, edm::ESParentContext{});
0797 waitTask.wait();
0798 }
0799 }
0800 }
0801
0802 edm::ESGetToken<edm::eventsetup::test::DummyData, RECORD1> m_token1;
0803 edm::ESGetToken<edm::eventsetup::test::DummyData, RECORD2> m_token2;
0804 };
0805 }
0806
0807 void testdependentrecord::getDataWithESGetTokenTest() {
0808 using edm::eventsetup::test::DummyData;
0809 using edm::eventsetup::test::DummyESProductResolverProvider;
0810 DummyData kGood{1};
0811 DummyData kBad{0};
0812
0813 SynchronousEventSetupsController controller;
0814 edm::ParameterSet pset = createDummyPset();
0815 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
0816
0817 try {
0818 {
0819 edm::eventsetup::ComponentDescription description("DummyESProductResolverProvider", "testOne", 0, true);
0820 edm::ParameterSet ps;
0821 ps.addParameter<std::string>("name", "test11");
0822 ps.registerIt();
0823 description.pid_ = ps.id();
0824 auto dummyProv = std::make_shared<DummyESProductResolverProvider>(kBad);
0825 dummyProv->setDescription(description);
0826 provider.add(dummyProv);
0827 }
0828 {
0829 edm::eventsetup::ComponentDescription description("DepRecordResolverProviderWithData", "testTwo", 1, true);
0830 edm::ParameterSet ps;
0831 ps.addParameter<std::string>("name", "test22");
0832 ps.addParameter<std::string>("appendToDataLabel", "blah");
0833 ps.registerIt();
0834 description.pid_ = ps.id();
0835 auto dummyProv = std::make_shared<DepRecordResolverProviderWithData>(kGood);
0836 dummyProv->setDescription(description);
0837 dummyProv->setAppendToDataLabel(ps);
0838 provider.add(dummyProv);
0839 }
0840
0841 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
0842 dummyFinder->setInterval(
0843 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 3))));
0844 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
0845
0846 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1)));
0847 edm::ESParentContext parentC;
0848 {
0849 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
0850 consumer.updateLookup(provider.recordsToResolverIndices());
0851 consumer.prefetch(provider.eventSetupImpl());
0852 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0853 static_cast<unsigned int>(edm::Transition::Event),
0854 consumer.esGetTokenIndices(edm::Transition::Event),
0855 parentC};
0856 auto const& data = eventSetup.getData(consumer.m_token);
0857 CPPUNIT_ASSERT(kGood.value_ == data.value_);
0858 }
0859 {
0860 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"", ""}};
0861 consumer.updateLookup(provider.recordsToResolverIndices());
0862 consumer.prefetch(provider.eventSetupImpl());
0863 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0864 static_cast<unsigned int>(edm::Transition::Event),
0865 consumer.esGetTokenIndices(edm::Transition::Event),
0866 parentC};
0867 auto const& data = eventSetup.getData(consumer.m_token);
0868 CPPUNIT_ASSERT(kBad.value_ == data.value_);
0869 }
0870 {
0871 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
0872 consumer.updateLookup(provider.recordsToResolverIndices());
0873 consumer.prefetch(provider.eventSetupImpl());
0874 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0875 static_cast<unsigned int>(edm::Transition::Event),
0876 consumer.esGetTokenIndices(edm::Transition::Event),
0877 parentC};
0878 auto const& depRecord = eventSetup.get<DepRecord>();
0879 auto const& data = depRecord.get(consumer.m_token);
0880 CPPUNIT_ASSERT(kGood.value_ == data.value_);
0881 }
0882 {
0883 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"", ""}};
0884 consumer.updateLookup(provider.recordsToResolverIndices());
0885 consumer.prefetch(provider.eventSetupImpl());
0886 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0887 static_cast<unsigned int>(edm::Transition::Event),
0888 consumer.esGetTokenIndices(edm::Transition::Event),
0889 parentC};
0890 auto const& depRecord = eventSetup.get<DepRecord>();
0891
0892 auto const& data = depRecord.get(consumer.m_token);
0893 CPPUNIT_ASSERT(kBad.value_ == data.value_);
0894 }
0895 {
0896 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
0897 consumer.updateLookup(provider.recordsToResolverIndices());
0898 consumer.prefetch(provider.eventSetupImpl());
0899 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0900 static_cast<unsigned int>(edm::Transition::Event),
0901 consumer.esGetTokenIndices(edm::Transition::Event),
0902 parentC};
0903 auto const& depRecord = eventSetup.get<DepRecord>();
0904
0905 auto const& data = depRecord.get(consumer.m_token);
0906 CPPUNIT_ASSERT(kGood.value_ == data.value_);
0907 }
0908 {
0909 DummyDataConsumer2<DummyRecord, DepRecord> consumer{edm::ESInputTag{"", ""}, edm::ESInputTag{"", "blah"}};
0910 consumer.updateLookup(provider.recordsToResolverIndices());
0911 consumer.prefetch(provider.eventSetupImpl());
0912 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0913 static_cast<unsigned int>(edm::Transition::Event),
0914 consumer.esGetTokenIndices(edm::Transition::Event),
0915 parentC};
0916 auto const& depRecord = eventSetup.get<DepRecord>();
0917
0918 auto const& data1 = depRecord.get(consumer.m_token1);
0919 CPPUNIT_ASSERT(kBad.value_ == data1.value_);
0920
0921 auto const& data2 = depRecord.get(consumer.m_token2);
0922 CPPUNIT_ASSERT(kGood.value_ == data2.value_);
0923 }
0924 {
0925 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"DoesNotExist", ""}};
0926 consumer.updateLookup(provider.recordsToResolverIndices());
0927 consumer.prefetch(provider.eventSetupImpl());
0928 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0929 static_cast<unsigned int>(edm::Transition::Event),
0930 consumer.esGetTokenIndices(edm::Transition::Event),
0931 parentC};
0932 auto const& depRecord = eventSetup.get<DepRecord>();
0933
0934 CPPUNIT_ASSERT_THROW(depRecord.get(consumer.m_token), cms::Exception);
0935 }
0936 {
0937 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"DoesNotExist", "blah"}};
0938 consumer.updateLookup(provider.recordsToResolverIndices());
0939 consumer.prefetch(provider.eventSetupImpl());
0940 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
0941 static_cast<unsigned int>(edm::Transition::Event),
0942 consumer.esGetTokenIndices(edm::Transition::Event),
0943 parentC};
0944 auto const& depRecord = eventSetup.get<DepRecord>();
0945
0946 CPPUNIT_ASSERT_THROW(depRecord.get(consumer.m_token), cms::Exception);
0947 }
0948 } catch (const cms::Exception& iException) {
0949 std::cout << "caught " << iException.explainSelf() << std::endl;
0950 throw;
0951 }
0952 }
0953
0954 void testdependentrecord::getHandleWithESGetTokenTest() {
0955 using edm::eventsetup::test::DummyData;
0956 using edm::eventsetup::test::DummyESProductResolverProvider;
0957 DummyData kGood{1};
0958 DummyData kBad{0};
0959
0960 SynchronousEventSetupsController controller;
0961 edm::ParameterSet pset = createDummyPset();
0962 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
0963
0964 try {
0965 {
0966 edm::eventsetup::ComponentDescription description("DummyESProductResolverProvider", "testOne", 0, true);
0967 edm::ParameterSet ps;
0968 ps.addParameter<std::string>("name", "test11");
0969 ps.registerIt();
0970 description.pid_ = ps.id();
0971 auto dummyProv = std::make_shared<DummyESProductResolverProvider>(kBad);
0972 dummyProv->setDescription(description);
0973 provider.add(dummyProv);
0974 }
0975 {
0976 edm::eventsetup::ComponentDescription description("DepRecordResolverProviderWithData", "testTwo", 1, true);
0977 edm::ParameterSet ps;
0978 ps.addParameter<std::string>("name", "test22");
0979 ps.addParameter<std::string>("appendToDataLabel", "blah");
0980 ps.registerIt();
0981 description.pid_ = ps.id();
0982 auto dummyProv = std::make_shared<DepRecordResolverProviderWithData>(kGood);
0983 dummyProv->setDescription(description);
0984 dummyProv->setAppendToDataLabel(ps);
0985 provider.add(dummyProv);
0986 }
0987 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
0988 dummyFinder->setInterval(
0989 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 3))));
0990 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
0991
0992 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1)));
0993
0994 edm::ESParentContext parentC;
0995 {
0996 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
0997 consumer.updateLookup(provider.recordsToResolverIndices());
0998 consumer.prefetch(provider.eventSetupImpl());
0999 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1000 static_cast<unsigned int>(edm::Transition::Event),
1001 consumer.esGetTokenIndices(edm::Transition::Event),
1002 parentC};
1003 edm::ESHandle<DummyData> data = eventSetup.getHandle(consumer.m_token);
1004 CPPUNIT_ASSERT(kGood.value_ == data->value_);
1005 const edm::eventsetup::ComponentDescription* desc = data.description();
1006 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1007 }
1008 {
1009 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"", ""}};
1010 consumer.updateLookup(provider.recordsToResolverIndices());
1011 consumer.prefetch(provider.eventSetupImpl());
1012 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1013 static_cast<unsigned int>(edm::Transition::Event),
1014 consumer.esGetTokenIndices(edm::Transition::Event),
1015 parentC};
1016 edm::ESHandle<DummyData> data = eventSetup.getHandle(consumer.m_token);
1017 CPPUNIT_ASSERT(kBad.value_ == data->value_);
1018 const edm::eventsetup::ComponentDescription* desc = data.description();
1019 CPPUNIT_ASSERT(desc->label_ == "testOne");
1020 }
1021 {
1022 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
1023 consumer.updateLookup(provider.recordsToResolverIndices());
1024 consumer.prefetch(provider.eventSetupImpl());
1025 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1026 static_cast<unsigned int>(edm::Transition::Event),
1027 consumer.esGetTokenIndices(edm::Transition::Event),
1028 parentC};
1029 auto const& depRecord = eventSetup.get<DepRecord>();
1030
1031 edm::ESHandle<DummyData> data = depRecord.getHandle(consumer.m_token);
1032 CPPUNIT_ASSERT(kGood.value_ == data->value_);
1033 const edm::eventsetup::ComponentDescription* desc = data.description();
1034 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1035 }
1036 {
1037 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"", ""}};
1038 consumer.updateLookup(provider.recordsToResolverIndices());
1039 consumer.prefetch(provider.eventSetupImpl());
1040 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1041 static_cast<unsigned int>(edm::Transition::Event),
1042 consumer.esGetTokenIndices(edm::Transition::Event),
1043 parentC};
1044 auto const& depRecord = eventSetup.get<DepRecord>();
1045
1046 edm::ESHandle<DummyData> data = depRecord.getHandle(consumer.m_token);
1047 CPPUNIT_ASSERT(kBad.value_ == data->value_);
1048 const edm::eventsetup::ComponentDescription* desc = data.description();
1049 CPPUNIT_ASSERT(desc->label_ == "testOne");
1050 }
1051 {
1052 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
1053 consumer.updateLookup(provider.recordsToResolverIndices());
1054 consumer.prefetch(provider.eventSetupImpl());
1055 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1056 static_cast<unsigned int>(edm::Transition::Event),
1057 consumer.esGetTokenIndices(edm::Transition::Event),
1058 parentC};
1059 auto const& depRecord = eventSetup.get<DepRecord>();
1060
1061 edm::ESHandle<DummyData> data = depRecord.getHandle(consumer.m_token);
1062 CPPUNIT_ASSERT(kGood.value_ == data->value_);
1063 const edm::eventsetup::ComponentDescription* desc = data.description();
1064 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1065 }
1066 {
1067 DummyDataConsumer2<DummyRecord, DepRecord> consumer{edm::ESInputTag{"", ""}, edm::ESInputTag{"", "blah"}};
1068 consumer.updateLookup(provider.recordsToResolverIndices());
1069 consumer.prefetch(provider.eventSetupImpl());
1070 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1071 static_cast<unsigned int>(edm::Transition::Event),
1072 consumer.esGetTokenIndices(edm::Transition::Event),
1073 parentC};
1074 auto const& depRecord = eventSetup.get<DepRecord>();
1075
1076 edm::ESHandle<DummyData> data1 = depRecord.getHandle(consumer.m_token1);
1077 CPPUNIT_ASSERT(kBad.value_ == data1->value_);
1078 const edm::eventsetup::ComponentDescription* desc = data1.description();
1079 CPPUNIT_ASSERT(desc->label_ == "testOne");
1080
1081 edm::ESHandle<DummyData> data2 = depRecord.getHandle(consumer.m_token2);
1082 CPPUNIT_ASSERT(kGood.value_ == data2->value_);
1083 desc = data2.description();
1084 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1085 }
1086 {
1087 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"DoesNotExist", ""}};
1088 consumer.updateLookup(provider.recordsToResolverIndices());
1089 consumer.prefetch(provider.eventSetupImpl());
1090 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1091 static_cast<unsigned int>(edm::Transition::Event),
1092 consumer.esGetTokenIndices(edm::Transition::Event),
1093 parentC};
1094 auto const& depRecord = eventSetup.get<DepRecord>();
1095
1096 CPPUNIT_ASSERT(not depRecord.getHandle(consumer.m_token));
1097 CPPUNIT_ASSERT_THROW(*depRecord.getHandle(consumer.m_token), cms::Exception);
1098 }
1099 {
1100 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"DoesNotExist", "blah"}};
1101 consumer.updateLookup(provider.recordsToResolverIndices());
1102 consumer.prefetch(provider.eventSetupImpl());
1103 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1104 static_cast<unsigned int>(edm::Transition::Event),
1105 consumer.esGetTokenIndices(edm::Transition::Event),
1106 parentC};
1107 auto const& depRecord = eventSetup.get<DepRecord>();
1108
1109 CPPUNIT_ASSERT(not depRecord.getHandle(consumer.m_token));
1110 CPPUNIT_ASSERT_THROW(*depRecord.getHandle(consumer.m_token), cms::Exception);
1111 }
1112 } catch (const cms::Exception& iException) {
1113 std::cout << "caught " << iException.explainSelf() << std::endl;
1114 throw;
1115 }
1116 }
1117
1118 void testdependentrecord::getTransientHandleWithESGetTokenTest() {
1119 using edm::eventsetup::test::DummyData;
1120 using edm::eventsetup::test::DummyESProductResolverProvider;
1121 DummyData kGood{1};
1122 DummyData kBad{0};
1123
1124 SynchronousEventSetupsController controller;
1125 edm::ParameterSet pset = createDummyPset();
1126 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
1127
1128 try {
1129 {
1130 edm::eventsetup::ComponentDescription description("DummyESProductResolverProvider", "testOne", 0, true);
1131 edm::ParameterSet ps;
1132 ps.addParameter<std::string>("name", "test11");
1133 ps.registerIt();
1134 description.pid_ = ps.id();
1135 auto dummyProv = std::make_shared<DummyESProductResolverProvider>(kBad);
1136 dummyProv->setDescription(description);
1137 provider.add(dummyProv);
1138 }
1139 {
1140 edm::eventsetup::ComponentDescription description("DepRecordResolverProviderWithData", "testTwo", 1, true);
1141 edm::ParameterSet ps;
1142 ps.addParameter<std::string>("name", "test22");
1143 ps.addParameter<std::string>("appendToDataLabel", "blah");
1144 ps.registerIt();
1145 description.pid_ = ps.id();
1146 auto dummyProv = std::make_shared<DepRecordResolverProviderWithData>(kGood);
1147 dummyProv->setDescription(description);
1148 dummyProv->setAppendToDataLabel(ps);
1149 provider.add(dummyProv);
1150 }
1151 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
1152 dummyFinder->setInterval(
1153 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 3))));
1154 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
1155
1156 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1)));
1157 edm::ESParentContext parentC;
1158 {
1159 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
1160 consumer.updateLookup(provider.recordsToResolverIndices());
1161 consumer.prefetch(provider.eventSetupImpl());
1162 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1163 static_cast<unsigned int>(edm::Transition::Event),
1164 consumer.esGetTokenIndices(edm::Transition::Event),
1165 parentC};
1166 edm::ESTransientHandle<DummyData> data = eventSetup.getTransientHandle(consumer.m_token);
1167 CPPUNIT_ASSERT(kGood.value_ == data->value_);
1168 const edm::eventsetup::ComponentDescription* desc = data.description();
1169 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1170 }
1171 {
1172 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"", ""}};
1173 consumer.updateLookup(provider.recordsToResolverIndices());
1174 consumer.prefetch(provider.eventSetupImpl());
1175 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1176 static_cast<unsigned int>(edm::Transition::Event),
1177 consumer.esGetTokenIndices(edm::Transition::Event),
1178 parentC};
1179 edm::ESTransientHandle<DummyData> data = eventSetup.getTransientHandle(consumer.m_token);
1180 CPPUNIT_ASSERT(kBad.value_ == data->value_);
1181 const edm::eventsetup::ComponentDescription* desc = data.description();
1182 CPPUNIT_ASSERT(desc->label_ == "testOne");
1183 }
1184 {
1185 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
1186 consumer.updateLookup(provider.recordsToResolverIndices());
1187 consumer.prefetch(provider.eventSetupImpl());
1188 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1189 static_cast<unsigned int>(edm::Transition::Event),
1190 consumer.esGetTokenIndices(edm::Transition::Event),
1191 parentC};
1192 auto const& depRecord = eventSetup.get<DepRecord>();
1193
1194 edm::ESTransientHandle<DummyData> data = depRecord.getTransientHandle(consumer.m_token);
1195 CPPUNIT_ASSERT(kGood.value_ == data->value_);
1196 const edm::eventsetup::ComponentDescription* desc = data.description();
1197 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1198 }
1199 {
1200 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"", ""}};
1201 consumer.updateLookup(provider.recordsToResolverIndices());
1202 consumer.prefetch(provider.eventSetupImpl());
1203 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1204 static_cast<unsigned int>(edm::Transition::Event),
1205 consumer.esGetTokenIndices(edm::Transition::Event),
1206 parentC};
1207 auto const& depRecord = eventSetup.get<DepRecord>();
1208
1209 edm::ESTransientHandle<DummyData> data = depRecord.getTransientHandle(consumer.m_token);
1210 CPPUNIT_ASSERT(kBad.value_ == data->value_);
1211 const edm::eventsetup::ComponentDescription* desc = data.description();
1212 CPPUNIT_ASSERT(desc->label_ == "testOne");
1213 }
1214 {
1215 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"", "blah"}};
1216 consumer.updateLookup(provider.recordsToResolverIndices());
1217 consumer.prefetch(provider.eventSetupImpl());
1218 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1219 static_cast<unsigned int>(edm::Transition::Event),
1220 consumer.esGetTokenIndices(edm::Transition::Event),
1221 parentC};
1222 auto const& depRecord = eventSetup.get<DepRecord>();
1223
1224 edm::ESTransientHandle<DummyData> data = depRecord.getTransientHandle(consumer.m_token);
1225 CPPUNIT_ASSERT(kGood.value_ == data->value_);
1226 const edm::eventsetup::ComponentDescription* desc = data.description();
1227 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1228 }
1229 {
1230 DummyDataConsumer2<DummyRecord, DepRecord> consumer{edm::ESInputTag{"", ""}, edm::ESInputTag{"", "blah"}};
1231 consumer.updateLookup(provider.recordsToResolverIndices());
1232 consumer.prefetch(provider.eventSetupImpl());
1233 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1234 static_cast<unsigned int>(edm::Transition::Event),
1235 consumer.esGetTokenIndices(edm::Transition::Event),
1236 parentC};
1237 auto const& depRecord = eventSetup.get<DepRecord>();
1238
1239 edm::ESTransientHandle<DummyData> data1 = depRecord.getTransientHandle(consumer.m_token1);
1240 CPPUNIT_ASSERT(kBad.value_ == data1->value_);
1241 const edm::eventsetup::ComponentDescription* desc = data1.description();
1242 CPPUNIT_ASSERT(desc->label_ == "testOne");
1243
1244 edm::ESTransientHandle<DummyData> data2 = depRecord.getTransientHandle(consumer.m_token2);
1245 CPPUNIT_ASSERT(kGood.value_ == data2->value_);
1246 desc = data2.description();
1247 CPPUNIT_ASSERT(desc->label_ == "testTwo");
1248 }
1249 {
1250 DummyDataConsumer<DummyRecord> consumer{edm::ESInputTag{"DoesNotExist", ""}};
1251 consumer.updateLookup(provider.recordsToResolverIndices());
1252 consumer.prefetch(provider.eventSetupImpl());
1253 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1254 static_cast<unsigned int>(edm::Transition::Event),
1255 consumer.esGetTokenIndices(edm::Transition::Event),
1256 parentC};
1257 auto const& depRecord = eventSetup.get<DepRecord>();
1258
1259 edm::ESTransientHandle<DummyData> data = depRecord.getTransientHandle(consumer.m_token);
1260 CPPUNIT_ASSERT(not data);
1261 CPPUNIT_ASSERT_THROW(*data, cms::Exception);
1262 }
1263 {
1264 DummyDataConsumer<DepRecord> consumer{edm::ESInputTag{"DoesNotExist", "blah"}};
1265 consumer.updateLookup(provider.recordsToResolverIndices());
1266 consumer.prefetch(provider.eventSetupImpl());
1267 const edm::EventSetup eventSetup{provider.eventSetupImpl(),
1268 static_cast<unsigned int>(edm::Transition::Event),
1269 consumer.esGetTokenIndices(edm::Transition::Event),
1270 parentC};
1271 auto const& depRecord = eventSetup.get<DepRecord>();
1272
1273 edm::ESTransientHandle<DummyData> data = depRecord.getTransientHandle(consumer.m_token);
1274 CPPUNIT_ASSERT(not data);
1275 CPPUNIT_ASSERT_THROW(*data, cms::Exception);
1276 }
1277 } catch (const cms::Exception& iException) {
1278 std::cout << "caught " << iException.explainSelf() << std::endl;
1279 throw;
1280 }
1281 }
1282
1283 void testdependentrecord::oneOfTwoRecordTest() {
1284 SynchronousEventSetupsController controller;
1285 edm::ParameterSet pset = createDummyPset();
1286 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
1287
1288 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> dummyProv =
1289 std::make_shared<DummyESProductResolverProvider>();
1290 provider.add(dummyProv);
1291
1292 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
1293 dummyFinder->setInterval(
1294 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 3))));
1295 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
1296
1297 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> depProv =
1298 std::make_shared<DepOn2RecordResolverProvider>();
1299 provider.add(depProv);
1300 {
1301 edm::ESParentContext parentC;
1302 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1)));
1303 const edm::EventSetup eventSetup1(provider.eventSetupImpl(), 0, nullptr, parentC);
1304 const DepOn2Record& depRecord = eventSetup1.get<DepOn2Record>();
1305
1306 depRecord.getRecord<DummyRecord>();
1307 CPPUNIT_ASSERT_THROW(depRecord.getRecord<Dummy2Record>(), edm::eventsetup::NoRecordException<Dummy2Record>);
1308
1309 try {
1310 depRecord.getRecord<Dummy2Record>();
1311 } catch (edm::eventsetup::NoRecordException<Dummy2Record>& e) {
1312
1313 CPPUNIT_ASSERT(0 != strstr(e.what(), "DepOn2Record"));
1314 CPPUNIT_ASSERT(0 != strstr(e.what(), "Dummy2Record"));
1315
1316 }
1317 }
1318 }
1319
1320 void testdependentrecord::resetTest() {
1321 SynchronousEventSetupsController controller;
1322 edm::ParameterSet pset = createDummyPset();
1323 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
1324
1325 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> dummyProv =
1326 std::make_shared<DummyESProductResolverProvider>();
1327 provider.add(dummyProv);
1328
1329 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
1330 dummyFinder->setInterval(
1331 edm::ValidityInterval(edm::IOVSyncValue(edm::EventID(1, 1, 1)), edm::IOVSyncValue(edm::EventID(1, 1, 3))));
1332 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummyFinder));
1333
1334 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> depProv = std::make_shared<DepRecordResolverProvider>();
1335 provider.add(depProv);
1336 {
1337 edm::ESParentContext parentC;
1338 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1)));
1339 const edm::EventSetup eventSetup1(provider.eventSetupImpl(), 0, nullptr, parentC);
1340 const DepRecord& depRecord = eventSetup1.get<DepRecord>();
1341 unsigned long long depCacheID = depRecord.cacheIdentifier();
1342 const DummyRecord& dummyRecord = depRecord.getRecord<DummyRecord>();
1343 unsigned long long dummyCacheID = dummyRecord.cacheIdentifier();
1344
1345 provider.resetRecordPlusDependentRecords(dummyRecord.key());
1346 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1)));
1347 CPPUNIT_ASSERT(dummyCacheID != dummyRecord.cacheIdentifier());
1348 CPPUNIT_ASSERT(depCacheID != depRecord.cacheIdentifier());
1349 }
1350 }
1351
1352 void testdependentrecord::alternateFinderTest() {
1353 auto dummyProvider = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
1354
1355 const edm::EventID eID_1(1, 1, 1);
1356 const edm::IOVSyncValue sync_1(eID_1);
1357 const edm::EventID eID_3(1, 1, 3);
1358 const edm::IOVSyncValue sync_3(eID_3);
1359 const edm::EventID eID_4(1, 1, 4);
1360 const edm::ValidityInterval definedInterval(sync_1, edm::IOVSyncValue(eID_4));
1361 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
1362 dummyFinder->setInterval(definedInterval);
1363 dummyProvider->addFinder(dummyFinder);
1364
1365 std::shared_ptr<DepRecordFinder> depFinder = std::make_shared<DepRecordFinder>();
1366 const edm::EventID eID_2(1, 1, 2);
1367 const edm::IOVSyncValue sync_2(eID_2);
1368 const edm::ValidityInterval depInterval(sync_1, sync_2);
1369 depFinder->setInterval(depInterval);
1370
1371 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
1372 DependentRecordIntervalFinder finder(depRecordKey);
1373 finder.setAlternateFinder(depFinder);
1374 finder.addProviderWeAreDependentOn(dummyProvider);
1375
1376 CPPUNIT_ASSERT(depInterval == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 1))));
1377
1378 const edm::ValidityInterval dep2Interval(sync_3, edm::IOVSyncValue(eID_4));
1379 depFinder->setInterval(dep2Interval);
1380
1381
1382 finder.findIntervalFor(depRecordKey, sync_3);
1383
1384 CPPUNIT_ASSERT(dep2Interval == finder.findIntervalFor(depRecordKey, sync_3));
1385
1386 dummyFinder->setInterval(edm::ValidityInterval::invalidInterval());
1387 depFinder->setInterval(edm::ValidityInterval::invalidInterval());
1388
1389 dummyProvider->initializeForNewSyncValue();
1390 CPPUNIT_ASSERT(edm::ValidityInterval::invalidInterval() ==
1391 finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 5))));
1392
1393 const edm::EventID eID_6(1, 1, 6);
1394 const edm::IOVSyncValue sync_6(eID_6);
1395 const edm::ValidityInterval unknownedEndInterval(sync_6, edm::IOVSyncValue::invalidIOVSyncValue());
1396 dummyFinder->setInterval(unknownedEndInterval);
1397
1398 const edm::EventID eID_7(1, 1, 7);
1399 const edm::IOVSyncValue sync_7(eID_7);
1400 const edm::ValidityInterval iov6_7(sync_6, sync_7);
1401 depFinder->setInterval(iov6_7);
1402
1403 dummyProvider->initializeForNewSyncValue();
1404 CPPUNIT_ASSERT(unknownedEndInterval == finder.findIntervalFor(depRecordKey, sync_6));
1405
1406
1407 dummyFinder->setInterval(depInterval);
1408 depFinder->setInterval(definedInterval);
1409 dummyProvider->initializeForNewSyncValue();
1410 CPPUNIT_ASSERT(depInterval == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 1))));
1411
1412 dummyFinder->setInterval(dep2Interval);
1413 dummyProvider->initializeForNewSyncValue();
1414 CPPUNIT_ASSERT(dep2Interval == finder.findIntervalFor(depRecordKey, sync_3));
1415 }
1416
1417 void testdependentrecord::invalidRecordTest() {
1418 auto dummyProvider1 = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
1419
1420 const edm::ValidityInterval invalid(edm::IOVSyncValue::invalidIOVSyncValue(),
1421 edm::IOVSyncValue::invalidIOVSyncValue());
1422
1423 dummyProvider1->setValidityInterval_forTesting(invalid);
1424
1425 auto dummyProvider2 = std::make_shared<EventSetupRecordProvider>(DummyRecord::keyForClass(), &activityRegistry);
1426 dummyProvider2->setValidityInterval_forTesting(invalid);
1427
1428 const EventSetupRecordKey depRecordKey = DepRecord::keyForClass();
1429 DependentRecordIntervalFinder finder(depRecordKey);
1430 finder.addProviderWeAreDependentOn(dummyProvider1);
1431 finder.addProviderWeAreDependentOn(dummyProvider2);
1432
1433 CPPUNIT_ASSERT(invalid == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 2))));
1434
1435 const edm::EventID eID_1(1, 1, 5);
1436 const edm::IOVSyncValue sync_1(eID_1);
1437 const edm::ValidityInterval definedInterval1(sync_1, edm::IOVSyncValue(edm::EventID(1, 1, 10)));
1438 const edm::EventID eID_2(1, 1, 2);
1439 const edm::IOVSyncValue sync_2(eID_2);
1440 const edm::ValidityInterval definedInterval2(sync_2, edm::IOVSyncValue(edm::EventID(1, 1, 6)));
1441 dummyProvider2->setValidityInterval_forTesting(definedInterval2);
1442
1443 const edm::ValidityInterval openEnded1(definedInterval2.first(), edm::IOVSyncValue::invalidIOVSyncValue());
1444
1445 dummyProvider1->initializeForNewSyncValue();
1446 dummyProvider2->initializeForNewSyncValue();
1447 CPPUNIT_ASSERT(openEnded1 == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 4))));
1448
1449 dummyProvider1->setValidityInterval_forTesting(definedInterval1);
1450
1451 const edm::ValidityInterval overlapInterval(std::max(definedInterval1.first(), definedInterval2.first()),
1452 std::min(definedInterval1.last(), definedInterval2.last()));
1453
1454 dummyProvider1->initializeForNewSyncValue();
1455 dummyProvider2->initializeForNewSyncValue();
1456 CPPUNIT_ASSERT(overlapInterval == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 5))));
1457
1458 dummyProvider2->setValidityInterval_forTesting(invalid);
1459 const edm::ValidityInterval openEnded2(definedInterval1.first(), edm::IOVSyncValue::invalidIOVSyncValue());
1460
1461 dummyProvider1->initializeForNewSyncValue();
1462 dummyProvider2->initializeForNewSyncValue();
1463 CPPUNIT_ASSERT(openEnded2 == finder.findIntervalFor(depRecordKey, edm::IOVSyncValue(edm::EventID(1, 1, 7))));
1464 }
1465
1466 void testdependentrecord::extendIOVTest() {
1467 SynchronousEventSetupsController controller;
1468 edm::ParameterSet pset = createDummyPset();
1469 EventSetupProvider& provider = *controller.makeProvider(pset, &activityRegistry);
1470
1471 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> dummyProv =
1472 std::make_shared<DummyESProductResolverProvider>();
1473 provider.add(dummyProv);
1474
1475 std::shared_ptr<DummyFinder> dummyFinder = std::make_shared<DummyFinder>();
1476
1477 edm::IOVSyncValue startSyncValue{edm::EventID{1, 1, 1}};
1478 dummyFinder->setInterval(edm::ValidityInterval{startSyncValue, edm::IOVSyncValue{edm::EventID{1, 1, 5}}});
1479 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>{dummyFinder});
1480
1481 std::shared_ptr<edm::eventsetup::ESProductResolverProvider> depProv =
1482 std::make_shared<DepOn2RecordResolverProvider>();
1483 provider.add(depProv);
1484
1485 edm::ESParentContext parentC;
1486 std::shared_ptr<Dummy2RecordFinder> dummy2Finder = std::make_shared<Dummy2RecordFinder>();
1487 dummy2Finder->setInterval(edm::ValidityInterval{startSyncValue, edm::IOVSyncValue{edm::EventID{1, 1, 6}}});
1488 provider.add(std::shared_ptr<edm::EventSetupRecordIntervalFinder>(dummy2Finder));
1489 {
1490 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 1), edm::Timestamp(1)));
1491 const edm::EventSetup eventSetup1(provider.eventSetupImpl(), 0, nullptr, parentC);
1492 unsigned long long id1 = eventSetup1.get<DepOn2Record>().cacheIdentifier();
1493 CPPUNIT_ASSERT(id1 == eventSetup1.get<DummyRecord>().cacheIdentifier());
1494 CPPUNIT_ASSERT(id1 == eventSetup1.get<Dummy2Record>().cacheIdentifier());
1495
1496 {
1497 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 5), edm::Timestamp(2)));
1498 const edm::EventSetup eventSetup(provider.eventSetupImpl(), 0, nullptr, parentC);
1499 unsigned long long id = eventSetup.get<DepOn2Record>().cacheIdentifier();
1500 CPPUNIT_ASSERT(id1 == id);
1501 CPPUNIT_ASSERT(id1 == eventSetup.get<DummyRecord>().cacheIdentifier());
1502 CPPUNIT_ASSERT(id1 == eventSetup.get<Dummy2Record>().cacheIdentifier());
1503 }
1504
1505 dummyFinder->setInterval(edm::ValidityInterval{startSyncValue, edm::IOVSyncValue{edm::EventID{1, 1, 7}}});
1506 {
1507 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 6), edm::Timestamp(7)));
1508 const edm::EventSetup eventSetup(provider.eventSetupImpl(), 0, nullptr, parentC);
1509 unsigned long long id = eventSetup.get<DepOn2Record>().cacheIdentifier();
1510 CPPUNIT_ASSERT(id1 == id);
1511 CPPUNIT_ASSERT(id1 == eventSetup.get<DummyRecord>().cacheIdentifier());
1512 CPPUNIT_ASSERT(id1 == eventSetup.get<Dummy2Record>().cacheIdentifier());
1513 }
1514
1515
1516 dummy2Finder->setInterval(edm::ValidityInterval{startSyncValue, edm::IOVSyncValue{edm::EventID{1, 1, 7}}});
1517
1518 {
1519 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 7), edm::Timestamp(7)));
1520 const edm::EventSetup eventSetup(provider.eventSetupImpl(), 0, nullptr, parentC);
1521 unsigned long long id = eventSetup.get<DepOn2Record>().cacheIdentifier();
1522 CPPUNIT_ASSERT(id1 == id);
1523 CPPUNIT_ASSERT(id1 == eventSetup.get<DummyRecord>().cacheIdentifier());
1524 CPPUNIT_ASSERT(id1 == eventSetup.get<Dummy2Record>().cacheIdentifier());
1525 }
1526
1527 dummy2Finder->setInterval(edm::ValidityInterval{startSyncValue, edm::IOVSyncValue{edm::EventID{1, 1, 8}}});
1528
1529 dummyFinder->setInterval(edm::ValidityInterval{startSyncValue, edm::IOVSyncValue{edm::EventID{1, 1, 8}}});
1530 {
1531 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 8), edm::Timestamp(7)));
1532 const edm::EventSetup eventSetup(provider.eventSetupImpl(), 0, nullptr, parentC);
1533 unsigned long long id = eventSetup.get<DepOn2Record>().cacheIdentifier();
1534 CPPUNIT_ASSERT(id1 == id);
1535 CPPUNIT_ASSERT(id1 == eventSetup.get<DummyRecord>().cacheIdentifier());
1536 CPPUNIT_ASSERT(id1 == eventSetup.get<Dummy2Record>().cacheIdentifier());
1537 }
1538
1539 dummy2Finder->setInterval(edm::ValidityInterval{startSyncValue, edm::IOVSyncValue{edm::EventID{1, 1, 9}}});
1540
1541 dummyFinder->setInterval(
1542 edm::ValidityInterval{edm::IOVSyncValue{edm::EventID{1, 1, 9}}, edm::IOVSyncValue{edm::EventID{1, 1, 9}}});
1543 {
1544 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 9), edm::Timestamp(7)));
1545 const edm::EventSetup eventSetup(provider.eventSetupImpl(), 0, nullptr, parentC);
1546 unsigned long long id = eventSetup.get<DepOn2Record>().cacheIdentifier();
1547 CPPUNIT_ASSERT(id1 + 1 == id);
1548 CPPUNIT_ASSERT(id1 + 1 == eventSetup.get<DummyRecord>().cacheIdentifier());
1549 CPPUNIT_ASSERT(id1 == eventSetup.get<Dummy2Record>().cacheIdentifier());
1550 }
1551
1552 dummy2Finder->setInterval(
1553 edm::ValidityInterval{edm::IOVSyncValue{edm::EventID{1, 1, 10}}, edm::IOVSyncValue{edm::EventID{1, 1, 10}}});
1554
1555 dummyFinder->setInterval(
1556 edm::ValidityInterval{edm::IOVSyncValue{edm::EventID{1, 1, 9}}, edm::IOVSyncValue{edm::EventID{1, 1, 10}}});
1557
1558 {
1559 controller.eventSetupForInstance(edm::IOVSyncValue(edm::EventID(1, 1, 10), edm::Timestamp(7)));
1560 const edm::EventSetup eventSetup(provider.eventSetupImpl(), 0, nullptr, parentC);
1561 unsigned long long id = eventSetup.get<DepOn2Record>().cacheIdentifier();
1562 CPPUNIT_ASSERT(id1 + 2 == id);
1563 CPPUNIT_ASSERT(id1 + 1 == eventSetup.get<DummyRecord>().cacheIdentifier());
1564 CPPUNIT_ASSERT(id1 + 1 == eventSetup.get<Dummy2Record>().cacheIdentifier());
1565 }
1566 }
1567 }