Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:59

0001 #include "DQM/L1TMonitorClient/interface/L1TdeGEMTPGClient.h"
0002 
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "DQMServices/Core/interface/DQMStore.h"
0009 #include "TRandom.h"
0010 using namespace edm;
0011 using namespace std;
0012 
0013 L1TdeGEMTPGClient::L1TdeGEMTPGClient(const edm::ParameterSet &ps)
0014     : monitorDir_(ps.getParameter<string>("monitorDir")),
0015       chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
0016       // variables
0017       clusterVars_(ps.getParameter<std::vector<std::string>>("clusterVars")),
0018       // binning
0019       clusterNBin_(ps.getParameter<std::vector<unsigned>>("clusterNBin")),
0020       clusterMinBin_(ps.getParameter<std::vector<double>>("clusterMinBin")),
0021       clusterMaxBin_(ps.getParameter<std::vector<double>>("clusterMaxBin")) {}
0022 
0023 L1TdeGEMTPGClient::~L1TdeGEMTPGClient() {}
0024 
0025 void L1TdeGEMTPGClient::dqmEndLuminosityBlock(DQMStore::IBooker &ibooker,
0026                                               DQMStore::IGetter &igetter,
0027                                               const edm::LuminosityBlock &lumiSeg,
0028                                               const edm::EventSetup &c) {
0029   book(ibooker);
0030   processHistograms(igetter);
0031 }
0032 
0033 //--------------------------------------------------------
0034 void L1TdeGEMTPGClient::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
0035   book(ibooker);
0036   processHistograms(igetter);
0037 }
0038 
0039 void L1TdeGEMTPGClient::book(DQMStore::IBooker &iBooker) {
0040   iBooker.setCurrentFolder(monitorDir_);
0041 
0042   // chamber type
0043   for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0044     // cluster variable
0045     for (unsigned iVar = 0; iVar < clusterVars_.size(); iVar++) {
0046       const std::string key("cluster_" + clusterVars_[iVar] + "_diff");
0047       const std::string histName(key + "_" + chambers_[iType]);
0048       const std::string histTitle(chambers_[iType] + " Cluster " + clusterVars_[iVar] + " (Emul - Data)");
0049       if (chamberHistos_[iType][key] == nullptr)
0050         chamberHistos_[iType][key] =
0051             iBooker.book1D(histName, histTitle, clusterNBin_[iVar], clusterMinBin_[iVar], clusterMaxBin_[iVar]);
0052       else
0053         chamberHistos_[iType][key]->Reset();
0054     }
0055   }
0056 }
0057 
0058 void L1TdeGEMTPGClient::processHistograms(DQMStore::IGetter &igetter) {
0059   MonitorElement *dataMon;
0060   MonitorElement *emulMon;
0061 
0062   // chamber type
0063   for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0064     // cluster variable
0065     for (unsigned iVar = 0; iVar < clusterVars_.size(); iVar++) {
0066       const std::string key("cluster_" + clusterVars_[iVar]);
0067       const std::string histData(key + "_data_" + chambers_[iType]);
0068       const std::string histEmul(key + "_emul_" + chambers_[iType]);
0069 
0070       dataMon = igetter.get(monitorDir_ + "/" + histData);
0071       emulMon = igetter.get(monitorDir_ + "/" + histEmul);
0072 
0073       TH1F *hDiff = chamberHistos_[iType][key + "_diff"]->getTH1F();
0074 
0075       if (dataMon && emulMon) {
0076         TH1F *dataHist = dataMon->getTH1F();
0077         TH1F *emulHist = emulMon->getTH1F();
0078         hDiff->Add(emulHist, dataHist, 1, -1);
0079       }
0080     }
0081   }
0082 }