Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:47:26

0001 // -*- C++ -*-
0002 //
0003 // Package:    WhatsItWatcherAnalyzer
0004 // Class:      WhatsItWatcherAnalyzer
0005 //
0006 /**\class WhatsItWatcherAnalyzer WhatsItWatcherAnalyzer.cc test/WhatsItWatcherAnalyzer/src/WhatsItWatcherAnalyzer.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 Jun 24 19:13:25 EDT 2005
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <iostream>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 
0028 #include "WhatsIt.h"
0029 #include "GadgetRcd.h"
0030 
0031 #include "FWCore/Framework/interface/ESHandle.h"
0032 
0033 #include "FWCore/Framework/interface/ESWatcher.h"
0034 
0035 //
0036 // class decleration
0037 //
0038 
0039 namespace edmtest {
0040 
0041   class WhatsItWatcherAnalyzer : public edm::one::EDAnalyzer<> {
0042   public:
0043     explicit WhatsItWatcherAnalyzer(const edm::ParameterSet&);
0044 
0045     void analyze(const edm::Event&, const edm::EventSetup&) override;
0046 
0047   private:
0048     // ----------member data ---------------------------
0049     void watch1(const GadgetRcd&);
0050     void watch2(const GadgetRcd&);
0051 
0052     edm::ESWatcher<GadgetRcd> watch1_;
0053     edm::ESWatcher<GadgetRcd> watch2_;
0054     edm::ESWatcher<GadgetRcd> watchBool_;
0055 
0056     edm::ESGetToken<edmtest::WhatsIt, GadgetRcd> token_;
0057   };
0058 
0059   //
0060   // constants, enums and typedefs
0061   //
0062 
0063   //
0064   // static data member definitions
0065   //
0066 
0067   //
0068   // constructors and destructor
0069   //
0070   WhatsItWatcherAnalyzer::WhatsItWatcherAnalyzer(const edm::ParameterSet& /*iConfig*/)
0071       : watch1_(this, &WhatsItWatcherAnalyzer::watch1),
0072         watch2_(std::bind(&WhatsItWatcherAnalyzer::watch2, this, std::placeholders::_1)),
0073         watchBool_(),
0074         token_(esConsumes()) {
0075     //now do what ever initialization is needed
0076   }
0077 
0078   //
0079   // member functions
0080   //
0081 
0082   // ------------ method called to produce the data  ------------
0083   void WhatsItWatcherAnalyzer::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
0084     bool w1 = watch1_.check(iSetup);
0085     bool w2 = watch2_.check(iSetup);
0086     bool w3 = watchBool_.check(iSetup);
0087     assert(w1 == w2);
0088     assert(w2 == w3);
0089   }
0090 
0091   void WhatsItWatcherAnalyzer::watch1(const GadgetRcd& iRcd) {
0092     edm::ESHandle<edmtest::WhatsIt> pSetup = iRcd.getHandle(token_);
0093 
0094     std::cout << "watch1: WhatsIt " << pSetup->a << " changed" << std::endl;
0095   }
0096 
0097   void WhatsItWatcherAnalyzer::watch2(const GadgetRcd& iRcd) {
0098     edm::ESHandle<WhatsIt> pSetup = iRcd.getHandle(token_);
0099 
0100     std::cout << "watch2: WhatsIt " << pSetup->a << " changed" << std::endl;
0101   }
0102 
0103 }  // namespace edmtest
0104 using namespace edmtest;
0105 //define this as a plug-in
0106 DEFINE_FWK_MODULE(WhatsItWatcherAnalyzer);