CMS 3D CMS Logo

DTDataIntegrityTest.cc
Go to the documentation of this file.
1 /*
2  * \file DTDataIntegrityTest.cc
3  *
4  * \author S. Bolognesi - CERN
5  *
6  * threadsafe version (//-) oct/nov 2014 - WATWanAbdullah ncpp-um-my
7  *
8  *
9  */
10 
12 
13 //Framework
21 
22 #include <iostream>
23 #include <string>
24 
25 
26 using namespace std;
27 using namespace edm;
28 
29 
31 
32  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: Constructor";
33 
34  // prescale on the # of LS to update the test
35  prescaleFactor = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
36 
37  checkUros = ps.getUntrackedParameter<bool>("checkUros",false);
38 
39  bookingdone = false;
40 
41 }
42 
43 
45 
46  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "DataIntegrityTest: analyzed " << nupdates << " updates";
47 
48 }
49 
51  edm::LuminosityBlock const & lumiSeg, edm::EventSetup const & context) {
52 
53 
54  if (!bookingdone) {
55 
56  //nSTAEvents = 0;
57  nupdates = 0;
58  run=0;
59 
60  // book the summary histogram
61 
62  ibooker.setCurrentFolder("DT/00-DataIntegrity");
63 
64  summaryHisto = ibooker.book2D("DataIntegritySummary","Summary Data Integrity",12,1,13,5,-2,3);
65  summaryHisto->setAxisTitle("Sector",1);
66  summaryHisto->setAxisTitle("Wheel",2);
67 
68  ibooker.setCurrentFolder("DT/00-DataIntegrity");
69 
70  summaryTDCHisto = ibooker.book2D("DataIntegrityTDCSummary","TDC Summary Data Integrity",12,1,13,5,-2,3);
71  summaryTDCHisto->setAxisTitle("Sector",1);
72  summaryTDCHisto->setAxisTitle("Wheel",2);
73 
74  ibooker.setCurrentFolder("DT/00-DataIntegrity");
75 
76  glbSummaryHisto = ibooker.book2D("DataIntegrityGlbSummary","Summary Data Integrity",12,1,13,5,-2,3);
77  glbSummaryHisto->setAxisTitle("Sector",1);
78  glbSummaryHisto->setAxisTitle("Wheel",2);
79 
80  context.get<DTReadOutMappingRcd>().get(mapping);
81 
82  }
83  bookingdone = true;
84 
85 
86  // counts number of lumiSegs
87  nLumiSegs = lumiSeg.id().luminosityBlock();
88  stringstream nLumiSegs_s; nLumiSegs_s << nLumiSegs;
89 
90  // prescale factor
91  if (nLumiSegs%prescaleFactor != 0) return;
92 
93  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
94  <<"[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
95 
96 
97  // counts number of updats
98  nupdates++;
99 
100 
101  //Counter for x bin in the timing histos
102  counter++;
103 
104  //Loop on FED id
105  //Monitoring only real used FEDs
106  int FEDIDmax=FEDNumbering::MAXDTFEDID;
107  int FEDIDmin=FEDNumbering::MINDTFEDID;
108  if (checkUros){
111  }
112  for (int dduId=FEDIDmin; dduId<=FEDIDmax; ++dduId){
113  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
114  <<"[DTDataIntegrityTest]:FED Id: "<<dduId;
115 
116  //Each nTimeBin onUpdate remove timing histos and book a new bunch of them
117  stringstream dduId_s; dduId_s << dduId;
118 
119  string histoType;
120 
121  //Check if the list of ROS is compatible with the channels enabled
122  string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_ROSStatus";
123  if (checkUros) rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_uROSStatus";
124  MonitorElement * FED_ROSStatus = igetter.get(rosStatusName);
125 
126  // Get the error summary histo
127  string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
128  if (checkUros) fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_uROSSummary";
129  MonitorElement * FED_ROSSummary = igetter.get(fedSummaryName);
130 
131  // Get the event lenght plot (used to count # of processed evts)
132  string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_EventLenght";
133  MonitorElement * FED_EvLenght = igetter.get(fedEvLenName);
134 
135  // Get the histos for FED integrity
136  string fedIntegrityFolder = "DT/00-DataIntegrity/";
137  MonitorElement * hFEDEntry = igetter.get(fedIntegrityFolder+"FEDEntries");
138  MonitorElement * hFEDFatal = igetter.get(fedIntegrityFolder+"FEDFatal");
139  MonitorElement * hFEDNonFatal = igetter.get(fedIntegrityFolder+"FEDNonFatal");
140 
141  if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
142 
143  if(FED_ROSSummary && FED_ROSStatus && FED_EvLenght) {
144  TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
145  TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
146  TH1F * histoEvLenght = FED_EvLenght->getTH1F();
147  // Check that the FED is in the ReadOut using the FEDIntegrity histos
148  bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
149  hFEDFatal->getBinContent(dduId-769) == 0 &&
150  hFEDNonFatal->getBinContent(dduId-769) == 0);
151  int nFEDEvts = histoEvLenght->Integral();
152  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) { // loop on the ROS
153  int wheelNumber, sectorNumber;
154  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
155  float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
156  float nROBErrors = histoROSStatus->Integral(2,8,rosNumber,rosNumber);
157  nErrors += nROBErrors;
158  float result =0.;
159  if(nFEDEvts!=0)
160  result = max((float)0., ((float)nFEDEvts-nROBErrors)/(float)nFEDEvts);
161  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
162  int tdcResult = -2;
163  float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
164  if(nTDCErrors == 0) { // no errors
165  tdcResult = 0;
166  } else { // there are errors
167  tdcResult = 2;
168  }
169  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
170  // FIXME: different errors should have different weights
171  float sectPerc = max((float)0., ((float)nFEDEvts-nErrors)/(float)nFEDEvts);
172  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
173 
174  if(fedNotReadout) {
175  // no data in this FED: it is off
176  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
177  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
178  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
179  }
180  }
181  }
182 
183  } else { // no data in this FED: it is off
184  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
185  int wheelNumber, sectorNumber;
186  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
187  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
188  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
189  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
190  }
191  }
192  }
193 
194  }
195 
196  }
197 
198 }
199 
201 
202  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
203 }
204 
205 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
206  //Use the DDU name to find the ME
207  stringstream dduID_s; dduID_s << FEDId;
208 
209  string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
210 
211  string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
212  return histoName;
213 }
214 
215 void DTDataIntegrityTest::bookHistos(DQMStore::IBooker & ibooker, string histoType, int dduId){
216  stringstream dduId_s; dduId_s << dduId;
217 
218  ibooker.setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
219  string histoName;
220 
221 }
222 
223 
224 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
225 
226  int dummy;
227  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
228 
229 }
230 
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
TH1F * getTH1F() const
int readOutToGeometry(int dduId, int rosId, int robId, int tdcId, int channelId, DTWireId &wireId) const
transform identifiers
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:307
MonitorElement * summaryTDCHisto
DTDataIntegrityTest(const edm::ParameterSet &ps)
Constructor.
MonitorElement * glbSummaryHisto
std::string getMEName(std::string histoType, int FEDId)
Get the ME name.
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
def wheelNumber(wheell)
Definition: plotscripts.py:45
MonitorElement * summaryHisto
#define LogTrace(id)
TH2F * getTH2F() const
int readOutToGeometry(int dduId, int rosNumber, int &wheel, int &sector)
edm::ESHandle< DTReadOutMapping > mapping
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
const T & get() const
Definition: EventSetup.h:59
LuminosityBlockNumber_t luminosityBlock() const
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
double getBinContent(int binx) const
get content of bin (1-D)
~DTDataIntegrityTest() override
Destructor.
HLT enums.
void bookHistos(DQMStore::IBooker &, std::string histoType, int dduId)
Book the MEs.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)