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:      DemoOneDQMEDAnalyzer
0005 //
0006 /**\class DemoOneDQMEDAnalyzer DemoOneDQMEDAnalyzer.cc DQMServices/Demo/plugins/DemoOneDQMEDAnalyzer.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/DQMOneEDAnalyzer.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 DemoOneDQMEDAnalyzer : public DQMOneEDAnalyzer<> {
0029 public:
0030   explicit DemoOneDQMEDAnalyzer(const edm::ParameterSet&);
0031   ~DemoOneDQMEDAnalyzer() 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   int eventCount_ = 0;
0047 };
0048 
0049 DemoOneDQMEDAnalyzer::DemoOneDQMEDAnalyzer(const edm::ParameterSet& iConfig)
0050     : folder_(iConfig.getParameter<std::string>("folder")) {
0051   // now do what ever initialization is needed
0052 }
0053 
0054 DemoOneDQMEDAnalyzer::~DemoOneDQMEDAnalyzer() {
0055   // do anything here that needs to be done at desctruction time
0056   // (e.g. close files, deallocate resources etc.)
0057 }
0058 
0059 // ------------ method called for each event  ------------
0060 void DemoOneDQMEDAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0061   using namespace edm;
0062 
0063   eventCount_++;
0064 
0065   example_->Fill(5);
0066   example2D_->Fill(eventCount_ / 10, eventCount_ / 10);
0067   example3D_->Fill(eventCount_ / 10, eventCount_ / 10, eventCount_ / 10.f);
0068   exampleTProfile_->Fill(eventCount_ / 10, eventCount_ / 10.f);
0069   exampleTProfile2D_->Fill(eventCount_ / 10, eventCount_ / 10, eventCount_ / 10.f);
0070 }
0071 
0072 void DemoOneDQMEDAnalyzer::bookHistograms(DQMStore::IBooker& ibook,
0073                                           edm::Run const& run,
0074                                           edm::EventSetup const& iSetup) {
0075   ibook.setCurrentFolder(folder_);
0076 
0077   example_ = ibook.book1D("EXAMPLE", "Example 1D", 20, 0., 10.);
0078   example2D_ = ibook.book2D("EXAMPLE_2D", "Example 2D", 20, 0, 20, 15, 0, 15);
0079   example3D_ = ibook.book3D("EXAMPLE_3D", "Example 3D", 20, 0, 20, 15, 0, 15, 25, 0, 25);
0080   exampleTProfile_ = ibook.bookProfile("EXAMPLE_TPROFILE", "Example TProfile", 20, 0, 20, 15, 0, 15);
0081   exampleTProfile2D_ = ibook.bookProfile2D("EXAMPLE_TPROFILE2D", "Example TProfile 2D", 20, 0, 20, 15, 0, 15, 0, 100);
0082 }
0083 
0084 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0085 void DemoOneDQMEDAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0086   edm::ParameterSetDescription desc;
0087   desc.add<std::string>("folder", "MY_FOLDER");
0088   descriptions.add("demoone", desc);
0089 }
0090 
0091 // define this as a plug-in
0092 DEFINE_FWK_MODULE(DemoOneDQMEDAnalyzer);