CMS 3D CMS Logo

L1TTestsSummary.cc
Go to the documentation of this file.
2 
12 #include <cstdio>
13 #include <sstream>
14 #include <cmath>
15 #include <vector>
16 #include <TMath.h>
17 #include <climits>
18 #include <TFile.h>
19 #include <TDirectory.h>
20 #include <TProfile.h>
21 
22 using namespace std;
23 using namespace edm;
24 
25 //____________________________________________________________________________
26 // Function: L1TTestsSummary
27 // Description: This is the constructor, basic variable initialization
28 // Inputs:
29 // * const edm::ParameterSet& ps = Parameter for this analyzer
30 //____________________________________________________________________________
32 
33  if(mVerbose){cout << "[L1TTestsSummary:] Called constructor" << endl;}
34 
35  // Get parameters
36  mParameters = ps;
37  mVerbose = ps.getUntrackedParameter<bool>("verbose" ,true);
38  mMonitorL1TRate = ps.getUntrackedParameter<bool>("MonitorL1TRate" ,true);
39  mMonitorL1TSync = ps.getUntrackedParameter<bool>("MonitorL1TSync" ,true);
40  mMonitorL1TOccupancy = ps.getUntrackedParameter<bool>("MonitorL1TOccupancy",true);
41 
42  mL1TRatePath = ps.getUntrackedParameter<string>("L1TRatePath" ,"L1T/L1TRate/Certification/");
43  mL1TSyncPath = ps.getUntrackedParameter<string>("L1TSyncPath" ,"L1T/L1TSync/Certification/");
44  mL1TOccupancyPath = ps.getUntrackedParameter<string>("L1TOccupancyPath","L1T/L1TOccupancy/Certification/");
45 }
46 
47 //____________________________________________________________________________
48 // Function: ~L1TTestsSummary
49 // Description: This is the destructor, basic variable deletion
50 //____________________________________________________________________________
52  if(mVerbose){cout << "[L1TTestsSummary:] Called destructor" << endl;}
53 }
54 
55 //____________________________________________________________________________
56 // Function: beginRun
57 // Description: This is will be run at the begining of each run
58 // Inputs:
59 // * const Run& r = Run information
60 // * const EventSetup& context = Event Setup information
61 //____________________________________________________________________________
63 
64  if(mVerbose){cout << "[L1TTestsSummary:] Called beginRun" << endl;}
65 
66  int maxLS = 2500;
67 
68  if(mMonitorL1TRate){
69 
70  if(mVerbose){cout << "[L1TTestsSummary:] Initializing L1TRate Module Monitoring" << endl;}
71 
72  igetter.setCurrentFolder(mL1TRatePath);
73  vector<string> histToMonitor = igetter.getMEs();
74  int histLines = histToMonitor.size()+1;
75 
76  ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
77  mL1TRateMonitor = ibooker.book2D("RateQualitySummary","L1T Rates Monitor Summary",maxLS,+0.5,double(maxLS)+0.5,histLines,0,histLines);
78  mL1TRateMonitor->setAxisTitle("Lumi Section" ,1);
79 
80  mL1TRateMonitor->setBinLabel(1,"Summary",2);
81  for(unsigned int i=0 ; i<histToMonitor.size() ; i++){
82  string name = igetter.get(mL1TRatePath+histToMonitor[i])->getTH1()->GetName();
83  mL1TRateMonitor->setBinLabel(i+2,name,2);
84  }
85  }
86  if(mMonitorL1TSync){
87 
88  if(mVerbose){cout << "[L1TTestsSummary:] Initializing L1TSync Module Monitoring" << endl;}
89 
90  igetter.setCurrentFolder(mL1TSyncPath);
91  vector<string> histToMonitor = igetter.getMEs();
92  int histLines = histToMonitor.size()+1;
93 
94  ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
95  mL1TSyncMonitor = ibooker.book2D("SyncQualitySummary","L1T Synchronization Monitor Summary",maxLS,0.5,double(maxLS)+0.5,histLines,0,histLines);
96  mL1TSyncMonitor->setAxisTitle("Lumi Section" ,1);
97 
98  mL1TSyncMonitor->setBinLabel(1,"Summary",2);
99  for(unsigned int i=0 ; i<histToMonitor.size() ; i++){
100  string name = igetter.get(mL1TSyncPath+histToMonitor[i])->getTH1()->GetName();
101  mL1TSyncMonitor->setBinLabel(i+2,name,2);
102  }
103 
104  }
105  if(mMonitorL1TOccupancy){
106 
107  if(mVerbose){cout << "[L1TTestsSummary:] Initializing L1TOccupancy Module Monitoring" << endl;}
108 
109  igetter.setCurrentFolder(mL1TOccupancyPath);
110  vector<string> histToMonitor = igetter.getMEs();
111  int histLines = histToMonitor.size()+1;
112 
113  ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
114  mL1TOccupancyMonitor = ibooker.book2D("OccupancySummary","L1T Occupancy Monitor Summary",maxLS,+0.5,double(maxLS)+0.5,histLines,0,histLines);
115  mL1TOccupancyMonitor->setAxisTitle("Lumi Section" ,1);
116 
117  mL1TOccupancyMonitor->setBinLabel(1,"Summary",2);
118  for(unsigned int i=0 ; i<histToMonitor.size() ; i++){
119  string name = igetter.get(mL1TOccupancyPath+histToMonitor[i])->getTH1()->GetName();
120  mL1TOccupancyMonitor->setBinLabel(i+2,name,2);
121  }
122  }
123 
124  //-> Making the summary of summaries
125  int testsToMonitor=1;
126  if(mMonitorL1TRate) {testsToMonitor++;}
127  if(mMonitorL1TSync) {testsToMonitor++;}
128  if(mMonitorL1TOccupancy){testsToMonitor++;}
129 
130  // Creating
131  ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
132  mL1TSummary = ibooker.book2D("L1TQualitySummary","L1 Tests Summary",maxLS,+0.5,double(maxLS)+0.5,testsToMonitor,0,testsToMonitor);
133  mL1TSummary->setAxisTitle("Lumi Section" ,1);
134  mL1TSummary->setBinLabel(1,"L1T Summary",2);
135 
136  int it=2;
137  if(mMonitorL1TRate) {mL1TSummary->setBinLabel(it,"Rates" ,2); binYRate =it; it++;}
138  if(mMonitorL1TSync) {mL1TSummary->setBinLabel(it,"Synchronization",2); binYSync =it; it++;}
139  if(mMonitorL1TOccupancy){mL1TSummary->setBinLabel(it,"Occupancy" ,2); binYOccpancy=it;}
140 
141 }
142 
143 //____________________________________________________________________________
144 // Function: endRun
145 // Description: This is will be run at the end of each run
146 // Inputs:
147 // * const Run& r = Run information
148 // * const EventSetup& context = Event Setup information
149 //____________________________________________________________________________
151 
152  book(ibooker, igetter);
153 
154  if(mVerbose){cout << "[L1TTestsSummary:] Called endRun()" << endl;}
155 
156  if(mMonitorL1TRate) {updateL1TRateMonitor(ibooker, igetter);}
157  if(mMonitorL1TSync) {updateL1TSyncMonitor(ibooker, igetter);}
158  if(mMonitorL1TOccupancy){updateL1TOccupancyMonitor(ibooker, igetter);}
159  updateL1TSummary(ibooker, igetter);
160 
161 }
162 
163 //____________________________________________________________________________
164 // Function: endLuminosityBlock
165 // Description: This is will be run at the end of each luminosity block
166 // Inputs:
167 // * const LuminosityBlock& lumiSeg = Luminosity Block information
168 // * const EventSetup& context = Event Setup information
169 //____________________________________________________________________________
171 
172  int eventLS = lumiSeg.id().luminosityBlock();
173 
174  book(ibooker, igetter);
175 
176  mProcessedLS.push_back(eventLS);
177 
178  if(mVerbose) {
179  cout << "[L1TTestsSummary:] Called endLuminosityBlock()" << endl;
180  cout << "[L1TTestsSummary:] Lumisection: " << eventLS << endl;
181  }
182 
183  if(mMonitorL1TRate) {updateL1TRateMonitor(ibooker, igetter);}
184  if(mMonitorL1TSync) {updateL1TSyncMonitor(ibooker, igetter);}
185  if(mMonitorL1TOccupancy){updateL1TOccupancyMonitor(ibooker, igetter);}
186  updateL1TSummary(ibooker, igetter);
187 
188 }
189 
190 //____________________________________________________________________________
191 // Function: updateL1TRateMonitor
192 // Description:
193 //____________________________________________________________________________
195 
196  igetter.setCurrentFolder(mL1TRatePath);
197  vector<string> histToMonitor = igetter.getMEs();
198 
199  for(unsigned int i=0 ; i<histToMonitor.size() ; i++){
200 
201  MonitorElement* me = igetter.get(mL1TRatePath+histToMonitor[i]);
202  if(mVerbose) {cout << "[L1TTestsSummary:] Found ME: " << me->getTH1()->GetName() << endl;}
203 
204  const QReport * myQReport = me->getQReport("L1TRateTest"); //get QReport associated to your ME
205  if(myQReport) {
206  float qtresult = myQReport->getQTresult(); // get QT result value
207  int qtstatus = myQReport->getStatus(); // get QT status value (see table below)
208  const string& qtmessage = myQReport->getMessage() ; // get the whole QT result message
209  vector<DQMChannel> qtBadChannels = myQReport->getBadChannels();
210 
211  if(mVerbose) {
212  cout << "[L1TTestsSummary:] Found QReport for ME: " << me->getTH1()->GetName() << endl;
213  cout << "[L1TTestsSummary:] Result=" << qtresult << " status=" << qtstatus << " message=" << qtmessage << endl;
214  cout << "[L1TTestsSummary:] Bad Channels size=" << qtBadChannels.size() << endl;
215  }
216 
217  for(unsigned int i=0 ; i<mProcessedLS.size()-1 ; i++){
218  int binx = mL1TRateMonitor->getTH2F()->GetXaxis()->FindBin(mProcessedLS[i]);
219  int biny = mL1TRateMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
220  mL1TRateMonitor->setBinContent(binx,biny,100);
221  }
222 
223  for(unsigned int a=0 ; a<qtBadChannels.size() ; a++){
224  for(unsigned int b=0 ; b<mProcessedLS.size()-1 ; b++){
225 
226  // Converting bin to value
227  double valueBinBad = me->getTH1()->GetBinCenter(qtBadChannels[a].getBin());
228 
229  if(valueBinBad==(mProcessedLS[b])){
230  int binx = mL1TRateMonitor->getTH2F()->GetXaxis()->FindBin(valueBinBad);
231  int biny = mL1TRateMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
232  mL1TRateMonitor->setBinContent(binx,biny,300);
233  }
234  }
235  }
236  }
237  }
238 
239  //-> Filling the summaries
240  int nBinX = mL1TRateMonitor->getTH2F()->GetXaxis()->GetNbins();
241  int nBinY = mL1TRateMonitor->getTH2F()->GetYaxis()->GetNbins();
242  for(int binx=1; binx<=nBinX ; binx++){
243  int GlobalStatus=0;
244  for(int biny=2; biny<=nBinY ; biny++){
245  double flag = mL1TRateMonitor->getBinContent(binx,biny);
246  if(GlobalStatus<flag){GlobalStatus=flag;}
247  }
248 
249  // NOTE: Assumes mL1TSummary has same size then mL1TRateMonitor
250  mL1TRateMonitor->setBinContent(binx, 1,GlobalStatus);
251  mL1TSummary ->setBinContent(binx,binYRate,GlobalStatus);
252  }
253 }
254 
255 //____________________________________________________________________________
256 // Function: updateL1TSyncMonitor
257 // Description:
258 // Note: Values certified by L1TRates are always about currentLS-1 since we
259 // use rate averages from the previous LS from GT
260 //____________________________________________________________________________
262 
263  igetter.setCurrentFolder(mL1TSyncPath);
264  vector<string> histToMonitor = igetter.getMEs();
265 
266  for(unsigned int i=0 ; i<histToMonitor.size() ; i++){
267 
268  MonitorElement* me = igetter.get(mL1TSyncPath+histToMonitor[i]);
269  if(mVerbose) {cout << "[L1TTestsSummary:] Found ME: " << me->getTH1()->GetName() << endl;}
270 
271  const QReport * myQReport = me->getQReport("L1TSyncTest"); //get QReport associated to your ME
272  if(myQReport) {
273  float qtresult = myQReport->getQTresult(); // get QT result value
274  int qtstatus = myQReport->getStatus(); // get QT status value (see table below)
275  const string& qtmessage = myQReport->getMessage() ; // get the whole QT result message
276  vector<DQMChannel> qtBadChannels = myQReport->getBadChannels();
277 
278  if(mVerbose) {
279  cout << "[L1TTestsSummary:] Found QReport for ME: " << me->getTH1()->GetName() << endl;
280  cout << "[L1TTestsSummary:] Result=" << qtresult << " status=" << qtstatus << " message=" << qtmessage << endl;
281  cout << "[L1TTestsSummary:] Bad Channels size=" << qtBadChannels.size() << endl;
282  }
283 
284  for(unsigned int i=0 ; i<mProcessedLS.size() ; i++){
285  int binx = mL1TSyncMonitor->getTH2F()->GetXaxis()->FindBin(mProcessedLS[i]);
286  int biny = mL1TSyncMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
287  mL1TSyncMonitor->setBinContent(binx,biny,100);
288  }
289 
290  for(unsigned int a=0 ; a<qtBadChannels.size() ; a++){
291  for(unsigned int b=0 ; b<mProcessedLS.size() ; b++){
292 
293  // Converting bin to value
294  double valueBinBad = me->getTH1()->GetBinCenter(qtBadChannels[a].getBin());
295 
296  if(valueBinBad==mProcessedLS[b]){
297  int binx = mL1TSyncMonitor->getTH2F()->GetXaxis()->FindBin(valueBinBad);
298  int biny = mL1TSyncMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
299  mL1TSyncMonitor->setBinContent(binx,biny,300);
300  }
301  }
302  }
303  }
304  }
305 
306  //-> Filling the summaries
307  int nBinX = mL1TSyncMonitor->getTH2F()->GetXaxis()->GetNbins();
308  int nBinY = mL1TSyncMonitor->getTH2F()->GetYaxis()->GetNbins();
309  for(int binx=1; binx<=nBinX ; binx++){
310  int GlobalStatus=0;
311  for(int biny=2; biny<=nBinY ; biny++){
312  double flag = mL1TSyncMonitor->getBinContent(binx,biny);
313  if(GlobalStatus<flag){GlobalStatus=flag;}
314  }
315 
316  // NOTE: Assumes mL1TSummary has same size then mL1TSyncMonitor
317  mL1TSyncMonitor->setBinContent(binx, 1,GlobalStatus);
318  mL1TSummary ->setBinContent(binx,binYSync,GlobalStatus);
319  }
320 }
321 
322 //____________________________________________________________________________
323 // Function: updateL1TOccupancyMonitor
324 // Description:
325 //____________________________________________________________________________
327 
328  igetter.setCurrentFolder(mL1TOccupancyPath);
329  vector<string> histToMonitor = igetter.getMEs();
330 
331  for(unsigned int i=0 ; i<histToMonitor.size() ; i++){
332 
333  MonitorElement* me = igetter.get(mL1TOccupancyPath+histToMonitor[i]);
334  if(mVerbose) {cout << "[L1TTestsSummary:] Found ME: " << me->getTH1()->GetName() << endl;}
335 
336  const QReport * myQReport = me->getQReport("L1TOccupancyTest"); //get QReport associated to your ME
337  if(myQReport) {
338  float qtresult = myQReport->getQTresult(); // get QT result value
339  int qtstatus = myQReport->getStatus(); // get QT status value (see table below)
340  const string& qtmessage = myQReport->getMessage() ; // get the whole QT result message
341  vector<DQMChannel> qtBadChannels = myQReport->getBadChannels();
342 
343  if(mVerbose) {
344  cout << "[L1TTestsSummary:] Found QReport for ME: " << me->getTH1()->GetName() << endl;
345  cout << "[L1TTestsSummary:] Result=" << qtresult << " status=" << qtstatus << " message=" << qtmessage << endl;
346  cout << "[L1TTestsSummary:] Bad Channels size=" << qtBadChannels.size() << endl;
347  }
348 
349  for(unsigned int i=0 ; i<mProcessedLS.size() ; i++){
350  int binx = mL1TOccupancyMonitor->getTH2F()->GetXaxis()->FindBin(mProcessedLS[i]);
351  int biny = mL1TOccupancyMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
352  mL1TOccupancyMonitor->setBinContent(binx,biny,100);
353  }
354 
355  for(unsigned int a=0 ; a<qtBadChannels.size() ; a++){
356  for(unsigned int b=0 ; b<mProcessedLS.size() ; b++){
357 
358  // Converting bin to value
359  double valueBinBad = me->getTH1()->GetBinCenter(qtBadChannels[a].getBin());
360 
361  if(valueBinBad==mProcessedLS[b]){
362  int binx = mL1TOccupancyMonitor->getTH2F()->GetXaxis()->FindBin(valueBinBad);
363  int biny = mL1TOccupancyMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
364  mL1TOccupancyMonitor->setBinContent(binx,biny,300);
365  }
366  }
367  }
368  }
369  }
370 
371  //-> Filling the summaries
372  int nBinX = mL1TOccupancyMonitor->getTH2F()->GetXaxis()->GetNbins();
373  int nBinY = mL1TOccupancyMonitor->getTH2F()->GetYaxis()->GetNbins();
374  for(int binx=1; binx<=nBinX ; binx++){
375  int GlobalStatus=0;
376  for(int biny=2; biny<=nBinY ; biny++){
377  double flag = mL1TOccupancyMonitor->getBinContent(binx,biny);
378  if(GlobalStatus<flag){GlobalStatus=flag;}
379  }
380 
381  // NOTE: Assumes mL1TSummary has same size then mL1TOccupancyMonitor
382  mL1TOccupancyMonitor->setBinContent(binx, 1,GlobalStatus);
383  mL1TSummary ->setBinContent(binx,binYOccpancy,GlobalStatus);
384  }
385 }
386 
387 //____________________________________________________________________________
388 // Function: updateL1TOccupancyMonitor
389 // Description:
390 //____________________________________________________________________________
392 
393  int nBinX = mL1TSummary->getTH2F()->GetXaxis()->GetNbins();
394  for(int binx=1; binx<=nBinX ; binx++){
395  int GlobalStatus=0;
396  if(mMonitorL1TRate){
397  if(mL1TSummary->getBinContent(binx,binYRate)>GlobalStatus){
398  GlobalStatus=mL1TSummary->getBinContent(binx,binYRate);
399  }
400  }
401  if(mMonitorL1TSync) {
402  if(mL1TSummary->getBinContent(binx,binYSync)>GlobalStatus){
403  GlobalStatus=mL1TSummary->getBinContent(binx,binYSync);
404  }
405  }
406  if(mMonitorL1TOccupancy){
407  if(mL1TSummary->getBinContent(binx,binYOccpancy)>GlobalStatus){
408  GlobalStatus=mL1TSummary->getBinContent(binx,binYOccpancy);
409  }
410  }
411  mL1TSummary->setBinContent(binx,1,GlobalStatus);
412  }
413 }
414 
415 //define this as a plug-in
LuminosityBlockID id() const
void updateL1TRateMonitor(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
T getUntrackedParameter(std::string const &, T const &) const
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to <qtname> (null pointer if QReport does not exist)
~L1TTestsSummary() override
const std::vector< DQMChannel > & getBadChannels() const
Definition: QReport.h:33
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
void updateL1TSummary(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TH1 * getTH1() const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:361
virtual void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void updateL1TOccupancyMonitor(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
const std::string & getMessage() const
get message attached to test
Definition: QReport.h:24
int getBin(double x, std::vector< double > boundaries)
Definition: Utilities.h:512
void updateL1TSyncMonitor(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
double b
Definition: hdecay.h:120
LuminosityBlockNumber_t luminosityBlock() const
int getStatus() const
get test status (see Core/interface/QTestStatus.h)
Definition: QReport.h:16
HLT enums.
L1TTestsSummary(const edm::ParameterSet &ps)
double a
Definition: hdecay.h:121
float getQTresult() const
get test result i.e. prob value
Definition: QReport.h:20
std::vector< std::string > getMEs()
Definition: DQMStore.cc:331
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)