Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    TestFailuresAnalyzer
0004 // Class:      TestFailuresAnalyzer
0005 //
0006 /**\class TestFailuresAnalyzer TestFailuresAnalyzer.cc stubs/TestFailuresAnalyzer/src/TestFailuresAnalyzer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Chris Jones
0015 //         Created:  Fri Sep  2 13:54:17 EDT 2005
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 
0024 #include "FWCore/Framework/interface/MakerMacros.h"
0025 #include "FWCore/Framework/interface/Event.h"
0026 
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028 
0029 #include "FWCore/Framework/test/stubs/TestFailuresAnalyzer.h"
0030 
0031 #include "FWCore/Utilities/interface/Exception.h"
0032 #include "FWCore/Utilities/interface/EDMException.h"
0033 //
0034 // class decleration
0035 //
0036 
0037 //
0038 // constants, enums and typedefs
0039 //
0040 
0041 //
0042 // static data member definitions
0043 //
0044 
0045 enum { kConstructor, kBeginOfJob, kEvent, kEndOfJob, kBeginOfJobBadXML, kEventCorruption };
0046 //
0047 // constructors and destructor
0048 //
0049 TestFailuresAnalyzer::TestFailuresAnalyzer(const edm::ParameterSet& iConfig)
0050     : whichFailure_(iConfig.getParameter<int>("whichFailure")),
0051       eventToThrow_(iConfig.getUntrackedParameter<unsigned long long>("eventToThrow", 2U)) {
0052   //now do what ever initialization is needed
0053   if (whichFailure_ == kConstructor) {
0054     throw cms::Exception("Test") << " constructor";
0055   }
0056 }
0057 
0058 //
0059 // member functions
0060 //
0061 
0062 // ------------ method called to produce the data  ------------
0063 void TestFailuresAnalyzer::beginJob() {
0064   if (whichFailure_ == kBeginOfJob) {
0065     throw cms::Exception("Test") << " beginJob";
0066   }
0067   if (whichFailure_ == kBeginOfJobBadXML) {
0068     throw cms::Exception("Test") << " beginJob with <BAD> >XML<";
0069   }
0070 }
0071 
0072 void TestFailuresAnalyzer::endJob() {
0073   if (whichFailure_ == kEndOfJob) {
0074     throw cms::Exception("Test") << " endJob";
0075   }
0076 }
0077 
0078 void TestFailuresAnalyzer::analyze(edm::StreamID,
0079                                    const edm::Event& e /* iEvent */,
0080                                    const edm::EventSetup& /* iSetup */) const {
0081   if (whichFailure_ == kEvent) {
0082     throw cms::Exception("Test") << " event";
0083   }
0084   if (whichFailure_ == kEventCorruption && eventToThrow_ == e.eventAuxiliary().event()) {
0085     throw edm::Exception(edm::errors::EventCorruption, "testing exception handling");
0086   }
0087 }
0088 
0089 //define this as a plug-in
0090 DEFINE_FWK_MODULE(TestFailuresAnalyzer);