Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:13

0001 #include <DQM/RPCMonitorClient/interface/RPCNoisyStripTest.h>
0002 #include "DQM/RPCMonitorClient/interface/RPCRollMapHisto.h"
0003 #include "DQM/RPCMonitorClient/interface/utils.h"
0004 
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
0007 
0008 RPCNoisyStripTest::RPCNoisyStripTest(const edm::ParameterSet& ps) {
0009   edm::LogVerbatim("rpcnoisetest") << "[RPCNoisyStripTest]: Constructor";
0010 
0011   prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
0012   numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
0013   numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
0014   useRollInfo_ = ps.getUntrackedParameter<bool>("UseRollInfo", false);
0015   testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
0016 }
0017 
0018 void RPCNoisyStripTest::beginJob(std::string& workingFolder) {
0019   edm::LogVerbatim("rpcnoisetest") << "[RPCNoisyStripTest]: Begin job ";
0020   globalFolder_ = workingFolder;
0021 }
0022 
0023 void RPCNoisyStripTest::clientOperation() {
0024   edm::LogVerbatim("rpcnoisetest") << "[RPCNoisyStripTest]: Client Operation";
0025 
0026   //Loop on MEs
0027   for (unsigned int i = 0; i < myOccupancyMe_.size(); i++) {
0028     this->fillGlobalME(myDetIds_[i], myOccupancyMe_[i]);
0029   }  //End loop on MEs
0030 }
0031 
0032 void RPCNoisyStripTest::myBooker(DQMStore::IBooker& ibooker) {
0033   ibooker.setCurrentFolder(globalFolder_);
0034 
0035   std::stringstream histoName;
0036 
0037   for (int w = -2; w <= 2; w++) {  //loop on wheels and disks
0038 
0039     if (testMode_) {
0040       histoName.str("");
0041       histoName << "RPCNoisyStrips_Distribution_Wheel" << w;
0042       NOISEDWheel[w + 2] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 6, -0.5, 5.5);
0043 
0044       histoName.str("");
0045       histoName << "RPCStripsDeviation_Distribution_Wheel" << w;
0046       DEVDWheel[w + 2] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 101, -0.01, 10.01);
0047     }
0048 
0049     histoName.str("");
0050     histoName << "RPCNoisyStrips_Roll_vs_Sector_Wheel" << w;
0051     auto me = RPCRollMapHisto::bookBarrel(ibooker, w, histoName.str(), histoName.str(), useRollInfo_);
0052     NOISEWheel[w + 2] = dynamic_cast<MonitorElement*>(me);
0053   }
0054 
0055   for (int d = -numberOfDisks_; d <= numberOfDisks_; d++) {  //ENDCAP
0056 
0057     if (d == 0)
0058       continue;
0059 
0060     int offset = numberOfDisks_;
0061     if (d > 0)
0062       offset--;
0063 
0064     if (testMode_) {
0065       histoName.str("");
0066       histoName << "RPCNoisyStrips_Distribution_Disk" << d;
0067       NOISEDDisk[d + offset] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 6, -0.5, 5.5);
0068 
0069       histoName.str("");
0070       histoName << "RPCStripsDeviation_Distribution_Disk" << d;
0071       DEVDDisk[d + offset] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 101, -0.01, 10.01);
0072     }
0073 
0074     histoName.str("");
0075     histoName << "RPCNoisyStrips_Ring_vs_Segment_Disk" << d;
0076     auto me = RPCRollMapHisto::bookEndcap(ibooker, d, histoName.str(), histoName.str(), useRollInfo_);
0077     NOISEDisk[d + offset] = dynamic_cast<MonitorElement*>(me);
0078   }
0079 }
0080 
0081 void RPCNoisyStripTest::getMonitorElements(std::vector<MonitorElement*>& meVector,
0082                                            std::vector<RPCDetId>& detIdVector,
0083                                            std::string& clientHistoName) {
0084   //Get NumberOfDigi ME for each roll
0085   for (unsigned int i = 0; i < meVector.size(); i++) {
0086     std::string meName = meVector[i]->getName();
0087 
0088     if (meName.find(clientHistoName) != std::string::npos) {
0089       myOccupancyMe_.push_back(meVector[i]);
0090       myDetIds_.push_back(detIdVector[i]);
0091     }
0092   }
0093 }
0094 
0095 void RPCNoisyStripTest::fillGlobalME(RPCDetId& detId, MonitorElement* myMe) {
0096   std::stringstream meName;
0097 
0098   MonitorElement* NOISE = nullptr;
0099   MonitorElement* DEVD = nullptr;
0100   MonitorElement* NOISED = nullptr;
0101 
0102   if (detId.region() == 0) {  //BARREL
0103     NOISE = NOISEWheel[detId.ring() + 2];
0104     if (testMode_) {
0105       DEVD = DEVDWheel[detId.ring() + 2];
0106       NOISED = NOISEDWheel[detId.ring() + 2];
0107     }
0108   } else if (detId.region() < 0 && (-detId.station() + numberOfDisks_) >= 0) {  //ENDCAP-
0109     NOISE = NOISEDisk[-detId.station() + numberOfDisks_];
0110     if (testMode_) {
0111       DEVD = DEVDDisk[-detId.station() + numberOfDisks_];
0112       NOISED = NOISEDDisk[-detId.station() + numberOfDisks_];
0113     }
0114   } else if ((-detId.station() + numberOfDisks_) >= 0) {  //ENDCAP +
0115     NOISE = NOISEDisk[detId.station() + numberOfDisks_ - 1];
0116     if (testMode_) {
0117       DEVD = DEVDDisk[detId.station() + numberOfDisks_ - 1];
0118       NOISED = NOISEDDisk[detId.station() + numberOfDisks_ - 1];
0119     }
0120   }
0121 
0122   int entries = (int)myMe->getEntries();
0123   int bins = (int)myMe->getNbinsX();
0124 
0125   std::vector<float> myvector;
0126 
0127   // count alive strips and alive strip values put in the vector
0128   for (int xbin = 1; xbin <= bins; xbin++) {
0129     float binContent = myMe->getBinContent(xbin);
0130     if (binContent > 0)
0131       myvector.push_back(binContent);
0132   }
0133 
0134   int noisyStrips = 0;
0135   // calculate mean on YAxis and check diff between bins and mean
0136   if (!myvector.empty()) {
0137     float ymean = entries / myvector.size();  //mean on Yaxis
0138     for (unsigned int i = 0; i < myvector.size(); i++) {
0139       float deviation = myvector[i] / ymean;
0140       if (deviation > 3.5)
0141         noisyStrips++;
0142       if (deviation > 5)
0143         deviation = 5;  //overflow
0144       if (DEVD)
0145         DEVD->Fill(deviation);
0146     }
0147 
0148     int xBin, yBin;
0149     if (detId.region() == 0) {  //Barrel
0150       xBin = detId.sector();
0151       rpcdqm::utils rollNumber;
0152       yBin = rollNumber.detId2RollNr(detId);
0153     } else {  //Endcap
0154       //get segment number
0155       RPCGeomServ RPCServ(detId);
0156       xBin = RPCServ.segment();
0157       (numberOfRings_ == 3 ? yBin = detId.ring() * 3 - detId.roll() + 1
0158                            : yBin = (detId.ring() - 1) * 3 - detId.roll() + 1);
0159     }
0160 
0161     if (NOISE)
0162       NOISE->setBinContent(xBin, yBin, noisyStrips);
0163     if (NOISED)
0164       NOISED->Fill(noisyStrips);
0165   }
0166 }