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