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: 2011/07/29 16:23:07 $
6  * $Revision: 1.39 $
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  // Get the error summary histo
140  string fedSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
141  MonitorElement * FED_ROSSummary = dbe->get(fedSummaryName);
142 
143  // Get the event lenght plot (used to counr # of processed evts)
144  string fedEvLenName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_EventLenght";
145  MonitorElement * FED_EvLenght = dbe->get(fedEvLenName);
146 
147  // Get the histos for FED integrity
148  string fedIntegrityFolder = "DT/FEDIntegrity/";
149  MonitorElement * hFEDEntry = dbe->get(fedIntegrityFolder+"FEDEntries");
150  MonitorElement * hFEDFatal = dbe->get(fedIntegrityFolder+"FEDFatal");
151  MonitorElement * hFEDNonFatal = dbe->get(fedIntegrityFolder+"FEDNonFatal");
152 
153  if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
154 
155  if(FED_ROSSummary && FED_ROSStatus && FED_EvLenght) {
156  TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
157  TH2F * histoROSStatus = FED_ROSStatus->getTH2F();
158  TH1F * histoEvLenght = FED_EvLenght->getTH1F();
159  // Check that the FED is in the ReadOut using the FEDIntegrity histos
160  bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
161  hFEDFatal->getBinContent(dduId-769) == 0 &&
162  hFEDNonFatal->getBinContent(dduId-769) == 0);
163  int nFEDEvts = histoEvLenght->Integral();
164  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) { // loop on the ROS
165  int wheelNumber, sectorNumber;
166  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
167  int result = -2;
168  float nErrors = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
169  nErrors += histoROSStatus->Integral(2,8,rosNumber,rosNumber);
170  if(nErrors == 0) { // no errors
171  result = 0;
172  } else { // there are errors
173  result = 2;
174  }
175  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
176  int tdcResult = -2;
177  float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber);
178  if(nTDCErrors == 0) { // no errors
179  tdcResult = 0;
180  } else { // there are errors
181  tdcResult = 2;
182  }
183  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
184  // FIXME: different errors should have different weights
185  float sectPerc = max((float)0., ((float)nFEDEvts-nErrors)/(float)nFEDEvts);
186  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
187 
188  if(fedNotReadout) {
189  // no data in this FED: it is off
190  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
191  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
192  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
193  }
194  }
195  }
196 
197  } else { // no data in this FED: it is off
198  for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
199  int wheelNumber, sectorNumber;
200  if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
201  summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
202  summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
203  glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
204  }
205  }
206  }
207 
208  }
209 
210  }
211 
212 }
213 
214 
215 
217 
218  LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
219 
220 // dbe->rmdir("DT/DTDataIntegrity");
221 }
222 
223 
224 
225 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
226  //Use the DDU name to find the ME
227  stringstream dduID_s; dduID_s << FEDId;
228 
229  string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str();
230 
231  string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
232  return histoName;
233 }
234 
235 
236 
237 void DTDataIntegrityTest::bookHistos(string histoType, int dduId){
238  stringstream dduId_s; dduId_s << dduId;
239  dbe->setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
240  string histoName;
241 
242 }
243 
244 
245 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
246 
247  int dummy;
248  return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
249 
250 }
251 
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:1473
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:850
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:434
Definition: Run.h:36