File indexing completed on 2024-04-06 12:12:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <atomic>
0011 #include <iostream>
0012 #include <memory>
0013 #include <tuple>
0014 #include <vector>
0015
0016 #include "DataFormats/Provenance/interface/BranchDescription.h"
0017 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0018 #include "FWCore/Framework/interface/CacheHandle.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/LuminosityBlock.h"
0021 #include "FWCore/Framework/interface/MakerMacros.h"
0022 #include "FWCore/Framework/interface/moduleAbilities.h"
0023 #include "FWCore/Framework/interface/limited/EDAnalyzer.h"
0024 #include "FWCore/Framework/interface/ProcessBlock.h"
0025 #include "FWCore/Framework/interface/Run.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 #include "FWCore/Utilities/interface/BranchType.h"
0028 #include "FWCore/Utilities/interface/EDMException.h"
0029 #include "FWCore/Utilities/interface/EDGetToken.h"
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031
0032 namespace edmtest {
0033 namespace limited {
0034
0035 namespace {
0036 struct Cache {
0037 Cache() : value(0) {}
0038
0039 mutable std::atomic<unsigned int> value;
0040 };
0041
0042 struct UnsafeCache {
0043 UnsafeCache() : value(0), lumi(0) {}
0044 unsigned int value;
0045 unsigned int lumi;
0046 };
0047
0048 }
0049
0050 class StreamIntAnalyzer : public edm::limited::EDAnalyzer<edm::StreamCache<UnsafeCache>> {
0051 public:
0052 explicit StreamIntAnalyzer(edm::ParameterSet const& p)
0053 : edm::limited::EDAnalyzerBase(p),
0054 edm::limited::EDAnalyzer<edm::StreamCache<UnsafeCache>>(p),
0055 trans_(p.getParameter<int>("transitions")),
0056 nLumis_(p.getUntrackedParameter<unsigned int>("nLumis", 1)) {
0057 callWhenNewProductsRegistered([](edm::BranchDescription const& desc) {
0058 std::cout << "limited::StreamIntAnalyzer " << desc.moduleLabel() << std::endl;
0059 });
0060 }
0061 const unsigned int trans_;
0062 const unsigned int nLumis_;
0063 mutable std::atomic<unsigned int> m_count{0};
0064 mutable std::atomic<unsigned int> m_countStreams{0};
0065 mutable std::atomic<unsigned int> m_countStreamBeginLumiTransitions{0};
0066 mutable std::atomic<unsigned int> m_countStreamEndLumiTransitions{0};
0067
0068 std::unique_ptr<UnsafeCache> beginStream(edm::StreamID iID) const override {
0069 ++m_count;
0070 ++m_countStreams;
0071 auto pCache = std::make_unique<UnsafeCache>();
0072 pCache->value = iID.value();
0073 return pCache;
0074 }
0075
0076 void streamBeginRun(edm::StreamID iID, edm::Run const&, edm::EventSetup const&) const override {
0077 ++m_count;
0078 if ((streamCache(iID))->value != iID.value()) {
0079 throw cms::Exception("cache value")
0080 << "StreamIntAnalyzer cache value " << (streamCache(iID))->value << " but it was supposed to be " << iID;
0081 }
0082 }
0083
0084 void streamBeginLuminosityBlock(edm::StreamID iID,
0085 edm::LuminosityBlock const&,
0086 edm::EventSetup const&) const override {
0087 ++m_countStreamBeginLumiTransitions;
0088 if ((streamCache(iID))->value != iID.value()) {
0089 throw cms::Exception("cache value")
0090 << "StreamIntAnalyzer cache value " << (streamCache(iID))->value << " but it was supposed to be " << iID;
0091 }
0092 }
0093
0094 void analyze(edm::StreamID iID, const edm::Event&, const edm::EventSetup&) const override {
0095 ++m_count;
0096 if ((streamCache(iID))->value != iID.value()) {
0097 throw cms::Exception("cache value")
0098 << "StreamIntAnalyzer cache value " << (streamCache(iID))->value << " but it was supposed to be " << iID;
0099 }
0100 }
0101
0102 void streamEndLuminosityBlock(edm::StreamID iID,
0103 edm::LuminosityBlock const&,
0104 edm::EventSetup const&) const override {
0105 ++m_countStreamEndLumiTransitions;
0106 if ((streamCache(iID))->value != iID.value()) {
0107 throw cms::Exception("cache value")
0108 << "StreamIntAnalyzer cache value " << (streamCache(iID))->value << " but it was supposed to be " << iID;
0109 }
0110 }
0111
0112 void streamEndRun(edm::StreamID iID, edm::Run const&, edm::EventSetup const&) const override {
0113 ++m_count;
0114 if ((streamCache(iID))->value != iID.value()) {
0115 throw cms::Exception("cache value")
0116 << "StreamIntAnalyzer cache value " << (streamCache(iID))->value << " but it was supposed to be " << iID;
0117 }
0118 }
0119
0120 void endStream(edm::StreamID iID) const override {
0121 ++m_count;
0122 if ((streamCache(iID))->value != iID.value()) {
0123 throw cms::Exception("cache value")
0124 << "StreamIntAnalyzer cache value " << (streamCache(iID))->value << " but it was supposed to be " << iID;
0125 }
0126 }
0127
0128 ~StreamIntAnalyzer() {
0129 if (m_count != trans_) {
0130 throw cms::Exception("transitions")
0131 << "StreamIntAnalyzer transitions " << m_count << " but it was supposed to be " << trans_;
0132 }
0133 unsigned int nStreamBeginLumiTransitions = m_countStreamBeginLumiTransitions.load();
0134 unsigned int nStreamEndLumiTransitions = m_countStreamEndLumiTransitions.load();
0135 unsigned int nStreams = m_countStreams.load();
0136 if (nStreamBeginLumiTransitions < nLumis_ || nStreamBeginLumiTransitions > (nLumis_ * nStreams)) {
0137 throw cms::Exception("transitions")
0138 << "StreamIntAnalyzer stream begin lumi transitions " << nStreamBeginLumiTransitions
0139 << " but it was supposed to be between " << nLumis_ << " and " << nLumis_ * nStreams;
0140 }
0141 if (nStreamEndLumiTransitions != nStreamBeginLumiTransitions) {
0142 throw cms::Exception("transitions")
0143 << "StreamIntAnalyzer stream end lumi transitions " << nStreamEndLumiTransitions
0144 << " does not equal stream begin lumi transitions " << nStreamBeginLumiTransitions;
0145 }
0146 }
0147 };
0148
0149 class RunIntAnalyzer : public edm::limited::EDAnalyzer<edm::RunCache<Cache>> {
0150 public:
0151 explicit RunIntAnalyzer(edm::ParameterSet const& p)
0152 : edm::limited::EDAnalyzerBase(p),
0153 edm::limited::EDAnalyzer<edm::RunCache<Cache>>(p),
0154 trans_(p.getParameter<int>("transitions")),
0155 cvalue_(p.getParameter<int>("cachevalue")) {}
0156 const unsigned int trans_;
0157 const unsigned int cvalue_;
0158 mutable std::atomic<unsigned int> m_count{0};
0159
0160 std::shared_ptr<Cache> globalBeginRun(edm::Run const&, edm::EventSetup const&) const override {
0161 ++m_count;
0162 return std::make_shared<Cache>();
0163 }
0164
0165 void analyze(edm::StreamID iID, const edm::Event& iEvent, const edm::EventSetup&) const override {
0166 ++m_count;
0167 ++((runCache(iEvent.getRun().index()))->value);
0168 }
0169
0170 void globalEndRun(edm::Run const& iRun, edm::EventSetup const&) const override {
0171 ++m_count;
0172 if ((runCache(iRun.index()))->value != cvalue_) {
0173 throw cms::Exception("cache value") << "RunIntAnalyzer cache value " << (runCache(iRun.index()))->value
0174 << " but it was supposed to be " << cvalue_;
0175 }
0176 }
0177
0178 ~RunIntAnalyzer() {
0179 if (m_count != trans_) {
0180 throw cms::Exception("transitions")
0181 << "RunIntAnalyzer transitions " << m_count << " but it was supposed to be " << trans_;
0182 }
0183 }
0184 };
0185
0186 class LumiIntAnalyzer : public edm::limited::EDAnalyzer<edm::LuminosityBlockCache<Cache>> {
0187 public:
0188 explicit LumiIntAnalyzer(edm::ParameterSet const& p)
0189 : edm::limited::EDAnalyzerBase(p),
0190 edm::limited::EDAnalyzer<edm::LuminosityBlockCache<Cache>>(p),
0191 trans_(p.getParameter<int>("transitions")),
0192 cvalue_(p.getParameter<int>("cachevalue")) {
0193
0194 auto const& tag = p.getParameter<edm::InputTag>("moduleLabel");
0195 if (not tag.label().empty()) {
0196 consumes<unsigned int, edm::InLumi>(tag);
0197 }
0198 }
0199 const unsigned int trans_;
0200 const unsigned int cvalue_;
0201 mutable std::atomic<unsigned int> m_count{0};
0202
0203 std::shared_ptr<Cache> globalBeginLuminosityBlock(edm::LuminosityBlock const&,
0204 edm::EventSetup const&) const override {
0205 ++m_count;
0206 return std::make_shared<Cache>();
0207 }
0208
0209 void analyze(edm::StreamID, const edm::Event& iEvent, const edm::EventSetup&) const override {
0210 ++m_count;
0211 ++(luminosityBlockCache(iEvent.getLuminosityBlock().index())->value);
0212 }
0213
0214 void globalEndLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const override {
0215 ++m_count;
0216 if ((luminosityBlockCache(iLB.index()))->value != cvalue_) {
0217 throw cms::Exception("cache value")
0218 << "LumiIntAnalyzer cache value " << (luminosityBlockCache(iLB.index()))->value
0219 << " but it was supposed to be " << cvalue_;
0220 }
0221 }
0222
0223 ~LumiIntAnalyzer() {
0224 if (m_count != trans_) {
0225 throw cms::Exception("transitions")
0226 << "LumiIntAnalyzer transitions " << m_count << " but it was supposed to be " << trans_;
0227 }
0228 }
0229 };
0230
0231 class RunSummaryIntAnalyzer
0232 : public edm::limited::EDAnalyzer<edm::StreamCache<UnsafeCache>, edm::RunSummaryCache<UnsafeCache>> {
0233 public:
0234 explicit RunSummaryIntAnalyzer(edm::ParameterSet const& p)
0235 : edm::limited::EDAnalyzerBase(p),
0236 edm::limited::EDAnalyzer<edm::StreamCache<UnsafeCache>, edm::RunSummaryCache<UnsafeCache>>(p),
0237 trans_(p.getParameter<int>("transitions")),
0238 cvalue_(p.getParameter<int>("cachevalue")) {}
0239 const unsigned int trans_;
0240 const unsigned int cvalue_;
0241 mutable std::atomic<unsigned int> m_count{0};
0242
0243 std::unique_ptr<UnsafeCache> beginStream(edm::StreamID) const override {
0244 ++m_count;
0245 return std::make_unique<UnsafeCache>();
0246 }
0247
0248 std::shared_ptr<UnsafeCache> globalBeginRunSummary(edm::Run const&, edm::EventSetup const&) const override {
0249 ++m_count;
0250 return std::make_shared<UnsafeCache>();
0251 }
0252
0253 void analyze(edm::StreamID iID, const edm::Event&, const edm::EventSetup&) const override {
0254 ++m_count;
0255 ++((streamCache(iID))->value);
0256 }
0257
0258 void streamEndRunSummary(edm::StreamID iID,
0259 edm::Run const&,
0260 edm::EventSetup const&,
0261 UnsafeCache* gCache) const override {
0262 ++m_count;
0263 gCache->value += (streamCache(iID))->value;
0264 (streamCache(iID))->value = 0;
0265 }
0266
0267 void globalEndRunSummary(edm::Run const&, edm::EventSetup const&, UnsafeCache* gCache) const override {
0268 ++m_count;
0269 if (gCache->value != cvalue_) {
0270 throw cms::Exception("cache value")
0271 << "RunSummaryIntAnalyzer cache value " << gCache->value << " but it was supposed to be " << cvalue_;
0272 }
0273 }
0274
0275 ~RunSummaryIntAnalyzer() {
0276 if (m_count != trans_) {
0277 throw cms::Exception("transitions")
0278 << "RunSummaryIntAnalyzer transitions " << m_count << " but it was supposed to be " << trans_;
0279 }
0280 }
0281 };
0282
0283 class LumiSummaryIntAnalyzer
0284 : public edm::limited::EDAnalyzer<edm::StreamCache<UnsafeCache>, edm::LuminosityBlockSummaryCache<UnsafeCache>> {
0285 public:
0286 explicit LumiSummaryIntAnalyzer(edm::ParameterSet const& p)
0287 : edm::limited::EDAnalyzerBase(p),
0288 edm::limited::EDAnalyzer<edm::StreamCache<UnsafeCache>, edm::LuminosityBlockSummaryCache<UnsafeCache>>(p),
0289 trans_(p.getParameter<int>("transitions")),
0290 cvalue_(p.getParameter<int>("cachevalue")) {}
0291 const unsigned int trans_;
0292 const unsigned int cvalue_;
0293 mutable std::atomic<unsigned int> m_count{0};
0294 mutable std::atomic<unsigned int> m_countLumis{0};
0295 mutable std::atomic<unsigned int> m_countStreams{0};
0296 mutable std::atomic<unsigned int> m_countStreamLumiTransitions{0};
0297
0298 std::unique_ptr<UnsafeCache> beginStream(edm::StreamID) const override {
0299 ++m_count;
0300 ++m_countStreams;
0301 return std::make_unique<UnsafeCache>();
0302 }
0303
0304 std::shared_ptr<UnsafeCache> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const& iLB,
0305 edm::EventSetup const&) const override {
0306 ++m_count;
0307 ++m_countLumis;
0308 auto gCache = std::make_shared<UnsafeCache>();
0309 gCache->lumi = iLB.luminosityBlockAuxiliary().luminosityBlock();
0310 return gCache;
0311 }
0312
0313 void analyze(edm::StreamID iID, const edm::Event& iEvent, const edm::EventSetup&) const override {
0314 ++m_count;
0315 ++((streamCache(iID))->value);
0316 }
0317
0318 void streamEndLuminosityBlockSummary(edm::StreamID iID,
0319 edm::LuminosityBlock const& iLB,
0320 edm::EventSetup const&,
0321 UnsafeCache* gCache) const override {
0322 ++m_countStreamLumiTransitions;
0323 if (gCache->lumi != iLB.luminosityBlockAuxiliary().luminosityBlock()) {
0324 throw cms::Exception("UnexpectedValue")
0325 << "streamEndLuminosityBlockSummary unexpected lumi number in Stream " << iID.value();
0326 }
0327 gCache->value += (streamCache(iID))->value;
0328 (streamCache(iID))->value = 0;
0329 }
0330
0331 void globalEndLuminosityBlockSummary(edm::LuminosityBlock const& iLB,
0332 edm::EventSetup const&,
0333 UnsafeCache* gCache) const override {
0334 ++m_count;
0335 if (gCache->lumi != iLB.luminosityBlockAuxiliary().luminosityBlock()) {
0336 throw cms::Exception("UnexpectedValue") << "globalEndLuminosityBlockSummary unexpected lumi number";
0337 }
0338 if (gCache->value != cvalue_) {
0339 throw cms::Exception("cache value")
0340 << "LumiSummaryIntAnalyzer cache value " << gCache->value << " but it was supposed to be " << cvalue_;
0341 }
0342 }
0343
0344 ~LumiSummaryIntAnalyzer() {
0345 if (m_count != trans_) {
0346 throw cms::Exception("transitions")
0347 << "LumiSummaryIntAnalyzer transitions " << m_count << " but it was supposed to be " << trans_;
0348 }
0349 unsigned int nStreamLumiTransitions = m_countStreamLumiTransitions.load();
0350 unsigned int nLumis = m_countLumis.load();
0351 unsigned int nStreams = m_countStreams.load();
0352 if (nStreamLumiTransitions < nLumis || nStreamLumiTransitions > (nLumis * nStreams)) {
0353 throw cms::Exception("transitions")
0354 << "LumiSummaryIntAnalyzer stream lumi transitions " << nStreamLumiTransitions
0355 << " but it was supposed to be between " << nLumis << " and " << nLumis * nStreams;
0356 }
0357 }
0358 };
0359
0360 class ProcessBlockIntAnalyzer : public edm::limited::EDAnalyzer<edm::WatchProcessBlock> {
0361 public:
0362 explicit ProcessBlockIntAnalyzer(edm::ParameterSet const& pset)
0363 : edm::limited::EDAnalyzerBase(pset),
0364 edm::limited::EDAnalyzer<edm::WatchProcessBlock>(pset),
0365 trans_(pset.getParameter<int>("transitions")) {
0366 {
0367 auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlock");
0368 if (not tag.label().empty()) {
0369 getTokenBegin_ = consumes<unsigned int, edm::InProcess>(tag);
0370 }
0371 }
0372 {
0373 auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlock");
0374 if (not tag.label().empty()) {
0375 getTokenEnd_ = consumes<unsigned int, edm::InProcess>(tag);
0376 }
0377 }
0378 }
0379
0380 void beginProcessBlock(edm::ProcessBlock const& processBlock) override {
0381 if (m_count != 0) {
0382 throw cms::Exception("transitions")
0383 << "ProcessBlockIntAnalyzer::begin transitions " << m_count << " but it was supposed to be " << 0;
0384 }
0385 ++m_count;
0386 const unsigned int valueToGet = 11;
0387 if (not getTokenBegin_.isUninitialized()) {
0388 if (processBlock.get(getTokenBegin_) != valueToGet) {
0389 throw cms::Exception("BadValue")
0390 << "expected " << valueToGet << " but got " << processBlock.get(getTokenBegin_);
0391 }
0392 }
0393 }
0394
0395 void analyze(edm::StreamID iID, edm::Event const&, edm::EventSetup const&) const override {
0396 if (m_count < 1u) {
0397 throw cms::Exception("out of sequence") << "analyze before beginProcessBlock " << m_count;
0398 }
0399 ++m_count;
0400 }
0401
0402 void endProcessBlock(edm::ProcessBlock const& processBlock) override {
0403 ++m_count;
0404 if (m_count != trans_) {
0405 throw cms::Exception("transitions")
0406 << "ProcessBlockIntAnalyzer::end transitions " << m_count << " but it was supposed to be " << trans_;
0407 }
0408 {
0409 const unsigned int valueToGet = 11;
0410 if (not getTokenBegin_.isUninitialized()) {
0411 if (processBlock.get(getTokenBegin_) != valueToGet) {
0412 throw cms::Exception("BadValue")
0413 << "expected " << valueToGet << " but got " << processBlock.get(getTokenBegin_);
0414 }
0415 }
0416 }
0417 {
0418 const unsigned int valueToGet = 21;
0419 if (not getTokenEnd_.isUninitialized()) {
0420 if (processBlock.get(getTokenEnd_) != valueToGet) {
0421 throw cms::Exception("BadValue")
0422 << "expected " << valueToGet << " but got " << processBlock.get(getTokenEnd_);
0423 }
0424 }
0425 }
0426 }
0427
0428 ~ProcessBlockIntAnalyzer() {
0429 if (m_count != trans_) {
0430 throw cms::Exception("transitions")
0431 << "ProcessBlockIntAnalyzer transitions " << m_count << " but it was supposed to be " << trans_;
0432 }
0433 }
0434
0435 private:
0436 const unsigned int trans_;
0437 mutable std::atomic<unsigned int> m_count{0};
0438 edm::EDGetTokenT<unsigned int> getTokenBegin_;
0439 edm::EDGetTokenT<unsigned int> getTokenEnd_;
0440 };
0441
0442 class TestInputProcessBlockCache {
0443 public:
0444 long long int value_ = 0;
0445 };
0446
0447 class TestInputProcessBlockCache1 {
0448 public:
0449 long long int value_ = 0;
0450 };
0451
0452 class InputProcessBlockIntAnalyzer
0453 : public edm::limited::EDAnalyzer<
0454 edm::InputProcessBlockCache<int, TestInputProcessBlockCache, TestInputProcessBlockCache1>> {
0455 public:
0456 explicit InputProcessBlockIntAnalyzer(edm::ParameterSet const& pset)
0457 : edm::limited::EDAnalyzerBase(pset),
0458 edm::limited::EDAnalyzer<
0459 edm::InputProcessBlockCache<int, TestInputProcessBlockCache, TestInputProcessBlockCache1>>(pset) {
0460 expectedTransitions_ = pset.getParameter<int>("transitions");
0461 expectedByRun_ = pset.getParameter<std::vector<int>>("expectedByRun");
0462 expectedSum_ = pset.getParameter<int>("expectedSum");
0463 {
0464 auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlock");
0465 if (not tag.label().empty()) {
0466 getTokenBegin_ = consumes<IntProduct, edm::InProcess>(tag);
0467 }
0468 }
0469 {
0470 auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlock");
0471 if (not tag.label().empty()) {
0472 getTokenEnd_ = consumes<IntProduct, edm::InProcess>(tag);
0473 }
0474 }
0475 {
0476 auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlockM");
0477 if (not tag.label().empty()) {
0478 getTokenBeginM_ = consumes<IntProduct, edm::InProcess>(tag);
0479 }
0480 }
0481 {
0482 auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlockM");
0483 if (not tag.label().empty()) {
0484 getTokenEndM_ = consumes<IntProduct, edm::InProcess>(tag);
0485 }
0486 }
0487 registerProcessBlockCacheFiller<int>(
0488 getTokenBegin_, [this](edm::ProcessBlock const& processBlock, std::shared_ptr<int> const& previousCache) {
0489 auto returnValue = std::make_shared<int>(0);
0490 *returnValue += processBlock.get(getTokenBegin_).value;
0491 *returnValue += processBlock.get(getTokenEnd_).value;
0492 ++transitions_;
0493 return returnValue;
0494 });
0495 registerProcessBlockCacheFiller<1>(getTokenBegin_,
0496 [this](edm::ProcessBlock const& processBlock,
0497 std::shared_ptr<TestInputProcessBlockCache> const& previousCache) {
0498 auto returnValue = std::make_shared<TestInputProcessBlockCache>();
0499 returnValue->value_ += processBlock.get(getTokenBegin_).value;
0500 returnValue->value_ += processBlock.get(getTokenEnd_).value;
0501 ++transitions_;
0502 return returnValue;
0503 });
0504 registerProcessBlockCacheFiller<TestInputProcessBlockCache1>(
0505 getTokenBegin_,
0506 [this](edm::ProcessBlock const& processBlock,
0507 std::shared_ptr<TestInputProcessBlockCache1> const& previousCache) {
0508 auto returnValue = std::make_shared<TestInputProcessBlockCache1>();
0509 returnValue->value_ += processBlock.get(getTokenBegin_).value;
0510 returnValue->value_ += processBlock.get(getTokenEnd_).value;
0511 ++transitions_;
0512 return returnValue;
0513 });
0514 }
0515
0516 void accessInputProcessBlock(edm::ProcessBlock const& processBlock) override {
0517 if (processBlock.processName() == "PROD1") {
0518 sum_ += processBlock.get(getTokenBegin_).value;
0519 sum_ += processBlock.get(getTokenEnd_).value;
0520 }
0521 if (processBlock.processName() == "MERGE") {
0522 sum_ += processBlock.get(getTokenBeginM_).value;
0523 sum_ += processBlock.get(getTokenEndM_).value;
0524 }
0525 ++transitions_;
0526 }
0527
0528 void analyze(edm::StreamID, edm::Event const& event, edm::EventSetup const&) const override {
0529 auto cacheTuple = processBlockCaches(event);
0530 if (!expectedByRun_.empty()) {
0531 if (expectedByRun_.at(event.run() - 1) != *std::get<edm::CacheHandle<int>>(cacheTuple)) {
0532 throw cms::Exception("UnexpectedValue")
0533 << "InputProcessBlockIntAnalyzer::analyze cached value was "
0534 << *std::get<edm::CacheHandle<int>>(cacheTuple) << " but it was supposed to be "
0535 << expectedByRun_.at(event.run() - 1);
0536 }
0537 if (expectedByRun_.at(event.run() - 1) != std::get<1>(cacheTuple)->value_) {
0538 throw cms::Exception("UnexpectedValue")
0539 << "InputProcessBlockIntAnalyzer::analyze second cached value was " << std::get<1>(cacheTuple)->value_
0540 << " but it was supposed to be " << expectedByRun_.at(event.run() - 1);
0541 }
0542 if (expectedByRun_.at(event.run() - 1) !=
0543 std::get<edm::CacheHandle<TestInputProcessBlockCache1>>(cacheTuple)->value_) {
0544 throw cms::Exception("UnexpectedValue")
0545 << "InputProcessBlockIntAnalyzer::analyze third cached value was "
0546 << std::get<edm::CacheHandle<TestInputProcessBlockCache1>>(cacheTuple)->value_
0547 << " but it was supposed to be " << expectedByRun_.at(event.run() - 1);
0548 }
0549 }
0550 ++transitions_;
0551 }
0552
0553 void endJob() override {
0554 if (transitions_ != expectedTransitions_) {
0555 throw cms::Exception("transitions") << "InputProcessBlockIntAnalyzer transitions " << transitions_
0556 << " but it was supposed to be " << expectedTransitions_;
0557 }
0558 if (sum_ != expectedSum_) {
0559 throw cms::Exception("UnexpectedValue")
0560 << "InputProcessBlockIntAnalyzer sum " << sum_ << " but it was supposed to be " << expectedSum_;
0561 }
0562 if (cacheSize() > 0u) {
0563 throw cms::Exception("UnexpectedValue")
0564 << "InputProcessBlockIntAnalyzer cache size not zero at endJob " << cacheSize();
0565 }
0566 }
0567
0568 private:
0569 edm::EDGetTokenT<IntProduct> getTokenBegin_;
0570 edm::EDGetTokenT<IntProduct> getTokenEnd_;
0571 edm::EDGetTokenT<IntProduct> getTokenBeginM_;
0572 edm::EDGetTokenT<IntProduct> getTokenEndM_;
0573 mutable std::atomic<unsigned int> transitions_{0};
0574 int sum_{0};
0575 unsigned int expectedTransitions_{0};
0576 std::vector<int> expectedByRun_;
0577 int expectedSum_{0};
0578 };
0579
0580 }
0581 }
0582
0583 DEFINE_FWK_MODULE(edmtest::limited::StreamIntAnalyzer);
0584 DEFINE_FWK_MODULE(edmtest::limited::RunIntAnalyzer);
0585 DEFINE_FWK_MODULE(edmtest::limited::LumiIntAnalyzer);
0586 DEFINE_FWK_MODULE(edmtest::limited::RunSummaryIntAnalyzer);
0587 DEFINE_FWK_MODULE(edmtest::limited::LumiSummaryIntAnalyzer);
0588 DEFINE_FWK_MODULE(edmtest::limited::ProcessBlockIntAnalyzer);
0589 DEFINE_FWK_MODULE(edmtest::limited::InputProcessBlockIntAnalyzer);