Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-31 22:35:52

0001 /*
0002  *  \author Anna Cimmino
0003  */
0004 #include <DQM/RPCMonitorClient/interface/RPCMultiplicityTest.h>
0005 #include <DQM/RPCMonitorClient/interface/RPCRollMapHisto.h>
0006 #include "DQM/RPCMonitorClient/interface/utils.h"
0007 
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
0010 
0011 RPCMultiplicityTest::RPCMultiplicityTest(const edm::ParameterSet& ps) {
0012   edm::LogVerbatim("multiplicity") << "[RPCMultiplicityTest]: Constructor";
0013   useRollInfo_ = ps.getUntrackedParameter<bool>("UseRollInfo", false);
0014   prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
0015   numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
0016   numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
0017   testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
0018 }
0019 
0020 void RPCMultiplicityTest::beginJob(std::string& workingFolder) {
0021   edm::LogVerbatim("multiplicity") << "[RPCMultiplicityTest]: Begin job";
0022   globalFolder_ = workingFolder;
0023 }
0024 
0025 void RPCMultiplicityTest::myBooker(DQMStore::IBooker& ibooker) {
0026   ibooker.setCurrentFolder(globalFolder_);
0027 
0028   std::stringstream histoName;
0029 
0030   for (int i = -2; i <= 2; i++) {  //loop on wheels and disks
0031 
0032     histoName.str("");
0033     histoName << "NumberOfDigi_Mean_Roll_vs_Sector_Wheel" << i;
0034 
0035     auto me = RPCRollMapHisto::bookBarrel(ibooker, i, histoName.str(), histoName.str(), useRollInfo_);
0036     MULTWheel[i + 2] = dynamic_cast<MonitorElement*>(me);
0037 
0038     if (testMode_) {
0039       histoName.str("");
0040       histoName << "NumberOfDigi_Mean_Distribution_Wheel" << i;
0041       MULTDWheel[i + 2] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 50.5);
0042     }
0043 
0044   }  //end wheels
0045 
0046   for (int d = -numberOfDisks_; d <= numberOfDisks_; d++) {
0047     if (d == 0)
0048       continue;
0049 
0050     int offset = numberOfDisks_;
0051     if (d > 0)
0052       offset--;  //used to skip case equale to zero
0053 
0054     histoName.str("");
0055     histoName << "NumberOfDigi_Mean_Ring_vs_Segment_Disk" << d;
0056     auto me = RPCRollMapHisto::bookEndcap(ibooker, d, histoName.str(), histoName.str(), useRollInfo_);
0057     MULTDisk[d + offset] = dynamic_cast<MonitorElement*>(me);
0058 
0059     if (testMode_) {
0060       histoName.str("");
0061       histoName << "NumberOfDigi_Mean_Distribution_Disk" << d;
0062       MULTDDisk[d + offset] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 50.5);
0063     }
0064   }  //end loop on wheels and disks
0065 }
0066 
0067 void RPCMultiplicityTest::getMonitorElements(std::vector<MonitorElement*>& meVector,
0068                                              std::vector<RPCDetId>& detIdVector,
0069                                              std::string& clientHistoName) {
0070   //Get NumberOfDigi ME for each roll
0071   for (unsigned int i = 0; i < meVector.size(); i++) {
0072     std::string meName = meVector[i]->getName();
0073 
0074     if (meName.find(clientHistoName) != std::string::npos) {
0075       myNumDigiMe_.push_back(meVector[i]);
0076       myDetIds_.push_back(detIdVector[i]);
0077     }
0078   }
0079 }
0080 
0081 void RPCMultiplicityTest::clientOperation() {
0082   edm::LogVerbatim("multiplicity") << "[RPCMultiplicityTest]: Client Operation";
0083 
0084   //Loop on MEs
0085   for (unsigned int i = 0; i < myNumDigiMe_.size(); i++) {
0086     this->fillGlobalME(myDetIds_[i], myNumDigiMe_[i]);
0087   }  //End loop on MEs
0088 }
0089 
0090 void RPCMultiplicityTest::fillGlobalME(RPCDetId& detId, MonitorElement* myMe) {
0091   MonitorElement* MULT = nullptr;
0092   MonitorElement* MULTD = nullptr;
0093 
0094   if (detId.region() == 0) {
0095     MULT = MULTWheel[detId.ring() + 2];
0096     if (testMode_) {
0097       MULTD = MULTDWheel[detId.ring() + 2];
0098     }
0099   } else {
0100     if (-detId.station() + numberOfDisks_ >= 0) {
0101       if (detId.region() < 0) {
0102         MULT = MULTDisk[-detId.station() + numberOfDisks_];
0103         if (testMode_) {
0104           MULTD = MULTDDisk[-detId.station() + numberOfDisks_];
0105         }
0106       } else {
0107         MULT = MULTDisk[detId.station() + numberOfDisks_ - 1];
0108         if (testMode_) {
0109           MULTD = MULTDDisk[detId.station() + numberOfDisks_ - 1];
0110         }
0111       }
0112     }
0113   }
0114 
0115   int xBin, yBin;
0116   if (detId.region() == 0) {  //Barrel
0117     xBin = detId.sector();
0118     rpcdqm::utils rollNumber;
0119     yBin = rollNumber.detId2RollNr(detId);
0120   } else {  //Endcap
0121     //get segment number
0122     RPCGeomServ RPCServ(detId);
0123     xBin = RPCServ.segment();
0124     (numberOfRings_ == 3 ? yBin = detId.ring() * 3 - detId.roll() + 1
0125                          : yBin = (detId.ring() - 1) * 3 - detId.roll() + 1);
0126   }
0127 
0128   float mean = myMe->getMean();
0129 
0130   if (MULT) {
0131     MULT->setBinContent(xBin, yBin, mean);
0132   }
0133   if (testMode_ && MULTD) {
0134     MULTD->Fill(mean);
0135   }
0136 }