Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/RPCMonitorClient/interface/RPCDCSSummary.h"
0002 
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "DQM/RPCMonitorClient/interface/RPCSummaryMapHisto.h"
0007 
0008 #include <fmt/format.h>
0009 
0010 RPCDCSSummary::RPCDCSSummary(const edm::ParameterSet& ps) {
0011   numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
0012 
0013   FEDRange_.first = ps.getUntrackedParameter<unsigned int>("MinimumRPCFEDId", 790);
0014   FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumRPCFEDId", 792);
0015 
0016   offlineDQM_ = ps.getUntrackedParameter<bool>("OfflineDQM", true);
0017 
0018   NumberOfFeds_ = FEDRange_.second - FEDRange_.first + 1;
0019   init_ = false;
0020   defaultValue_ = 1.;
0021 
0022   runInfoToken_ = esConsumes<edm::Transition::EndLuminosityBlock>();
0023 }
0024 
0025 void RPCDCSSummary::beginJob() {}
0026 
0027 void RPCDCSSummary::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0028                                           DQMStore::IGetter& igetter,
0029                                           edm::LuminosityBlock const& lumiB,
0030                                           edm::EventSetup const& setup) {
0031   if (!init_) {
0032     this->checkDCSbit(setup);
0033     if (!offlineDQM_) {
0034       this->myBooker(ibooker);
0035     }
0036   }
0037 }
0038 
0039 void RPCDCSSummary::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0040   if (offlineDQM_) {
0041     this->myBooker(ibooker);
0042   }
0043 }
0044 
0045 void RPCDCSSummary::checkDCSbit(edm::EventSetup const& setup) {
0046   defaultValue_ = 1.;
0047 
0048   if (auto runInfoRec = setup.tryToGet<RunInfoRcd>()) {
0049     defaultValue_ = -1.;
0050     //get fed summary information
0051     auto sumFED = runInfoRec->get(runInfoToken_);
0052     const std::vector<int> FedsInIds = sumFED.m_fed_in;
0053     unsigned int f = 0;
0054     bool flag = false;
0055     while (!flag && f < FedsInIds.size()) {
0056       int fedID = FedsInIds[f];
0057       //make sure fed id is in allowed range
0058       if (fedID >= FEDRange_.first && fedID <= FEDRange_.second) {
0059         defaultValue_ = 1.;
0060         flag = true;
0061       }
0062       f++;
0063     }
0064   }
0065   init_ = true;
0066 }
0067 
0068 void RPCDCSSummary::myBooker(DQMStore::IBooker& ibooker) {
0069   ibooker.setCurrentFolder("RPC/EventInfo");
0070   // global fraction
0071   totalDCSFraction = ibooker.bookFloat("DCSSummary");
0072   totalDCSFraction->Fill(defaultValue_);
0073 
0074   DCSMap_ = RPCSummaryMapHisto::book(ibooker, "DCSSummaryMap", "RPC DCS Summary Map");
0075 
0076   //fill the histo with "1" --- just for the moment
0077   RPCSummaryMapHisto::setBinsBarrel(DCSMap_, 1);
0078   RPCSummaryMapHisto::setBinsEndcap(DCSMap_, 1);
0079 
0080   // book the ME
0081   ibooker.setCurrentFolder("RPC/EventInfo/DCSContents");
0082 
0083   const int limit = std::max(2, numberOfDisks_);
0084 
0085   for (int i = -1 * limit; i <= limit; i++) {  //loop on wheels and disks
0086     if (i > -3 && i < nWheels_ - 2) {          //wheels
0087       const std::string s = fmt::format("RPC_Wheel{}", i);
0088       dcsWheelFractions[i + 2] = ibooker.bookFloat(s);
0089       dcsWheelFractions[i + 2]->Fill(defaultValue_);
0090     }
0091 
0092     if (i == 0 || i > numberOfDisks_ || i < -numberOfDisks_)
0093       continue;
0094 
0095     if (i > -3 && i < nDisks_ - 2) {
0096       const std::string s = fmt::format("RPC_Disk{}", i);
0097       dcsDiskFractions[i + 2] = ibooker.bookFloat(s);
0098       dcsDiskFractions[i + 2]->Fill(defaultValue_);
0099     }
0100   }
0101 }