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  * $Date: 2010/07/14 15:36:39 $
6  * $Revision: 1.36 $
7  * \author S. Bolognesi - CERN
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 
38 }
39 
40 
42 
43  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "DataIntegrityTest: analyzed " << nupdates << " updates";
44 
45 }
46 
47 
49 
50  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: BeginJob";
51 
52  //nSTAEvents = 0;
53  nupdates = 0;
54  run=0;
55 
57 
58  // book the summary histogram
59  dbe->setCurrentFolder("DT/00-DataIntegrity");
60  summaryHisto = dbe->book2D("DataIntegritySummary","Summary Data Integrity",12,1,13,5,-2,3);
61  summaryHisto->setAxisTitle("Sector",1);
62  summaryHisto->setAxisTitle("Wheel",2);
63 
64  dbe->setCurrentFolder("DT/00-DataIntegrity");
65  summaryTDCHisto = dbe->book2D("DataIntegrityTDCSummary","TDC Summary Data Integrity",12,1,13,5,-2,3);
66  summaryTDCHisto->setAxisTitle("Sector",1);
67  summaryTDCHisto->setAxisTitle("Wheel",2);
68 
69  dbe->setCurrentFolder("DT/00-DataIntegrity");
70  glbSummaryHisto = dbe->book2D("DataIntegrityGlbSummary","Summary Data Integrity",12,1,13,5,-2,3);
71  glbSummaryHisto->setAxisTitle("Sector",1);
72  glbSummaryHisto->setAxisTitle("Wheel",2);
73 
74 }
75 
76 void DTDataIntegrityTest::beginRun(const Run& run, const EventSetup& context){
77 
78  context.get<DTReadOutMappingRcd>().get(mapping);
79 
80 }
81 
82 
83 
85 
86  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest]: Begin of LS transition";
87 
88  // Get the run number
89  run = lumiSeg.run();
90 
91 }
92 
93 
94 
95 void DTDataIntegrityTest::analyze(const Event& e, const EventSetup& context){
96  // count the analyzed events
97  nevents++;
98  if(nevents%1000 == 0)
99  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
100  << "[DTDataIntegrityTest]: "<<nevents<<" events";
101 }
102 
103 
104 
106 
107  // counts number of lumiSegs
108  nLumiSegs = lumiSeg.id().luminosityBlock();
109  stringstream nLumiSegs_s; nLumiSegs_s << nLumiSegs;
110 
111  // prescale factor
112  if (nLumiSegs%prescaleFactor != 0) return;
113 
114  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
115  <<"[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
116 
117 
118  // counts number of updats
119  nupdates++;
120 
121 
122  //Counter for x bin in the timing histos
123  counter++;
124 
125  //Loop on FED id
126  for (int dduId=FEDNumbering::MINDTFEDID; dduId<=FEDNumbering::MAXDTFEDID; ++dduId){
127  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
128  <<"[DTDataIntegrityTest]:FED Id: "<<dduId;
129 
130  //Each nTimeBin onUpdate remove timing histos and book a new bunch of them
131  stringstream dduId_s; dduId_s << dduId;
132 
133  string histoType;
134 
135  //Check if the list of ROS is compatible with the channels enabled
136  string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_ROSStatus";
137  MonitorElement * FED_ROSStatus = dbe->get(rosStatusName);
138 
139  // Fill the summary histo
140  // Get the error summary histo
141  string wheelSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
142  MonitorElement * FED_ROSSummary = dbe->get(wheelSummaryName);
143 
144  // Get the histos for FED integrity
145  string fedIntegrityFolder = "DT/FEDIntegrity_DT/";
146  MonitorElement * hFEDEntry = dbe->get(fedIntegrityFolder+"FEDEntries");
147  MonitorElement * hFEDFatal = dbe->get(fedIntegrityFolder+"FEDFatal");
148  MonitorElement * hFEDNonFatal = dbe->get(fedIntegrityFolder+"FEDNonFatal");
149 
150  if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
151 
152  if(FED_ROSSummary && FED_ROSStatus) {
153  TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
154  TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
155  // Check that the FED is in the ReadOut using the FEDIntegrity histos
156  bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
157  hFEDFatal->getBinContent(dduId-769) == 0 &&
158  hFEDNonFatal->getBinContent(dduId-769) == 0);
159  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) { // loop on the ROS
160  int wheelNumber, sectorNumber;
161  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
162  int result = -2;
163  float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
164  nErrors += histoROSStatus->Integral(2,8,rosNumber,rosNumber);
165  //nErrors += histoROSStatus->Integral(10,12,rosNumber,rosNumber); Ev Id Mismatch triggers to many minor errors
166  if(nErrors == 0) { // no errors
167  result = 0;
168  } else { // there are errors
169  result = 2;
170  }
171  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
172  int tdcResult = -2;
173  float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
174  if(nTDCErrors == 0) { // no errors
175  tdcResult = 0;
176  } else { // there are errors
177  tdcResult = 2;
178  }
179  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
180  // FIXME: different errors should have different weights
181  float sectPerc = max((float)0., ((float)nevents-nErrors)/(float)nevents);
182  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
183 
184  if(fedNotReadout) {
185  // no data in this FED: it is off
186  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
187  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
188  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
189  }
190  }
191  }
192 
193  } else { // no data in this FED: it is off
194  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
195  int wheelNumber, sectorNumber;
196  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
197  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
198  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
199  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
200  }
201  }
202  }
203 
204  }
205 
206  }
207 
208 }
209 
210 
211 
213 
214  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
215 
216 // dbe->rmdir("DT/DTDataIntegrity");
217 }
218 
219 
220 
221 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
222  //Use the DDU name to find the ME
223  stringstream dduID_s; dduID_s << FEDId;
224 
225  string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
226 
227  string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
228  return histoName;
229 }
230 
231 
232 
233 void DTDataIntegrityTest::bookHistos(string histoType, int dduId){
234  stringstream dduId_s; dduId_s << dduId;
235  dbe->setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
236  string histoName;
237 
238 }
239 
240 
241 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
242 
243  int dummy;
244  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
245 
246 }
247 
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:1270
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.
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:647
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:42
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31