Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:07

0001 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Utilities/interface/EDGetToken.h"
0006 
0007 #include "DataFormats/Common/interface/EndPathStatus.h"
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "DataFormats/Common/interface/PathStatus.h"
0010 
0011 #include <iostream>
0012 
0013 namespace edm {
0014   class EventSetup;
0015   class StreamID;
0016 }  // namespace edm
0017 
0018 namespace edmtest {
0019 
0020   class TestGetPathStatus : public edm::global::EDAnalyzer<> {
0021   public:
0022     explicit TestGetPathStatus(edm::ParameterSet const& pset);
0023     virtual ~TestGetPathStatus() {}
0024 
0025     void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
0026 
0027   private:
0028     std::vector<int> expectedStates_;
0029     std::vector<unsigned int> expectedIndexes_;
0030 
0031     edm::EDGetTokenT<edm::PathStatus> tokenPathStatus_;
0032     edm::EDGetTokenT<edm::EndPathStatus> tokenEndPathStatus_;
0033   };
0034 
0035   TestGetPathStatus::TestGetPathStatus(edm::ParameterSet const& pset)
0036       : expectedStates_(pset.getParameter<std::vector<int>>("expectedStates")),
0037         expectedIndexes_(pset.getParameter<std::vector<unsigned int>>("expectedIndexes")),
0038         tokenPathStatus_(consumes(pset.getParameter<edm::InputTag>("pathStatusTag"))),
0039         tokenEndPathStatus_(consumes(pset.getParameter<edm::InputTag>("endPathStatusTag"))) {}
0040 
0041   void TestGetPathStatus::analyze(edm::StreamID, edm::Event const& event, edm::EventSetup const&) const {
0042     auto const& pathStatus = event.get(tokenPathStatus_);
0043 
0044     unsigned int eventID = event.id().event();
0045     if (eventID < expectedStates_.size() && expectedStates_[eventID] != static_cast<int>(pathStatus.state())) {
0046       std::cerr << "TestGetPathStatus::analyze unexpected path status state" << std::endl;
0047       abort();
0048     }
0049     if (eventID < expectedIndexes_.size() && expectedIndexes_[eventID] != pathStatus.index()) {
0050       std::cerr << "TestGetPathStatus::analyze unexpected path status index " << std::endl;
0051       abort();
0052     }
0053 
0054     (void)event.get(tokenEndPathStatus_);
0055   }
0056 }  // namespace edmtest
0057 using edmtest::TestGetPathStatus;
0058 DEFINE_FWK_MODULE(TestGetPathStatus);