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 string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
00141 MonitorElement * FED_ROSSummary = dbe->get(fedSummaryName);
00142
00143
00144 string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_EventLenght";
00145 MonitorElement * FED_EvLenght = dbe->get(fedEvLenName);
00146
00147
00148 string fedIntegrityFolder = "DT/FEDIntegrity/";
00149 MonitorElement * hFEDEntry = dbe->get(fedIntegrityFolder+"FEDEntries");
00150 MonitorElement * hFEDFatal = dbe->get(fedIntegrityFolder+"FEDFatal");
00151 MonitorElement * hFEDNonFatal = dbe->get(fedIntegrityFolder+"FEDNonFatal");
00152
00153 if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
00154
00155 if(FED_ROSSummary && FED_ROSStatus && FED_EvLenght) {
00156 TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
00157 TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
00158 TH1F * histoEvLenght = FED_EvLenght->getTH1F();
00159
00160 bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
00161 hFEDFatal->getBinContent(dduId-769) == 0 &&
00162 hFEDNonFatal->getBinContent(dduId-769) == 0);
00163 int nFEDEvts = histoEvLenght->Integral();
00164 for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
00165 int wheelNumber, sectorNumber;
00166 if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
00167 int result = -2;
00168 float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
00169 nErrors += histoROSStatus->Integral(2,8,rosNumber,rosNumber);
00170 if(nErrors == 0) {
00171 result = 0;
00172 } else {
00173 result = 2;
00174 }
00175 summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
00176 int tdcResult = -2;
00177 float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
00178 if(nTDCErrors == 0) {
00179 tdcResult = 0;
00180 } else {
00181 tdcResult = 2;
00182 }
00183 summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
00184
00185 float sectPerc = max((float)0., ((float)nFEDEvts-nErrors)/(float)nFEDEvts);
00186 glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
00187
00188 if(fedNotReadout) {
00189
00190 summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00191 summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00192 glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
00193 }
00194 }
00195 }
00196
00197 } else {
00198 for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
00199 int wheelNumber, sectorNumber;
00200 if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
00201 summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00202 summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00203 glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
00204 }
00205 }
00206 }
00207
00208 }
00209
00210 }
00211
00212 }
00213
00214
00215
00216 void DTDataIntegrityTest::endJob(){
00217
00218 LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
00219
00220
00221 }
00222
00223
00224
00225 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
00226
00227 stringstream dduID_s; dduID_s << FEDId;
00228
00229 string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
00230
00231 string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
00232 return histoName;
00233 }
00234
00235
00236
00237 void DTDataIntegrityTest::bookHistos(string histoType, int dduId){
00238 stringstream dduId_s; dduId_s << dduId;
00239 dbe->setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
00240 string histoName;
00241
00242 }
00243
00244
00245 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
00246
00247 int dummy;
00248 return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
00249
00250 }
00251