Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:36

0001 // This test module will look for history information in event data.
0002 
0003 #include <iostream>
0004 #include <vector>
0005 
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 namespace edmtest {
0012   class TestHistoryKeeping : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0013   public:
0014     explicit TestHistoryKeeping(edm::ParameterSet const& pset);
0015 
0016     void analyze(edm::Event const& e, edm::EventSetup const&) final;
0017 
0018     void beginRun(edm::Run const& r, edm::EventSetup const&) final;
0019     void endRun(edm::Run const& r, edm::EventSetup const&) final;
0020 
0021   private:
0022     std::vector<std::string> expectedProcesses_;
0023     int numberOfExpectedHLTProcessesInEachRun_;
0024   };  // class TestHistoryKeeping
0025 
0026   //--------------------------------------------------------------------
0027   //
0028   // Implementation details
0029   //--------------------------------------------------------------------
0030 
0031   TestHistoryKeeping::TestHistoryKeeping(edm::ParameterSet const& pset)
0032       : expectedProcesses_(pset.getParameter<std::vector<std::string> >("expected_processes")),
0033         numberOfExpectedHLTProcessesInEachRun_(
0034             pset.getParameter<int>("number_of_expected_HLT_processes_for_each_run")) {
0035     // Nothing to do.
0036   }
0037 
0038   void TestHistoryKeeping::beginRun(edm::Run const&, edm::EventSetup const&) {
0039     // At begin run, we're looking at, make sure we can get at the
0040     // parameter sets for any HLT processing.
0041   }
0042 
0043   void TestHistoryKeeping::analyze(edm::Event const& ev, edm::EventSetup const&) {
0044     for (std::vector<std::string>::const_iterator i = expectedProcesses_.begin(), e = expectedProcesses_.end(); i != e;
0045          ++i) {
0046       edm::ParameterSet ps;
0047       assert(ev.getProcessParameterSet(*i, ps));
0048       assert(!ps.empty());
0049       assert(ps.getParameter<std::string>("@process_name") == *i);
0050     }
0051   }
0052 
0053   void TestHistoryKeeping::endRun(edm::Run const&, edm::EventSetup const&) {
0054     // Nothing to do.
0055   }
0056 
0057 }  // namespace edmtest
0058 
0059 using edmtest::TestHistoryKeeping;
0060 DEFINE_FWK_MODULE(TestHistoryKeeping);