00001
00007 #include "DQM/SiPixelMonitorClient/interface/SiPixelDataQuality.h"
00008 #include "DQM/SiPixelMonitorClient/interface/SiPixelUtility.h"
00009 #include "DQM/SiPixelMonitorClient/interface/SiPixelEDAClient.h"
00010 #include "DQM/SiPixelMonitorClient/interface/ANSIColors.h"
00011 #include "DQM/SiPixelMonitorClient/interface/SiPixelHistoPlotter.h"
00012 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
00013
00014 #include "DQMServices/Core/interface/DQMStore.h"
00015 #include "DQMServices/Core/interface/MonitorElement.h"
00016 #include "DQM/TrackerCommon/interface/CgiReader.h"
00017
00018 #include "FWCore/ParameterSet/interface/FileInPath.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020
00021 #include "DataFormats/DetId/interface/DetId.h"
00022 #include "DataFormats/GeometrySurface/interface/Surface.h"
00023 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00024 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00025 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00026
00027 #include "CondFormats/SiPixelObjects/interface/DetectorIndex.h"
00028 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h"
00029
00030 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00031 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00032 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00033 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00034 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00035
00036 #include "TClass.h"
00037 #include "TText.h"
00038 #include "TROOT.h"
00039 #include "TPad.h"
00040 #include "TStyle.h"
00041 #include "TSystem.h"
00042 #include "TString.h"
00043 #include "TImage.h"
00044 #include "TPaveText.h"
00045 #include "TImageDump.h"
00046 #include "TRandom.h"
00047 #include "TStopwatch.h"
00048 #include "TAxis.h"
00049 #include "TPaveLabel.h"
00050 #include "Rtypes.h"
00051 #include "TH1F.h"
00052 #include "TH2F.h"
00053 #include "TProfile.h"
00054
00055 #include <iostream>
00056 #include <math.h>
00057 #include <map>
00058
00059 #include <fstream>
00060 #include <cstdlib>
00061
00062 using namespace std;
00063 using namespace edm;
00064
00065
00069 SiPixelDataQuality::SiPixelDataQuality(bool offlineXMLfile) : offlineXMLfile_(offlineXMLfile) {
00070 edm::LogInfo("SiPixelDataQuality") <<
00071 " Creating SiPixelDataQuality " << "\n" ;
00072
00073 allMods_=0;
00074 errorMods_=0;
00075 qflag_=1.;
00076
00077 allmodsMap=0;
00078 errmodsMap=0;
00079 goodmodsMap=0;
00080 allmodsVec=0;
00081 errmodsVec=0;
00082 goodmodsVec=0;
00083 for (int i = 0; i < 40; ++i)
00084 {lastallmods_[i] = 0; lasterrmods_[i] = 0;}
00085 timeoutCounter_=0;
00086 lastLS_=-1;
00087 }
00088
00089
00093 SiPixelDataQuality::~SiPixelDataQuality() {
00094 edm::LogInfo("SiPixelDataQuality") <<
00095 " Deleting SiPixelDataQuality " << "\n" ;
00096 if(allmodsMap) delete allmodsMap;
00097 if(errmodsMap) delete errmodsMap;
00098 if(goodmodsMap) delete goodmodsMap;
00099 if(allmodsVec) delete allmodsVec;
00100 if(errmodsVec) delete errmodsVec;
00101 if(goodmodsVec) delete goodmodsVec;
00102 }
00103
00104
00105
00110 int SiPixelDataQuality::getDetId(MonitorElement * mE)
00111 {
00112 string mEName = mE->getName() ;
00113
00114 int detId = 0;
00115
00116 if( mEName.find("_3") != string::npos )
00117 {
00118 string detIdString = mEName.substr((mEName.find_last_of("_"))+1,9);
00119 std::istringstream isst;
00120 isst.str(detIdString);
00121 isst>>detId;
00122
00123
00124
00125
00126
00127
00128
00129 }
00130
00131 return detId ;
00132
00133 }
00134
00136
00137 void SiPixelDataQuality::bookGlobalQualityFlag(DQMStore * bei, bool Tier0Flag, int nFEDs) {
00138
00139 bei->cd();
00140
00141 bei->setCurrentFolder("Pixel/Barrel");
00142 if(!Tier0Flag){
00143 ClusterModAll = bei->book1D("NClustertoChargeRatio_AllMod","Cluster Noise All Modules", 768, 0., 768.);
00144 ClusterMod1 = bei->book1D("NClustertoChargeRatio_NormMod1", "Normalized N_{Clusters} to Charge Ratio per Module1", 192, 0., 192.);
00145 ClusterMod2 = bei->book1D("NClustertoChargeRatio_NormMod2", "Normalized N_{Clusters} to Charge Ratio per Module2", 192, 0., 192.);
00146 ClusterMod3 = bei->book1D("NClustertoChargeRatio_NormMod3", "Normalized N_{Clusters} to Charge Ratio per Module3", 192, 0., 192.);
00147 ClusterMod4 = bei->book1D("NClustertoChargeRatio_NormMod4", "Normalized N_{Clusters} to Charge Ratio per Module4", 192, 0., 192.);
00148 }
00149 bei->setCurrentFolder("Pixel/EventInfo");
00150 if(!Tier0Flag){
00151
00152
00153
00154
00155
00156
00157
00158 SummaryReportMap = bei->book2D("reportSummaryMap","Pixel Summary Map",3000,0.,3000.,40,0.,40.);
00159 SummaryReportMap->setAxisTitle("Lumi Section",1);
00160 SummaryReportMap->setAxisTitle("Pixel FED #",2);
00161 allmodsVec = new TH1D("allmodsVec","allmodsVec",40,0.,40.);
00162 errmodsVec = new TH1D("errmodsVec","errmodsVec",40,0.,40.);
00163 goodmodsVec = new TH1D("goodmodsVec","goodmodsVec",40,0.,40.);
00164 }else{
00165 SummaryReportMap = bei->book2D("reportSummaryMap","Pixel Summary Map",2,0.,2.,7,0.,7.);
00166 SummaryReportMap->setBinLabel(1,"Barrel",1);
00167 SummaryReportMap->setBinLabel(2,"Endcaps",1);
00168 SummaryReportMap->setBinLabel(1,"Errors",2);
00169 SummaryReportMap->setBinLabel(2,"NDigis",2);
00170 SummaryReportMap->setBinLabel(3,"DigiCharge",2);
00171 SummaryReportMap->setBinLabel(4,"ClusterSize",2);
00172 SummaryReportMap->setBinLabel(5,"NClusters",2);
00173 SummaryReportMap->setBinLabel(6,"ClusterCharge",2);
00174 SummaryReportMap->setBinLabel(7,"HitEff",2);
00175 allmodsMap = new TH2F("allmodsMap","allmodsMap",2,0.,2.,7,0.,7.);
00176 errmodsMap = new TH2F("errmodsMap","errmodsMap",2,0.,2.,7,0.,7.);
00177 goodmodsMap = new TH2F("goodmodsMap","goodmodsMap",2,0.,2.,7,0.,7.);
00178 }
00179 SummaryPixel = bei->bookFloat("reportSummary");
00180 bei->setCurrentFolder("Pixel/EventInfo/reportSummaryContents");
00181 SummaryBarrel = bei->bookFloat("PixelBarrelFraction");
00182 SummaryEndcap = bei->bookFloat("PixelEndcapFraction");
00183
00184 bei->setCurrentFolder("Pixel/AdditionalPixelErrors");
00185 NErrorsFEDs = bei->bookFloat("FEDsNErrorsCut");
00186 bei->setCurrentFolder("Pixel/Barrel");
00187 NErrorsBarrel = bei->bookFloat("BarrelNErrorsCut");
00188 NDigisBarrel = bei->bookInt("BarrelNDigisCut");
00189 DigiChargeBarrel = bei->bookInt("BarrelDigiChargeCut");
00190 ClusterSizeBarrel = bei->bookInt("BarrelClusterSizeCut");
00191 NClustersBarrel = bei->bookInt("BarrelNClustersCut");
00192 ClusterChargeBarrel = bei->bookInt("BarrelClusterChargeCut");
00193 bei->setCurrentFolder("Pixel/Endcap");
00194 NErrorsEndcap = bei->bookFloat("EndcapNErrorsCut");
00195 NDigisEndcap = bei->bookInt("EndcapNDigisCut");
00196 DigiChargeEndcap = bei->bookInt("EndcapDigiChargeCut");
00197 ClusterSizeEndcap = bei->bookInt("EndcapClusterSizeCut");
00198 NClustersEndcap = bei->bookInt("EndcapNClustersCut");
00199 ClusterChargeEndcap = bei->bookInt("EndcapClusterChargeCut");
00200 if(Tier0Flag){
00201 bei->setCurrentFolder("Pixel/Tracks");
00202 NPixelTracks = bei->bookInt("PixelTracksCut");
00203 }
00204
00205
00206 if(nFEDs>0){
00207 SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00208 if(SummaryPixel) SummaryPixel->Fill(1.);
00209 SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00210 if(SummaryBarrel) SummaryBarrel->Fill(1.);
00211 SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00212 if(SummaryEndcap) SummaryEndcap->Fill(1.);
00213 }else{
00214 SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00215 if(SummaryPixel) SummaryPixel->Fill(-1.);
00216 SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00217 if(SummaryBarrel) SummaryBarrel->Fill(-1.);
00218 SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00219 if(SummaryEndcap) SummaryEndcap->Fill(-1.);
00220 }
00221 NErrorsBarrel = bei->get("Pixel/Barrel/BarrelNErrorsCut");
00222 if(NErrorsBarrel) NErrorsBarrel->Fill(1.);
00223 NErrorsEndcap = bei->get("Pixel/Endcap/EndcapNErrorsCut");
00224 if(NErrorsEndcap) NErrorsEndcap->Fill(1.);
00225 NErrorsFEDs = bei->get("Pixel/AdditionalPixelErrors/FEDsNErrorsCut");
00226 if(NErrorsFEDs) NErrorsFEDs->Fill(1.);
00227 NDigisBarrel = bei->get("Pixel/Barrel/BarrelNDigisCut");
00228 if(NDigisBarrel) NDigisBarrel->Fill(1);
00229 NDigisEndcap = bei->get("Pixel/Endcap/EndcapNDigisCut");
00230 if(NDigisEndcap) NDigisEndcap->Fill(1);
00231 DigiChargeBarrel = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
00232 if(DigiChargeBarrel) DigiChargeBarrel->Fill(1);
00233 DigiChargeEndcap = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
00234 if(DigiChargeEndcap) DigiChargeEndcap->Fill(1);
00235 ClusterSizeBarrel = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
00236 if(ClusterSizeBarrel) ClusterSizeBarrel->Fill(1);
00237 ClusterSizeEndcap = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
00238 if(ClusterSizeEndcap) ClusterSizeEndcap->Fill(1);
00239 ClusterChargeBarrel = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
00240 if(ClusterChargeBarrel) ClusterChargeBarrel->Fill(1);
00241 ClusterChargeEndcap = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
00242 if(ClusterChargeEndcap) ClusterChargeEndcap->Fill(1);
00243 NClustersBarrel = bei->get("Pixel/Barrel/BarrelNClustersCut");
00244 if(NClustersBarrel) NClustersBarrel->Fill(1);
00245 NClustersEndcap = bei->get("Pixel/Endcap/EndcapNClustersCut");
00246 if(NClustersEndcap) NClustersEndcap->Fill(1);
00247 if(Tier0Flag){
00248 NPixelTracks = bei->get("Pixel/Tracks/PixelTracksCut");
00249 if(NPixelTracks) NPixelTracks->Fill(1);
00250 }
00251
00252 SummaryReportMap = bei->get("Pixel/EventInfo/reportSummaryMap");
00253 if(SummaryReportMap){
00254 if(!Tier0Flag) for(int i=1; i!=3001; i++) for(int j=1; j!=41; j++) SummaryReportMap->setBinContent(i,j,-1.);
00255 if(Tier0Flag) for(int i=1; i!=3; i++) for(int j=1; j!=8; j++) SummaryReportMap->setBinContent(i,j,-1.);
00256 }
00257 if(!Tier0Flag){
00258 for(int j=1; j!=41; j++){
00259 if(allmodsVec) allmodsVec->SetBinContent(j,0.);
00260 if(errmodsVec) errmodsVec->SetBinContent(j,0.);
00261 if(goodmodsVec) goodmodsVec->SetBinContent(j,0.);
00262 }
00263 }
00264 if(Tier0Flag){
00265 for(int i=1; i!=3; i++) for(int j=1; j!=8; j++){
00266 if(allmodsMap) allmodsMap->SetBinContent(i,j,0.);
00267 if(errmodsMap) errmodsMap->SetBinContent(i,j,0.);
00268 if(goodmodsMap) goodmodsMap->SetBinContent(i,j,0.);
00269 }
00270 }
00271
00272 bei->cd();
00273 }
00274
00275
00276
00277 void SiPixelDataQuality::computeGlobalQualityFlag(DQMStore * bei,
00278 bool init,
00279 int nFEDs,
00280 bool Tier0Flag){
00281
00282
00283
00284
00285
00286
00287 if(init){
00288
00289 allMods_=0; errorMods_=0; qflag_=0.;
00290 barrelMods_=0; endcapMods_=0;
00291 objectCount_=0;
00292 DONE_ = false;
00293
00294
00295 n_errors_barrel_=0; barrel_error_flag_=0.;
00296 n_errors_endcap_=0; endcap_error_flag_=0.;
00297 n_errors_pixel_=0; pixel_error_flag_=0.;
00298 digiStatsBarrel = false, clusterStatsBarrel = false, trackStatsBarrel = false;
00299 digiCounterBarrel = 0, clusterCounterBarrel = 0, trackCounterBarrel = 0;
00300 digiStatsEndcap = false, clusterStatsEndcap = false, trackStatsEndcap = false;
00301 digiCounterEndcap = 0, clusterCounterEndcap = 0, trackCounterEndcap = 0;
00302 init=false;
00303 }
00304 if(nFEDs==0) return;
00305
00306 string currDir = bei->pwd();
00307 string dname = currDir.substr(currDir.find_last_of("/")+1);
00308
00309
00310 if((!Tier0Flag && dname.find("Module_")!=string::npos) ||
00311 (Tier0Flag && (dname.find("Ladder_")!=string::npos || dname.find("Blade_")!=string::npos))){
00312
00313 objectCount_++;
00314
00315 if(currDir.find("Pixel")!=string::npos) allMods_++;
00316 if(currDir.find("Barrel")!=string::npos) barrelMods_++;
00317 if(currDir.find("Endcap")!=string::npos) endcapMods_++;
00318 vector<string> meVec = bei->getMEs();
00319 for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
00320 string full_path = currDir + "/" + (*it);
00321
00322 if(full_path.find("ndigis_")!=string::npos){
00323
00324 MonitorElement * me = bei->get(full_path);
00325 if(!me) continue;
00326
00327 if(me->getEntries()>25){
00328
00329 if(full_path.find("Barrel")!=string::npos) digiCounterBarrel++;
00330 if(full_path.find("Endcap")!=string::npos) digiCounterEndcap++;
00331
00332 }
00333 }else if(Tier0Flag && full_path.find("nclusters_OnTrack_")!=string::npos){
00334 MonitorElement * me = bei->get(full_path);
00335 if(!me) continue;
00336 if(me->getEntries()>25){
00337 if(full_path.find("Barrel")!=string::npos) clusterCounterBarrel++;
00338 if(full_path.find("Endcap")!=string::npos) clusterCounterEndcap++;
00339 }
00340 }else if(!Tier0Flag && full_path.find("nclusters_")!=string::npos){
00341 MonitorElement * me = bei->get(full_path);
00342 if(!me) continue;
00343 if(me->getEntries()>25){
00344 if(full_path.find("Barrel")!=string::npos) clusterCounterBarrel++;
00345 if(full_path.find("Endcap")!=string::npos) clusterCounterEndcap++;
00346 }
00347 }
00348 }
00349 }
00350 vector<string> subDirVec = bei->getSubdirs();
00351 for (vector<string>::const_iterator ic = subDirVec.begin();
00352 ic != subDirVec.end(); ic++) {
00353 bei->cd(*ic);
00354 init=false;
00355 computeGlobalQualityFlag(bei,init,nFEDs,Tier0Flag);
00356 bei->goUp();
00357 }
00358
00359
00360 if(!Tier0Flag){
00361 if(objectCount_ == 1440) DONE_ = true;
00362 }else{
00363 if(objectCount_ == 288) DONE_ = true;
00364 }
00365
00366 if(DONE_ && currDir=="Pixel/EventInfo/reportSummaryContents"){
00367
00368
00369 MonitorElement * me_err = bei->get("Pixel/AdditionalPixelErrors/FedETypeNErrArray");
00370 MonitorElement * me_evt = bei->get("Pixel/EventInfo/processedEvents");
00371 if(me_err && me_evt){
00372 for(int i=1; i!=41; i++)for(int j=1; j!=22; j++)
00373 if(me_err->getBinContent(i,j)>0){
00374 n_errors_pixel_=n_errors_pixel_+int(me_err->getBinContent(i,j));
00375 if(i<33) n_errors_barrel_=n_errors_barrel_+int(me_err->getBinContent(i,j));
00376 if(i>32) n_errors_endcap_=n_errors_endcap_+int(me_err->getBinContent(i,j));
00377 }
00378 int NProcEvts = me_evt->getIntValue();
00379 if(NProcEvts>0){
00380 barrel_error_flag_ = (float(NProcEvts)-float(n_errors_barrel_))/float(NProcEvts);
00381 endcap_error_flag_ = (float(NProcEvts)-float(n_errors_endcap_))/float(NProcEvts);
00382 pixel_error_flag_ = (float(NProcEvts)-float(n_errors_barrel_)-float(n_errors_endcap_))/float(NProcEvts);
00383 }
00384 }
00385 NErrorsBarrel = bei->get("Pixel/Barrel/BarrelNErrorsCut");
00386 if(NErrorsBarrel) NErrorsBarrel->Fill(barrel_error_flag_);
00387 NErrorsEndcap = bei->get("Pixel/Endcap/EndcapNErrorsCut");
00388 if(NErrorsEndcap) NErrorsEndcap->Fill(endcap_error_flag_);
00389
00390 string meName0;
00391 MonitorElement * me;
00392
00393
00394 if(!Tier0Flag){
00395 meName0 = "Pixel/Barrel/SUMDIG_ndigis_Barrel";
00396 if(digiCounterBarrel/768 > 0.5) digiStatsBarrel = true;
00397 if(digiCounterEndcap/672 > 0.5) digiStatsEndcap = true;
00398
00399 }else{
00400 meName0 = "Pixel/Barrel/SUMOFF_ndigis_Barrel";
00401 if(digiCounterBarrel/192 > 0.5) digiStatsBarrel = true;
00402 if(digiCounterEndcap/96 > 0.5) digiStatsEndcap = true;
00403 }
00404 me = bei->get(meName0);
00405 if(me){
00406 NDigisBarrel = bei->get("Pixel/Barrel/BarrelNDigisCut");
00407
00408 if(NDigisBarrel && digiStatsBarrel){
00409 if(me->hasError()) NDigisBarrel->Fill(0);
00410 else NDigisBarrel->Fill(1);
00411 }
00412 }
00413 if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMDIG_ndigis_Endcap";
00414 else meName0 = "Pixel/Endcap/SUMOFF_ndigis_Endcap";
00415 me = bei->get(meName0);
00416 if(me){
00417 NDigisEndcap = bei->get("Pixel/Endcap/EndcapNDigisCut");
00418 if(NDigisEndcap && digiStatsEndcap){
00419 if(me->hasError()) NDigisEndcap->Fill(0);
00420 else NDigisEndcap->Fill(1);
00421 }
00422 }
00423 if(!Tier0Flag) meName0 = "Pixel/Barrel/SUMDIG_adc_Barrel";
00424 else meName0 = "Pixel/Barrel/SUMOFF_adc_Barrel";
00425 me = bei->get(meName0);
00426 if(me){
00427 DigiChargeBarrel = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
00428 if(DigiChargeBarrel && digiStatsBarrel){
00429 if(me->hasError()) DigiChargeBarrel->Fill(0);
00430 else DigiChargeBarrel->Fill(1);
00431 }
00432 }
00433 if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMDIG_adc_Endcap";
00434 else meName0 = "Pixel/Endcap/SUMOFF_adc_Endcap";
00435 me = bei->get(meName0);
00436 if(me){
00437 DigiChargeEndcap = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
00438 if(DigiChargeEndcap && digiStatsEndcap){
00439 if(me->hasError()) DigiChargeEndcap->Fill(0);
00440 else DigiChargeEndcap->Fill(1);
00441 }
00442 }
00443
00444
00445
00446 if(!Tier0Flag){
00447 meName0 = "Pixel/Barrel/SUMCLU_size_Barrel";
00448 if(clusterCounterBarrel/768 > 0.5) clusterStatsBarrel = true;
00449 if(clusterCounterEndcap/672 > 0.5) clusterStatsEndcap = true;
00450 }else{
00451 meName0 = "Pixel/Barrel/SUMOFF_size_OnTrack_Barrel";
00452 if(clusterCounterBarrel/192 > 0.5) clusterStatsBarrel = true;
00453 if(clusterCounterEndcap/96 > 0.5) clusterStatsEndcap = true;
00454 }
00455 me = bei->get(meName0);
00456 if(me){
00457 ClusterSizeBarrel = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
00458 if(ClusterSizeBarrel && clusterStatsBarrel){
00459 if(me->hasError()) ClusterSizeBarrel->Fill(0);
00460 else ClusterSizeBarrel->Fill(1);
00461 }
00462 }
00463 if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMCLU_size_Endcap";
00464 else meName0 = "Pixel/Endcap/SUMOFF_size_OnTrack_Endcap";
00465 me = bei->get(meName0);
00466 if(me){
00467 ClusterSizeEndcap = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
00468 if(ClusterSizeEndcap && clusterStatsEndcap){
00469 if(me->hasError()) ClusterSizeEndcap->Fill(0);
00470 else ClusterSizeEndcap->Fill(1);
00471 }
00472 }
00473 if(!Tier0Flag) meName0 = "Pixel/Barrel/SUMCLU_charge_Barrel";
00474 else meName0 = "Pixel/Barrel/SUMOFF_charge_OnTrack_Barrel";
00475 me = bei->get(meName0);
00476 if(me){
00477 ClusterChargeBarrel = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
00478 if(ClusterChargeBarrel && clusterStatsBarrel){
00479 if(me->hasError()) ClusterChargeBarrel->Fill(0);
00480 else ClusterChargeBarrel->Fill(1);
00481 }
00482 }
00483 if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMCLU_charge_Endcap";
00484 else meName0 = "Pixel/Endcap/SUMOFF_charge_OnTrack_Endcap";
00485 me = bei->get(meName0);
00486 if(me){
00487 ClusterChargeEndcap = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
00488 if(ClusterChargeEndcap && clusterStatsEndcap){
00489 if(me->hasError()) ClusterChargeEndcap->Fill(0);
00490 else ClusterChargeEndcap->Fill(1);
00491 }
00492 }
00493 if(!Tier0Flag) meName0 = "Pixel/Barrel/SUMCLU_nclusters_Barrel";
00494 else meName0 = "Pixel/Barrel/SUMOFF_nclusters_OnTrack_Barrel";
00495 me = bei->get(meName0);
00496 if(me){
00497 NClustersBarrel = bei->get("Pixel/Barrel/BarrelNClustersCut");
00498 if(NClustersBarrel && clusterStatsBarrel){
00499 if(me->hasError()) NClustersBarrel->Fill(0);
00500 else NClustersBarrel->Fill(1);
00501 }
00502 }
00503 if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMCLU_nclusters_Endcap";
00504 else meName0 = "Pixel/Endcap/SUMOFF_nclusters_OnTrack_Endcap";
00505 me = bei->get(meName0);
00506 if(me){
00507 NClustersEndcap = bei->get("Pixel/Endcap/EndcapNClustersCut");
00508 if(NClustersEndcap && clusterStatsEndcap){
00509 if(me->hasError()) NClustersEndcap->Fill(0);
00510 else NClustersEndcap->Fill(1);
00511 }
00512 }
00513
00514 meName0 = "Pixel/Tracks/ntracks_generalTracks";
00515 me = bei->get(meName0);
00516 if(me){
00517 NPixelTracks = bei->get("Pixel/Tracks/PixelTracksCut");
00518 if(NPixelTracks && me->getBinContent(1)>1000){
00519 if((float)me->getBinContent(2)/(float)me->getBinContent(1)<0.01){
00520 NPixelTracks->Fill(0);
00521 }else{
00522 NPixelTracks->Fill(1);
00523 }
00524 }
00525 }
00526
00527
00528
00529
00530
00531 float pixelFlag = -1., barrelFlag = -1., endcapFlag = -1.;
00532 float barrel_errors_temp[1]={-1.}; int barrel_cuts_temp[5]={5*-1};
00533 float endcap_errors_temp[1]={-1.}; int endcap_cuts_temp[5]={5*-1};
00534 int pixel_cuts_temp[1]={-1};
00535 float combinedCuts = 1.; int numerator = 0, denominator = 0;
00536
00537
00538 me = bei->get("Pixel/Barrel/BarrelNErrorsCut");
00539 if(me) barrel_errors_temp[0] = me->getFloatValue();
00540 me = bei->get("Pixel/Barrel/BarrelNDigisCut");
00541 if(me) barrel_cuts_temp[0] = me->getIntValue();
00542 me = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
00543 if(me) barrel_cuts_temp[1] = me->getIntValue();
00544 me = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
00545 if(me) barrel_cuts_temp[2] = me->getIntValue();
00546 me = bei->get("Pixel/Barrel/BarrelNClustersCut");
00547 if(me) barrel_cuts_temp[3] = me->getIntValue();
00548 me = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
00549 if(me) barrel_cuts_temp[4] = me->getIntValue();
00550 for(int k=0; k!=5; k++){
00551 if(barrel_cuts_temp[k]>=0){
00552 numerator = numerator + barrel_cuts_temp[k];
00553 denominator++;
00554
00555 }
00556 }
00557 if(denominator!=0) combinedCuts = float(numerator)/float(denominator);
00558 barrelFlag = barrel_errors_temp[0] * combinedCuts;
00559
00560
00561
00562
00563
00564 combinedCuts = 1.; numerator = 0; denominator = 0;
00565 me = bei->get("Pixel/Endcap/EndcapNErrorsCut");
00566 if(me) endcap_errors_temp[0] = me->getFloatValue();
00567 me = bei->get("Pixel/Endcap/EndcapNDigisCut");
00568 if(me) endcap_cuts_temp[0] = me->getIntValue();
00569 me = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
00570 if(me) endcap_cuts_temp[1] = me->getIntValue();
00571 me = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
00572 if(me) endcap_cuts_temp[2] = me->getIntValue();
00573 me = bei->get("Pixel/Endcap/EndcapNClustersCut");
00574 if(me) endcap_cuts_temp[3] = me->getIntValue();
00575 me = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
00576 if(me) endcap_cuts_temp[4] = me->getIntValue();
00577 for(int k=0; k!=5; k++){
00578 if(endcap_cuts_temp[k]>=0){
00579 numerator = numerator + endcap_cuts_temp[k];
00580 denominator++;
00581
00582 }
00583 }
00584 if(denominator!=0) combinedCuts = float(numerator)/float(denominator);
00585 endcapFlag = endcap_errors_temp[0] * combinedCuts;
00586
00587
00588
00589 combinedCuts = 1.; numerator = 0; denominator = 0;
00590 me = bei->get("Pixel/Tracks/PixelTracksCut");
00591 if(me) pixel_cuts_temp[0] = me->getIntValue();
00592
00593
00594 combinedCuts = 1.; numerator = 0; denominator = 0;
00595 for(int k=0; k!=5; k++){
00596 if(barrel_cuts_temp[k]>=0){
00597 numerator = numerator + barrel_cuts_temp[k];
00598 denominator++;
00599 }
00600
00601 if(endcap_cuts_temp[k]>=0){
00602 numerator = numerator + endcap_cuts_temp[k];
00603 denominator++;
00604 }
00605 if(k<1 && pixel_cuts_temp[k]>=0){
00606 numerator = numerator + pixel_cuts_temp[k];
00607 denominator++;
00608 }
00609
00610 }
00611 if(denominator!=0) combinedCuts = float(numerator)/float(denominator);
00612 pixelFlag = float(pixel_error_flag_) * float(combinedCuts);
00613
00614
00615
00616 SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00617 if(SummaryPixel) SummaryPixel->Fill(pixelFlag);
00618 SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00619 if(SummaryBarrel) SummaryBarrel->Fill(barrelFlag);
00620 SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00621 if(SummaryEndcap) SummaryEndcap->Fill(endcapFlag);
00622 }
00623 }
00624
00625
00626
00627 void SiPixelDataQuality::computeGlobalQualityFlagByLumi(DQMStore * bei,
00628 bool init,
00629 int nFEDs,
00630 bool Tier0Flag,
00631 int nEvents_lastLS_,
00632 int nErrorsBarrel_lastLS_,
00633 int nErrorsEndcap_lastLS_){
00634
00635
00636
00637
00638
00639
00640
00641 if(nFEDs==0) return;
00642
00643
00644 float BarrelRate_LS = 1.;
00645 float EndcapRate_LS = 1.;
00646 float PixelRate_LS = 1.;
00647 MonitorElement * me = bei->get("Pixel/AdditionalPixelErrors/byLumiErrors");
00648 if(me){
00649
00650 double nBarrelErrors_LS = me->getBinContent(1) - nErrorsBarrel_lastLS_;
00651 double nEndcapErrors_LS = me->getBinContent(2) - nErrorsEndcap_lastLS_;
00652 double nEvents_LS = me->getBinContent(0) - nEvents_lastLS_;
00653
00654 if(nBarrelErrors_LS/nEvents_LS>0.5) BarrelRate_LS=0.;
00655 if(nEndcapErrors_LS/nEvents_LS>0.5) EndcapRate_LS=0.;
00656 if((nBarrelErrors_LS + nEndcapErrors_LS)/nEvents_LS>0.5) PixelRate_LS=0.;
00657
00658 }
00659
00660
00661 float BarrelClusterCharge = 1.;
00662 float EndcapClusterCharge = 1.;
00663 float PixelClusterCharge = 1.;
00664 MonitorElement * me1 = bei->get("Pixel/Clusters/OnTrack/charge_siPixelClusters_Barrel");
00665 if(me1 && me1->getMean()<12.) BarrelClusterCharge = 0.;
00666
00667 MonitorElement * me2 = bei->get("Pixel/Clusters/OnTrack/charge_siPixelClusters_Endcap");
00668 if(me2 && me2->getMean()<12.) EndcapClusterCharge = 0.;
00669
00670 MonitorElement * me3 = bei->get("Pixel/Clusters/OnTrack/charge_siPixelClusters");
00671 if(me3 && me3->getMean()<12.) PixelClusterCharge = 0.;
00672
00673
00674
00675 float BarrelOccupancy = 1.;
00676 float EndcapOccupancy = 1.;
00677 float PixelOccupancy = 1.;
00678 MonitorElement * me4 = bei->get("Pixel/averageDigiOccupancy");
00679 if(me4){
00680 double minBarrelOcc = 999999.;
00681 double maxBarrelOcc = -1.;
00682 double meanBarrelOcc = 0.;
00683 double minEndcapOcc = 999999.;
00684 double maxEndcapOcc = -1.;
00685 double meanEndcapOcc = 0.;
00686 for(int i=1; i!=41; i++){
00687 if(i<=32 && me4->getBinContent(i)<minBarrelOcc) minBarrelOcc=me4->getBinContent(i);
00688 if(i<=32 && me4->getBinContent(i)>maxBarrelOcc) maxBarrelOcc=me4->getBinContent(i);
00689 if(i<=32) meanBarrelOcc+=me4->getBinContent(i);
00690 if(i>32 && me4->getBinContent(i)<minEndcapOcc) minEndcapOcc=me4->getBinContent(i);
00691 if(i>32 && me4->getBinContent(i)>maxEndcapOcc) maxEndcapOcc=me4->getBinContent(i);
00692 if(i>32) meanEndcapOcc+=me4->getBinContent(i);
00693
00694 }
00695 meanBarrelOcc = meanBarrelOcc/32.;
00696 meanEndcapOcc = meanEndcapOcc/8.;
00697
00698 if(minBarrelOcc<0.1*meanBarrelOcc || maxBarrelOcc>2.5*meanBarrelOcc) BarrelOccupancy=0.;
00699 if(minEndcapOcc<0.2*meanEndcapOcc || maxEndcapOcc>1.8*meanEndcapOcc) EndcapOccupancy=0.;
00700 PixelOccupancy=BarrelOccupancy*EndcapOccupancy;
00701
00702 }
00703
00704 float pixelFlag = PixelRate_LS * PixelClusterCharge * PixelOccupancy;
00705 float barrelFlag = BarrelRate_LS * BarrelClusterCharge * BarrelOccupancy;
00706 float endcapFlag = EndcapRate_LS * EndcapClusterCharge * EndcapOccupancy;
00707
00708 SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00709 if(SummaryPixel) SummaryPixel->Fill(pixelFlag);
00710 SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00711 if(SummaryBarrel) SummaryBarrel->Fill(barrelFlag);
00712 SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00713 if(SummaryEndcap) SummaryEndcap->Fill(endcapFlag);
00714
00715 }
00716
00717
00718
00719 void SiPixelDataQuality::fillGlobalQualityPlot(DQMStore * bei, bool init, edm::EventSetup const& eSetup, int nFEDs, bool Tier0Flag, int lumisec){
00720
00721
00722
00723 if(init){
00724 count=0; errcount=0;
00725 init=false;
00726 count1=0;
00727 count2=0;
00728 count3=0;
00729 count4=0;
00730 count5=0;
00731 count6=0;
00732 modCounter_=0;
00733 if(!Tier0Flag){
00734
00735
00736
00737
00738
00739 for(int j=1; j!=41; j++){
00740 if(allmodsVec) lastallmods_[j-1] = allmodsVec->GetBinContent(j);
00741 if(errmodsVec) lasterrmods_[j-1] = errmodsVec->GetBinContent(j);
00742 if(allmodsVec) allmodsVec->SetBinContent(j,0.);
00743 if(errmodsVec) errmodsVec->SetBinContent(j,0.);
00744 if(goodmodsVec) goodmodsVec->SetBinContent(j,0.);
00745 }
00746 }
00747 if(Tier0Flag){
00748 for(int i=1; i!=3; i++) for(int j=1; j!=8; j++){
00749 if(allmodsMap) allmodsMap->SetBinContent(i,j,0.);
00750 if(errmodsMap) errmodsMap->SetBinContent(i,j,0.);
00751 if(goodmodsMap) goodmodsMap->SetBinContent(i,j,0.);
00752 }
00753 }
00754 }
00755
00756
00757
00758
00759 if(nFEDs==0) return;
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954 if(!Tier0Flag){
00955
00956 MonitorElement * meTmp = bei->get("Pixel/Barrel/NClustertoChargeRatio_AllMod");
00957 MonitorElement * meTop = bei->get("Pixel/Barrel/SUMCLU_nclusters_Barrel");
00958 MonitorElement * meBot = bei->get("Pixel/Barrel/SUMCLU_charge_Barrel");
00959 if(meTop && meBot && meTmp){
00960 for (int bin = 1; bin < 769; ++bin){
00961 float content = 0.0;
00962 if (meBot->getBinContent(bin) > 0.0){
00963 content = meTop->getBinContent(bin)/meBot->getBinContent(bin);
00964 }
00965 meTmp->setBinContent(bin,content);
00966 }
00967 for (int j = 0; j < 4; ++j){
00968 static const char buf[] = "Pixel/Barrel/NClustertoChargeRatio_NormMod%i";
00969 char modplot[sizeof(buf)+2];
00970 sprintf(modplot,buf,j+1);
00971 MonitorElement * meFinal = bei->get(modplot);
00972 if(!meFinal) continue;
00973 for (int i = 1; i < 769; ++i){
00974 int k = 3 - j;
00975 if (int(i+k)%4 == 0)
00976 meFinal->setBinContent(int((i+k)/4), meTmp->getBinContent(i));
00977 }
00978
00979 float SFLay[3], TotLay[3];
00980 for (int ll = 0; ll < 3; ++ll) TotLay[ll] = 0.0;
00981 for (int bin = 1; bin < (meFinal->getNbinsX()+1);++bin){
00982 int layer = int((bin%48)/16);
00983 TotLay[layer] += meFinal->getBinContent(bin);
00984 }
00985 float laynorm = TotLay[1]/64.;
00986 for (int ll = 0; ll < 3; ++ll){
00987 SFLay[ll] = 0.0; if (TotLay[ll] > 0.0 && TotLay[1] > 0.0) SFLay[ll] = TotLay[1]/TotLay[ll]*(1./laynorm);
00988 }
00989
00990 for (int bin = 1; bin < (meFinal->getNbinsX()+1); ++bin){
00991
00992 int layer = int((bin%48)/16);
00993 float content = meFinal->getBinContent(bin);
00994
00995 meFinal->setBinContent(bin,content*SFLay[layer]);
00996 }
00997 }
00998 }
00999
01000 eSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap);
01001 string currDir = bei->pwd();
01002 if(currDir.find("Reference")!=string::npos || currDir.find("Additional")!=string::npos) return;
01003
01004 string dname = currDir.substr(currDir.find_last_of("/")+1);
01005 if(dname.find("Module_")!=string::npos && currDir.find("Reference")==string::npos){
01006 vector<string> meVec = bei->getMEs();
01007 int detId=-1; int fedId=-1;
01008 for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++){
01009
01010 string full_path = currDir + "/" + (*it);
01011 if(detId==-1 && full_path.find("SUMOFF")==string::npos &&
01012 (full_path.find("ndigis")!=string::npos && full_path.find("SUMDIG")==string::npos) &&
01013 (getDetId(bei->get(full_path)) > 100)){
01014 MonitorElement * me = bei->get(full_path);
01015 if (!me) continue;
01016 if((full_path.find("ndigis")!=string::npos)){
01017 modCounter_++;
01018 detId = getDetId(me);
01019 for(int fedid=0; fedid!=40; ++fedid){
01020 SiPixelFrameConverter converter(theCablingMap.product(),fedid);
01021 uint32_t newDetId = detId;
01022 if(converter.hasDetUnit(newDetId)){
01023 fedId=fedid;
01024 break;
01025 }
01026 }
01027 double NDigis = 0;
01028 if(full_path.find("ndigis")!=string::npos) NDigis = me->getEntries();
01029 float weight = (allmodsVec->GetBinContent(fedId+1))+NDigis;
01030
01031 allmodsVec->SetBinContent(fedId+1,weight);
01032
01033 }
01034 }
01035 }
01036 }
01037
01038
01039
01040
01041 vector<string> subDirVec = bei->getSubdirs();
01042 for (vector<string>::const_iterator ic = subDirVec.begin();
01043 ic != subDirVec.end(); ic++) {
01044 bei->cd(*ic);
01045 init=false;
01046 fillGlobalQualityPlot(bei,init,eSetup,nFEDs,Tier0Flag,lumisec);
01047 bei->goUp();
01048 }
01049
01050 if(modCounter_==1440){
01051 bei->cd("Pixel/EventInfo/reportSummaryContents");
01052 if(bei->pwd()=="Pixel/EventInfo/reportSummaryContents"){
01053 for(int i=0; i!=40; i++){
01054 static const char buf[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
01055 char fedplot[sizeof(buf)+4];
01056 int NErrors = 0;
01057 for(int j=0; j!=37; j++){
01058 sprintf(fedplot,buf,i,j);
01059 MonitorElement * me = bei->get(fedplot);
01060 if(me) NErrors = NErrors + me->getIntValue();
01061 }
01062
01063
01064 if(NErrors>0){ errmodsVec->SetBinContent(i+1,NErrors); }
01065 }
01066 SummaryReportMap = bei->get("Pixel/EventInfo/reportSummaryMap");
01067 if(SummaryReportMap){
01068 float contents=0.;
01069 for(int i=1; i!=41; i++){
01070
01071
01072 float mydigis = allmodsVec->GetBinContent(i) - lastallmods_[i-1];
01073 float myerrs = errmodsVec->GetBinContent(i) - lasterrmods_[i-1];
01074 if ((mydigis + myerrs) > 0.){
01075 contents = mydigis/(mydigis + myerrs);
01076
01077 }else{
01078
01079
01080 contents = -0.5;
01081 }
01082 SummaryReportMap->setBinContent(lumisec+1,i,contents);
01083 }
01084 }
01085 }
01086 }
01087 }else{
01088 float barrel_errors_temp[1]={-1.}; int barrel_cuts_temp[6]={6*-1};
01089 float endcap_errors_temp[1]={-1.}; int endcap_cuts_temp[6]={6*-1};
01090 int pixel_cuts_temp[1]={-1};
01091
01092 MonitorElement * me;
01093 me = bei->get("Pixel/Barrel/BarrelNErrorsCut");
01094 if(me) barrel_errors_temp[0] = me->getFloatValue();
01095 me = bei->get("Pixel/Endcap/EndcapNErrorsCut");
01096 if(me) endcap_errors_temp[0] = me->getFloatValue();
01097 SummaryReportMap->setBinContent(1,1,barrel_errors_temp[0]);
01098 SummaryReportMap->setBinContent(2,1,endcap_errors_temp[0]);
01099 me = bei->get("Pixel/Barrel/BarrelNDigisCut");
01100 if(me) barrel_cuts_temp[0] = me->getIntValue();
01101 me = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
01102 if(me) barrel_cuts_temp[1] = me->getIntValue();
01103 me = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
01104 if(me) barrel_cuts_temp[2] = me->getIntValue();
01105 me = bei->get("Pixel/Barrel/BarrelNClustersCut");
01106 if(me) barrel_cuts_temp[3] = me->getIntValue();
01107 me = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
01108 if(me) barrel_cuts_temp[4] = me->getIntValue();
01109 me = bei->get("Pixel/Endcap/EndcapNDigisCut");
01110 if(me) endcap_cuts_temp[0] = me->getIntValue();
01111 me = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
01112 if(me) endcap_cuts_temp[1] = me->getIntValue();
01113 me = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
01114 if(me) endcap_cuts_temp[2] = me->getIntValue();
01115 me = bei->get("Pixel/Endcap/EndcapNClustersCut");
01116 if(me) endcap_cuts_temp[3] = me->getIntValue();
01117 me = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
01118 if(me) endcap_cuts_temp[4] = me->getIntValue();
01119 for(int j=2; j!=7; j++){
01120 SummaryReportMap->setBinContent(1,j,barrel_cuts_temp[j-2]);
01121 SummaryReportMap->setBinContent(2,j,endcap_cuts_temp[j-2]);
01122
01123 }
01124 me = bei->get("Pixel/Tracks/PixelTracksCut");
01125 if(me) pixel_cuts_temp[0] = me->getIntValue();
01126 SummaryReportMap->setBinContent(1,7,pixel_cuts_temp[0]);
01127 SummaryReportMap->setBinContent(2,7,pixel_cuts_temp[0]);
01128 }
01129 if(allmodsMap) allmodsMap->Clear();
01130 if(goodmodsMap) goodmodsMap->Clear();
01131 if(errmodsMap) errmodsMap->Clear();
01132 }
01133
01134
01135