File indexing completed on 2024-09-11 04:32:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "DQM/DTMonitorClient/src/DTDataIntegrityTest.h"
0012
0013
0014 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0015 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
0016 #include "DQMServices/Core/interface/DQMStore.h"
0017 #include "FWCore/ServiceRegistry/interface/Service.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019
0020 #include <iostream>
0021 #include <string>
0022
0023 using namespace std;
0024 using namespace edm;
0025
0026 DTDataIntegrityTest::DTDataIntegrityTest(const ParameterSet& ps)
0027 : nevents(0), mappingToken_(esConsumes<edm::Transition::EndLuminosityBlock>()) {
0028 LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: Constructor";
0029
0030
0031 prescaleFactor = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
0032
0033 bookingdone = false;
0034 }
0035
0036 DTDataIntegrityTest::~DTDataIntegrityTest() {
0037 LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
0038 << "DataIntegrityTest: analyzed " << nupdates << " updates";
0039 }
0040
0041 void DTDataIntegrityTest::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0042 DQMStore::IGetter& igetter,
0043 edm::LuminosityBlock const& lumiSeg,
0044 edm::EventSetup const& context) {
0045 if (!bookingdone) {
0046
0047 nupdates = 0;
0048 run = 0;
0049
0050
0051
0052 ibooker.setCurrentFolder("DT/00-DataIntegrity");
0053
0054 summaryHisto = ibooker.book2D("DataIntegritySummary", "Summary Data Integrity", 12, 1, 13, 5, -2, 3);
0055 summaryHisto->setAxisTitle("Sector", 1);
0056 summaryHisto->setAxisTitle("Wheel", 2);
0057
0058 ibooker.setCurrentFolder("DT/00-DataIntegrity");
0059
0060 summaryTDCHisto = ibooker.book2D("DataIntegrityTDCSummary", "TDC Summary Data Integrity", 12, 1, 13, 5, -2, 3);
0061 summaryTDCHisto->setAxisTitle("Sector", 1);
0062 summaryTDCHisto->setAxisTitle("Wheel", 2);
0063
0064 ibooker.setCurrentFolder("DT/00-DataIntegrity");
0065
0066 glbSummaryHisto = ibooker.book2D("DataIntegrityGlbSummary", "Summary Data Integrity", 12, 1, 13, 5, -2, 3);
0067 glbSummaryHisto->setAxisTitle("Sector", 1);
0068 glbSummaryHisto->setAxisTitle("Wheel", 2);
0069
0070 mapping = &context.getData(mappingToken_);
0071 }
0072 bookingdone = true;
0073
0074
0075 nLumiSegs = lumiSeg.id().luminosityBlock();
0076 string nLumiSegs_s = to_string(nLumiSegs);
0077
0078
0079 if (nLumiSegs % prescaleFactor != 0)
0080 return;
0081
0082 LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
0083 << "[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
0084
0085
0086 nupdates++;
0087
0088
0089 counter++;
0090
0091
0092
0093 int FEDIDmin = FEDNumbering::MINDTUROSFEDID;
0094 int FEDIDmax = FEDNumbering::MAXDTUROSFEDID;
0095
0096 for (int dduId = FEDIDmin; dduId <= FEDIDmax; ++dduId) {
0097 LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]:FED Id: " << dduId;
0098
0099
0100 string dduId_s = to_string(dduId);
0101
0102 string histoType;
0103
0104
0105 string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s + "/FED" + dduId_s + "_uROSStatus";
0106 MonitorElement* FED_ROSStatus = igetter.get(rosStatusName);
0107
0108
0109 string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s + "_ROSSummary";
0110 MonitorElement* FED_ROSSummary1 = nullptr;
0111 MonitorElement* FED_ROSSummary2 = nullptr;
0112 string fedSummaryName1 = "";
0113 string fedSummaryName2 = "";
0114 string sign = "-";
0115 if (dduId == FEDIDmin || dduId == FEDIDmax) {
0116 if (dduId == FEDIDmax)
0117 sign = "";
0118 fedSummaryName2 = "DT/00-DataIntegrity/ROSSummary_W" + sign + "2";
0119 fedSummaryName1 = "DT/00-DataIntegrity/ROSSummary_W" + sign + "1";
0120 FED_ROSSummary1 = igetter.get(fedSummaryName1);
0121 FED_ROSSummary2 = igetter.get(fedSummaryName2);
0122 } else {
0123 fedSummaryName = "DT/00-DataIntegrity/ROSSummary_W0";
0124 FED_ROSSummary1 = igetter.get(fedSummaryName);
0125 FED_ROSSummary2 = igetter.get(fedSummaryName);
0126 }
0127
0128
0129 string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s + "/FED" + dduId_s + "_EventLength";
0130 MonitorElement* FED_EvLength = igetter.get(fedEvLenName);
0131
0132
0133 string fedIntegrityFolder = "DT/00-DataIntegrity/";
0134 MonitorElement* hFEDEntry = igetter.get(fedIntegrityFolder + "FEDEntries");
0135 MonitorElement* hFEDFatal = igetter.get(fedIntegrityFolder + "FEDFatal");
0136
0137 if (hFEDEntry && hFEDFatal) {
0138 int offsetFED = 1368;
0139
0140 bool fedNotReadout =
0141 (hFEDEntry->getBinContent(dduId - offsetFED) == 0 && hFEDFatal->getBinContent(dduId - offsetFED) == 0);
0142 int wheel = dduId - offsetFED - 2;
0143 if (FED_ROSSummary1 && FED_ROSSummary2 && FED_ROSStatus && FED_EvLength && !fedNotReadout) {
0144 TH2F* histoFEDSummary1 = FED_ROSSummary1->getTH2F();
0145 TH2F* histoFEDSummary2 = FED_ROSSummary2->getTH2F();
0146 TH2F* histoROSStatus = FED_ROSStatus->getTH2F();
0147 TH1F* histoEvLength = FED_EvLength->getTH1F();
0148
0149 int nFEDEvts = histoEvLength->Integral();
0150
0151 if (!(nFEDEvts > 0))
0152 continue;
0153 int extraFEDevents1 = 0;
0154 int extraFEDevents2 = 0;
0155
0156 for (int urosNumber = 1; urosNumber <= DOCESLOTS; ++urosNumber) {
0157 string urosNumber_s = to_string(urosNumber);
0158
0159 string fedUrosEvLenName = "DT/00-DataIntegrity/FED" + dduId_s + "/uROS" + urosNumber_s + "/FED" + dduId_s +
0160 "_uROS" + urosNumber_s + "_EventLength";
0161 MonitorElement* FED_uROS_EvLength = igetter.get(fedUrosEvLenName);
0162 TH1F* histoUrosEvLength = FED_uROS_EvLength->getTH1F();
0163 int nFEDEvtsUros = histoUrosEvLength->Integral();
0164
0165
0166 if (urosNumber == 1) {
0167 extraFEDevents1 = nFEDEvtsUros;
0168 continue;
0169 }
0170 if (urosNumber == 2) {
0171 extraFEDevents2 = nFEDEvtsUros;
0172 continue;
0173 }
0174
0175 if (nFEDEvtsUros > 0) {
0176 nFEDEvtsUros = extraFEDevents1 + extraFEDevents2 + nFEDEvtsUros / 3.;
0177 float nGErrors = histoROSStatus->Integral(1, 12, urosNumber, urosNumber);
0178
0179
0180 int ros = getROS(urosNumber, 0);
0181 for (int iros = ros; iros < (ros + 3); ++iros) {
0182
0183 float nROBErrors1 = histoFEDSummary1->Integral(1, 5, iros, iros);
0184 float nErrors1 = nROBErrors1 + nGErrors;
0185 float result1 = 0.;
0186 if (nFEDEvtsUros != 0)
0187 result1 = max((float)0., ((float)nFEDEvtsUros - nROBErrors1) / (float)nFEDEvtsUros);
0188 summaryHisto->setBinContent(iros, wheel + 3, result1);
0189 double tdcResult1 = -2;
0190 float nTDCErrors1 = histoFEDSummary1->Integral(6, 6, iros, iros);
0191 if (nTDCErrors1 == 0) {
0192 tdcResult1 = 0.5;
0193 } else {
0194 tdcResult1 = 2.5;
0195 }
0196 summaryTDCHisto->setBinContent(iros, wheel + 3, tdcResult1);
0197
0198
0199 float sectPerc1 = 0.;
0200 if (nFEDEvtsUros != 0)
0201 sectPerc1 = max((float)0., ((float)nFEDEvtsUros - nErrors1) / (float)nFEDEvtsUros);
0202 glbSummaryHisto->setBinContent(iros, wheel + 3, sectPerc1);
0203 if (dduId == (FEDIDmax - 1))
0204 continue;
0205
0206
0207 float nROBErrors2 = histoFEDSummary2->Integral(1, 5, iros, iros);
0208 float nErrors2 = nROBErrors2 + nGErrors;
0209 float result2 = 0.;
0210 if (nFEDEvtsUros != 0)
0211 result2 = max((float)0., ((float)nFEDEvtsUros - nROBErrors2) / (float)nFEDEvtsUros);
0212 summaryHisto->setBinContent(iros, wheel * 2 + 3, result2);
0213
0214 double tdcResult2 = -2;
0215 float nTDCErrors2 = histoFEDSummary2->Integral(6, 6, iros, iros);
0216 if (nTDCErrors2 == 0) {
0217 tdcResult2 = 0.5;
0218 } else {
0219 tdcResult2 = 2.5;
0220 }
0221 summaryTDCHisto->setBinContent(iros, wheel * 2 + 3, tdcResult2);
0222
0223
0224 float sectPerc2 = 0.;
0225 if (nFEDEvtsUros != 0)
0226 sectPerc2 = max((float)0., ((float)nFEDEvtsUros - nErrors2) / (float)nFEDEvtsUros);
0227 glbSummaryHisto->setBinContent(iros, wheel * 2 + 3, sectPerc2);
0228 }
0229 }
0230 }
0231 } else {
0232 for (int i = 1; i <= DOCESLOTS; ++i) {
0233 summaryHisto->setBinContent(i, wheel + 3, 0.5);
0234 summaryTDCHisto->setBinContent(i, wheel + 3, 1.5);
0235 glbSummaryHisto->setBinContent(i, wheel + 3, 0.5);
0236 if (dduId == (FEDIDmax - 1))
0237 continue;
0238 summaryHisto->setBinContent(i, wheel * 2 + 3, 0.5);
0239 summaryTDCHisto->setBinContent(i, wheel * 2 + 3, 1.5);
0240 glbSummaryHisto->setBinContent(i, wheel * 2 + 3, 0.5);
0241 }
0242 }
0243
0244 }
0245
0246 }
0247 }
0248
0249 void DTDataIntegrityTest::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0250 LogTrace("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest] endjob called!";
0251 }
0252
0253 string DTDataIntegrityTest::getMEName(string histoType, int FEDId) {
0254
0255 stringstream dduID_s;
0256 dduID_s << FEDId;
0257
0258 string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
0259
0260 string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
0261 return histoName;
0262 }
0263
0264 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector) {
0265 int dummy;
0266 return mapping->readOutToGeometry(dduId, ros, 2, 2, 2, wheel, dummy, sector, dummy, dummy, dummy);
0267 }
0268
0269 int DTDataIntegrityTest::getROS(int uROS, int link) {
0270 int slot = 0;
0271 switch (uROS) {
0272 case 1: {
0273 slot = 5;
0274 break;
0275 }
0276 case 2: {
0277 slot = 11;
0278 break;
0279 }
0280 case 3: {
0281 slot = 1;
0282 break;
0283 }
0284 case 4: {
0285 slot = 7;
0286 break;
0287 }
0288 case 5: {
0289 slot = 2;
0290 break;
0291 }
0292 case 6: {
0293 slot = 8;
0294 break;
0295 }
0296 case 9: {
0297 slot = 9;
0298 break;
0299 }
0300 case 10: {
0301 slot = 3;
0302 break;
0303 }
0304 case 11: {
0305 slot = 10;
0306 break;
0307 }
0308 case 12: {
0309 slot = 4;
0310 break;
0311 }
0312 }
0313
0314 if (slot % 6 == 5)
0315 return link + 1;
0316
0317 int ros = (link / 24) + 3 * (slot % 6) - 2;
0318 return ros;
0319 }