Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-18 03:27:07

0001 /* *  \author Anna Cimmino*/
0002 #include <DQM/RPCMonitorClient/interface/RPCDeadChannelTest.h>
0003 #include <DQM/RPCMonitorClient/interface/utils.h>
0004 #include <DQM/RPCMonitorClient/interface/RPCRollMapHisto.h>
0005 // Framework
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 // Geometry
0008 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
0009 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
0010 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0011 
0012 RPCDeadChannelTest::RPCDeadChannelTest(const edm::ParameterSet& ps) {
0013   edm::LogVerbatim("rpcdeadchanneltest") << "[RPCDeadChannelTest]: Constructor";
0014 
0015   useRollInfo_ = ps.getUntrackedParameter<bool>("UseRollInfo", false);
0016 
0017   prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
0018   numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
0019   numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
0020 }
0021 
0022 void RPCDeadChannelTest::beginJob(std::string& workingFolder) {
0023   edm::LogVerbatim("rpcdeadchanneltest") << "[RPCDeadChannelTest]: Begin Job";
0024   globalFolder_ = workingFolder;
0025 }
0026 
0027 void RPCDeadChannelTest::getMonitorElements(std::vector<MonitorElement*>& meVector,
0028                                             std::vector<RPCDetId>& detIdVector,
0029                                             std::string& clientHistoName) {
0030   for (unsigned int i = 0; i < meVector.size(); i++) {
0031     std::string meName = meVector[i]->getName();
0032 
0033     if (meName.find(clientHistoName) != std::string::npos) {
0034       myOccupancyMe_.push_back(meVector[i]);
0035       myDetIds_.push_back(detIdVector[i]);
0036     }
0037   }
0038 }
0039 
0040 void RPCDeadChannelTest::clientOperation() {
0041   edm::LogVerbatim("rpcdeadchanneltest") << "[RPCDeadChannelTest]:Client Operation";
0042 
0043   MonitorElement* DEAD = nullptr;
0044 
0045   //Loop on chambers
0046   for (unsigned int i = 0; i < myOccupancyMe_.size(); i++) {
0047     RPCDetId& detId = myDetIds_[i];
0048     MonitorElement* myMe = myOccupancyMe_[i];
0049 
0050     if (!myMe)
0051       continue;
0052 
0053     const QReport* theOccupancyQReport = myMe->getQReport("DeadChannel_0");
0054 
0055     float deadFraction = 0.0;
0056 
0057     if (theOccupancyQReport) {
0058       float qtresult = theOccupancyQReport->getQTresult();
0059       // std::vector<dqm::me_util::Channel> badChannels = theOccupancyQReport->getBadChannels();
0060       deadFraction = 1.0 - qtresult;
0061 
0062     } else {
0063       int xBins = myMe->getNbinsX();
0064       float emptyBins = 0.0;
0065       for (int x = 1; x <= xBins; x++) {
0066         if (myMe->getBinContent(x) == 0) {
0067           emptyBins++;
0068         }
0069       }
0070       if (xBins != 0) {
0071         deadFraction = emptyBins / xBins;
0072       }
0073     }
0074 
0075     if (detId.region() == 0)
0076       DEAD = DEADWheel[detId.ring() + 2];
0077     else {
0078       if (-detId.station() + numberOfDisks_ >= 0) {
0079         if (detId.region() < 0) {
0080           DEAD = DEADDisk[-detId.station() + numberOfDisks_];
0081         } else {
0082           DEAD = DEADDisk[detId.station() + numberOfDisks_ - 1];
0083         }
0084       }
0085     }
0086 
0087     if (DEAD) {
0088       int xBin, yBin;
0089       if (detId.region() == 0) {  //Barrel
0090         xBin = detId.sector();
0091         rpcdqm::utils rollNumber;
0092         yBin = rollNumber.detId2RollNr(detId);
0093       } else {  //Endcap
0094         //get segment number
0095         RPCGeomServ RPCServ(detId);
0096         xBin = RPCServ.segment();
0097         (numberOfRings_ == 3 ? yBin = detId.ring() * 3 - detId.roll() + 1
0098                              : yBin = (detId.ring() - 1) * 3 - detId.roll() + 1);
0099       }
0100       DEAD->setBinContent(xBin, yBin, deadFraction);
0101     }
0102 
0103   }  //End loop on rolls in given chambers
0104 }
0105 
0106 void RPCDeadChannelTest::myBooker(DQMStore::IBooker& ibooker) {
0107   ibooker.setCurrentFolder(globalFolder_);
0108 
0109   std::stringstream histoName;
0110 
0111   int limit = numberOfDisks_;
0112   if (numberOfDisks_ < 2)
0113     limit = 2;
0114 
0115   for (int i = -1 * limit; i <= limit; i++) {  //loop on wheels and disks
0116     if (i > -3 && i < 3) {                     //wheels
0117       histoName.str("");
0118       histoName << "DeadChannelFraction_Roll_vs_Sector_Wheel" << i;
0119       auto me = RPCRollMapHisto::bookBarrel(ibooker, i, histoName.str(), histoName.str(), useRollInfo_);
0120       DEADWheel[i + 2] = dynamic_cast<MonitorElement*>(me);
0121 
0122       for (int x = 1; x <= 12; x++) {
0123         for (int y = 1; y <= 21; y++) {
0124           DEADWheel[i + 2]->setBinContent(x, y, -1);
0125         }
0126       }
0127 
0128     }  //end wheels
0129 
0130     if (i == 0 || i > numberOfDisks_ || i < (-1 * numberOfDisks_)) {
0131       continue;
0132     }
0133 
0134     int offset = numberOfDisks_;
0135     if (i > 0) {
0136       offset--;
0137     }  //used to skip case equale to zero
0138 
0139     histoName.str("");
0140     histoName << "DeadChannelFraction_Ring_vs_Segment_Disk" << i;
0141     auto me = RPCRollMapHisto::bookEndcap(ibooker, i, histoName.str(), histoName.str(), useRollInfo_);
0142     DEADDisk[i + offset] = dynamic_cast<MonitorElement*>(me);
0143   }  //end loop on wheels and disks
0144 }