CMS 3D CMS Logo

SiPixelDataQuality.cc
Go to the documentation of this file.
1 
12 
14 
17 
23 
26 
32 
33 #include "Rtypes.h"
34 #include "TAxis.h"
35 #include "TClass.h"
36 #include "TH1F.h"
37 #include "TH2F.h"
38 #include "TImage.h"
39 #include "TImageDump.h"
40 #include "TPad.h"
41 #include "TPaveLabel.h"
42 #include "TPaveText.h"
43 #include "TProfile.h"
44 #include "TROOT.h"
45 #include "TRandom.h"
46 #include "TStopwatch.h"
47 #include "TString.h"
48 #include "TStyle.h"
49 #include "TSystem.h"
50 #include "TText.h"
51 
52 #include <cmath>
53 #include <iostream>
54 #include <map>
55 
56 #include <cstdlib> // for free() - Root can allocate with malloc() - sigh...
57 #include <fstream>
58 
59 using namespace std;
60 using namespace edm;
61 
62 //------------------------------------------------------------------------------
66 SiPixelDataQuality::SiPixelDataQuality(bool offlineXMLfile) : offlineXMLfile_(offlineXMLfile) {
67  edm::LogInfo("SiPixelDataQuality") << " Creating SiPixelDataQuality "
68  << "\n";
69 
70  allMods_ = 0;
71  errorMods_ = 0;
72  qflag_ = 1.;
73 
74  allmodsMap = nullptr;
75  errmodsMap = nullptr;
76  goodmodsMap = nullptr;
77  allmodsVec = nullptr;
78  errmodsVec = nullptr;
79  goodmodsVec = nullptr;
80  for (int i = 0; i < 40; ++i) {
81  lastallmods_[i] = 0;
82  lasterrmods_[i] = 0;
83  }
84  timeoutCounter_ = 0;
85  lastLS_ = -1;
86 }
87 
88 //------------------------------------------------------------------------------
93  edm::LogInfo("SiPixelDataQuality") << " Deleting SiPixelDataQuality "
94  << "\n";
95  if (allmodsMap)
96  delete allmodsMap;
97  if (errmodsMap)
98  delete errmodsMap;
99  if (goodmodsMap)
100  delete goodmodsMap;
101  if (allmodsVec)
102  delete allmodsVec;
103  if (errmodsVec)
104  delete errmodsVec;
105  if (goodmodsVec)
106  delete goodmodsVec;
107 }
108 
109 //------------------------------------------------------------------------------
115  const string &mEName = mE->getName();
116 
117  int detId = 0;
118 
119  if (mEName.find("_3") != string::npos) {
120  string detIdString = mEName.substr((mEName.find_last_of('_')) + 1, 9);
121  std::istringstream isst;
122  isst.str(detIdString);
123  isst >> detId;
124  }
125 
126  return detId;
127 }
128 
130 
132  // std::cout<<"BOOK GLOBAL QUALITY FLAG MEs!"<<std::endl;
133  iBooker.cd();
134 
135  iBooker.setCurrentFolder("Pixel/Barrel");
136  if (!Tier0Flag) {
137  ClusterModAll = iBooker.book1D("NClustertoChargeRatio_AllMod", "Cluster Noise All Modules", 768, 0., 768.);
138  ClusterMod1 = iBooker.book1D(
139  "NClustertoChargeRatio_NormMod1", "Normalized N_{Clusters} to Charge Ratio per Module1", 192, 0., 192.);
140  ClusterMod2 = iBooker.book1D(
141  "NClustertoChargeRatio_NormMod2", "Normalized N_{Clusters} to Charge Ratio per Module2", 192, 0., 192.);
142  ClusterMod3 = iBooker.book1D(
143  "NClustertoChargeRatio_NormMod3", "Normalized N_{Clusters} to Charge Ratio per Module3", 192, 0., 192.);
144  ClusterMod4 = iBooker.book1D(
145  "NClustertoChargeRatio_NormMod4", "Normalized N_{Clusters} to Charge Ratio per Module4", 192, 0., 192.);
146  }
147  iBooker.setCurrentFolder("Pixel/EventInfo");
148  if (!Tier0Flag) {
149  SummaryReportMap = iBooker.book2D("reportSummaryMap", "Pixel Summary Map", 3000, 0., 3000., 40, 0., 40.);
150  SummaryReportMap->setAxisTitle("Lumi Section", 1);
151  SummaryReportMap->setAxisTitle("Pixel FED #", 2);
152  allmodsVec = new TH1D("allmodsVec", "allmodsVec", 40, 0., 40.);
153  errmodsVec = new TH1D("errmodsVec", "errmodsVec", 40, 0., 40.);
154  goodmodsVec = new TH1D("goodmodsVec", "goodmodsVec", 40, 0., 40.);
155  } else {
156  SummaryReportMap = iBooker.book2D("reportSummaryMap", "Pixel Summary Map", 2, 0., 2., 7, 0., 7.);
157  SummaryReportMap->setBinLabel(1, "Barrel", 1);
158  SummaryReportMap->setBinLabel(2, "Endcaps", 1);
159  SummaryReportMap->setBinLabel(1, "Errors", 2);
160  SummaryReportMap->setBinLabel(2, "NDigis", 2);
161  SummaryReportMap->setBinLabel(3, "DigiCharge", 2);
162  SummaryReportMap->setBinLabel(4, "ClusterSize", 2);
163  SummaryReportMap->setBinLabel(5, "NClusters", 2);
164  SummaryReportMap->setBinLabel(6, "ClusterCharge", 2);
165  SummaryReportMap->setBinLabel(7, "HitEff", 2);
166  allmodsMap = new TH2F("allmodsMap", "allmodsMap", 2, 0., 2., 7, 0., 7.);
167  errmodsMap = new TH2F("errmodsMap", "errmodsMap", 2, 0., 2., 7, 0., 7.);
168  goodmodsMap = new TH2F("goodmodsMap", "goodmodsMap", 2, 0., 2., 7, 0., 7.);
169  }
170  SummaryPixel = iBooker.bookFloat("reportSummary");
171  iBooker.setCurrentFolder("Pixel/EventInfo/reportSummaryContents");
172  SummaryBarrel = iBooker.bookFloat("PixelBarrelFraction");
173  SummaryEndcap = iBooker.bookFloat("PixelEndcapFraction");
174  // book the data certification cuts:
175  iBooker.setCurrentFolder("Pixel/AdditionalPixelErrors");
176  NErrorsFEDs = iBooker.bookFloat("FEDsNErrorsCut");
177  iBooker.setCurrentFolder("Pixel/Barrel");
178  NErrorsBarrel = iBooker.bookFloat("BarrelNErrorsCut");
179  NDigisBarrel = iBooker.bookInt("BarrelNDigisCut");
180  DigiChargeBarrel = iBooker.bookInt("BarrelDigiChargeCut");
181  ClusterSizeBarrel = iBooker.bookInt("BarrelClusterSizeCut");
182  NClustersBarrel = iBooker.bookInt("BarrelNClustersCut");
183  ClusterChargeBarrel = iBooker.bookInt("BarrelClusterChargeCut");
184  iBooker.setCurrentFolder("Pixel/Endcap");
185  NErrorsEndcap = iBooker.bookFloat("EndcapNErrorsCut");
186  NDigisEndcap = iBooker.bookInt("EndcapNDigisCut");
187  DigiChargeEndcap = iBooker.bookInt("EndcapDigiChargeCut");
188  ClusterSizeEndcap = iBooker.bookInt("EndcapClusterSizeCut");
189  NClustersEndcap = iBooker.bookInt("EndcapNClustersCut");
190  ClusterChargeEndcap = iBooker.bookInt("EndcapClusterChargeCut");
191  if (Tier0Flag) {
192  iBooker.setCurrentFolder("Pixel/Tracks");
193  NPixelTracks = iBooker.bookInt("PixelTracksCut");
194  }
195 
196  // Init MonitoringElements:
197  if (nFEDs > 0) {
198  if (SummaryPixel)
199  SummaryPixel->Fill(1.);
200  if (SummaryBarrel)
201  SummaryBarrel->Fill(1.);
202  if (SummaryEndcap)
203  SummaryEndcap->Fill(1.);
204  } else {
205  if (SummaryPixel)
206  SummaryPixel->Fill(-1.);
207  if (SummaryBarrel)
208  SummaryBarrel->Fill(-1.);
209  if (SummaryEndcap)
210  SummaryEndcap->Fill(-1.);
211  }
212  if (NErrorsBarrel)
213  NErrorsBarrel->Fill(1.);
214  if (NErrorsEndcap)
215  NErrorsEndcap->Fill(1.);
216  if (NErrorsFEDs)
217  NErrorsFEDs->Fill(1.);
218  if (NDigisBarrel)
219  NDigisBarrel->Fill(1);
220  if (NDigisEndcap)
221  NDigisEndcap->Fill(1);
222  if (DigiChargeBarrel)
224  if (DigiChargeEndcap)
226  if (ClusterSizeBarrel)
228  if (ClusterSizeEndcap)
234  if (NClustersBarrel)
235  NClustersBarrel->Fill(1);
236  if (NClustersEndcap)
237  NClustersEndcap->Fill(1);
238  if (Tier0Flag) {
239  if (NPixelTracks)
240  NPixelTracks->Fill(1);
241  }
242 
243  if (SummaryReportMap) {
244  if (!Tier0Flag)
245  for (int i = 1; i != 3001; i++)
246  for (int j = 1; j != 41; j++)
248  if (Tier0Flag)
249  for (int i = 1; i != 3; i++)
250  for (int j = 1; j != 8; j++)
252  }
253  if (!Tier0Flag) {
254  for (int j = 1; j != 41; j++) {
255  if (allmodsVec)
256  allmodsVec->SetBinContent(j, 0.);
257  if (errmodsVec)
258  errmodsVec->SetBinContent(j, 0.);
259  if (goodmodsVec)
260  goodmodsVec->SetBinContent(j, 0.);
261  }
262  }
263  if (Tier0Flag) {
264  for (int i = 1; i != 3; i++)
265  for (int j = 1; j != 8; j++) {
266  if (allmodsMap)
267  allmodsMap->SetBinContent(i, j, 0.);
268  if (errmodsMap)
269  errmodsMap->SetBinContent(i, j, 0.);
270  if (goodmodsMap)
271  goodmodsMap->SetBinContent(i, j, 0.);
272  }
273  }
274 
275  iBooker.cd();
276 }
277 
278 //**********************************************************************************************
279 
281  DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool init, int nFEDs, bool Tier0Flag) {
282  if (init) {
283  allMods_ = 0;
284  errorMods_ = 0;
285  qflag_ = 0.;
286  barrelMods_ = 0;
287  endcapMods_ = 0;
288  objectCount_ = 0;
289  DONE_ = false;
290 
291  // Error counters and flags:
292  n_errors_barrel_ = 0;
293  barrel_error_flag_ = 0.;
294  n_errors_endcap_ = 0;
295  endcap_error_flag_ = 0.;
296  n_errors_pixel_ = 0;
297  pixel_error_flag_ = 0.;
298  digiStatsBarrel = false, clusterStatsBarrel = false, trackStatsBarrel = false;
300  digiStatsEndcap = false, clusterStatsEndcap = false, trackStatsEndcap = false;
302  init = false;
303  }
304  if (nFEDs == 0)
305  return;
306 
307  string currDir = iBooker.pwd();
308  string dname = currDir.substr(currDir.find_last_of('/') + 1);
309 
310  if ((!Tier0Flag && dname.find("Module_") != string::npos) ||
311  (Tier0Flag && (dname.find("Ladder_") != string::npos || dname.find("Blade_") != string::npos))) {
312  objectCount_++;
313 
314  if (currDir.find("Pixel") != string::npos)
315  allMods_++;
316  if (currDir.find("Barrel") != string::npos)
317  barrelMods_++;
318  if (currDir.find("Endcap") != string::npos)
319  endcapMods_++;
320  vector<string> meVec = iGetter.getMEs();
321  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
322  string full_path = currDir + "/" + (*it);
323  if (full_path.find("ndigis_") != string::npos) {
324  MonitorElement *me = iGetter.get(full_path);
325  if (!me)
326  continue;
327  if (me->getEntries() > 25) {
328  if (full_path.find("Barrel") != string::npos)
330  if (full_path.find("Endcap") != string::npos)
332  }
333  } else if (Tier0Flag && full_path.find("nclusters_OnTrack_") != string::npos) {
334  MonitorElement *me = iGetter.get(full_path);
335  if (!me)
336  continue;
337  if (me->getEntries() > 25) {
338  if (full_path.find("Barrel") != string::npos)
340  if (full_path.find("Endcap") != string::npos)
342  }
343  } else if (!Tier0Flag && full_path.find("nclusters_") != string::npos) {
344  MonitorElement *me = iGetter.get(full_path);
345  if (!me)
346  continue;
347  if (me->getEntries() > 25) {
348  if (full_path.find("Barrel") != string::npos)
350  if (full_path.find("Endcap") != string::npos)
352  }
353  }
354  }
355  }
356  vector<string> subDirVec = iGetter.getSubdirs();
357  for (vector<string>::const_iterator ic = subDirVec.begin(); ic != subDirVec.end(); ic++) {
358  iGetter.cd(*ic);
359  iBooker.cd(*ic);
360  init = false;
361  computeGlobalQualityFlag(iBooker, iGetter, init, nFEDs, Tier0Flag);
362  iBooker.goUp();
363  iGetter.setCurrentFolder(iBooker.pwd());
364  }
365 
366  // Make sure I have finished looping over all Modules/Ladders/Blades:
367  if (!Tier0Flag) { // online case
368  if (objectCount_ == 1440)
369  DONE_ = true;
370  } else { // offline case
371  if (objectCount_ == 288)
372  DONE_ = true;
373  }
374 
375  if (DONE_ && currDir == "Pixel/EventInfo/reportSummaryContents") {
376  // Evaluate error flag now, only stored in AdditionalPixelErrors:
377  MonitorElement *me_err = iGetter.get("Pixel/AdditionalPixelErrors/FedETypeNErr");
378  MonitorElement *me_evt = iGetter.get("Pixel/EventInfo/processedEvents");
379  if (me_err && me_evt) {
380  for (int i = 1; i != 41; i++)
381  for (int j = 1; j != 22; j++)
382  if (me_err->getBinContent(i, j) > 0) {
384  if (i < 33)
386  if (i > 32)
388  }
389  int NProcEvts = me_evt->getIntValue();
390  if (NProcEvts > 0) {
391  barrel_error_flag_ = (float(NProcEvts) - float(n_errors_barrel_)) / float(NProcEvts);
392  endcap_error_flag_ = (float(NProcEvts) - float(n_errors_endcap_)) / float(NProcEvts);
393  pixel_error_flag_ = (float(NProcEvts) - float(n_errors_barrel_) - float(n_errors_endcap_)) / float(NProcEvts);
394  }
395  }
396  NErrorsBarrel = iGetter.get("Pixel/Barrel/BarrelNErrorsCut");
397  if (NErrorsBarrel)
399  NErrorsEndcap = iGetter.get("Pixel/Endcap/EndcapNErrorsCut");
400  if (NErrorsEndcap)
402 
403  string meName0;
405 
406  // Fill the Digi flags:
407  if (!Tier0Flag) {
408  meName0 = "Pixel/Barrel/SUMDIG_ndigis_Barrel";
409  if (digiCounterBarrel / 768 > 0.5)
410  digiStatsBarrel = true;
411  if (digiCounterEndcap / 672 > 0.5)
412  digiStatsEndcap = true;
413  } else {
414  meName0 = "Pixel/Barrel/SUMOFF_ndigis_Barrel";
415  if (digiCounterBarrel / 192 > 0.5)
416  digiStatsBarrel = true;
417  if (digiCounterEndcap / 96 > 0.5)
418  digiStatsEndcap = true;
419  }
420  me = iGetter.get(meName0);
421  if (me) {
422  NDigisBarrel = iGetter.get("Pixel/Barrel/BarrelNDigisCut");
423  if (NDigisBarrel && digiStatsBarrel) {
424  if (me->hasError())
425  NDigisBarrel->Fill(0);
426  else
427  NDigisBarrel->Fill(1);
428  }
429  }
430  if (!Tier0Flag)
431  meName0 = "Pixel/Endcap/SUMDIG_ndigis_Endcap";
432  else
433  meName0 = "Pixel/Endcap/SUMOFF_ndigis_Endcap";
434  me = iGetter.get(meName0);
435  if (me) {
436  NDigisEndcap = iGetter.get("Pixel/Endcap/EndcapNDigisCut");
437  if (NDigisEndcap && digiStatsEndcap) {
438  if (me->hasError())
439  NDigisEndcap->Fill(0);
440  else
441  NDigisEndcap->Fill(1);
442  }
443  }
444  if (!Tier0Flag)
445  meName0 = "Pixel/Barrel/SUMDIG_adc_Barrel";
446  else
447  meName0 = "Pixel/Barrel/SUMOFF_adc_Barrel";
448  me = iGetter.get(meName0);
449  if (me) {
450  DigiChargeBarrel = iGetter.get("Pixel/Barrel/BarrelDigiChargeCut");
452  if (me->hasError())
454  else
456  }
457  }
458  if (!Tier0Flag)
459  meName0 = "Pixel/Endcap/SUMDIG_adc_Endcap";
460  else
461  meName0 = "Pixel/Endcap/SUMOFF_adc_Endcap";
462  me = iGetter.get(meName0);
463  if (me) {
464  DigiChargeEndcap = iGetter.get("Pixel/Endcap/EndcapDigiChargeCut");
466  if (me->hasError())
468  else
470  }
471  }
472 
473  // Fill the Cluster flags:
474  if (!Tier0Flag) {
475  meName0 = "Pixel/Barrel/SUMCLU_size_Barrel";
476  if (clusterCounterBarrel / 768 > 0.5)
477  clusterStatsBarrel = true;
478  if (clusterCounterEndcap / 672 > 0.5)
479  clusterStatsEndcap = true;
480  } else {
481  meName0 = "Pixel/Barrel/SUMOFF_size_OnTrack_Barrel";
482  if (clusterCounterBarrel / 192 > 0.5)
483  clusterStatsBarrel = true;
484  if (clusterCounterEndcap / 96 > 0.5)
485  clusterStatsEndcap = true;
486  }
487  me = iGetter.get(meName0);
488  if (me) {
489  ClusterSizeBarrel = iGetter.get("Pixel/Barrel/BarrelClusterSizeCut");
491  if (me->hasError())
493  else
495  }
496  }
497  if (!Tier0Flag)
498  meName0 = "Pixel/Endcap/SUMCLU_size_Endcap";
499  else
500  meName0 = "Pixel/Endcap/SUMOFF_size_OnTrack_Endcap";
501  me = iGetter.get(meName0);
502  if (me) {
503  ClusterSizeEndcap = iGetter.get("Pixel/Endcap/EndcapClusterSizeCut");
505  if (me->hasError())
507  else
509  }
510  }
511  if (!Tier0Flag)
512  meName0 = "Pixel/Barrel/SUMCLU_charge_Barrel";
513  else
514  meName0 = "Pixel/Barrel/SUMOFF_charge_OnTrack_Barrel";
515  me = iGetter.get(meName0);
516  if (me) {
517  ClusterChargeBarrel = iGetter.get("Pixel/Barrel/BarrelClusterChargeCut");
519  if (me->hasError())
521  else
523  }
524  }
525  if (!Tier0Flag)
526  meName0 = "Pixel/Endcap/SUMCLU_charge_Endcap";
527  else
528  meName0 = "Pixel/Endcap/SUMOFF_charge_OnTrack_Endcap";
529  me = iGetter.get(meName0);
530  if (me) {
531  ClusterChargeEndcap = iGetter.get("Pixel/Endcap/EndcapClusterChargeCut");
533  if (me->hasError())
535  else
537  }
538  }
539  if (!Tier0Flag)
540  meName0 = "Pixel/Barrel/SUMCLU_nclusters_Barrel";
541  else
542  meName0 = "Pixel/Barrel/SUMOFF_nclusters_OnTrack_Barrel";
543  me = iGetter.get(meName0);
544  if (me) {
545  NClustersBarrel = iGetter.get("Pixel/Barrel/BarrelNClustersCut");
547  if (me->hasError())
548  NClustersBarrel->Fill(0);
549  else
550  NClustersBarrel->Fill(1);
551  }
552  }
553  if (!Tier0Flag)
554  meName0 = "Pixel/Endcap/SUMCLU_nclusters_Endcap";
555  else
556  meName0 = "Pixel/Endcap/SUMOFF_nclusters_OnTrack_Endcap";
557  me = iGetter.get(meName0);
558  if (me) {
559  NClustersEndcap = iGetter.get("Pixel/Endcap/EndcapNClustersCut");
561  if (me->hasError())
562  NClustersEndcap->Fill(0);
563  else
564  NClustersEndcap->Fill(1);
565  }
566  }
567  // Pixel Track multiplicity / Pixel hit efficiency
568  meName0 = "Pixel/Tracks/ntracks_generalTracks";
569  me = iGetter.get(meName0);
570  if (me) {
571  NPixelTracks = iGetter.get("Pixel/Tracks/PixelTracksCut");
572  if (NPixelTracks && me->getBinContent(1) > 1000) {
573  if ((float)me->getBinContent(2) / (float)me->getBinContent(1) < 0.01) {
574  NPixelTracks->Fill(0);
575  } else {
576  NPixelTracks->Fill(1);
577  }
578  }
579  }
580 
581  //********************************************************************************************************
582 
583  // Final combination of all Data Quality results:
584  float pixelFlag = -1., barrelFlag = -1., endcapFlag = -1.;
585  float barrel_errors_temp[1] = {-1.};
586  int barrel_cuts_temp[5] = {5 * -1};
587  float endcap_errors_temp[1] = {-1.};
588  int endcap_cuts_temp[5] = {5 * -1};
589  int pixel_cuts_temp[1] = {-1};
590  float combinedCuts = 1.;
591  int numerator = 0, denominator = 0;
592 
593  // Barrel results:
594  me = iGetter.get("Pixel/Barrel/BarrelNErrorsCut");
595  if (me)
596  barrel_errors_temp[0] = me->getFloatValue();
597  me = iGetter.get("Pixel/Barrel/BarrelNDigisCut");
598  if (me)
599  barrel_cuts_temp[0] = me->getIntValue();
600  me = iGetter.get("Pixel/Barrel/BarrelDigiChargeCut");
601  if (me)
602  barrel_cuts_temp[1] = me->getIntValue();
603  me = iGetter.get("Pixel/Barrel/BarrelClusterSizeCut");
604  if (me)
605  barrel_cuts_temp[2] = me->getIntValue();
606  me = iGetter.get("Pixel/Barrel/BarrelNClustersCut");
607  if (me)
608  barrel_cuts_temp[3] = me->getIntValue();
609  me = iGetter.get("Pixel/Barrel/BarrelClusterChargeCut");
610  if (me)
611  barrel_cuts_temp[4] = me->getIntValue();
612  for (int k = 0; k != 5; k++) {
613  if (barrel_cuts_temp[k] >= 0) {
614  numerator = numerator + barrel_cuts_temp[k];
615  denominator++;
616  }
617  }
618  if (denominator != 0)
619  combinedCuts = float(numerator) / float(denominator);
620  barrelFlag = barrel_errors_temp[0] * combinedCuts;
621 
622  // Endcap results:
623  combinedCuts = 1.;
624  numerator = 0;
625  denominator = 0;
626  me = iGetter.get("Pixel/Endcap/EndcapNErrorsCut");
627  if (me)
628  endcap_errors_temp[0] = me->getFloatValue();
629  me = iGetter.get("Pixel/Endcap/EndcapNDigisCut");
630  if (me)
631  endcap_cuts_temp[0] = me->getIntValue();
632  me = iGetter.get("Pixel/Endcap/EndcapDigiChargeCut");
633  if (me)
634  endcap_cuts_temp[1] = me->getIntValue();
635  me = iGetter.get("Pixel/Endcap/EndcapClusterSizeCut");
636  if (me)
637  endcap_cuts_temp[2] = me->getIntValue();
638  me = iGetter.get("Pixel/Endcap/EndcapNClustersCut");
639  if (me)
640  endcap_cuts_temp[3] = me->getIntValue();
641  me = iGetter.get("Pixel/Endcap/EndcapClusterChargeCut");
642  if (me)
643  endcap_cuts_temp[4] = me->getIntValue();
644  for (int k = 0; k != 5; k++) {
645  if (endcap_cuts_temp[k] >= 0) {
646  numerator = numerator + endcap_cuts_temp[k];
647  denominator++;
648  }
649  }
650  if (denominator != 0)
651  combinedCuts = float(numerator) / float(denominator);
652  endcapFlag = endcap_errors_temp[0] * combinedCuts;
653 
654  // Track results:
655  combinedCuts = 1.;
656  numerator = 0;
657  denominator = 0;
658  me = iGetter.get("Pixel/Tracks/PixelTracksCut");
659  if (me)
660  pixel_cuts_temp[0] = me->getIntValue();
661 
662  // Combination of all:
663  combinedCuts = 1.;
664  numerator = 0;
665  denominator = 0;
666  for (int k = 0; k != 5; k++) {
667  if (barrel_cuts_temp[k] >= 0) {
668  numerator = numerator + barrel_cuts_temp[k];
669  denominator++;
670  }
671  if (endcap_cuts_temp[k] >= 0) {
672  numerator = numerator + endcap_cuts_temp[k];
673  denominator++;
674  }
675  if (k < 1 && pixel_cuts_temp[k] >= 0) {
676  numerator = numerator + pixel_cuts_temp[k];
677  denominator++;
678  }
679  }
680  if (denominator != 0)
681  combinedCuts = float(numerator) / float(denominator);
682  pixelFlag = float(pixel_error_flag_) * float(combinedCuts);
683 
684  SummaryPixel = iGetter.get("Pixel/EventInfo/reportSummary");
685  if (SummaryPixel)
686  SummaryPixel->Fill(pixelFlag);
687  SummaryBarrel = iGetter.get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
688  if (SummaryBarrel)
689  SummaryBarrel->Fill(barrelFlag);
690  SummaryEndcap = iGetter.get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
691  if (SummaryEndcap)
692  SummaryEndcap->Fill(endcapFlag);
693  }
694 }
695 
696 //**********************************************************************************************
697 
699  bool init,
700  int nFEDs,
701  bool Tier0Flag,
702  int nEvents_lastLS_,
703  int nErrorsBarrel_lastLS_,
704  int nErrorsEndcap_lastLS_) {
705  if (nFEDs == 0)
706  return;
707 
708  // evaluate fatal FED errors for data quality:
709  float BarrelRate_LS = 1.;
710  float EndcapRate_LS = 1.;
711  float PixelRate_LS = 1.;
712  MonitorElement *me = iGetter.get("Pixel/AdditionalPixelErrors/byLumiErrors");
713  if (me) {
714  double nBarrelErrors_LS = me->getBinContent(1) - nErrorsBarrel_lastLS_;
715  double nEndcapErrors_LS = me->getBinContent(2) - nErrorsEndcap_lastLS_;
716  double nEvents_LS = me->getBinContent(0) - nEvents_lastLS_;
717  if (nBarrelErrors_LS / nEvents_LS > 0.5)
718  BarrelRate_LS = 0.;
719  if (nEndcapErrors_LS / nEvents_LS > 0.5)
720  EndcapRate_LS = 0.;
721  if ((nBarrelErrors_LS + nEndcapErrors_LS) / nEvents_LS > 0.5)
722  PixelRate_LS = 0.;
723  }
724 
725  // evaluate mean cluster charge on tracks for data quality:
726  float BarrelClusterCharge = 1.;
727  float EndcapClusterCharge = 1.;
728  float PixelClusterCharge = 1.;
729  MonitorElement *me1 = iGetter.get("Pixel/Clusters/OnTrack/charge_siPixelClusters_Barrel");
730  if (me1 && me1->getMean() < 12.)
731  BarrelClusterCharge = 0.;
732  MonitorElement *me2 = iGetter.get("Pixel/Clusters/OnTrack/charge_siPixelClusters_Endcap");
733  if (me2 && me2->getMean() < 12.)
734  EndcapClusterCharge = 0.;
735  MonitorElement *me3 = iGetter.get("Pixel/Clusters/OnTrack/charge_siPixelClusters");
736  if (me3 && me3->getMean() < 12.)
737  PixelClusterCharge = 0.;
738 
739  // evaluate average FED occupancy for data quality:
740  float BarrelOccupancy = 1.;
741  float EndcapOccupancy = 1.;
742  float PixelOccupancy = 1.;
743  MonitorElement *me4 = iGetter.get("Pixel/averageDigiOccupancy");
744  if (me4) {
745  double minBarrelOcc = 999999.;
746  double maxBarrelOcc = -1.;
747  double meanBarrelOcc = 0.;
748  double minEndcapOcc = 999999.;
749  double maxEndcapOcc = -1.;
750  double meanEndcapOcc = 0.;
751  for (int i = 1; i != 41; i++) {
752  if (i <= 32 && me4->getBinContent(i) < minBarrelOcc)
753  minBarrelOcc = me4->getBinContent(i);
754  if (i <= 32 && me4->getBinContent(i) > maxBarrelOcc)
755  maxBarrelOcc = me4->getBinContent(i);
756  if (i <= 32)
757  meanBarrelOcc += me4->getBinContent(i);
758  if (i > 32 && me4->getBinContent(i) < minEndcapOcc)
759  minEndcapOcc = me4->getBinContent(i);
760  if (i > 32 && me4->getBinContent(i) > maxEndcapOcc)
761  maxEndcapOcc = me4->getBinContent(i);
762  if (i > 32)
763  meanEndcapOcc += me4->getBinContent(i);
764  }
765  meanBarrelOcc = meanBarrelOcc / 32.;
766  meanEndcapOcc = meanEndcapOcc / 8.;
767  if (minBarrelOcc < 0.1 * meanBarrelOcc || maxBarrelOcc > 2.5 * meanBarrelOcc)
768  BarrelOccupancy = 0.;
769  if (minEndcapOcc < 0.2 * meanEndcapOcc || maxEndcapOcc > 1.8 * meanEndcapOcc)
770  EndcapOccupancy = 0.;
771  PixelOccupancy = BarrelOccupancy * EndcapOccupancy;
772  }
773 
774  float pixelFlag = PixelRate_LS * PixelClusterCharge * PixelOccupancy;
775  float barrelFlag = BarrelRate_LS * BarrelClusterCharge * BarrelOccupancy;
776  float endcapFlag = EndcapRate_LS * EndcapClusterCharge * EndcapOccupancy;
777  SummaryPixel = iGetter.get("Pixel/EventInfo/reportSummary");
778  if (SummaryPixel)
779  SummaryPixel->Fill(pixelFlag);
780  SummaryBarrel = iGetter.get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
781  if (SummaryBarrel)
782  SummaryBarrel->Fill(barrelFlag);
783  SummaryEndcap = iGetter.get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
784  if (SummaryEndcap)
785  SummaryEndcap->Fill(endcapFlag);
786 }
787 
788 //**********************************************************************************************
789 
791  DQMStore::IGetter &iGetter,
792  bool init,
793  const SiPixelFedCablingMap *theCablingMap,
794  int nFEDs,
795  bool Tier0Flag,
796  int lumisec) {
797  // std::cout<<"Entering SiPixelDataQuality::fillGlobalQualityPlot:
798  // "<<nFEDs<<std::endl;
799  if (init) {
800  count = 0;
801  errcount = 0;
802  init = false;
803  count1 = 0;
804  count2 = 0;
805  count3 = 0;
806  count4 = 0;
807  count5 = 0;
808  count6 = 0;
809  modCounter_ = 0;
810  if (!Tier0Flag) {
811  // The plots that these Vecs are integrated throughout a run
812  // So at each lumi section I save their last values (lastmods)
813  // And then subtract them out later when filling the SummaryMap
814  for (int j = 1; j != 41; j++) {
815  if (allmodsVec)
816  lastallmods_[j - 1] = allmodsVec->GetBinContent(j);
817  if (errmodsVec)
818  lasterrmods_[j - 1] = errmodsVec->GetBinContent(j);
819  if (allmodsVec)
820  allmodsVec->SetBinContent(j, 0.);
821  if (errmodsVec)
822  errmodsVec->SetBinContent(j, 0.);
823  if (goodmodsVec)
824  goodmodsVec->SetBinContent(j, 0.);
825  }
826  }
827  if (Tier0Flag) {
828  for (int i = 1; i != 3; i++)
829  for (int j = 1; j != 8; j++) {
830  if (allmodsMap)
831  allmodsMap->SetBinContent(i, j, 0.);
832  if (errmodsMap)
833  errmodsMap->SetBinContent(i, j, 0.);
834  if (goodmodsMap)
835  goodmodsMap->SetBinContent(i, j, 0.);
836  }
837  }
838  }
839 
840  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
841  // Fill Maps:
842  // Online:
843  if (nFEDs == 0)
844  return;
845 
846  if (!Tier0Flag) {
847  // Not elegant, but not sure where else to put this sweet new plot!
848  MonitorElement *meTmp = iGetter.get("Pixel/Barrel/NClustertoChargeRatio_AllMod");
849  MonitorElement *meTop = iGetter.get("Pixel/Barrel/SUMCLU_nclusters_Barrel");
850  MonitorElement *meBot = iGetter.get("Pixel/Barrel/SUMCLU_charge_Barrel");
851  if (meTop && meBot && meTmp) {
852  for (int bin = 1; bin < 769; ++bin) {
853  float content = 0.0;
854  if (meBot->getBinContent(bin) > 0.0) {
855  content = meTop->getBinContent(bin) / meBot->getBinContent(bin);
856  }
857  meTmp->setBinContent(bin, content);
858  }
859  for (int j = 0; j < 4; ++j) {
860  static const char buf[] = "Pixel/Barrel/NClustertoChargeRatio_NormMod%i";
861  char modplot[sizeof(buf) + 16];
862  sprintf(modplot, buf, j + 1);
863  MonitorElement *meFinal = iGetter.get(modplot);
864  if (!meFinal)
865  continue;
866  for (int i = 1; i < 769; ++i) {
867  int k = 3 - j;
868  if (int(i + k) % 4 == 0)
869  meFinal->setBinContent(int((i + k) / 4), meTmp->getBinContent(i));
870  }
871  // Filling done. Now modification.
872  float SFLay[3], TotLay[3];
873  for (int ll = 0; ll < 3; ++ll)
874  TotLay[ll] = 0.0;
875  for (int bin = 1; bin < (meFinal->getNbinsX() + 1); ++bin) {
876  int layer = int((bin % 48) / 16);
877  TotLay[layer] += meFinal->getBinContent(bin);
878  }
879  float laynorm = TotLay[1] / 64.;
880  for (int ll = 0; ll < 3; ++ll) {
881  SFLay[ll] = 0.0;
882  if (TotLay[ll] > 0.0 && TotLay[1] > 0.0)
883  SFLay[ll] = TotLay[1] / TotLay[ll] * (1. / laynorm);
884  }
885  // now loop through plot
886  for (int bin = 1; bin < (meFinal->getNbinsX() + 1); ++bin) {
887  // access the layer number for bin: int((i%48)/16)
888  int layer = int((bin % 48) / 16);
889  float content = meFinal->getBinContent(bin);
890  // apply scale factor to bin content
891  meFinal->setBinContent(bin, content * SFLay[layer]);
892  }
893  }
894  }
895 
896  string currDir = iBooker.pwd();
897  if (currDir.find("Reference") != string::npos || currDir.find("Additional") != string::npos)
898  return;
899  string dname = currDir.substr(currDir.find_last_of('/') + 1);
900  if (dname.find("Module_") != string::npos && currDir.find("Reference") == string::npos) {
901  vector<string> meVec = iGetter.getMEs();
902  int detId = -1;
903  int fedId = -1;
904  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end();
905  it++) { // loop over all modules and fill ndigis into allmodsMap
906  // checking for any digis or FED errors to decide if this module is in
907  // DAQ:
908  string full_path = currDir + "/" + (*it);
909  if (detId == -1 && full_path.find("SUMOFF") == string::npos &&
910  (full_path.find("ndigis") != string::npos && full_path.find("SUMDIG") == string::npos) &&
911  (getDetId(iGetter.get(full_path)) > 100)) {
912  MonitorElement *me = iGetter.get(full_path);
913  if (!me)
914  continue;
915  if ((full_path.find("ndigis") != string::npos)) {
916  modCounter_++;
917  detId = getDetId(me);
918  for (int fedid = 0; fedid != 40; ++fedid) {
919  SiPixelFrameConverter converter(theCablingMap, fedid);
920  uint32_t newDetId = detId;
921  if (converter.hasDetUnit(newDetId)) {
922  fedId = fedid;
923  break;
924  }
925  }
926  double NDigis = 0;
927  if (full_path.find("ndigis") != string::npos)
928  NDigis = me->getEntries();
929  float weight = (allmodsVec->GetBinContent(fedId + 1)) + NDigis;
930  allmodsVec->SetBinContent(fedId + 1, weight);
931  }
932  }
933  } // end loop over MEs
934  } // end of module dir's
935  vector<string> subDirVec = iGetter.getSubdirs();
936  for (vector<string>::const_iterator ic = subDirVec.begin(); ic != subDirVec.end(); ic++) {
937  iBooker.cd(*ic);
938  iGetter.cd(*ic);
939  init = false;
940  fillGlobalQualityPlot(iBooker, iGetter, init, theCablingMap, nFEDs, Tier0Flag, lumisec);
941  iBooker.goUp();
942  iGetter.setCurrentFolder(iBooker.pwd());
943  }
944  if (modCounter_ == 1440) {
945  iBooker.cd("Pixel/EventInfo/reportSummaryContents");
946  iGetter.cd("Pixel/EventInfo/reportSummaryContents");
947  if (iBooker.pwd() == "Pixel/EventInfo/reportSummaryContents") {
948  for (int i = 0; i != 40; i++) { // loop over FEDs to fetch the errors
949  static const char buf[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErr";
950  char fedplot[sizeof(buf) + 4];
951  int NErrors = 0;
952  for (int j = 0; j != 37; j++) { // loop over FED channels within a FED
953  sprintf(fedplot, buf, i);
954  MonitorElement *me = iGetter.get(fedplot);
955  if (me)
956  NErrors = NErrors + me->getBinContent(j + 1);
957  }
958  // If I fill, then I end up majorly overcounting the numbers of
959  // errors...
960  if (NErrors > 0) {
961  errmodsVec->SetBinContent(i + 1, NErrors);
962  }
963  }
964  SummaryReportMap = iGetter.get("Pixel/EventInfo/reportSummaryMap");
965  if (SummaryReportMap) {
966  float contents = 0.;
967  for (int i = 1; i != 41; i++) {
968  // Dynamically subtracting previous (integrated) lumi section values
969  // in order to only show current lumi section's numbers
970  float mydigis = allmodsVec->GetBinContent(i) - lastallmods_[i - 1];
971  float myerrs = errmodsVec->GetBinContent(i) - lasterrmods_[i - 1];
972  if ((mydigis + myerrs) > 0.) {
973  contents = mydigis / (mydigis + myerrs);
974  } else {
975  // Changed so that dynamic zooming will still
976  // advance over these bins(in renderplugins)
977  contents = -0.5;
978  }
979  SummaryReportMap->setBinContent(lumisec + 1, i, contents);
980  } // end for loop over summaryReportMap bins
981  } // end if reportSummaryMap ME exists
982  } // end if in summary directory
983  } // end if modCounter_
984  } else { // Offline
985  float barrel_errors_temp[1] = {-1.};
986  int barrel_cuts_temp[6] = {6 * -1};
987  float endcap_errors_temp[1] = {-1.};
988  int endcap_cuts_temp[6] = {6 * -1};
989  int pixel_cuts_temp[1] = {-1};
990  // Barrel results:
992  me = iGetter.get("Pixel/Barrel/BarrelNErrorsCut");
993  if (me)
994  barrel_errors_temp[0] = me->getFloatValue();
995  me = iGetter.get("Pixel/Endcap/EndcapNErrorsCut");
996  if (me)
997  endcap_errors_temp[0] = me->getFloatValue();
998  SummaryReportMap->setBinContent(1, 1, barrel_errors_temp[0]);
999  SummaryReportMap->setBinContent(2, 1, endcap_errors_temp[0]);
1000  me = iGetter.get("Pixel/Barrel/BarrelNDigisCut");
1001  if (me)
1002  barrel_cuts_temp[0] = me->getIntValue();
1003  me = iGetter.get("Pixel/Barrel/BarrelDigiChargeCut");
1004  if (me)
1005  barrel_cuts_temp[1] = me->getIntValue();
1006  me = iGetter.get("Pixel/Barrel/BarrelClusterSizeCut");
1007  if (me)
1008  barrel_cuts_temp[2] = me->getIntValue();
1009  me = iGetter.get("Pixel/Barrel/BarrelNClustersCut");
1010  if (me)
1011  barrel_cuts_temp[3] = me->getIntValue();
1012  me = iGetter.get("Pixel/Barrel/BarrelClusterChargeCut");
1013  if (me)
1014  barrel_cuts_temp[4] = me->getIntValue();
1015  me = iGetter.get("Pixel/Endcap/EndcapNDigisCut");
1016  if (me)
1017  endcap_cuts_temp[0] = me->getIntValue();
1018  me = iGetter.get("Pixel/Endcap/EndcapDigiChargeCut");
1019  if (me)
1020  endcap_cuts_temp[1] = me->getIntValue();
1021  me = iGetter.get("Pixel/Endcap/EndcapClusterSizeCut");
1022  if (me)
1023  endcap_cuts_temp[2] = me->getIntValue();
1024  me = iGetter.get("Pixel/Endcap/EndcapNClustersCut");
1025  if (me)
1026  endcap_cuts_temp[3] = me->getIntValue();
1027  me = iGetter.get("Pixel/Endcap/EndcapClusterChargeCut");
1028  if (me)
1029  endcap_cuts_temp[4] = me->getIntValue();
1030  for (int j = 2; j != 7; j++) {
1031  SummaryReportMap->setBinContent(1, j, barrel_cuts_temp[j - 2]);
1032  SummaryReportMap->setBinContent(2, j, endcap_cuts_temp[j - 2]);
1033  }
1034  me = iGetter.get("Pixel/Tracks/PixelTracksCut");
1035  if (me)
1036  pixel_cuts_temp[0] = me->getIntValue();
1037  SummaryReportMap->setBinContent(1, 7, pixel_cuts_temp[0]);
1038  SummaryReportMap->setBinContent(2, 7, pixel_cuts_temp[0]);
1039  } // end of offline map
1040  if (allmodsMap)
1041  allmodsMap->Clear();
1042  if (goodmodsMap)
1043  goodmodsMap->Clear();
1044  if (errmodsMap)
1045  errmodsMap->Clear();
1046 }
1047 
1048 //**********************************************************************************************
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * ClusterChargeBarrel
virtual std::vector< std::string > getMEs() const
Definition: DQMStore.cc:737
virtual std::string pwd()
Definition: DQMStore.cc:20
MonitorElement * ClusterModAll
MonitorElement * SummaryBarrel
MonitorElement * ClusterSizeEndcap
Definition: weight.py:1
int getDetId(MonitorElement *mE)
(Documentation under construction).
MonitorElement * NPixelTracks
constexpr std::array< uint8_t, layerIndexSize > layer
MonitorElement * NErrorsFEDs
MonitorElement * NDigisEndcap
void Fill(long long x)
MonitorElement * SummaryPixel
MonitorElement * NErrorsEndcap
MonitorElement * ClusterMod3
MonitorElement * ClusterMod1
MonitorElement * ClusterMod4
MonitorElement * NErrorsBarrel
MonitorElement * ClusterMod2
MonitorElement * NClustersEndcap
MonitorElement * ClusterSizeBarrel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
void computeGlobalQualityFlag(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool init, int nFEDs, bool Tier0Flag)
Log< level::Info, false > LogInfo
Definition: init.py:1
MonitorElement * SummaryReportMap
~SiPixelDataQuality()
Destructor of the SiPixelDataQuality class.
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * DigiChargeEndcap
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
MonitorElement * SummaryEndcap
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:73
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
void computeGlobalQualityFlagByLumi(DQMStore::IGetter &iGetter, bool init, int nFEDs, bool Tier0Flag, int nEvents_lastLS_, int nErrorsBarrel_lastLS_, int nErrorsEndcap_lastLS_)
const std::string & getName() const
get name of ME
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
HLT enums.
MonitorElement * NDigisBarrel
virtual int getNbinsX() const
get # of bins in X-axis
void fillGlobalQualityPlot(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool init, const SiPixelFedCablingMap *theCablingMap, int nFEDs, bool Tier0Flag, int lumisec)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * ClusterChargeEndcap
MonitorElement * DigiChargeBarrel
MonitorElement * NClustersBarrel
SiPixelDataQuality(bool offlineXMLfile)
Constructor of the SiPixelInformationExtractor class.
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
virtual int64_t getIntValue() const
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:717
void bookGlobalQualityFlag(DQMStore::IBooker &iBooker, bool Tier0Flag, int nFEDs)