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  } //booking
82  bookingdone = true;
83 
84 
85  // counts number of lumiSegs
86  nLumiSegs = lumiSeg.id().luminosityBlock();
87  string nLumiSegs_s = to_string(nLumiSegs);
88 
89  // prescale factor
90  if (nLumiSegs%prescaleFactor != 0) return;
91 
92  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
93  <<"[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
94 
95 
96  // counts number of updats
97  nupdates++;
98 
99 
100  //Counter for x bin in the timing histos
101  counter++;
102 
103  //Loop on FED id
104  //Monitoring only real used FEDs
105  int FEDIDmax=FEDNumbering::MAXDTFEDID;
106  int FEDIDmin=FEDNumbering::MINDTFEDID;
107  if (checkUros){
110  }
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  string dduId_s = to_string(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 + "/FED" + dduId_s + "_ROSStatus";
123  if (checkUros) rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s + "/FED" + dduId_s + "_uROSStatus";
124  MonitorElement * FED_ROSStatus = igetter.get(rosStatusName);
125 
126  // Get the error summary histo
127  string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s + "_ROSSummary";
128  MonitorElement * FED_ROSSummary = nullptr;
129  MonitorElement * FED_ROSSummary1 = nullptr;
130  MonitorElement * FED_ROSSummary2 = nullptr;
131  string fedSummaryName1 = "";
132  string fedSummaryName2 = "";
133  string sign = "-";
134  if (checkUros) {
135  if(dduId==FEDIDmin || dduId==FEDIDmax){
136  if(dduId==FEDIDmax) sign="";
137  fedSummaryName2 = "DT/00-DataIntegrity/ROSSummary_W" + sign + "2";
138  fedSummaryName1 = "DT/00-DataIntegrity/ROSSummary_W" + sign + "1";
139  FED_ROSSummary1 = igetter.get(fedSummaryName1);
140  FED_ROSSummary2 = igetter.get(fedSummaryName2);
141  }
142  else { fedSummaryName = "DT/00-DataIntegrity/ROSSummary_W0";
143  FED_ROSSummary1 = igetter.get(fedSummaryName);
144  FED_ROSSummary2 = igetter.get(fedSummaryName); //for wheel compatibility...
145  }
146  }
147  else FED_ROSSummary = igetter.get(fedSummaryName); //legacy case
148 
149  // Get the event length plot (used to count # of processed evts)
150  string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s + "/FED" + dduId_s + "_EventLength";
151  MonitorElement * FED_EvLength = igetter.get(fedEvLenName);
152 
153  // Get the histos for FED integrity
154  string fedIntegrityFolder = "DT/00-DataIntegrity/";
155  MonitorElement * hFEDEntry = igetter.get(fedIntegrityFolder+"FEDEntries");
156  MonitorElement * hFEDFatal = igetter.get(fedIntegrityFolder+"FEDFatal");
157  MonitorElement * hFEDNonFatal = igetter.get(fedIntegrityFolder+"FEDNonFatal");
158 
159  if (checkUros){
160 
161  if (hFEDEntry) {
162  int offsetFED=1368;
163  // Check that the FED is in the ReadOut using the FEDIntegrity histos
164  bool fedNotReadout = (hFEDEntry->getBinContent(dduId-offsetFED)) == 0;
165  int wheel = dduId-offsetFED-2;
166  if(FED_ROSSummary1 && FED_ROSSummary2 && FED_ROSStatus && FED_EvLength && !fedNotReadout ) {
167  TH2F * histoFEDSummary1 = FED_ROSSummary1->getTH2F();
168  TH2F * histoFEDSummary2 = FED_ROSSummary2->getTH2F(); // same for central FED...
169  TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
170  TH1F * histoEvLength = FED_EvLength->getTH1F();
171 
172  int nFEDEvts = histoEvLength->Integral();
173  //if(dduId==FEDIDmin || dduId==FEDIDmax) nFEDEvts = nFEDEvts/2.; // split in 2 for external FEDs
174  if (!(nFEDEvts>0)) continue;
175  int extraFEDevents1 = 0;
176  int extraFEDevents2 = 0;
177 
178  for(int urosNumber = 1; urosNumber <= DOCESLOTS; ++urosNumber) { // loop on the uROS
179  string urosNumber_s = to_string(urosNumber);
180  // Get the event length plot for this uROS (used to count # of processed evts)
181  string fedUrosEvLenName = "DT/00-DataIntegrity/FED" + dduId_s + "/uROS" + urosNumber_s +
182  "/FED" + dduId_s + "_uROS" + urosNumber_s + "_EventLength";
183  MonitorElement * FED_uROS_EvLength = igetter.get(fedUrosEvLenName);
184  TH1F * histoUrosEvLength = FED_uROS_EvLength->getTH1F();
185  int nFEDEvtsUros = histoUrosEvLength->Integral();
186 
187  //station 4 sectors drievn by uROS 1 & 2
188  if (urosNumber==1) {extraFEDevents1=nFEDEvtsUros; continue;}
189  if (urosNumber==2) {extraFEDevents2=nFEDEvtsUros; continue;}
190 
191  if(nFEDEvtsUros>0) { //this uROS is active
192  nFEDEvtsUros = extraFEDevents1+extraFEDevents2+nFEDEvtsUros / 3.; // split in 3 ROS
193  float nGErrors = histoROSStatus->Integral(1,12,urosNumber,urosNumber);//Only Global Errors,
194  //not possible to distinguish which ROS, so coumting them in the 3/12 ROSes
195 
196  int ros = getROS(urosNumber,0);
197  for (int iros=ros; iros<(ros+3); ++iros){
198  // -1,0,+1 wheels
199  float nROBErrors1 = histoFEDSummary1->Integral(1,5,iros,iros); //Errors and Not OK Flag
200  float nErrors1 = nROBErrors1+nGErrors;
201  float result1 =0.;
202  if(nFEDEvtsUros!=0)
203  result1 = max((float)0., ((float)nFEDEvtsUros-nROBErrors1)/(float)nFEDEvtsUros);
204  summaryHisto->setBinContent(iros,wheel+3,result1);
205  double tdcResult1 = -2;
206  float nTDCErrors1 = histoFEDSummary1->Integral(6,6,iros,iros); //Only TDC fatal considered
207  if(nTDCErrors1 == 0) { // no errors
208  tdcResult1 = 0.5;
209  } else { // there are errors
210  tdcResult1 = 2.5;
211  }
212  summaryTDCHisto->setBinContent(iros,wheel+3,tdcResult1);
213 
214  // FIXME: different errors should have different weights
215  float sectPerc1 = 0.;
216  if(nFEDEvtsUros!=0)
217  sectPerc1 = max((float)0., ((float)nFEDEvtsUros-nErrors1)/(float)nFEDEvtsUros);
218  glbSummaryHisto->setBinContent(iros,wheel+3,sectPerc1);
219  if(dduId==(FEDIDmax-1)) continue; //wheel 0 case
220 
221  // -2,+2 wheels
222  float nROBErrors2 = histoFEDSummary2->Integral(1,5,iros,iros); //Errors and Not OK Flag
223  float nErrors2 = nROBErrors2+nGErrors;
224  float result2 =0.;
225  if(nFEDEvtsUros!=0)
226  result2 = max((float)0., ((float)nFEDEvtsUros-nROBErrors2)/(float)nFEDEvtsUros);
227  summaryHisto->setBinContent(iros,wheel*2+3,result2);
228 
229  double tdcResult2 = -2;
230  float nTDCErrors2 = histoFEDSummary2->Integral(6,6,iros,iros); //Only TDC fatal considered
231  if(nTDCErrors2 == 0) { // no errors
232  tdcResult2 = 0.5;
233  } else { // there are errors
234  tdcResult2 = 2.5;
235  }
236  summaryTDCHisto->setBinContent(iros,wheel*2+3,tdcResult2);
237 
238  // FIXME: different errors should have different weights
239  float sectPerc2 = 0.;
240  if(nFEDEvtsUros!=0)
241  sectPerc2 = max((float)0., ((float)nFEDEvtsUros-nErrors2)/(float)nFEDEvtsUros);
242  glbSummaryHisto->setBinContent(iros,wheel*2+3,sectPerc2);
243  } //loop in three ros
244  }// this uROS is active
245  } //loop on uros
246  } else { // no data in this FED: it is off, no ROS suummary/status or evLength and fedNotReadout
247  for(int i = 1; i <= DOCESLOTS; ++i) {
248  summaryHisto->setBinContent(i,wheel+3,0.5);
249  summaryTDCHisto->setBinContent(i,wheel+3,1.5);
250  glbSummaryHisto->setBinContent(i,wheel+3,0.5);
251  if (dduId==(FEDIDmax-1)) continue; //wheel 0 case
252  summaryHisto->setBinContent(i,wheel*2+3,0.5);
253  summaryTDCHisto->setBinContent(i,wheel*2+3,1.5);
254  glbSummaryHisto->setBinContent(i,wheel*2+3,0.5);
255  } //loop on uros
256  } // no data in this FED: it is off, no ROS suummary/status or evLength
257 
258  } //FEDentry
259  } else { //legacy case
260  if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
261  if(FED_ROSSummary && FED_ROSStatus && FED_EvLength) {
262  TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
263  TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
264  TH1F * histoEvLength = FED_EvLength->getTH1F();
265  // Check that the FED is in the ReadOut using the FEDIntegrity histos
266  bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
267  hFEDFatal->getBinContent(dduId-769) == 0 &&
268  hFEDNonFatal->getBinContent(dduId-769) == 0);
269 
270  int nFEDEvts = histoEvLength->Integral();
271  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) { // loop on the ROS
272  int wheelNumber, sectorNumber;
273  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
274  float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
275  float nROBErrors = histoROSStatus->Integral(2,8,rosNumber,rosNumber);
276  nErrors += nROBErrors;
277  float result =0.;
278  if(nFEDEvts!=0)
279  result = max((float)0., ((float)nFEDEvts-nROBErrors)/(float)nFEDEvts);
280  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
281  int tdcResult = -2;
282  float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
283  if(nTDCErrors == 0) { // no errors
284  tdcResult = 0;
285  } else { // there are errors
286  tdcResult = 2;
287  }
288  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
289  // FIXME: different errors should have different weights
290  float sectPerc = max((float)0., ((float)nFEDEvts-nErrors)/(float)nFEDEvts);
291  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
292 
293  if(fedNotReadout) {
294  // no data in this FED: it is off
295  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
296  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
297  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
298  } //fedNotReadout
299  } //mapping
300  } //loop on ros
301  } else { // no data in this FED: it is off, no ROS suummary/status or evLength
302  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
303  int wheelNumber, sectorNumber;
304  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
305  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
306  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
307  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
308  } //mapping
309  } //loop on ros
310  } // no data in this FED: it is off, no ROS suummary/status or evLength
311 
312  }// no FED entry, fatal, nonfatal
313 
314  } //legacy case
315 
316  } // loop on dduIds
317 }
318 
320 
321  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
322 }
323 
324 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
325  //Use the DDU name to find the ME
326  stringstream dduID_s; dduID_s << FEDId;
327 
328  string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
329 
330  string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
331  return histoName;
332 }
333 
334 void DTDataIntegrityTest::bookHistos(DQMStore::IBooker & ibooker, string histoType, int dduId){
335  stringstream dduId_s; dduId_s << dduId;
336 
337  ibooker.setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
338  string histoName;
339 
340 }
341 
342 
343 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
344 
345  int dummy;
346  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
347 
348 }
349 
350 int DTDataIntegrityTest::getROS(int uROS, int link){
351 
352  int slot = 0;
353  switch(uROS){
354  case 1:{
355  slot = 5;
356  break;
357  }
358  case 2:{
359  slot = 11;
360  break;
361  }
362  case 3:{
363  slot = 1;
364  break;
365  }
366  case 4:{
367  slot = 7;
368  break;
369  }
370  case 5:{
371  slot = 2;
372  break;
373  }
374  case 6:{
375  slot = 8;
376  break;
377  }
378  case 9:{
379  slot = 9;
380  break;
381  }
382  case 10:{
383  slot = 3;
384  break;
385  }
386  case 11:{
387  slot = 10;
388  break;
389  }
390  case 12:{
391  slot = 4;
392  break;
393  }
394  }
395 
396  if (slot%6 == 5) return link+1;
397 
398  int ros = (link/24) + 3*(slot%6) - 2;
399  return ros;
400 }
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 * summaryTDCHisto
DTDataIntegrityTest(const edm::ParameterSet &ps)
Constructor.
MonitorElement * glbSummaryHisto
static const int DOCESLOTS
std::string getMEName(std::string histoType, int FEDId)
Get the ME name.
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
def wheelNumber(wheell)
Definition: plotscripts.py:47
MonitorElement * summaryHisto
#define LogTrace(id)
TH2F * getTH2F() const
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
int readOutToGeometry(int dduId, int rosNumber, int &wheel, int &sector)
edm::ESHandle< DTReadOutMapping > mapping
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
LuminosityBlockNumber_t luminosityBlock() const
int getROS(int uROS, int link)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
double getBinContent(int binx) const
get content of bin (1-D)
~DTDataIntegrityTest() override
Destructor.
HLT enums.
T get() const
Definition: EventSetup.h:71
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)