Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:22

0001 #include "DQM/HLTEvF/plugins/TriggerRatesMonitorClient.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 //
0006 // -------------------------------------- Constructor --------------------------------------------
0007 //
0008 TriggerRatesMonitorClient::TriggerRatesMonitorClient(const edm::ParameterSet& iConfig)
0009     : m_dqm_path(iConfig.getUntrackedParameter<std::string>("dqmPath")) {
0010   edm::LogInfo("TriggerRatesMonitorClient")
0011       << "Constructor  TriggerRatesMonitorClient::TriggerRatesMonitorClient " << std::endl;
0012 }
0013 
0014 //
0015 // -------------------------------------- beginJob --------------------------------------------
0016 //
0017 void TriggerRatesMonitorClient::beginJob() {
0018   edm::LogInfo("TriggerRatesMonitorClient") << "TriggerRatesMonitorClient::beginJob " << std::endl;
0019 }
0020 
0021 //
0022 // -------------------------------------- get and book in the endJob --------------------------------------------
0023 //
0024 void TriggerRatesMonitorClient::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) {
0025   // create and cd into new folder
0026   ibooker_.setCurrentFolder(m_dqm_path);
0027 
0028   //get available histograms
0029   std::vector<std::string> directories = igetter_.getSubdirs();
0030   m_hltXpd_counts.resize(directories.size());
0031 
0032   int i = 0;
0033   for (auto const& dir : directories) {
0034     //    std::cout << "dir: " << dir << std::endl;
0035     ibooker_.setCurrentFolder(m_dqm_path + "/" + dir);
0036 
0037     std::vector<std::string> const& all_mes = igetter_.getMEs();
0038     std::vector<std::string> mes;
0039     for (auto const& me : all_mes)
0040       if (me.find("accept") != std::string::npos)
0041         mes.push_back(me);
0042 
0043     int nbinsY = mes.size();
0044     double xminY = 0.;
0045     double xmaxY = xminY + 1. * nbinsY;
0046     int nbinsX = 0;
0047     int ibinY = 1;
0048     for (auto const& me : mes) {
0049       //      std::cout << "me: " << me << std::endl;
0050       ibooker_.setCurrentFolder(m_dqm_path + "/" + dir);
0051       TH1F* histo = igetter_.get(me)->getTH1F();
0052 
0053       if (m_hltXpd_counts[i] == nullptr) {
0054         // get range and binning for new MEs
0055         nbinsX = histo->GetNbinsX();
0056         double xminX = histo->GetXaxis()->GetXmin();
0057         double xmaxX = histo->GetXaxis()->GetXmax();
0058 
0059         //book new histogram
0060         std::string hname = dir + "_summary";
0061         ibooker_.setCurrentFolder(m_dqm_path);
0062         m_hltXpd_counts[i] = ibooker_.book2D(hname, hname, nbinsX, xminX, xmaxX, nbinsY, xminY, xmaxY)->getTH2F();
0063       } else {
0064         m_hltXpd_counts[i]->GetYaxis()->SetBinLabel(ibinY, me.c_str());
0065       }
0066 
0067       // handle mes
0068       for (int ibinX = 1; ibinX <= nbinsX; ++ibinX) {
0069         float rate = histo->GetBinContent(ibinX);
0070         m_hltXpd_counts[i]->SetBinContent(ibinX, ibinY, rate);
0071       }
0072       ibinY++;
0073     }
0074 
0075     i++;
0076   }
0077 }
0078 
0079 //
0080 // -------------------------------------- get in the endLumi if needed --------------------------------------------
0081 //
0082 void TriggerRatesMonitorClient::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker_,
0083                                                       DQMStore::IGetter& igetter_,
0084                                                       edm::LuminosityBlock const& iLumi,
0085                                                       edm::EventSetup const& iSetup) {
0086   edm::LogInfo("TriggerRatesMonitorClient") << "TriggerRatesMonitorClient::endLumi " << std::endl;
0087 }
0088 
0089 void TriggerRatesMonitorClient::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0090   edm::ParameterSetDescription desc;
0091   desc.addUntracked<std::string>("dqmPath", "HLT/Datasets");
0092   descriptions.add("triggerRatesMonitorClient", desc);
0093 }
0094 
0095 // Define this as a plug-in
0096 #include "FWCore/Framework/interface/MakerMacros.h"
0097 DEFINE_FWK_MODULE(TriggerRatesMonitorClient);