Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/L1TMonitorClient/interface/L1TRPCTFClient.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 
0011 #include <TF1.h>
0012 #include <cstdio>
0013 #include <sstream>
0014 #include <cmath>
0015 #include <TProfile.h>
0016 #include <TProfile2D.h>
0017 
0018 using namespace edm;
0019 using namespace std;
0020 
0021 L1TRPCTFClient::L1TRPCTFClient(const edm::ParameterSet &ps) {
0022   parameters_ = ps;
0023   initialize();
0024 }
0025 
0026 L1TRPCTFClient::~L1TRPCTFClient() { LogInfo("TriggerDQM") << "[TriggerDQM]: ending... "; }
0027 
0028 //--------------------------------------------------------
0029 void L1TRPCTFClient::initialize() {
0030   counterLS_ = 0;
0031   counterEvt_ = 0;
0032 
0033   // base folder for the contents of this job
0034   monitorName_ = parameters_.getUntrackedParameter<string>("monitorName", "");
0035   //  cout << "Monitor name = " << monitorName_ << endl;
0036   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
0037   //  cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
0038   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
0039   //  cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
0040   output_dir_ = parameters_.getUntrackedParameter<string>("output_dir", "");
0041   //  cout << "DQM output dir = " << output_dir_ << endl;
0042   input_dir_ = parameters_.getUntrackedParameter<string>("input_dir", "");
0043   //  cout << "DQM input dir = " << input_dir_ << endl;
0044 
0045   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
0046 
0047   m_runInEventLoop = parameters_.getUntrackedParameter<bool>("runInEventLoop", false);
0048   m_runInEndLumi = parameters_.getUntrackedParameter<bool>("runInEndLumi", false);
0049   m_runInEndRun = parameters_.getUntrackedParameter<bool>("runInEndRun", false);
0050   m_runInEndJob = parameters_.getUntrackedParameter<bool>("runInEndJob", false);
0051 
0052   LogInfo("TriggerDQM");
0053 }
0054 
0055 //--------------------------------------------------------
0056 void L1TRPCTFClient::book(DQMStore::IBooker &ibooker) {
0057   LogInfo("TriggerDQM") << "[TriggerDQM]: Begin Job";
0058 
0059   ibooker.setCurrentFolder(output_dir_);
0060 
0061   m_deadChannels = ibooker.book2D("RPCTF_deadchannels", "RPCTF deadchannels", 33, -16.5, 16.5, 144, -0.5, 143.5);
0062   m_noisyChannels = ibooker.book2D("RPCTF_noisychannels", "RPCTF noisy channels", 33, -16.5, 16.5, 144, -0.5, 143.5);
0063 }
0064 
0065 //--------------------------------------------------------
0066 
0067 void L1TRPCTFClient::dqmEndLuminosityBlock(DQMStore::IBooker &ibooker,
0068                                            DQMStore::IGetter &igetter,
0069                                            const edm::LuminosityBlock &lumiSeg,
0070                                            const edm::EventSetup &c) {
0071   if (verbose_)
0072     std::cout << "L1TRPCTFClient::endLuminosityBlock" << std::endl;
0073 
0074   if (m_runInEndLumi) {
0075     book(ibooker);
0076     processHistograms(igetter);
0077   }
0078 }
0079 
0080 void L1TRPCTFClient::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
0081   book(ibooker);
0082   processHistograms(igetter);
0083 }
0084 
0085 //--------------------------------------------------------
0086 void L1TRPCTFClient::processHistograms(DQMStore::IGetter &igetter) {
0087   igetter.setCurrentFolder(input_dir_);
0088 
0089   {
0090     MonitorElement *me = igetter.get(input_dir_ + "/RPCTF_muons_eta_phi_bx0");
0091 
0092     if (me) {
0093       const QReport *qreport;
0094 
0095       qreport = me->getQReport("DeadChannels_RPCTF_2D");
0096       if (qreport) {
0097         vector<dqm::me_util::Channel> badChannels = qreport->getBadChannels();
0098         for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
0099              ++channel) {
0100           m_deadChannels->setBinContent((*channel).getBinX(), (*channel).getBinY(), 100);
0101         }  // for(badchannels)
0102       }    //if (qreport)
0103 
0104       qreport = me->getQReport("HotChannels_RPCTF_2D");
0105       if (qreport) {
0106         vector<dqm::me_util::Channel> badChannels = qreport->getBadChannels();
0107         for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
0108              ++channel) {
0109           // (*channel).getBinY() == 0 for NoisyChannels QTEST
0110           m_noisyChannels->setBinContent((*channel).getBinX(), 100);
0111         }  // for(badchannels)
0112       }    //if (qreport)
0113            //      else std::cout << "dupa" << std::endl;
0114     }      // if (me)
0115   }
0116 
0117   if (verbose_) {
0118     std::vector<string> meVec = igetter.getMEs();
0119     for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
0120       std::string full_path = input_dir_ + "/" + (*it);
0121       MonitorElement *me = igetter.get(full_path);
0122 
0123       // for this MEs, get list of associated QTs
0124       std::vector<QReport *> Qtest_map = me->getQReports();
0125 
0126       if (!Qtest_map.empty()) {
0127         std::cout << "Test: " << full_path << std::endl;
0128         for (std::vector<QReport *>::const_iterator it = Qtest_map.begin(); it != Qtest_map.end(); ++it) {
0129           std::cout << " Name " << (*it)->getQRName() << " Status " << (*it)->getStatus() << std::endl;
0130 
0131           std::vector<dqm::me_util::Channel> badChannels = (*it)->getBadChannels();
0132 
0133           vector<dqm::me_util::Channel>::iterator badchsit = badChannels.begin();
0134           while (badchsit != badChannels.end()) {
0135             int ix = (*badchsit).getBinX();
0136             int iy = (*badchsit).getBinY();
0137             std::cout << "(" << ix << "," << iy << ") ";
0138             ++badchsit;
0139           }
0140           std::cout << std::endl;
0141         }
0142       }
0143 
0144     }  //
0145   }
0146 }