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