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:      DemoNormalDQMEDAnalyzer
0005 //
0006 /**\class DemoNormalDQMEDAnalyzer DemoNormalDQMEDAnalyzer.cc DQMServices/Demo/plugins/DemoNormalDQMEDAnalyzer.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:07 GMT
0016 //
0017 //
0018 
0019 #include <string>
0020 
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "DQMServices/Core/interface/DQMEDAnalyzer.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 class DemoNormalDQMEDAnalyzer : public DQMEDAnalyzer {
0029 public:
0030   explicit DemoNormalDQMEDAnalyzer(const edm::ParameterSet&);
0031   ~DemoNormalDQMEDAnalyzer() override;
0032 
0033   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0034 
0035 private:
0036   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0037 
0038   void analyze(const edm::Event&, const edm::EventSetup&) override;
0039 
0040   std::string folder_;
0041   MonitorElement* example_;
0042   MonitorElement* example2D_;
0043   MonitorElement* example3D_;
0044   MonitorElement* exampleTProfile_;
0045   MonitorElement* exampleTProfile2D_;
0046 };
0047 
0048 DemoNormalDQMEDAnalyzer::DemoNormalDQMEDAnalyzer(const edm::ParameterSet& iConfig)
0049     : folder_(iConfig.getParameter<std::string>("folder")) {
0050   // now do what ever initialization is needed
0051 }
0052 
0053 DemoNormalDQMEDAnalyzer::~DemoNormalDQMEDAnalyzer() {
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 DemoNormalDQMEDAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0060   using namespace edm;
0061   example_->Fill(5);
0062   example2D_->Fill(1.0, 2.0);
0063   example3D_->Fill(1.0, 2.0, 3.0);
0064   exampleTProfile_->Fill(1.0, 2.0);
0065   exampleTProfile2D_->Fill(1.0, 2.0, 3.0);
0066 }
0067 
0068 void DemoNormalDQMEDAnalyzer::bookHistograms(DQMStore::IBooker& ibook,
0069                                              edm::Run const& run,
0070                                              edm::EventSetup const& iSetup) {
0071   ibook.setCurrentFolder(folder_);
0072 
0073   example_ = ibook.book1D(
0074       "EXAMPLE", "Example 1D", 20, 0., 10., [](TH1*) { edm::LogInfo("DemoNormalDQMEDAnalyzer") << "booked!\n"; });
0075   example2D_ = ibook.book2D("EXAMPLE_2D", "Example 2D", 20, 0, 20, 15, 0, 15);
0076   example3D_ = ibook.book3D("EXAMPLE_3D", "Example 3D", 20, 0, 20, 15, 0, 15, 25, 0, 25);
0077   exampleTProfile_ = ibook.bookProfile("EXAMPLE_TPROFILE", "Example TProfile", 20, 0, 20, 15, 0, 15);
0078   exampleTProfile2D_ = ibook.bookProfile2D("EXAMPLE_TPROFILE2D", "Example TProfile 2D", 20, 0, 20, 15, 0, 15, 0, 100);
0079 }
0080 
0081 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0082 void DemoNormalDQMEDAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0083   edm::ParameterSetDescription desc;
0084   desc.add<std::string>("folder", "MY_FOLDER");
0085   descriptions.add("demo", desc);
0086 }
0087 
0088 // define this as a plug-in
0089 DEFINE_FWK_MODULE(DemoNormalDQMEDAnalyzer);