CMS 3D CMS Logo

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