CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTDataIntegrityTest.cc
Go to the documentation of this file.
1 
2 /*
3  * \file DTDataIntegrityTest.cc
4  *
5  * \author S. Bolognesi - CERN
6  *
7  */
8 
10 
11 //Framework
19 
20 #include <iostream>
21 #include <string>
22 
23 
24 using namespace std;
25 using namespace edm;
26 
27 
29 
30  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: Constructor";
31 
32  // prescale on the # of LS to update the test
33  prescaleFactor = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
34 
35 
36 }
37 
38 
40 
41  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "DataIntegrityTest: analyzed " << nupdates << " updates";
42 
43 }
44 
45 
47 
48  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: BeginJob";
49 
50  //nSTAEvents = 0;
51  nupdates = 0;
52  run=0;
53 
55 
56  // book the summary histogram
57  dbe->setCurrentFolder("DT/00-DataIntegrity");
58  summaryHisto = dbe->book2D("DataIntegritySummary","Summary Data Integrity",12,1,13,5,-2,3);
59  summaryHisto->setAxisTitle("Sector",1);
60  summaryHisto->setAxisTitle("Wheel",2);
61 
62  dbe->setCurrentFolder("DT/00-DataIntegrity");
63  summaryTDCHisto = dbe->book2D("DataIntegrityTDCSummary","TDC Summary Data Integrity",12,1,13,5,-2,3);
64  summaryTDCHisto->setAxisTitle("Sector",1);
65  summaryTDCHisto->setAxisTitle("Wheel",2);
66 
67  dbe->setCurrentFolder("DT/00-DataIntegrity");
68  glbSummaryHisto = dbe->book2D("DataIntegrityGlbSummary","Summary Data Integrity",12,1,13,5,-2,3);
69  glbSummaryHisto->setAxisTitle("Sector",1);
70  glbSummaryHisto->setAxisTitle("Wheel",2);
71 
72 }
73 
74 void DTDataIntegrityTest::beginRun(const Run& run, const EventSetup& context){
75 
76  context.get<DTReadOutMappingRcd>().get(mapping);
77 
78 }
79 
80 
81 
83 
84  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest]: Begin of LS transition";
85 
86  // Get the run number
87  run = lumiSeg.run();
88 
89 }
90 
91 
92 
93 void DTDataIntegrityTest::analyze(const Event& e, const EventSetup& context){
94  // count the analyzed events
95  nevents++;
96  if(nevents%1000 == 0)
97  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
98  << "[DTDataIntegrityTest]: "<<nevents<<" events";
99 }
100 
101 
102 
104 
105  // counts number of lumiSegs
106  nLumiSegs = lumiSeg.id().luminosityBlock();
107  stringstream nLumiSegs_s; nLumiSegs_s << nLumiSegs;
108 
109  // prescale factor
110  if (nLumiSegs%prescaleFactor != 0) return;
111 
112  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
113  <<"[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
114 
115 
116  // counts number of updats
117  nupdates++;
118 
119 
120  //Counter for x bin in the timing histos
121  counter++;
122 
123  //Loop on FED id
124  for (int dduId=FEDNumbering::MINDTFEDID; dduId<=FEDNumbering::MAXDTFEDID; ++dduId){
125  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
126  <<"[DTDataIntegrityTest]:FED Id: "<<dduId;
127 
128  //Each nTimeBin onUpdate remove timing histos and book a new bunch of them
129  stringstream dduId_s; dduId_s << dduId;
130 
131  string histoType;
132 
133  //Check if the list of ROS is compatible with the channels enabled
134  string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_ROSStatus";
135  MonitorElement * FED_ROSStatus = dbe->get(rosStatusName);
136 
137  // Get the error summary histo
138  string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
139  MonitorElement * FED_ROSSummary = dbe->get(fedSummaryName);
140 
141  // Get the event lenght plot (used to counr # of processed evts)
142  string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_EventLenght";
143  MonitorElement * FED_EvLenght = dbe->get(fedEvLenName);
144 
145  // Get the histos for FED integrity
146  string fedIntegrityFolder = "DT/FEDIntegrity/";
147  MonitorElement * hFEDEntry = dbe->get(fedIntegrityFolder+"FEDEntries");
148  MonitorElement * hFEDFatal = dbe->get(fedIntegrityFolder+"FEDFatal");
149  MonitorElement * hFEDNonFatal = dbe->get(fedIntegrityFolder+"FEDNonFatal");
150 
151  if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
152 
153  if(FED_ROSSummary && FED_ROSStatus && FED_EvLenght) {
154  TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
155  TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
156  TH1F * histoEvLenght = FED_EvLenght->getTH1F();
157  // Check that the FED is in the ReadOut using the FEDIntegrity histos
158  bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
159  hFEDFatal->getBinContent(dduId-769) == 0 &&
160  hFEDNonFatal->getBinContent(dduId-769) == 0);
161  int nFEDEvts = histoEvLenght->Integral();
162  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) { // loop on the ROS
163  int wheelNumber, sectorNumber;
164  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
165  int result = -2;
166  float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
167  nErrors += histoROSStatus->Integral(2,8,rosNumber,rosNumber);
168  if(nErrors == 0) { // no errors
169  result = 0;
170  } else { // there are errors
171  result = 2;
172  }
173  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
174  int tdcResult = -2;
175  float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
176  if(nTDCErrors == 0) { // no errors
177  tdcResult = 0;
178  } else { // there are errors
179  tdcResult = 2;
180  }
181  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
182  // FIXME: different errors should have different weights
183  float sectPerc = max((float)0., ((float)nFEDEvts-nErrors)/(float)nFEDEvts);
184  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
185 
186  if(fedNotReadout) {
187  // no data in this FED: it is off
188  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
189  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
190  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
191  }
192  }
193  }
194 
195  } else { // no data in this FED: it is off
196  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
197  int wheelNumber, sectorNumber;
198  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
199  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
200  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
201  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
202  }
203  }
204  }
205 
206  }
207 
208  }
209 
210 }
211 
212 
213 
215 
216  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
217 
218 // dbe->rmdir("DT/DTDataIntegrity");
219 }
220 
221 
222 
223 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
224  //Use the DDU name to find the ME
225  stringstream dduID_s; dduID_s << FEDId;
226 
227  string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
228 
229  string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
230  return histoName;
231 }
232 
233 
234 
235 void DTDataIntegrityTest::bookHistos(string histoType, int dduId){
236  stringstream dduId_s; dduId_s << dduId;
237  dbe->setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
238  string histoName;
239 
240 }
241 
242 
243 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
244 
245  int dummy;
246  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
247 
248 }
249 
LuminosityBlockID id() const
void beginJob()
BeginJob.
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * summaryTDCHisto
DTDataIntegrityTest(const edm::ParameterSet &ps)
Constructor.
~DTDataIntegrityTest()
Destructor.
MonitorElement * glbSummaryHisto
std::string getMEName(std::string histoType, int FEDId)
Get the ME name.
const T & max(const T &a, const T &b)
tuple result
Definition: query.py:137
RunNumber_t run() const
int nevents
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1696
MonitorElement * summaryHisto
#define LogTrace(id)
int readOutToGeometry(int dduId, int rosNumber, int &wheel, int &sector)
edm::ESHandle< DTReadOutMapping > mapping
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
DQM Client Diagnostic.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
const T & get() const
Definition: EventSetup.h:55
void bookHistos(std::string histoType, int dduId)
Book the MEs.
TH1F * getTH1F(void) const
LuminosityBlockNumber_t luminosityBlock() const
double getBinContent(int binx) const
get content of bin (1-D)
void beginRun(const edm::Run &run, const edm::EventSetup &c)
BeginRun.
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1070
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
def wheelNumber
Definition: plotscripts.py:45
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41