File indexing completed on 2023-03-17 10:56:03
0001
0002 #include "DQM/SiPixelMonitorClient/interface/SiPixelDaqInfo.h"
0003 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0004 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0005 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0006
0007 using namespace std;
0008 using namespace edm;
0009 SiPixelDaqInfo::SiPixelDaqInfo(const edm::ParameterSet &ps) {
0010 FEDRange_.first = ps.getUntrackedParameter<unsigned int>("MinimumPixelFEDId", 0);
0011 FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumPixelFEDId", 39);
0012 daqSource_ = ps.getUntrackedParameter<string>("daqSource", "source");
0013
0014 NumberOfFeds_ = FEDRange_.second - FEDRange_.first + 1;
0015
0016 NEvents_ = 0;
0017 for (int i = 0; i != 40; i++)
0018 FEDs_[i] = 0;
0019
0020 firstLumi = true;
0021
0022
0023 daqSourceToken_ = consumes<FEDRawDataCollection>(ps.getUntrackedParameter<string>("daqSource", "source"));
0024 runInfoToken_ = esConsumes<RunInfo, RunInfoRcd, edm::Transition::EndLuminosityBlock>();
0025 }
0026
0027 SiPixelDaqInfo::~SiPixelDaqInfo() {}
0028
0029 void SiPixelDaqInfo::dqmEndLuminosityBlock(DQMStore::IBooker &iBooker,
0030 DQMStore::IGetter &iGetter,
0031 const edm::LuminosityBlock &lumiBlock,
0032 const edm::EventSetup &iSetup) {
0033
0034 if (firstLumi) {
0035 iBooker.setCurrentFolder("Pixel/EventInfo");
0036 Fraction_ = iBooker.bookFloat("DAQSummary");
0037 iBooker.setCurrentFolder("Pixel/EventInfo/DAQContents");
0038 FractionBarrel_ = iBooker.bookFloat("PixelBarrelFraction");
0039 FractionEndcap_ = iBooker.bookFloat("PixelEndcapFraction");
0040
0041 firstLumi = false;
0042 }
0043
0044 if (auto runInfoRec = iSetup.tryToGet<RunInfoRcd>()) {
0045
0046 const RunInfo &sumFED = runInfoRec->get(runInfoToken_);
0047 vector<int> FedsInIds = sumFED.m_fed_in;
0048
0049 int FedCount = 0;
0050 int FedCountBarrel = 0;
0051 int FedCountEndcap = 0;
0052
0053
0054 for (unsigned int fedItr = 0; fedItr < FedsInIds.size(); ++fedItr) {
0055 int fedID = FedsInIds[fedItr];
0056
0057 if (fedID >= FEDRange_.first && fedID <= FEDRange_.second) {
0058 ++FedCount;
0059 if (fedID >= 0 && fedID <= 31)
0060 ++FedCountBarrel;
0061 else if (fedID >= 32 && fedID <= 39)
0062 ++FedCountEndcap;
0063 }
0064 }
0065
0066 if (FedCountBarrel <= 32) {
0067 MonitorElement *mefed = iGetter.get("Pixel/EventInfo/DAQContents/fedcounter");
0068 FedCountBarrel = 0;
0069 FedCountEndcap = 0;
0070 FedCount = 0;
0071 NumberOfFeds_ = 40;
0072 if (mefed) {
0073 for (int i = 0; i != 40; i++) {
0074 if (i <= 31 && mefed->getBinContent(i + 1) > 0)
0075 FedCountBarrel++;
0076 if (i >= 32 && mefed->getBinContent(i + 1) > 0)
0077 FedCountEndcap++;
0078 if (mefed->getBinContent(i + 1) > 0)
0079 FedCount++;
0080 }
0081 }
0082 }
0083 if (NumberOfFeds_ > 0) {
0084
0085 Fraction_->Fill(FedCount / NumberOfFeds_);
0086
0087 FractionBarrel_->Fill(FedCountBarrel / 32.);
0088
0089 FractionEndcap_->Fill(FedCountEndcap / 8.);
0090 } else {
0091 Fraction_->Fill(-1);
0092 FractionBarrel_->Fill(-1);
0093 FractionEndcap_->Fill(-1);
0094 }
0095 } else {
0096 Fraction_->Fill(-1);
0097 FractionBarrel_->Fill(-1);
0098 FractionEndcap_->Fill(-1);
0099 return;
0100 }
0101 }
0102
0103 void SiPixelDaqInfo::dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) {}