test
CMS 3D CMS Logo

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