Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    DoodadESProducer
0004 // Class:      DoodadESProducer
0005 //
0006 /**\class DoodadESProducer DoodadESProducer.h test/DoodadESProducer/interface/DoodadESProducer.h
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Chris Jones
0015 //         Created:  Fri Jun 24 14:33:04 EDT 2005
0016 //
0017 //
0018 
0019 // user include files
0020 #include "FWCore/Framework/interface/ESProducer.h"
0021 #include "FWCore/Framework/interface/ModuleFactory.h"
0022 
0023 #include "FWCore/Integration/test/Doodad.h"
0024 #include "FWCore/Integration/test/GadgetRcd.h"
0025 
0026 // system include files
0027 #include <memory>
0028 #include <stdexcept>
0029 
0030 //
0031 // class decleration
0032 //
0033 namespace edmtest {
0034 
0035   class DoodadESProducer : public edm::ESProducer {
0036   public:
0037     DoodadESProducer(edm::ParameterSet const&);
0038     ~DoodadESProducer();
0039 
0040     typedef std::unique_ptr<Doodad> ReturnType;
0041 
0042     ReturnType produce(GadgetRcd const&);
0043 
0044   private:
0045     // ----------member data ---------------------------
0046     bool exceptionInformation_;
0047   };
0048 
0049   //
0050   // constants, enums and typedefs
0051   //
0052 
0053   //
0054   // static data member definitions
0055 
0056   //
0057   // constructors and destructor
0058   //
0059   DoodadESProducer::DoodadESProducer(edm::ParameterSet const& iConfig)
0060       : exceptionInformation_(iConfig.getUntrackedParameter<bool>("throwException", false)) {
0061     //the following line is needed to tell the framework what
0062     // data is being produced
0063     setWhatProduced(this);
0064 
0065     //now do what ever other initialization is needed
0066   }
0067 
0068   DoodadESProducer::~DoodadESProducer() {
0069     // do anything here that needs to be done at desctruction time
0070     // (e.g. close files, deallocate resources etc.)
0071   }
0072 
0073   //
0074   // member functions
0075   //
0076 
0077   // ------------ method called to produce the data  ------------
0078   DoodadESProducer::ReturnType DoodadESProducer::produce(GadgetRcd const& /*iRecord*/) {
0079     if (exceptionInformation_) {
0080       throw std::runtime_error("test exception catching");
0081     }
0082 
0083     using namespace edmtest;
0084 
0085     auto pDoodad = std::make_unique<Doodad>();
0086 
0087     pDoodad->a = 1;
0088 
0089     return pDoodad;
0090   }
0091 }  // namespace edmtest
0092 
0093 using namespace edmtest;
0094 //define this as a plug-in
0095 DEFINE_FWK_EVENTSETUP_MODULE(DoodadESProducer);