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