Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:11

0001 // -*- C++ -*-
0002 //
0003 // Package:    DQMServices/Demo
0004 // Class:      DemoGlobalDQMEDAnalyzer
0005 //
0006 /**\class DemoGlobalDQMEDAnalyzer DemoGlobalDQMEDAnalyzer.cc DQMServices/Demo/plugins/DemoGlobalDQMEDAnalyzer.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Marcel Schneider
0015 //         Created:  Wed, 22 May 2019 15:18:23 GMT
0016 //
0017 //
0018 
0019 #include <string>
0020 
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h"
0023 
0024 #include "FWCore/Framework/interface/Event.h"
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 
0028 struct Histograms_Demo2 {
0029   typedef dqm::reco::MonitorElement MonitorElement;
0030   MonitorElement* histo_;
0031 };
0032 
0033 class DemoGlobalDQMEDAnalyzer : public DQMGlobalEDAnalyzer<Histograms_Demo2> {
0034 public:
0035   explicit DemoGlobalDQMEDAnalyzer(const edm::ParameterSet&);
0036   ~DemoGlobalDQMEDAnalyzer() override;
0037 
0038   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0039 
0040 private:
0041   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms_Demo2&) const override;
0042 
0043   void dqmAnalyze(edm::Event const&, edm::EventSetup const&, Histograms_Demo2 const&) const override;
0044 
0045   std::string folder_;
0046 };
0047 
0048 DemoGlobalDQMEDAnalyzer::DemoGlobalDQMEDAnalyzer(const edm::ParameterSet& iConfig)
0049     : folder_(iConfig.getParameter<std::string>("folder")) {
0050   // now do what ever initialization is needed
0051 }
0052 
0053 DemoGlobalDQMEDAnalyzer::~DemoGlobalDQMEDAnalyzer() {
0054   // do anything here that needs to be done at desctruction time
0055   // (e.g. close files, deallocate resources etc.)
0056 }
0057 
0058 // ------------ method called for each event  ------------
0059 void DemoGlobalDQMEDAnalyzer::dqmAnalyze(edm::Event const& iEvent,
0060                                          edm::EventSetup const& iSetup,
0061                                          Histograms_Demo2 const& histos) const {
0062   histos.histo_->Fill(5);
0063 }
0064 
0065 void DemoGlobalDQMEDAnalyzer::bookHistograms(DQMStore::IBooker& ibook,
0066                                              edm::Run const& run,
0067                                              edm::EventSetup const& iSetup,
0068                                              Histograms_Demo2& histos) const {
0069   ibook.setCurrentFolder(folder_);
0070   histos.histo_ = ibook.book1D("EXAMPLE", "EXAMPLE", 10, 0., 10.);
0071 }
0072 
0073 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0074 void DemoGlobalDQMEDAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0075   edm::ParameterSetDescription desc;
0076   desc.add<std::string>("folder", "MY_FOLDER");
0077   descriptions.add("demo2", desc);
0078 }
0079 
0080 // define this as a plug-in
0081 DEFINE_FWK_MODULE(DemoGlobalDQMEDAnalyzer);