Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-13 23:27:16

0001 
0002 /*----------------------------------------------------------------------
0003 
0004 Toy edm::stream::EDFilter modules of
0005 edm::*Cache templates and edm::*Producer classes
0006 for testing purposes only.
0007 
0008 ----------------------------------------------------------------------*/
0009 
0010 #include <atomic>
0011 #include <functional>
0012 #include <iostream>
0013 #include <map>
0014 #include <tuple>
0015 #include <unistd.h>
0016 #include <vector>
0017 
0018 #include "FWCore/Framework/interface/CacheHandle.h"
0019 #include "FWCore/Framework/interface/stream/EDFilter.h"
0020 #include "FWCore/Framework/interface/maker/WorkerT.h"
0021 #include "FWCore/Framework/interface/HistoryAppender.h"
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 #include "FWCore/ServiceRegistry/interface/ParentContext.h"
0024 #include "FWCore/ServiceRegistry/interface/StreamContext.h"
0025 #include "FWCore/Utilities/interface/GlobalIdentifier.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/Framework/interface/ProcessBlock.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/Utilities/interface/EDMException.h"
0031 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0032 
0033 namespace edmtest {
0034   namespace stream {
0035 
0036     // anonymous namespace here causes build warnings
0037     namespace cache {
0038       struct Cache {
0039         Cache() : value(0), run(0), lumi(0) {}
0040         //Using mutable since we want to update the value.
0041         mutable std::atomic<unsigned int> value;
0042         mutable std::atomic<unsigned int> run;
0043         mutable std::atomic<unsigned int> lumi;
0044       };
0045 
0046       struct TestGlobalCacheFil {
0047         CMS_THREAD_SAFE mutable edm::EDPutTokenT<unsigned int> token_;
0048         CMS_THREAD_SAFE mutable edm::EDGetTokenT<unsigned int> getTokenBegin_;
0049         CMS_THREAD_SAFE mutable edm::EDGetTokenT<unsigned int> getTokenEnd_;
0050         unsigned int trans_{0};
0051         mutable std::atomic<unsigned int> m_count{0};
0052       };
0053     }  // namespace cache
0054 
0055     using Cache = cache::Cache;
0056     using TestGlobalCacheFil = cache::TestGlobalCacheFil;
0057 
0058     class GlobalIntFilter : public edm::stream::EDFilter<edm::GlobalCache<Cache>> {
0059     public:
0060       static std::atomic<unsigned int> m_count;
0061       unsigned int trans_;
0062       static std::atomic<unsigned int> cvalue_;
0063 
0064       static std::unique_ptr<Cache> initializeGlobalCache(edm::ParameterSet const&) {
0065         ++m_count;
0066         return std::make_unique<Cache>();
0067       }
0068 
0069       GlobalIntFilter(edm::ParameterSet const& p, const Cache* iGlobal) {
0070         trans_ = p.getParameter<int>("transitions");
0071         cvalue_ = p.getParameter<int>("cachevalue");
0072         produces<unsigned int>();
0073       }
0074 
0075       static void globalBeginJob(Cache* iGlobal) {
0076         ++m_count;
0077         if (iGlobal->value != 0) {
0078           throw cms::Exception("cache value") << iGlobal->value << " but it was supposed to be 0";
0079         }
0080       }
0081 
0082       bool filter(edm::Event&, edm::EventSetup const&) override {
0083         ++m_count;
0084         ++((globalCache())->value);
0085 
0086         return true;
0087       }
0088 
0089       static void globalEndJob(Cache* iGlobal) {
0090         ++m_count;
0091         if (iGlobal->value != cvalue_) {
0092           throw cms::Exception("cache value") << iGlobal->value << " but it was supposed to be " << cvalue_;
0093         }
0094       }
0095 
0096       ~GlobalIntFilter() {
0097         if (m_count != trans_) {
0098           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0099         }
0100       }
0101     };
0102 
0103     class RunIntFilter : public edm::stream::EDFilter<edm::RunCache<Cache>> {
0104     public:
0105       static std::atomic<unsigned int> m_count;
0106       unsigned int trans_;
0107       static std::atomic<unsigned int> cvalue_;
0108       static std::atomic<bool> gbr;
0109       static std::atomic<bool> ger;
0110       bool br;
0111       bool er;
0112 
0113       RunIntFilter(edm::ParameterSet const& p) {
0114         trans_ = p.getParameter<int>("transitions");
0115         cvalue_ = p.getParameter<int>("cachevalue");
0116         m_count = 0;
0117         produces<unsigned int>();
0118       }
0119 
0120       bool filter(edm::Event&, edm::EventSetup const&) override {
0121         ++m_count;
0122         ++(runCache()->value);
0123 
0124         return true;
0125       }
0126 
0127       static std::shared_ptr<Cache> globalBeginRun(edm::Run const& iRun, edm::EventSetup const&, GlobalCache const*) {
0128         ++m_count;
0129         gbr = true;
0130         ger = false;
0131         auto pCache = std::make_shared<Cache>();
0132         ++(pCache->run);
0133         return pCache;
0134       }
0135 
0136       static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext) {
0137         ++m_count;
0138         auto pCache = iContext->run();
0139         if (pCache->run != 1) {
0140           throw cms::Exception("end out of sequence") << "globalEndRun seen before globalBeginRun in Run" << iRun.run();
0141         }
0142         ger = true;
0143         gbr = false;
0144         if (iContext->run()->value != cvalue_) {
0145           throw cms::Exception("cache value") << iContext->run()->value << " but it was supposed to be " << cvalue_;
0146         }
0147       }
0148 
0149       ~RunIntFilter() {
0150         if (m_count != trans_) {
0151           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0152         }
0153       }
0154     };
0155 
0156     class LumiIntFilter : public edm::stream::EDFilter<edm::LuminosityBlockCache<Cache>> {
0157     public:
0158       static std::atomic<unsigned int> m_count;
0159       unsigned int trans_;
0160       static std::atomic<unsigned int> cvalue_;
0161       static std::atomic<bool> gbl;
0162       static std::atomic<bool> gel;
0163       static std::atomic<bool> bl;
0164       static std::atomic<bool> el;
0165 
0166       LumiIntFilter(edm::ParameterSet const& p) {
0167         trans_ = p.getParameter<int>("transitions");
0168         cvalue_ = p.getParameter<int>("cachevalue");
0169         m_count = 0;
0170         produces<unsigned int>();
0171       }
0172 
0173       bool filter(edm::Event&, edm::EventSetup const&) override {
0174         ++m_count;
0175         ++(luminosityBlockCache()->value);
0176 
0177         return true;
0178       }
0179 
0180       static std::shared_ptr<Cache> globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB,
0181                                                                edm::EventSetup const&,
0182                                                                RunContext const*) {
0183         ++m_count;
0184         gbl = true;
0185         gel = false;
0186         auto pCache = std::make_shared<Cache>();
0187         ++(pCache->lumi);
0188         return pCache;
0189       }
0190 
0191       void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {
0192         bl = true;
0193         el = false;
0194         if (!gbl) {
0195           throw cms::Exception("begin out of sequence")
0196               << "beginLuminosityBlock seen before globalBeginLuminosityBlock";
0197         }
0198       }
0199 
0200       static void globalEndLuminosityBlock(edm::LuminosityBlock const&,
0201                                            edm::EventSetup const&,
0202                                            LuminosityBlockContext const* iLBContext) {
0203         ++m_count;
0204         if (iLBContext->luminosityBlock()->value != cvalue_) {
0205           throw cms::Exception("cache value") << "LumiIntFilter cache value " << iLBContext->luminosityBlock()->value
0206                                               << " but it was supposed to be " << cvalue_;
0207         }
0208       }
0209 
0210       static void endLuminosityBlock(edm::Run const&, edm::EventSetup const&, LuminosityBlockContext const*) {
0211         el = true;
0212         bl = false;
0213         if (gel) {
0214           throw cms::Exception("end out of sequence") << "globalEndLuminosityBlock seen before endLuminosityBlock";
0215         }
0216       }
0217 
0218       ~LumiIntFilter() {
0219         if (m_count != trans_) {
0220           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0221         }
0222       }
0223     };
0224 
0225     class RunSummaryIntFilter : public edm::stream::EDFilter<edm::RunCache<Cache>, edm::RunSummaryCache<Cache>> {
0226     public:
0227       static std::atomic<unsigned int> m_count;
0228       unsigned int trans_;
0229       static std::atomic<unsigned int> cvalue_;
0230       static std::atomic<bool> gbr;
0231       static std::atomic<bool> ger;
0232       static std::atomic<bool> gbrs;
0233       static std::atomic<bool> gers;
0234       static std::atomic<bool> brs;
0235       static std::atomic<bool> ers;
0236       static std::atomic<bool> br;
0237       static std::atomic<bool> er;
0238 
0239       RunSummaryIntFilter(edm::ParameterSet const& p) {
0240         trans_ = p.getParameter<int>("transitions");
0241         cvalue_ = p.getParameter<int>("cachevalue");
0242         m_count = 0;
0243         produces<unsigned int>();
0244       }
0245 
0246       void beginRun(edm::Run const&, edm::EventSetup const&) override {
0247         br = true;
0248         er = false;
0249       }
0250 
0251       bool filter(edm::Event&, edm::EventSetup const&) override {
0252         ++m_count;
0253         ++(runCache()->value);
0254 
0255         return true;
0256       }
0257 
0258       static std::shared_ptr<Cache> globalBeginRun(edm::Run const& iRun, edm::EventSetup const&, GlobalCache const*) {
0259         ++m_count;
0260         gbr = true;
0261         ger = false;
0262         auto pCache = std::make_shared<Cache>();
0263         ++(pCache->run);
0264         return pCache;
0265       }
0266 
0267       static std::shared_ptr<Cache> globalBeginRunSummary(edm::Run const&, edm::EventSetup const&, GlobalCache const*) {
0268         ++m_count;
0269         gbrs = true;
0270         gers = false;
0271         brs = true;
0272         ers = false;
0273         if (!gbr) {
0274           throw cms::Exception("begin out of sequence") << "globalBeginRunSummary seen before globalBeginRun";
0275         }
0276         return std::make_shared<Cache>();
0277       }
0278 
0279       void endRunSummary(edm::Run const&, edm::EventSetup const&, Cache* gCache) const override {
0280         brs = false;
0281         ers = true;
0282         gCache->value += runCache()->value;
0283         runCache()->value = 0;
0284         if (!er) {
0285           throw cms::Exception("end out of sequence") << "endRunSummary seen before endRun";
0286         }
0287       }
0288 
0289       static void globalEndRunSummary(edm::Run const&, edm::EventSetup const&, RunContext const*, Cache* gCache) {
0290         ++m_count;
0291         gbrs = false;
0292         gers = true;
0293         if (!ers) {
0294           throw cms::Exception("end out of sequence") << "globalEndRunSummary seen before endRunSummary";
0295         }
0296         if (gCache->value != cvalue_) {
0297           throw cms::Exception("cache value") << gCache->value << " but it was supposed to be " << cvalue_;
0298         }
0299       }
0300 
0301       static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext) {
0302         ++m_count;
0303         gbr = false;
0304         ger = true;
0305         auto pCache = iContext->run();
0306         if (pCache->run != 1) {
0307           throw cms::Exception("end out of sequence") << "globalEndRun seen before globalBeginRun in Run" << iRun.run();
0308         }
0309       }
0310 
0311       void endRun(edm::Run const&, edm::EventSetup const&) override {
0312         er = true;
0313         br = false;
0314       }
0315 
0316       ~RunSummaryIntFilter() {
0317         if (m_count != trans_) {
0318           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0319         }
0320       }
0321     };
0322 
0323     class LumiSummaryIntFilter
0324         : public edm::stream::EDFilter<edm::LuminosityBlockCache<Cache>, edm::LuminosityBlockSummaryCache<Cache>> {
0325     public:
0326       static std::atomic<unsigned int> m_count;
0327       static std::atomic<unsigned int> m_lumiSumCalls;
0328       unsigned int trans_;
0329       static std::atomic<unsigned int> cvalue_;
0330       static std::atomic<bool> gbl;
0331       static std::atomic<bool> gel;
0332       static std::atomic<bool> gbls;
0333       static std::atomic<bool> gels;
0334       static std::atomic<bool> bls;
0335       static std::atomic<bool> els;
0336       static std::atomic<bool> bl;
0337       static std::atomic<bool> el;
0338 
0339       LumiSummaryIntFilter(edm::ParameterSet const& p) {
0340         trans_ = p.getParameter<int>("transitions");
0341         cvalue_ = p.getParameter<int>("cachevalue");
0342         m_count = 0;
0343         produces<unsigned int>();
0344       }
0345 
0346       bool filter(edm::Event&, edm::EventSetup const&) override {
0347         ++m_count;
0348         ++(luminosityBlockCache()->value);
0349 
0350         return true;
0351       }
0352 
0353       void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {
0354         bl = true;
0355         el = false;
0356       }
0357 
0358       static std::shared_ptr<Cache> globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB,
0359                                                                edm::EventSetup const&,
0360                                                                RunContext const*) {
0361         ++m_count;
0362         gbl = true;
0363         gel = false;
0364         auto pCache = std::make_shared<Cache>();
0365         ++(pCache->lumi);
0366         return pCache;
0367       }
0368 
0369       static std::shared_ptr<Cache> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&,
0370                                                                       edm::EventSetup const&,
0371                                                                       LuminosityBlockContext const*) {
0372         ++m_count;
0373         gbls = true;
0374         gels = false;
0375         bls = true;
0376         els = false;
0377         if (!gbl) {
0378           throw cms::Exception("begin out of sequence")
0379               << "globalBeginLuminosityBlockSummary seen before globalBeginLuminosityBlock";
0380         }
0381         return std::make_shared<Cache>();
0382       }
0383 
0384       void endLuminosityBlockSummary(edm::LuminosityBlock const&,
0385                                      edm::EventSetup const&,
0386                                      Cache* gCache) const override {
0387         ++m_lumiSumCalls;
0388         bls = false;
0389         els = true;
0390         //This routine could be called at the same time as another stream is calling filter so must do the change atomically
0391         auto v = luminosityBlockCache()->value.exchange(0);
0392         gCache->value += v;
0393         if (el) {
0394           throw cms::Exception("end out of sequence") << "endLuminosityBlock seen before endLuminosityBlockSummary";
0395         }
0396       }
0397 
0398       static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&,
0399                                                   edm::EventSetup const&,
0400                                                   LuminosityBlockContext const*,
0401                                                   Cache* gCache) {
0402         ++m_count;
0403         auto nLumis = m_lumiSumCalls.load();
0404         gbls = false;
0405         gels = true;
0406         if (!els) {
0407           throw cms::Exception("end out of sequence")
0408               << "LumiSummaryIntFilter "
0409               << "globalEndLuminosityBlockSummary seen before endLuminosityBlockSummary";
0410         }
0411         if (gCache->value != cvalue_) {
0412           throw cms::Exception("cache value")
0413               << gCache->value << " but it was supposed to be " << cvalue_ << " endLumiBlockSummary called " << nLumis;
0414         }
0415       }
0416 
0417       static void globalEndLuminosityBlock(edm::LuminosityBlock const& iLB,
0418                                            edm::EventSetup const&,
0419                                            LuminosityBlockContext const* iLBContext) {
0420         ++m_count;
0421         auto pCache = iLBContext->luminosityBlock();
0422         if (pCache->lumi != 1) {
0423           throw cms::Exception("end out of sequence")
0424               << "globalEndLuminosityBlock seen before globalBeginLuminosityBlock in LuminosityBlock"
0425               << iLB.luminosityBlock();
0426         }
0427         gel = true;
0428         gbl = false;
0429         if (!gels) {
0430           throw cms::Exception("end out of sequence")
0431               << "globalEndLuminosityBlockSummary seen before globalEndLuminosityBlock";
0432         }
0433       }
0434 
0435       static void endLuminosityBlock(edm::Run const&, edm::EventSetup const&, LuminosityBlockContext const*) {
0436         el = true;
0437         bl = false;
0438       }
0439 
0440       ~LumiSummaryIntFilter() {
0441         if (m_count != trans_) {
0442           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0443         }
0444       }
0445     };
0446 
0447     class ProcessBlockIntFilter
0448         : public edm::stream::EDFilter<edm::WatchProcessBlock, edm::GlobalCache<TestGlobalCacheFil>> {
0449     public:
0450       explicit ProcessBlockIntFilter(edm::ParameterSet const& pset, TestGlobalCacheFil const* testGlobalCache) {
0451         produces<unsigned int>();
0452 
0453         {
0454           auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlock");
0455           if (not tag.label().empty()) {
0456             testGlobalCache->getTokenBegin_ = consumes<unsigned int, edm::InProcess>(tag);
0457           }
0458         }
0459         {
0460           auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlock");
0461           if (not tag.label().empty()) {
0462             testGlobalCache->getTokenEnd_ = consumes<unsigned int, edm::InProcess>(tag);
0463           }
0464         }
0465       }
0466 
0467       static std::unique_ptr<TestGlobalCacheFil> initializeGlobalCache(edm::ParameterSet const& pset) {
0468         auto testGlobalCache = std::make_unique<TestGlobalCacheFil>();
0469         testGlobalCache->trans_ = pset.getParameter<int>("transitions");
0470         return testGlobalCache;
0471       }
0472 
0473       static void beginProcessBlock(edm::ProcessBlock const& processBlock, TestGlobalCacheFil* testGlobalCache) {
0474         if (testGlobalCache->m_count != 0) {
0475           throw cms::Exception("transitions") << "ProcessBlockIntFilter::begin transitions " << testGlobalCache->m_count
0476                                               << " but it was supposed to be " << 0;
0477         }
0478         ++testGlobalCache->m_count;
0479         const unsigned int valueToGet = 71;
0480         if (not testGlobalCache->getTokenBegin_.isUninitialized()) {
0481           if (processBlock.get(testGlobalCache->getTokenBegin_) != valueToGet) {
0482             throw cms::Exception("BadValue")
0483                 << "expected " << valueToGet << " but got " << processBlock.get(testGlobalCache->getTokenBegin_);
0484           }
0485         }
0486       }
0487 
0488       bool filter(edm::Event&, edm::EventSetup const&) override {
0489         TestGlobalCacheFil const* testGlobalCache = globalCache();
0490         if (testGlobalCache->m_count < 1u) {
0491           throw cms::Exception("out of sequence") << "produce before beginProcessBlock " << testGlobalCache->m_count;
0492         }
0493         ++testGlobalCache->m_count;
0494         return true;
0495       }
0496 
0497       static void endProcessBlock(edm::ProcessBlock const& processBlock, TestGlobalCacheFil* testGlobalCache) {
0498         ++testGlobalCache->m_count;
0499         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0500           throw cms::Exception("transitions") << "ProcessBlockIntFilter::end transitions " << testGlobalCache->m_count
0501                                               << " but it was supposed to be " << testGlobalCache->trans_;
0502         }
0503         {
0504           const unsigned int valueToGet = 71;
0505           if (not testGlobalCache->getTokenBegin_.isUninitialized()) {
0506             if (processBlock.get(testGlobalCache->getTokenBegin_) != valueToGet) {
0507               throw cms::Exception("BadValue")
0508                   << "expected " << valueToGet << " but got " << processBlock.get(testGlobalCache->getTokenBegin_);
0509             }
0510           }
0511         }
0512         {
0513           const unsigned int valueToGet = 81;
0514           if (not testGlobalCache->getTokenEnd_.isUninitialized()) {
0515             if (processBlock.get(testGlobalCache->getTokenEnd_) != valueToGet) {
0516               throw cms::Exception("BadValue")
0517                   << "expected " << valueToGet << " but got " << processBlock.get(testGlobalCache->getTokenEnd_);
0518             }
0519           }
0520         }
0521       }
0522 
0523       static void globalEndJob(TestGlobalCacheFil* testGlobalCache) {
0524         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0525           throw cms::Exception("transitions") << "ProcessBlockIntFilter transitions " << testGlobalCache->m_count
0526                                               << " but it was supposed to be " << testGlobalCache->trans_;
0527         }
0528       }
0529 
0530       ~ProcessBlockIntFilter() {
0531         TestGlobalCacheFil const* testGlobalCache = globalCache();
0532         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0533           throw cms::Exception("transitions") << "ProcessBlockIntFilter transitions " << testGlobalCache->m_count
0534                                               << " but it was supposed to be " << testGlobalCache->trans_;
0535         }
0536       }
0537     };
0538 
0539     class TestBeginProcessBlockFilter
0540         : public edm::stream::EDFilter<edm::BeginProcessBlockProducer, edm::GlobalCache<TestGlobalCacheFil>> {
0541     public:
0542       explicit TestBeginProcessBlockFilter(edm::ParameterSet const& pset, TestGlobalCacheFil const* testGlobalCache) {
0543         testGlobalCache->token_ = produces<unsigned int, edm::Transition::BeginProcessBlock>("begin");
0544         produces<unsigned int>();
0545 
0546         auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlock");
0547         if (not tag.label().empty()) {
0548           testGlobalCache->getTokenBegin_ = consumes<unsigned int, edm::InProcess>(tag);
0549         }
0550       }
0551 
0552       static std::unique_ptr<TestGlobalCacheFil> initializeGlobalCache(edm::ParameterSet const& pset) {
0553         auto testGlobalCache = std::make_unique<TestGlobalCacheFil>();
0554         testGlobalCache->trans_ = pset.getParameter<int>("transitions");
0555         return testGlobalCache;
0556       }
0557 
0558       static void beginProcessBlockProduce(edm::ProcessBlock& processBlock, TestGlobalCacheFil const* testGlobalCache) {
0559         if (testGlobalCache->m_count != 0) {
0560           throw cms::Exception("transitions") << "TestBeginProcessBlockFilter transitions " << testGlobalCache->m_count
0561                                               << " but it was supposed to be " << 0;
0562         }
0563         ++testGlobalCache->m_count;
0564 
0565         const unsigned int valueToPutAndGet = 71;
0566         processBlock.emplace(testGlobalCache->token_, valueToPutAndGet);
0567 
0568         if (not testGlobalCache->getTokenBegin_.isUninitialized()) {
0569           if (processBlock.get(testGlobalCache->getTokenBegin_) != valueToPutAndGet) {
0570             throw cms::Exception("BadValue")
0571                 << "expected " << valueToPutAndGet << " but got " << processBlock.get(testGlobalCache->getTokenBegin_);
0572           }
0573         }
0574       }
0575 
0576       bool filter(edm::Event&, edm::EventSetup const&) override {
0577         TestGlobalCacheFil const* testGlobalCache = globalCache();
0578         if (testGlobalCache->m_count < 1u) {
0579           throw cms::Exception("out of sequence")
0580               << "produce before beginProcessBlockProduce " << testGlobalCache->m_count;
0581         }
0582         ++testGlobalCache->m_count;
0583         return true;
0584       }
0585 
0586       static void globalEndJob(TestGlobalCacheFil* testGlobalCache) {
0587         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0588           throw cms::Exception("transitions") << "TestBeginProcessBlockFilter transitions " << testGlobalCache->m_count
0589                                               << " but it was supposed to be " << testGlobalCache->trans_;
0590         }
0591       }
0592 
0593       ~TestBeginProcessBlockFilter() {
0594         TestGlobalCacheFil const* testGlobalCache = globalCache();
0595         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0596           throw cms::Exception("transitions") << "TestBeginProcessBlockFilter transitions " << testGlobalCache->m_count
0597                                               << " but it was supposed to be " << testGlobalCache->trans_;
0598         }
0599       }
0600     };
0601 
0602     class TestEndProcessBlockFilter
0603         : public edm::stream::EDFilter<edm::EndProcessBlockProducer, edm::GlobalCache<TestGlobalCacheFil>> {
0604     public:
0605       explicit TestEndProcessBlockFilter(edm::ParameterSet const& pset, TestGlobalCacheFil const* testGlobalCache) {
0606         testGlobalCache->token_ = produces<unsigned int, edm::Transition::EndProcessBlock>("end");
0607         produces<unsigned int>();
0608 
0609         auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlock");
0610         if (not tag.label().empty()) {
0611           testGlobalCache->getTokenEnd_ = consumes<unsigned int, edm::InProcess>(tag);
0612         }
0613       }
0614 
0615       static std::unique_ptr<TestGlobalCacheFil> initializeGlobalCache(edm::ParameterSet const& pset) {
0616         auto testGlobalCache = std::make_unique<TestGlobalCacheFil>();
0617         testGlobalCache->trans_ = pset.getParameter<int>("transitions");
0618         return testGlobalCache;
0619       }
0620 
0621       bool filter(edm::Event&, edm::EventSetup const&) override {
0622         TestGlobalCacheFil const* testGlobalCache = globalCache();
0623         ++testGlobalCache->m_count;
0624         return true;
0625       }
0626 
0627       static void endProcessBlockProduce(edm::ProcessBlock& processBlock, TestGlobalCacheFil const* testGlobalCache) {
0628         ++testGlobalCache->m_count;
0629         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0630           throw cms::Exception("transitions") << "TestEndProcessBlockFilter transitions " << testGlobalCache->m_count
0631                                               << " but it was supposed to be " << testGlobalCache->trans_;
0632         }
0633 
0634         const unsigned int valueToPutAndGet = 81;
0635         processBlock.emplace(testGlobalCache->token_, valueToPutAndGet);
0636         if (not testGlobalCache->getTokenEnd_.isUninitialized()) {
0637           if (processBlock.get(testGlobalCache->getTokenEnd_) != valueToPutAndGet) {
0638             throw cms::Exception("BadValue")
0639                 << "expected " << valueToPutAndGet << " but got " << processBlock.get(testGlobalCache->getTokenEnd_);
0640           }
0641         }
0642       }
0643 
0644       static void globalEndJob(TestGlobalCacheFil* testGlobalCache) {
0645         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0646           throw cms::Exception("transitions") << "TestEndProcessBlockFilter transitions " << testGlobalCache->m_count
0647                                               << " but it was supposed to be " << testGlobalCache->trans_;
0648         }
0649       }
0650 
0651       ~TestEndProcessBlockFilter() {
0652         TestGlobalCacheFil const* testGlobalCache = globalCache();
0653         if (testGlobalCache->m_count != testGlobalCache->trans_) {
0654           throw cms::Exception("transitions") << "~TestEndProcessBlockFilter transitions " << testGlobalCache->m_count
0655                                               << " but it was supposed to be " << testGlobalCache->trans_;
0656         }
0657       }
0658     };
0659 
0660     class TestBeginRunFilter : public edm::stream::EDFilter<edm::RunCache<Cache>, edm::BeginRunProducer> {
0661     public:
0662       static std::atomic<unsigned int> m_count;
0663       unsigned int trans_;
0664       static std::atomic<unsigned int> cvalue_;
0665       static std::atomic<bool> gbr;
0666       static std::atomic<bool> ger;
0667 
0668       TestBeginRunFilter(edm::ParameterSet const& p) {
0669         trans_ = p.getParameter<int>("transitions");
0670         cvalue_ = p.getParameter<int>("cachevalue");
0671         m_count = 0;
0672         produces<unsigned int>();
0673         produces<unsigned int, edm::Transition::BeginRun>("a");
0674       }
0675 
0676       static std::shared_ptr<Cache> globalBeginRun(edm::Run const& iRun, edm::EventSetup const&, GlobalCache const*) {
0677         ++m_count;
0678         gbr = true;
0679         ger = false;
0680         auto pCache = std::make_shared<Cache>();
0681         ++(pCache->run);
0682         return pCache;
0683       }
0684 
0685       bool filter(edm::Event&, edm::EventSetup const&) override {
0686         ++m_count;
0687         return true;
0688       }
0689 
0690       static void globalBeginRunProduce(edm::Run& iRun, edm::EventSetup const&, RunContext const*) {
0691         ++m_count;
0692         if (!gbr) {
0693           throw cms::Exception("begin out of sequence") << "globalBeginRunProduce seen before globalBeginRun";
0694         }
0695       }
0696 
0697       static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext) {
0698         ++m_count;
0699         auto pCache = iContext->run();
0700         if (pCache->run != 1) {
0701           throw cms::Exception("end out of sequence") << "globalEndRun seen before globalBeginRun in Run" << iRun.run();
0702         }
0703         gbr = false;
0704         ger = true;
0705       }
0706 
0707       ~TestBeginRunFilter() {
0708         if (m_count != trans_) {
0709           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0710         }
0711       }
0712     };
0713 
0714     class TestEndRunFilter : public edm::stream::EDFilter<edm::RunCache<Cache>, edm::EndRunProducer> {
0715     public:
0716       static std::atomic<unsigned int> m_count;
0717       unsigned int trans_;
0718       static std::atomic<unsigned int> cvalue_;
0719       static std::atomic<bool> gbr;
0720       static std::atomic<bool> ger;
0721 
0722       static std::shared_ptr<Cache> globalBeginRun(edm::Run const& iRun, edm::EventSetup const&, GlobalCache const*) {
0723         ++m_count;
0724         gbr = true;
0725         ger = false;
0726         auto pCache = std::make_shared<Cache>();
0727         ++(pCache->run);
0728         return pCache;
0729       }
0730 
0731       TestEndRunFilter(edm::ParameterSet const& p) {
0732         trans_ = p.getParameter<int>("transitions");
0733         cvalue_ = p.getParameter<int>("cachevalue");
0734         m_count = 0;
0735         produces<unsigned int>();
0736         produces<unsigned int, edm::Transition::EndRun>("a");
0737       }
0738 
0739       bool filter(edm::Event&, edm::EventSetup const&) override {
0740         ++m_count;
0741 
0742         return true;
0743       }
0744 
0745       static void globalEndRunProduce(edm::Run& iRun, edm::EventSetup const&, RunContext const*) {
0746         ++m_count;
0747         if (ger) {
0748           throw cms::Exception("end out of sequence") << "globalEndRun seen before globalEndRunProduce";
0749         }
0750       }
0751 
0752       static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext) {
0753         ++m_count;
0754         auto pCache = iContext->run();
0755         if (pCache->run != 1) {
0756           throw cms::Exception("end out of sequence") << "globalEndRun seen before globalBeginRun in Run" << iRun.run();
0757         }
0758         gbr = false;
0759         ger = true;
0760       }
0761 
0762       ~TestEndRunFilter() {
0763         if (m_count != trans_) {
0764           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0765         }
0766       }
0767     };
0768 
0769     class TestBeginLumiBlockFilter
0770         : public edm::stream::EDFilter<edm::LuminosityBlockCache<Cache>, edm::BeginLuminosityBlockProducer> {
0771     public:
0772       static std::atomic<unsigned int> m_count;
0773       unsigned int trans_;
0774       static std::atomic<unsigned int> cvalue_;
0775       static std::atomic<bool> gbl;
0776       static std::atomic<bool> gel;
0777 
0778       TestBeginLumiBlockFilter(edm::ParameterSet const& p) {
0779         trans_ = p.getParameter<int>("transitions");
0780         cvalue_ = p.getParameter<int>("cachevalue");
0781         m_count = 0;
0782         produces<unsigned int>();
0783         produces<unsigned int, edm::Transition::BeginLuminosityBlock>("a");
0784       }
0785 
0786       bool filter(edm::Event&, edm::EventSetup const&) override {
0787         ++m_count;
0788 
0789         return true;
0790       }
0791 
0792       static void globalBeginLuminosityBlockProduce(edm::LuminosityBlock&,
0793                                                     edm::EventSetup const&,
0794                                                     LuminosityBlockContext const*) {
0795         ++m_count;
0796         if (!gbl) {
0797           throw cms::Exception("begin out of sequence")
0798               << "globalBeginLumiBlockProduce seen before globalBeginLumiBlock";
0799         }
0800       }
0801 
0802       static std::shared_ptr<Cache> globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB,
0803                                                                edm::EventSetup const&,
0804                                                                RunContext const*) {
0805         ++m_count;
0806         gbl = true;
0807         gel = false;
0808         auto pCache = std::make_shared<Cache>();
0809         ++(pCache->lumi);
0810         return pCache;
0811       }
0812 
0813       static void globalEndLuminosityBlock(edm::LuminosityBlock const& iLB,
0814                                            edm::EventSetup const&,
0815                                            LuminosityBlockContext const* iLBContext) {
0816         ++m_count;
0817         auto pCache = iLBContext->luminosityBlock();
0818         if (pCache->lumi != 1) {
0819           throw cms::Exception("end out of sequence")
0820               << "globalEndLuminosityBlock seen before globalBeginLuminosityBlock in LuminosityBlock"
0821               << iLB.luminosityBlock();
0822         }
0823         gel = true;
0824         gbl = false;
0825       }
0826 
0827       ~TestBeginLumiBlockFilter() {
0828         if (m_count != trans_) {
0829           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0830         }
0831       }
0832     };
0833 
0834     class TestEndLumiBlockFilter
0835         : public edm::stream::EDFilter<edm::LuminosityBlockCache<Cache>, edm::EndLuminosityBlockProducer> {
0836     public:
0837       static std::atomic<unsigned int> m_count;
0838       unsigned int trans_;
0839       static std::atomic<unsigned int> cvalue_;
0840       static std::atomic<bool> gbl;
0841       static std::atomic<bool> gel;
0842 
0843       TestEndLumiBlockFilter(edm::ParameterSet const& p) {
0844         trans_ = p.getParameter<int>("transitions");
0845         cvalue_ = p.getParameter<int>("cachevalue");
0846         m_count = 0;
0847         produces<unsigned int>();
0848         produces<unsigned int, edm::Transition::EndLuminosityBlock>("a");
0849       }
0850 
0851       bool filter(edm::Event&, edm::EventSetup const&) override {
0852         ++m_count;
0853 
0854         return true;
0855       }
0856 
0857       static std::shared_ptr<Cache> globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB,
0858                                                                edm::EventSetup const&,
0859                                                                RunContext const*) {
0860         ++m_count;
0861         gbl = true;
0862         gel = false;
0863         auto pCache = std::make_shared<Cache>();
0864         ++(pCache->lumi);
0865         return pCache;
0866       }
0867 
0868       static void globalEndLuminosityBlock(edm::LuminosityBlock const& iLB,
0869                                            edm::EventSetup const&,
0870                                            LuminosityBlockContext const* iLBContext) {
0871         ++m_count;
0872         auto pCache = iLBContext->luminosityBlock();
0873         if (pCache->lumi != 1) {
0874           throw cms::Exception("end out of sequence")
0875               << "globalEndLuminosityBlock seen before globalBeginLuminosityBlock in LuminosityBlock"
0876               << iLB.luminosityBlock();
0877         }
0878         gel = true;
0879         gbl = false;
0880       }
0881 
0882       static void globalEndLuminosityBlockProduce(edm::LuminosityBlock&,
0883                                                   edm::EventSetup const&,
0884                                                   LuminosityBlockContext const*) {
0885         ++m_count;
0886       }
0887 
0888       ~TestEndLumiBlockFilter() {
0889         if (m_count != trans_) {
0890           throw cms::Exception("transitions") << m_count << " but it was supposed to be " << trans_;
0891         }
0892       }
0893     };
0894 
0895     class TestInputProcessBlockCache {
0896     public:
0897       long long int value_ = 0;
0898     };
0899 
0900     class TestInputProcessBlockCache1 {
0901     public:
0902       long long int value_ = 0;
0903     };
0904 
0905     class InputProcessBlockIntFilter
0906         : public edm::stream::EDFilter<
0907               edm::InputProcessBlockCache<int, TestInputProcessBlockCache, TestInputProcessBlockCache1>> {
0908     public:
0909       explicit InputProcessBlockIntFilter(edm::ParameterSet const& pset) {
0910         {
0911           expectedByRun_ = pset.getParameter<std::vector<int>>("expectedByRun");
0912           sleepTime_ = pset.getParameter<unsigned int>("sleepTime");
0913           auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlock");
0914           if (not tag.label().empty()) {
0915             getTokenBegin_ = consumes<IntProduct, edm::InProcess>(tag);
0916           }
0917         }
0918         {
0919           auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlock");
0920           if (not tag.label().empty()) {
0921             getTokenEnd_ = consumes<IntProduct, edm::InProcess>(tag);
0922           }
0923         }
0924         registerProcessBlockCacheFiller<TestInputProcessBlockCache1>(
0925             getTokenBegin_,
0926             [this](edm::ProcessBlock const& processBlock,
0927                    std::shared_ptr<TestInputProcessBlockCache1> const& previousCache) {
0928               auto returnValue = std::make_shared<TestInputProcessBlockCache1>();
0929               returnValue->value_ += processBlock.get(getTokenBegin_).value;
0930               returnValue->value_ += processBlock.get(getTokenEnd_).value;
0931               return returnValue;
0932             });
0933       }
0934 
0935       static void accessInputProcessBlock(edm::ProcessBlock const&) {
0936         edm::LogAbsolute("InputProcessBlockIntFilter") << "InputProcessBlockIntFilter::accessInputProcessBlock";
0937       }
0938 
0939       bool filter(edm::Event& event, edm::EventSetup const&) override {
0940         auto cacheTuple = processBlockCaches(event);
0941         if (!expectedByRun_.empty()) {
0942           if (expectedByRun_.at(event.run() - 1) !=
0943               std::get<edm::CacheHandle<TestInputProcessBlockCache1>>(cacheTuple)->value_) {
0944             throw cms::Exception("UnexpectedValue")
0945                 << "InputProcessBlockIntFilter::filter cached value was "
0946                 << std::get<edm::CacheHandle<TestInputProcessBlockCache1>>(cacheTuple)->value_
0947                 << " but it was supposed to be " << expectedByRun_.at(event.run() - 1);
0948           }
0949         }
0950         // Force events to be processed concurrently
0951         if (sleepTime_ > 0) {
0952           usleep(sleepTime_);
0953         }
0954         return true;
0955       }
0956 
0957     private:
0958       edm::EDGetTokenT<IntProduct> getTokenBegin_;
0959       edm::EDGetTokenT<IntProduct> getTokenEnd_;
0960       std::vector<int> expectedByRun_;
0961       unsigned int sleepTime_{0};
0962     };
0963 
0964     struct InputProcessBlockGlobalCacheAn {
0965       // The tokens are duplicated in this test module to prove that they
0966       // work both as GlobalCache members and module data members.
0967       // We need them as GlobalCache members for accessInputProcessBlock.
0968       // In registerProcessBlockCacheFiller we use tokens that are member
0969       // variables of the class and because the lambda captures the "this"
0970       // pointer of the zeroth stream module instance. We always
0971       // use the zeroth EDConsumer. In the case of registerProcessBlockCacheFiller,
0972       // either set of tokens would work. Note that in the GlobalCache case
0973       // there is a slight weirdness that the zeroth consumer is used but
0974       // the token comes from the last consumer instance. It works because
0975       // all the stream module instances have EDConsumer base classes with
0976       // containers with the same contents in the same order (not 100% guaranteed,
0977       // but it would be difficult to implement a module where this isn't true).
0978       CMS_THREAD_SAFE mutable edm::EDGetTokenT<IntProduct> getTokenBegin_;
0979       CMS_THREAD_SAFE mutable edm::EDGetTokenT<IntProduct> getTokenEnd_;
0980       CMS_THREAD_SAFE mutable edm::EDGetTokenT<IntProduct> getTokenBeginM_;
0981       CMS_THREAD_SAFE mutable edm::EDGetTokenT<IntProduct> getTokenEndM_;
0982       mutable std::atomic<unsigned int> transitions_{0};
0983       int sum_{0};
0984       unsigned int expectedTransitions_{0};
0985       std::vector<int> expectedByRun_;
0986       int expectedSum_{0};
0987       unsigned int sleepTime_{0};
0988     };
0989 
0990     // Same thing as previous class except with a GlobalCache added
0991     class InputProcessBlockIntFilterG
0992         : public edm::stream::EDFilter<
0993               edm::InputProcessBlockCache<int, TestInputProcessBlockCache, TestInputProcessBlockCache1>,
0994               edm::GlobalCache<InputProcessBlockGlobalCacheAn>> {
0995     public:
0996       explicit InputProcessBlockIntFilterG(edm::ParameterSet const& pset,
0997                                            InputProcessBlockGlobalCacheAn const* testGlobalCache) {
0998         {
0999           auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlock");
1000           if (not tag.label().empty()) {
1001             getTokenBegin_ = consumes<IntProduct, edm::InProcess>(tag);
1002             testGlobalCache->getTokenBegin_ = getTokenBegin_;
1003           }
1004         }
1005         {
1006           auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlock");
1007           if (not tag.label().empty()) {
1008             getTokenEnd_ = consumes<IntProduct, edm::InProcess>(tag);
1009             testGlobalCache->getTokenEnd_ = getTokenEnd_;
1010           }
1011         }
1012         {
1013           auto tag = pset.getParameter<edm::InputTag>("consumesBeginProcessBlockM");
1014           if (not tag.label().empty()) {
1015             getTokenBeginM_ = consumes<IntProduct, edm::InProcess>(tag);
1016             testGlobalCache->getTokenBeginM_ = getTokenBeginM_;
1017           }
1018         }
1019         {
1020           auto tag = pset.getParameter<edm::InputTag>("consumesEndProcessBlockM");
1021           if (not tag.label().empty()) {
1022             getTokenEndM_ = consumes<IntProduct, edm::InProcess>(tag);
1023             testGlobalCache->getTokenEndM_ = getTokenEndM_;
1024           }
1025         }
1026         registerProcessBlockCacheFiller<int>(
1027             getTokenBegin_, [this](edm::ProcessBlock const& processBlock, std::shared_ptr<int> const& previousCache) {
1028               auto returnValue = std::make_shared<int>(0);
1029               *returnValue += processBlock.get(getTokenBegin_).value;
1030               *returnValue += processBlock.get(getTokenEnd_).value;
1031               ++globalCache()->transitions_;
1032               return returnValue;
1033             });
1034         registerProcessBlockCacheFiller<1>(getTokenBegin_,
1035                                            [this](edm::ProcessBlock const& processBlock,
1036                                                   std::shared_ptr<TestInputProcessBlockCache> const& previousCache) {
1037                                              auto returnValue = std::make_shared<TestInputProcessBlockCache>();
1038                                              returnValue->value_ += processBlock.get(getTokenBegin_).value;
1039                                              returnValue->value_ += processBlock.get(getTokenEnd_).value;
1040                                              ++globalCache()->transitions_;
1041                                              return returnValue;
1042                                            });
1043         registerProcessBlockCacheFiller<TestInputProcessBlockCache1>(
1044             getTokenBegin_,
1045             [this](edm::ProcessBlock const& processBlock,
1046                    std::shared_ptr<TestInputProcessBlockCache1> const& previousCache) {
1047               auto returnValue = std::make_shared<TestInputProcessBlockCache1>();
1048               returnValue->value_ += processBlock.get(getTokenBegin_).value;
1049               returnValue->value_ += processBlock.get(getTokenEnd_).value;
1050               ++globalCache()->transitions_;
1051               return returnValue;
1052             });
1053       }
1054 
1055       static std::unique_ptr<InputProcessBlockGlobalCacheAn> initializeGlobalCache(edm::ParameterSet const& pset) {
1056         auto testGlobalCache = std::make_unique<InputProcessBlockGlobalCacheAn>();
1057         testGlobalCache->expectedTransitions_ = pset.getParameter<int>("transitions");
1058         testGlobalCache->expectedByRun_ = pset.getParameter<std::vector<int>>("expectedByRun");
1059         testGlobalCache->expectedSum_ = pset.getParameter<int>("expectedSum");
1060         testGlobalCache->sleepTime_ = pset.getParameter<unsigned int>("sleepTime");
1061         return testGlobalCache;
1062       }
1063 
1064       static void accessInputProcessBlock(edm::ProcessBlock const& processBlock,
1065                                           InputProcessBlockGlobalCacheAn* testGlobalCache) {
1066         if (processBlock.processName() == "PROD1") {
1067           testGlobalCache->sum_ += processBlock.get(testGlobalCache->getTokenBegin_).value;
1068           testGlobalCache->sum_ += processBlock.get(testGlobalCache->getTokenEnd_).value;
1069         }
1070         if (processBlock.processName() == "MERGE") {
1071           testGlobalCache->sum_ += processBlock.get(testGlobalCache->getTokenBeginM_).value;
1072           testGlobalCache->sum_ += processBlock.get(testGlobalCache->getTokenEndM_).value;
1073         }
1074         ++testGlobalCache->transitions_;
1075       }
1076 
1077       bool filter(edm::Event& event, edm::EventSetup const&) override {
1078         auto cacheTuple = processBlockCaches(event);
1079         auto testGlobalCache = globalCache();
1080         if (!testGlobalCache->expectedByRun_.empty()) {
1081           if (testGlobalCache->expectedByRun_.at(event.run() - 1) != *std::get<edm::CacheHandle<int>>(cacheTuple)) {
1082             throw cms::Exception("UnexpectedValue")
1083                 << "InputProcessBlockIntFilterG::filter cached value was "
1084                 << *std::get<edm::CacheHandle<int>>(cacheTuple) << " but it was supposed to be "
1085                 << testGlobalCache->expectedByRun_.at(event.run() - 1);
1086           }
1087           if (testGlobalCache->expectedByRun_.at(event.run() - 1) != std::get<1>(cacheTuple)->value_) {
1088             throw cms::Exception("UnexpectedValue")
1089                 << "InputProcessBlockIntFilterG::filter second cached value was " << std::get<1>(cacheTuple)->value_
1090                 << " but it was supposed to be " << testGlobalCache->expectedByRun_.at(event.run() - 1);
1091           }
1092           if (testGlobalCache->expectedByRun_.at(event.run() - 1) !=
1093               std::get<edm::CacheHandle<TestInputProcessBlockCache1>>(cacheTuple)->value_) {
1094             throw cms::Exception("UnexpectedValue")
1095                 << "InputProcessBlockIntFilterG::filter third cached value was "
1096                 << std::get<edm::CacheHandle<TestInputProcessBlockCache1>>(cacheTuple)->value_
1097                 << " but it was supposed to be " << testGlobalCache->expectedByRun_.at(event.run() - 1);
1098           }
1099         }
1100         ++testGlobalCache->transitions_;
1101 
1102         // Force events to be processed concurrently
1103         if (testGlobalCache->sleepTime_ > 0) {
1104           usleep(testGlobalCache->sleepTime_);
1105         }
1106         return true;
1107       }
1108 
1109       static void globalEndJob(InputProcessBlockGlobalCacheAn* testGlobalCache) {
1110         if (testGlobalCache->transitions_ != testGlobalCache->expectedTransitions_) {
1111           throw cms::Exception("transitions")
1112               << "InputProcessBlockIntFilterG transitions " << testGlobalCache->transitions_
1113               << " but it was supposed to be " << testGlobalCache->expectedTransitions_;
1114         }
1115 
1116         if (testGlobalCache->sum_ != testGlobalCache->expectedSum_) {
1117           throw cms::Exception("UnexpectedValue") << "InputProcessBlockIntFilterG sum " << testGlobalCache->sum_
1118                                                   << " but it was supposed to be " << testGlobalCache->expectedSum_;
1119         }
1120       }
1121 
1122     private:
1123       edm::EDGetTokenT<IntProduct> getTokenBegin_;
1124       edm::EDGetTokenT<IntProduct> getTokenEnd_;
1125       edm::EDGetTokenT<IntProduct> getTokenBeginM_;
1126       edm::EDGetTokenT<IntProduct> getTokenEndM_;
1127     };
1128 
1129   }  // namespace stream
1130 }  // namespace edmtest
1131 std::atomic<unsigned int> edmtest::stream::GlobalIntFilter::m_count{0};
1132 std::atomic<unsigned int> edmtest::stream::RunIntFilter::m_count{0};
1133 std::atomic<unsigned int> edmtest::stream::LumiIntFilter::m_count{0};
1134 std::atomic<unsigned int> edmtest::stream::RunSummaryIntFilter::m_count{0};
1135 std::atomic<unsigned int> edmtest::stream::LumiSummaryIntFilter::m_count{0};
1136 std::atomic<unsigned int> edmtest::stream::TestBeginRunFilter::m_count{0};
1137 std::atomic<unsigned int> edmtest::stream::TestEndRunFilter::m_count{0};
1138 std::atomic<unsigned int> edmtest::stream::TestBeginLumiBlockFilter::m_count{0};
1139 std::atomic<unsigned int> edmtest::stream::TestEndLumiBlockFilter::m_count{0};
1140 std::atomic<unsigned int> edmtest::stream::GlobalIntFilter::cvalue_{0};
1141 std::atomic<unsigned int> edmtest::stream::RunIntFilter::cvalue_{0};
1142 std::atomic<unsigned int> edmtest::stream::LumiIntFilter::cvalue_{0};
1143 std::atomic<unsigned int> edmtest::stream::RunSummaryIntFilter::cvalue_{0};
1144 std::atomic<unsigned int> edmtest::stream::LumiSummaryIntFilter::cvalue_{0};
1145 std::atomic<unsigned int> edmtest::stream::TestBeginRunFilter::cvalue_{0};
1146 std::atomic<unsigned int> edmtest::stream::TestEndRunFilter::cvalue_{0};
1147 std::atomic<unsigned int> edmtest::stream::TestBeginLumiBlockFilter::cvalue_{0};
1148 std::atomic<unsigned int> edmtest::stream::TestEndLumiBlockFilter::cvalue_{0};
1149 std::atomic<bool> edmtest::stream::RunIntFilter::gbr{false};
1150 std::atomic<bool> edmtest::stream::RunIntFilter::ger{false};
1151 std::atomic<bool> edmtest::stream::LumiIntFilter::gbl{false};
1152 std::atomic<bool> edmtest::stream::LumiIntFilter::gel{false};
1153 std::atomic<bool> edmtest::stream::LumiIntFilter::bl{false};
1154 std::atomic<bool> edmtest::stream::LumiIntFilter::el{false};
1155 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::gbr{false};
1156 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::ger{false};
1157 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::gbrs{false};
1158 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::gers{false};
1159 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::brs{false};
1160 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::ers{false};
1161 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::br{false};
1162 std::atomic<bool> edmtest::stream::RunSummaryIntFilter::er{false};
1163 std::atomic<unsigned int> edmtest::stream::LumiSummaryIntFilter::m_lumiSumCalls{0};
1164 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::gbl{false};
1165 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::gel{false};
1166 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::gbls{false};
1167 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::gels{false};
1168 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::bls{false};
1169 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::els{false};
1170 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::bl{false};
1171 std::atomic<bool> edmtest::stream::LumiSummaryIntFilter::el{false};
1172 std::atomic<bool> edmtest::stream::TestBeginRunFilter::gbr{false};
1173 std::atomic<bool> edmtest::stream::TestBeginRunFilter::ger{false};
1174 std::atomic<bool> edmtest::stream::TestEndRunFilter::gbr{false};
1175 std::atomic<bool> edmtest::stream::TestEndRunFilter::ger{false};
1176 std::atomic<bool> edmtest::stream::TestBeginLumiBlockFilter::gbl{false};
1177 std::atomic<bool> edmtest::stream::TestBeginLumiBlockFilter::gel{false};
1178 std::atomic<bool> edmtest::stream::TestEndLumiBlockFilter::gbl{false};
1179 std::atomic<bool> edmtest::stream::TestEndLumiBlockFilter::gel{false};
1180 DEFINE_FWK_MODULE(edmtest::stream::GlobalIntFilter);
1181 DEFINE_FWK_MODULE(edmtest::stream::RunIntFilter);
1182 DEFINE_FWK_MODULE(edmtest::stream::LumiIntFilter);
1183 DEFINE_FWK_MODULE(edmtest::stream::RunSummaryIntFilter);
1184 DEFINE_FWK_MODULE(edmtest::stream::LumiSummaryIntFilter);
1185 DEFINE_FWK_MODULE(edmtest::stream::ProcessBlockIntFilter);
1186 DEFINE_FWK_MODULE(edmtest::stream::TestBeginProcessBlockFilter);
1187 DEFINE_FWK_MODULE(edmtest::stream::TestEndProcessBlockFilter);
1188 DEFINE_FWK_MODULE(edmtest::stream::TestBeginRunFilter);
1189 DEFINE_FWK_MODULE(edmtest::stream::TestEndRunFilter);
1190 DEFINE_FWK_MODULE(edmtest::stream::TestBeginLumiBlockFilter);
1191 DEFINE_FWK_MODULE(edmtest::stream::TestEndLumiBlockFilter);
1192 DEFINE_FWK_MODULE(edmtest::stream::InputProcessBlockIntFilter);
1193 DEFINE_FWK_MODULE(edmtest::stream::InputProcessBlockIntFilterG);