File indexing completed on 2024-04-06 12:08:12
0001 #include "DQM/RPCMonitorClient/interface/RPCDaqInfo.h"
0002 #include "DQM/RPCMonitorClient/interface/RPCSummaryMapHisto.h"
0003
0004 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "CondFormats/RunInfo/interface/RunSummary.h"
0008
0009 #include <fmt/format.h>
0010
0011 RPCDaqInfo::RPCDaqInfo(const edm::ParameterSet& ps) {
0012 FEDRange_.first = ps.getUntrackedParameter<unsigned int>("MinimumRPCFEDId", 790);
0013 FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumRPCFEDId", 792);
0014
0015 NumberOfFeds_ = FEDRange_.second - FEDRange_.first + 1;
0016
0017 numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
0018
0019 runInfoToken_ = esConsumes<edm::Transition::EndLuminosityBlock>();
0020
0021 init_ = false;
0022 }
0023
0024 void RPCDaqInfo::beginJob() {}
0025 void RPCDaqInfo::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0026 DQMStore::IGetter& igetter,
0027 edm::LuminosityBlock const& LB,
0028 edm::EventSetup const& iSetup) {
0029 if (!init_) {
0030 this->myBooker(ibooker);
0031 }
0032
0033 if (auto runInfoRec = iSetup.tryToGet<RunInfoRcd>()) {
0034
0035 auto sumFED = runInfoRec->get(runInfoToken_);
0036 const std::vector<int> FedsInIds = sumFED.m_fed_in;
0037
0038 int FedCount = 0;
0039
0040
0041 for (const int fedID : FedsInIds) {
0042
0043 if (fedID >= FEDRange_.first && fedID <= FEDRange_.second)
0044 ++FedCount;
0045 }
0046
0047
0048 if (NumberOfFeds_ > 0)
0049 DaqFraction_->Fill(FedCount / NumberOfFeds_);
0050 else
0051 DaqFraction_->Fill(-1);
0052
0053 } else {
0054 DaqFraction_->Fill(-1);
0055 return;
0056 }
0057 }
0058
0059 void RPCDaqInfo::dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) {}
0060
0061 void RPCDaqInfo::myBooker(DQMStore::IBooker& ibooker) {
0062
0063 ibooker.setCurrentFolder("RPC/EventInfo/DAQContents");
0064
0065 const int limit = std::max(2, numberOfDisks_);
0066
0067 for (int i = -limit; i <= limit; ++i) {
0068 if (i > -3 && i < nWheels_ - 2) {
0069 const std::string meName = fmt::format("RPC_Wheel{}", i);
0070 daqWheelFractions[i + 2] = ibooker.bookFloat(meName);
0071 daqWheelFractions[i + 2]->Fill(-1);
0072 }
0073
0074 if (i == 0 || i > numberOfDisks_ || i < -numberOfDisks_)
0075 continue;
0076
0077 if (i > -3 && i < nDisks_ - 2) {
0078 const std::string meName = fmt::format("RPC_Disk{}", i);
0079 daqDiskFractions[i + 2] = ibooker.bookFloat(meName);
0080 daqDiskFractions[i + 2]->Fill(-1);
0081 }
0082 }
0083
0084
0085 ibooker.setCurrentFolder("RPC/EventInfo");
0086
0087 DaqFraction_ = ibooker.bookFloat("DAQSummary");
0088 DaqMap_ = RPCSummaryMapHisto::book(ibooker, "DAQSummaryMap", "RPC DAQ Summary Map");
0089 RPCSummaryMapHisto::setBinsBarrel(DaqMap_, 1);
0090 RPCSummaryMapHisto::setBinsEndcap(DaqMap_, 1);
0091
0092 init_ = true;
0093 }