Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQMServices/Examples/interface/DQMExample_Step2.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 #include <cmath>
0005 #include <cstdio>
0006 #include <iomanip>
0007 #include <iostream>
0008 #include <sstream>
0009 #include <string>
0010 
0011 //
0012 // -------------------------------------- Constructor
0013 // --------------------------------------------
0014 //
0015 DQMExample_Step2::DQMExample_Step2(const edm::ParameterSet &ps) {
0016   edm::LogInfo("DQMExample_Step2") << "Constructor  DQMExample_Step2::DQMExample_Step2 " << std::endl;
0017 
0018   // Get parameters from configuration file
0019   numMonitorName_ = ps.getParameter<std::string>("numMonitorName");
0020   denMonitorName_ = ps.getParameter<std::string>("denMonitorName");
0021 }
0022 
0023 //
0024 // -- Destructor
0025 //
0026 DQMExample_Step2::~DQMExample_Step2() {
0027   edm::LogInfo("DQMExample_Step2") << "Destructor DQMExample_Step2::~DQMExample_Step2 " << std::endl;
0028 }
0029 
0030 //
0031 // -------------------------------------- beginJob
0032 // --------------------------------------------
0033 //
0034 void DQMExample_Step2::beginJob() { edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::beginJob " << std::endl; }
0035 //
0036 // -------------------------------------- get and book in the endJob
0037 // --------------------------------------------
0038 //
0039 void DQMExample_Step2::dqmEndJob(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) {
0040   // create and cd into new folder
0041   ibooker_.setCurrentFolder("What_I_do_in_the_client/Ratio");
0042 
0043   // get available histograms
0044   MonitorElement *numerator = igetter_.get(numMonitorName_);
0045   MonitorElement *denominator = igetter_.get(denMonitorName_);
0046 
0047   if (!numerator || !denominator) {
0048     edm::LogError("DQMExample_Step2") << "MEs not found!" << std::endl;
0049     return;
0050   }
0051 
0052   // book new histogram
0053   h_ptRatio = ibooker_.book1D("ptRatio", "pt ratio pf matched objects", 50, 0., 100.);
0054   h_ptRatio->setAxisTitle("pt [GeV]");
0055 
0056   for (int iBin = 1; iBin < numerator->getNbinsX(); ++iBin) {
0057     if (denominator->getBinContent(iBin) == 0)
0058       h_ptRatio->setBinContent(iBin, 0.);
0059     else
0060       h_ptRatio->setBinContent(iBin, numerator->getBinContent(iBin) / denominator->getBinContent(iBin));
0061   }
0062 }
0063 
0064 //
0065 // -------------------------------------- get in the endLumi if needed
0066 // --------------------------------------------
0067 //
0068 void DQMExample_Step2::dqmEndLuminosityBlock(DQMStore::IBooker &ibooker_,
0069                                              DQMStore::IGetter &igetter_,
0070                                              edm::LuminosityBlock const &iLumi,
0071                                              edm::EventSetup const &iSetup) {
0072   edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::endLumi " << std::endl;
0073 }