CMS 3D CMS Logo

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