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  bookingdone = false;
38 
39 }
40 
41 
43 
44  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "DataIntegrityTest: analyzed " << nupdates << " updates";
45 
46 }
47 
49  edm::LuminosityBlock const & lumiSeg, edm::EventSetup const & context) {
50 
51 
52  if (!bookingdone) {
53 
54  //nSTAEvents = 0;
55  nupdates = 0;
56  run=0;
57 
58  // book the summary histogram
59 
60  ibooker.setCurrentFolder("DT/00-DataIntegrity");
61 
62  summaryHisto = ibooker.book2D("DataIntegritySummary","Summary Data Integrity",12,1,13,5,-2,3);
63  summaryHisto->setAxisTitle("Sector",1);
64  summaryHisto->setAxisTitle("Wheel",2);
65 
66  ibooker.setCurrentFolder("DT/00-DataIntegrity");
67 
68  summaryTDCHisto = ibooker.book2D("DataIntegrityTDCSummary","TDC Summary Data Integrity",12,1,13,5,-2,3);
69  summaryTDCHisto->setAxisTitle("Sector",1);
70  summaryTDCHisto->setAxisTitle("Wheel",2);
71 
72  ibooker.setCurrentFolder("DT/00-DataIntegrity");
73 
74  glbSummaryHisto = ibooker.book2D("DataIntegrityGlbSummary","Summary Data Integrity",12,1,13,5,-2,3);
75  glbSummaryHisto->setAxisTitle("Sector",1);
76  glbSummaryHisto->setAxisTitle("Wheel",2);
77 
78  context.get<DTReadOutMappingRcd>().get(mapping);
79 
80  }
81  bookingdone = true;
82 
83 
84  // counts number of lumiSegs
85  nLumiSegs = lumiSeg.id().luminosityBlock();
86  stringstream nLumiSegs_s; nLumiSegs_s << nLumiSegs;
87 
88  // prescale factor
89  if (nLumiSegs%prescaleFactor != 0) return;
90 
91  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
92  <<"[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
93 
94 
95  // counts number of updats
96  nupdates++;
97 
98 
99  //Counter for x bin in the timing histos
100  counter++;
101 
102  //Loop on FED id
103  //Monitoring only real used FEDs
104  for (int dduId=FEDNumbering::MINDTFEDID; dduId<=774; ++dduId){
105  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
106  <<"[DTDataIntegrityTest]:FED Id: "<<dduId;
107 
108  //Each nTimeBin onUpdate remove timing histos and book a new bunch of them
109  stringstream dduId_s; dduId_s << dduId;
110 
111  string histoType;
112 
113  //Check if the list of ROS is compatible with the channels enabled
114  string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_ROSStatus";
115  MonitorElement * FED_ROSStatus = igetter.get(rosStatusName);
116 
117  // Get the error summary histo
118  string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
119  MonitorElement * FED_ROSSummary = igetter.get(fedSummaryName);
120 
121  // Get the event lenght plot (used to counr # of processed evts)
122  string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_EventLenght";
123  MonitorElement * FED_EvLenght = igetter.get(fedEvLenName);
124 
125  // Get the histos for FED integrity
126  string fedIntegrityFolder = "DT/00-DataIntegrity/";
127  MonitorElement * hFEDEntry = igetter.get(fedIntegrityFolder+"FEDEntries");
128  MonitorElement * hFEDFatal = igetter.get(fedIntegrityFolder+"FEDFatal");
129  MonitorElement * hFEDNonFatal = igetter.get(fedIntegrityFolder+"FEDNonFatal");
130 
131  if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
132 
133  if(FED_ROSSummary && FED_ROSStatus && FED_EvLenght) {
134  TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
135  TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
136  TH1F * histoEvLenght = FED_EvLenght->getTH1F();
137  // Check that the FED is in the ReadOut using the FEDIntegrity histos
138  bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
139  hFEDFatal->getBinContent(dduId-769) == 0 &&
140  hFEDNonFatal->getBinContent(dduId-769) == 0);
141  int nFEDEvts = histoEvLenght->Integral();
142  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) { // loop on the ROS
143  int wheelNumber, sectorNumber;
144  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
145  float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
146  float nROBErrors = histoROSStatus->Integral(2,8,rosNumber,rosNumber);
147  nErrors += nROBErrors;
148  float result =0.;
149  if(nFEDEvts!=0)
150  result = max((float)0., ((float)nFEDEvts-nROBErrors)/(float)nFEDEvts);
151  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
152  int tdcResult = -2;
153  float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
154  if(nTDCErrors == 0) { // no errors
155  tdcResult = 0;
156  } else { // there are errors
157  tdcResult = 2;
158  }
159  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
160  // FIXME: different errors should have different weights
161  float sectPerc = max((float)0., ((float)nFEDEvts-nErrors)/(float)nFEDEvts);
162  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
163 
164  if(fedNotReadout) {
165  // no data in this FED: it is off
166  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
167  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
168  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
169  }
170  }
171  }
172 
173  } else { // no data in this FED: it is off
174  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
175  int wheelNumber, sectorNumber;
176  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
177  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
178  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
179  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
180  }
181  }
182  }
183 
184  }
185 
186  }
187 
188 }
189 
191 
192  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
193 }
194 
195 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
196  //Use the DDU name to find the ME
197  stringstream dduID_s; dduID_s << FEDId;
198 
199  string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
200 
201  string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
202  return histoName;
203 }
204 
205 void DTDataIntegrityTest::bookHistos(DQMStore::IBooker & ibooker, string histoType, int dduId){
206  stringstream dduId_s; dduId_s << dduId;
207 
208  ibooker.setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
209  string histoName;
210 
211 }
212 
213 
214 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
215 
216  int dummy;
217  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
218 
219 }
220 
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
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:305
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)
int readOutToGeometry(int dduId, int rosNumber, int &wheel, int &sector)
edm::ESHandle< DTReadOutMapping > mapping
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
TH1F * getTH1F(void) const
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.
TH2F * getTH2F(void) const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)