00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <DQM/DTMonitorClient/src/DTDataIntegrityTest.h>
00012
00013
00014 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00015 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
00016 #include "CondFormats/DataRecord/interface/DTReadOutMappingRcd.h"
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019 #include "FWCore/ServiceRegistry/interface/Service.h"
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021
00022 #include <iostream>
00023 #include <string>
00024
00025
00026 using namespace std;
00027 using namespace edm;
00028
00029
00030 DTDataIntegrityTest::DTDataIntegrityTest(const ParameterSet& ps) : nevents(0) {
00031
00032 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: Constructor";
00033
00034
00035 prescaleFactor = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
00036
00037
00038 }
00039
00040
00041 DTDataIntegrityTest::~DTDataIntegrityTest(){
00042
00043 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "DataIntegrityTest: analyzed " << nupdates << " updates";
00044
00045 }
00046
00047
00048 void DTDataIntegrityTest::beginJob(){
00049
00050 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: BeginJob";
00051
00052
00053 nupdates = 0;
00054 run=0;
00055
00056 dbe = Service<DQMStore>().operator->();
00057
00058
00059 dbe->setCurrentFolder("DT/00-DataIntegrity");
00060 summaryHisto = dbe->book2D("DataIntegritySummary","Summary Data Integrity",12,1,13,5,-2,3);
00061 summaryHisto->setAxisTitle("Sector",1);
00062 summaryHisto->setAxisTitle("Wheel",2);
00063
00064 dbe->setCurrentFolder("DT/00-DataIntegrity");
00065 summaryTDCHisto = dbe->book2D("DataIntegrityTDCSummary","TDC Summary Data Integrity",12,1,13,5,-2,3);
00066 summaryTDCHisto->setAxisTitle("Sector",1);
00067 summaryTDCHisto->setAxisTitle("Wheel",2);
00068
00069 dbe->setCurrentFolder("DT/00-DataIntegrity");
00070 glbSummaryHisto = dbe->book2D("DataIntegrityGlbSummary","Summary Data Integrity",12,1,13,5,-2,3);
00071 glbSummaryHisto->setAxisTitle("Sector",1);
00072 glbSummaryHisto->setAxisTitle("Wheel",2);
00073
00074 }
00075
00076 void DTDataIntegrityTest::beginRun(const Run& run, const EventSetup& context){
00077
00078 context.get<DTReadOutMappingRcd>().get(mapping);
00079
00080 }
00081
00082
00083
00084 void DTDataIntegrityTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00085
00086 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest]: Begin of LS transition";
00087
00088
00089 run = lumiSeg.run();
00090
00091 }
00092
00093
00094
00095 void DTDataIntegrityTest::analyze(const Event& e, const EventSetup& context){
00096
00097 nevents++;
00098 if(nevents%1000 == 0)
00099 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
00100 << "[DTDataIntegrityTest]: "<<nevents<<" events";
00101 }
00102
00103
00104
00105 void DTDataIntegrityTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00106
00107
00108 nLumiSegs = lumiSeg.id().luminosityBlock();
00109 stringstream nLumiSegs_s; nLumiSegs_s << nLumiSegs;
00110
00111
00112 if (nLumiSegs%prescaleFactor != 0) return;
00113
00114 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
00115 <<"[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
00116
00117
00118
00119 nupdates++;
00120
00121
00122
00123 counter++;
00124
00125
00126 for (int dduId=FEDNumbering::MINDTFEDID; dduId<=FEDNumbering::MAXDTFEDID; ++dduId){
00127 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
00128 <<"[DTDataIntegrityTest]:FED Id: "<<dduId;
00129
00130
00131 stringstream dduId_s; dduId_s << dduId;
00132
00133 string histoType;
00134
00135
00136 string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_ROSStatus";
00137 MonitorElement * FED_ROSStatus = dbe->get(rosStatusName);
00138
00139
00140
00141 string wheelSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
00142 MonitorElement * FED_ROSSummary = dbe->get(wheelSummaryName);
00143
00144
00145 string fedIntegrityFolder = "DT/FEDIntegrity_DT/";
00146 MonitorElement * hFEDEntry = dbe->get(fedIntegrityFolder+"FEDEntries");
00147 MonitorElement * hFEDFatal = dbe->get(fedIntegrityFolder+"FEDFatal");
00148 MonitorElement * hFEDNonFatal = dbe->get(fedIntegrityFolder+"FEDNonFatal");
00149
00150 if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
00151
00152 if(FED_ROSSummary && FED_ROSStatus) {
00153 TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
00154 TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
00155
00156 bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
00157 hFEDFatal->getBinContent(dduId-769) == 0 &&
00158 hFEDNonFatal->getBinContent(dduId-769) == 0);
00159 for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
00160 int wheelNumber, sectorNumber;
00161 if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
00162 int result = -2;
00163 float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
00164 nErrors += histoROSStatus->Integral(2,8,rosNumber,rosNumber);
00165
00166 if(nErrors == 0) {
00167 result = 0;
00168 } else {
00169 result = 2;
00170 }
00171 summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
00172 int tdcResult = -2;
00173 float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
00174 if(nTDCErrors == 0) {
00175 tdcResult = 0;
00176 } else {
00177 tdcResult = 2;
00178 }
00179 summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
00180
00181 float sectPerc = max((float)0., ((float)nevents-nErrors)/(float)nevents);
00182 glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
00183
00184 if(fedNotReadout) {
00185
00186 summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00187 summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00188 glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
00189 }
00190 }
00191 }
00192
00193 } else {
00194 for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
00195 int wheelNumber, sectorNumber;
00196 if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
00197 summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00198 summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00199 glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
00200 }
00201 }
00202 }
00203
00204 }
00205
00206 }
00207
00208 }
00209
00210
00211
00212 void DTDataIntegrityTest::endJob(){
00213
00214 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
00215
00216
00217 }
00218
00219
00220
00221 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
00222
00223 stringstream dduID_s; dduID_s << FEDId;
00224
00225 string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
00226
00227 string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
00228 return histoName;
00229 }
00230
00231
00232
00233 void DTDataIntegrityTest::bookHistos(string histoType, int dduId){
00234 stringstream dduId_s; dduId_s << dduId;
00235 dbe->setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
00236 string histoName;
00237
00238 }
00239
00240
00241 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
00242
00243 int dummy;
00244 return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
00245
00246 }
00247