Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:47

0001 #include "DummyClient.h"
0002 #include "HeterogeneousCore/SonicCore/interface/SonicOneEDAnalyzer.h"
0003 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 #include <memory>
0009 
0010 namespace sonictest {
0011   //designed similar to IntTestAnalyzer
0012   class SonicDummyOneAnalyzer : public SonicOneEDAnalyzer<DummyClient> {
0013   public:
0014     explicit SonicDummyOneAnalyzer(edm::ParameterSet const& cfg)
0015         : SonicOneEDAnalyzer<DummyClient>(cfg),
0016           input_(cfg.getParameter<int>("input")),
0017           expected_(cfg.getParameter<int>("expected")) {}
0018 
0019     void acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, Input& iInput) override { iInput = input_; }
0020 
0021     void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup, Output const& iOutput) override {
0022       if (iOutput != expected_)
0023         throw cms::Exception("ValueMismatch")
0024             << "The value is " << iOutput << " but it was supposed to be " << expected_;
0025     }
0026 
0027     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0028       edm::ParameterSetDescription desc;
0029       DummyClient::fillPSetDescription(desc);
0030       desc.add<int>("input");
0031       desc.add<int>("expected");
0032       //to ensure distinct cfi names
0033       descriptions.addWithDefaultLabel(desc);
0034     }
0035 
0036   private:
0037     //members
0038     int input_, expected_;
0039   };
0040 }  // namespace sonictest
0041 
0042 using sonictest::SonicDummyOneAnalyzer;
0043 DEFINE_FWK_MODULE(SonicDummyOneAnalyzer);