CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DQM/SiPixelMonitorClient/src/SiPixelDataQuality.cc

Go to the documentation of this file.
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> // for free() - Root can allocate with malloc() - sigh...
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 // } else {
00123 //  cout << ACYellow << ACBold
00124 //       << "[SiPixelInformationExtractor::getDetId()] "
00125 //       << ACPlain
00126 //       << "Could not extract detId from "
00127 //       << mEName
00128 //       << endl ;
00129  }
00130       
00131   return detId ;
00132   
00133 }
00134 
00136 
00137 void SiPixelDataQuality::bookGlobalQualityFlag(DQMStore * bei, bool Tier0Flag, int nFEDs) {
00138 //std::cout<<"BOOK GLOBAL QUALITY FLAG MEs!"<<std::endl;
00139   bei->cd();
00140   
00141   bei->setCurrentFolder("Pixel/EventInfo");
00142   if(!Tier0Flag){
00143     /*SummaryReportMap = bei->book2D("reportSummaryMap","Pixel Summary Map",40,0.,40.,36,1.,37.);
00144     SummaryReportMap->setAxisTitle("Pixel FED #",1);
00145     SummaryReportMap->setAxisTitle("Pixel FED Channel #",2);
00146     allmodsMap = new TH2F("allmodsMap","allmodsMap",40,0.,40.,36,1.,37.);
00147     errmodsMap = new TH2F("errmodsMap","errmodsMap",40,0.,40.,36,1.,37.);
00148     goodmodsMap = new TH2F("goodmodsMap","goodmodsMap",40,0.,40.,36,1.,37.);
00149     */
00150     SummaryReportMap = bei->book2D("reportSummaryMap","Pixel Summary Map",3000,0.,3000.,40,0.,40.);
00151     SummaryReportMap->setAxisTitle("Lumi Section",1);
00152     SummaryReportMap->setAxisTitle("Pixel FED #",2);
00153     allmodsVec = new TH1D("allmodsVec","allmodsVec",40,0.,40.);
00154     errmodsVec = new TH1D("errmodsVec","errmodsVec",40,0.,40.);
00155     goodmodsVec = new TH1D("goodmodsVec","goodmodsVec",40,0.,40.);
00156   }else{
00157     SummaryReportMap = bei->book2D("reportSummaryMap","Pixel Summary Map",2,0.,2.,7,0.,7.);
00158     SummaryReportMap->setBinLabel(1,"Barrel",1);
00159     SummaryReportMap->setBinLabel(2,"Endcaps",1);
00160     SummaryReportMap->setBinLabel(1,"Errors",2);
00161     SummaryReportMap->setBinLabel(2,"NDigis",2);
00162     SummaryReportMap->setBinLabel(3,"DigiCharge",2);
00163     SummaryReportMap->setBinLabel(4,"ClusterSize",2);
00164     SummaryReportMap->setBinLabel(5,"NClusters",2);
00165     SummaryReportMap->setBinLabel(6,"ClusterCharge",2);
00166     SummaryReportMap->setBinLabel(7,"HitEff",2);
00167     allmodsMap = new TH2F("allmodsMap","allmodsMap",2,0.,2.,7,0.,7.);
00168     errmodsMap = new TH2F("errmodsMap","errmodsMap",2,0.,2.,7,0.,7.);
00169     goodmodsMap = new TH2F("goodmodsMap","goodmodsMap",2,0.,2.,7,0.,7.);
00170   }  
00171     SummaryPixel = bei->bookFloat("reportSummary");
00172   bei->setCurrentFolder("Pixel/EventInfo/reportSummaryContents");
00173     SummaryBarrel = bei->bookFloat("PixelBarrelFraction");
00174     SummaryEndcap = bei->bookFloat("PixelEndcapFraction");
00175   // book the data certification cuts:
00176   bei->setCurrentFolder("Pixel/AdditionalPixelErrors");
00177     NErrorsFEDs = bei->bookFloat("FEDsNErrorsCut");
00178   bei->setCurrentFolder("Pixel/Barrel");
00179     NErrorsBarrel = bei->bookFloat("BarrelNErrorsCut");
00180     NDigisBarrel = bei->bookInt("BarrelNDigisCut");
00181     DigiChargeBarrel = bei->bookInt("BarrelDigiChargeCut");
00182     ClusterSizeBarrel = bei->bookInt("BarrelClusterSizeCut");
00183     NClustersBarrel = bei->bookInt("BarrelNClustersCut");
00184     ClusterChargeBarrel = bei->bookInt("BarrelClusterChargeCut");
00185   bei->setCurrentFolder("Pixel/Endcap");
00186     NErrorsEndcap = bei->bookFloat("EndcapNErrorsCut");
00187     NDigisEndcap = bei->bookInt("EndcapNDigisCut");
00188     DigiChargeEndcap = bei->bookInt("EndcapDigiChargeCut");
00189     ClusterSizeEndcap = bei->bookInt("EndcapClusterSizeCut");
00190     NClustersEndcap = bei->bookInt("EndcapNClustersCut");
00191     ClusterChargeEndcap = bei->bookInt("EndcapClusterChargeCut");
00192   if(Tier0Flag){
00193     bei->setCurrentFolder("Pixel/Tracks");
00194       NPixelTracks = bei->bookInt("PixelTracksCut");
00195   }
00196     
00197     // Init MonitoringElements:
00198     if(nFEDs>0){
00199       SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00200       if(SummaryPixel) SummaryPixel->Fill(1.);
00201       SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00202       if(SummaryBarrel) SummaryBarrel->Fill(1.);
00203       SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00204       if(SummaryEndcap) SummaryEndcap->Fill(1.);
00205     }else{
00206       SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00207       if(SummaryPixel) SummaryPixel->Fill(-1.);
00208       SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00209       if(SummaryBarrel) SummaryBarrel->Fill(-1.);
00210       SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00211       if(SummaryEndcap) SummaryEndcap->Fill(-1.);
00212     }
00213     NErrorsBarrel = bei->get("Pixel/Barrel/BarrelNErrorsCut");
00214     if(NErrorsBarrel) NErrorsBarrel->Fill(1.);
00215     NErrorsEndcap = bei->get("Pixel/Endcap/EndcapNErrorsCut");
00216     if(NErrorsEndcap) NErrorsEndcap->Fill(1.);
00217     NErrorsFEDs = bei->get("Pixel/AdditionalPixelErrors/FEDsNErrorsCut");
00218     if(NErrorsFEDs) NErrorsFEDs->Fill(1.);
00219     NDigisBarrel = bei->get("Pixel/Barrel/BarrelNDigisCut");
00220     if(NDigisBarrel) NDigisBarrel->Fill(1);
00221     NDigisEndcap = bei->get("Pixel/Endcap/EndcapNDigisCut");
00222     if(NDigisEndcap) NDigisEndcap->Fill(1);
00223     DigiChargeBarrel = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
00224     if(DigiChargeBarrel) DigiChargeBarrel->Fill(1);
00225     DigiChargeEndcap = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
00226     if(DigiChargeEndcap) DigiChargeEndcap->Fill(1);
00227     ClusterSizeBarrel = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
00228     if(ClusterSizeBarrel) ClusterSizeBarrel->Fill(1);
00229     ClusterSizeEndcap = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
00230     if(ClusterSizeEndcap) ClusterSizeEndcap->Fill(1);
00231     ClusterChargeBarrel = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
00232     if(ClusterChargeBarrel) ClusterChargeBarrel->Fill(1);
00233     ClusterChargeEndcap = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
00234     if(ClusterChargeEndcap) ClusterChargeEndcap->Fill(1);
00235     NClustersBarrel = bei->get("Pixel/Barrel/BarrelNClustersCut");
00236     if(NClustersBarrel) NClustersBarrel->Fill(1);
00237     NClustersEndcap = bei->get("Pixel/Endcap/EndcapNClustersCut");
00238     if(NClustersEndcap) NClustersEndcap->Fill(1);
00239     if(Tier0Flag){
00240       NPixelTracks = bei->get("Pixel/Tracks/PixelTracksCut");
00241       if(NPixelTracks) NPixelTracks->Fill(1);
00242     }
00243    
00244     SummaryReportMap = bei->get("Pixel/EventInfo/reportSummaryMap");
00245     if(SummaryReportMap){
00246       if(!Tier0Flag) for(int i=1; i!=3001; i++) for(int j=1; j!=41; j++) SummaryReportMap->setBinContent(i,j,-1.);
00247       if(Tier0Flag) for(int i=1; i!=3; i++) for(int j=1; j!=8; j++) SummaryReportMap->setBinContent(i,j,-1.);
00248     }
00249     if(!Tier0Flag){
00250       for(int j=1; j!=41; j++){
00251         if(allmodsVec) allmodsVec->SetBinContent(j,0.);
00252         if(errmodsVec) errmodsVec->SetBinContent(j,0.);
00253         if(goodmodsVec) goodmodsVec->SetBinContent(j,0.);
00254       }
00255     }
00256     if(Tier0Flag){
00257       for(int i=1; i!=3; i++) for(int j=1; j!=8; j++){
00258         if(allmodsMap) allmodsMap->SetBinContent(i,j,0.);
00259         if(errmodsMap) errmodsMap->SetBinContent(i,j,0.);
00260         if(goodmodsMap) goodmodsMap->SetBinContent(i,j,0.);
00261       }
00262     }
00263     
00264   bei->cd();  
00265 }
00266 
00267 //**********************************************************************************************
00268 
00269 void SiPixelDataQuality::computeGlobalQualityFlag(DQMStore * bei, 
00270                                                            bool init,
00271                                                            int nFEDs,
00272                                                            bool Tier0Flag){
00273 //cout<<"entering SiPixelDataQuality::ComputeGlobalQualityFlag"<<endl;
00274 //   cout << ACRed << ACBold
00275 //        << "[SiPixelDataQuality::ComputeGlobalQualityFlag]"
00276 //        << ACPlain
00277 //        << " Enter" 
00278 //        << endl ;
00279   if(init){
00280 //cout<<"Entering SiPixelDataQuality::computeGlobalQualityFlag for the first time"<<endl;
00281     allMods_=0; errorMods_=0; qflag_=0.; 
00282     barrelMods_=0; endcapMods_=0;
00283     objectCount_=0;
00284     DONE_ = false;
00285     
00286     //Error counters and flags:
00287     n_errors_barrel_=0; barrel_error_flag_=0.;
00288     n_errors_endcap_=0; endcap_error_flag_=0.;
00289     n_errors_pixel_=0; pixel_error_flag_=0.;
00290     digiStatsBarrel = false, clusterStatsBarrel = false, trackStatsBarrel = false;
00291     digiCounterBarrel = 0, clusterCounterBarrel = 0, trackCounterBarrel = 0;
00292     digiStatsEndcap = false, clusterStatsEndcap = false, trackStatsEndcap = false;
00293     digiCounterEndcap = 0, clusterCounterEndcap = 0, trackCounterEndcap = 0;
00294     init=false;
00295   }
00296   if(nFEDs==0) return;  
00297   
00298   string currDir = bei->pwd();
00299   string dname = currDir.substr(currDir.find_last_of("/")+1);
00300 //cout<<"currDir="<<currDir<<endl;
00301   
00302   if((!Tier0Flag && dname.find("Module_")!=string::npos) || 
00303      (Tier0Flag && (dname.find("Ladder_")!=string::npos || dname.find("Blade_")!=string::npos))){
00304 
00305     objectCount_++;
00306 
00307     if(currDir.find("Pixel")!=string::npos) allMods_++;
00308     if(currDir.find("Barrel")!=string::npos) barrelMods_++;
00309     if(currDir.find("Endcap")!=string::npos) endcapMods_++;
00310     vector<string> meVec = bei->getMEs();
00311     for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
00312       string full_path = currDir + "/" + (*it);
00313       //cout<<"full_path:"<<full_path<<endl;
00314       if(full_path.find("ndigis_")!=string::npos){
00315       //cout<<"found an ndigi histo now"<<endl;
00316         MonitorElement * me = bei->get(full_path);
00317         if(!me) continue;
00318         //cout<<"got the histo now"<<endl;
00319         if(me->getEntries()>25){
00320         //cout<<"histo has more than 50 entries"<<endl;
00321           if(full_path.find("Barrel")!=string::npos) digiCounterBarrel++;
00322           if(full_path.find("Endcap")!=string::npos) digiCounterEndcap++;
00323           //cout<<"counter are now: "<<digiCounterBarrel<<","<<digiCounterBarrelL1<<endl;
00324         }
00325       }else if(Tier0Flag && full_path.find("nclusters_OnTrack_")!=string::npos){
00326         MonitorElement * me = bei->get(full_path);
00327         if(!me) continue;
00328         if(me->getEntries()>25){
00329           if(full_path.find("Barrel")!=string::npos) clusterCounterBarrel++;
00330           if(full_path.find("Endcap")!=string::npos) clusterCounterEndcap++;
00331         }
00332       }else if(!Tier0Flag && full_path.find("nclusters_")!=string::npos){
00333         MonitorElement * me = bei->get(full_path);
00334         if(!me) continue;
00335         if(me->getEntries()>25){
00336           if(full_path.find("Barrel")!=string::npos) clusterCounterBarrel++;
00337           if(full_path.find("Endcap")!=string::npos) clusterCounterEndcap++;
00338         }
00339       }
00340     }
00341   }
00342   vector<string> subDirVec = bei->getSubdirs();  
00343   for (vector<string>::const_iterator ic = subDirVec.begin();
00344        ic != subDirVec.end(); ic++) {
00345     bei->cd(*ic);
00346     init=false;
00347     computeGlobalQualityFlag(bei,init,nFEDs,Tier0Flag);
00348     bei->goUp();
00349   }
00350   
00351   // Make sure I have finished looping over all Modules/Ladders/Blades:
00352   if(!Tier0Flag){ // online case
00353     if(objectCount_ == 1440) DONE_ = true;
00354   }else{ // offline case
00355     if(objectCount_ == 288) DONE_ = true;
00356   } 
00357   
00358   if(DONE_ && currDir=="Pixel/EventInfo/reportSummaryContents"){ 
00359 
00360   // Evaluate error flag now, only stored in AdditionalPixelErrors:
00361   MonitorElement * me_err = bei->get("Pixel/AdditionalPixelErrors/FedETypeNErrArray");
00362   MonitorElement * me_evt = bei->get("Pixel/EventInfo/processedEvents");
00363   if(me_err && me_evt){
00364     for(int i=1; i!=41; i++)for(int j=1; j!=22; j++)
00365       if(me_err->getBinContent(i,j)>0){
00366         n_errors_pixel_=n_errors_pixel_+int(me_err->getBinContent(i,j));
00367         if(i<33) n_errors_barrel_=n_errors_barrel_+int(me_err->getBinContent(i,j));
00368         if(i>32) n_errors_endcap_=n_errors_endcap_+int(me_err->getBinContent(i,j));
00369       }
00370     int NProcEvts = me_evt->getIntValue();
00371     if(NProcEvts>0){
00372       barrel_error_flag_ = (float(NProcEvts)-float(n_errors_barrel_))/float(NProcEvts);
00373       endcap_error_flag_ = (float(NProcEvts)-float(n_errors_endcap_))/float(NProcEvts);
00374       pixel_error_flag_ = (float(NProcEvts)-float(n_errors_barrel_)-float(n_errors_endcap_))/float(NProcEvts);
00375     }
00376   }
00377   NErrorsBarrel = bei->get("Pixel/Barrel/BarrelNErrorsCut");
00378   if(NErrorsBarrel) NErrorsBarrel->Fill(barrel_error_flag_);
00379   NErrorsEndcap = bei->get("Pixel/Endcap/EndcapNErrorsCut");
00380   if(NErrorsEndcap)   NErrorsEndcap->Fill(endcap_error_flag_);
00381   
00382   string meName0;
00383   MonitorElement * me;
00384   
00385   // Fill the Digi flags:
00386   if(!Tier0Flag){
00387     meName0 = "Pixel/Barrel/SUMDIG_ndigis_Barrel";
00388     if(digiCounterBarrel/768 > 0.5) digiStatsBarrel = true;
00389     if(digiCounterEndcap/672 > 0.5) digiStatsEndcap = true;
00390     //cout<<"digiStatsBarrel="<<digiStatsBarrel<<" , digiStatsEndcap="<<digiStatsEndcap<<endl;
00391   }else{
00392     meName0 = "Pixel/Barrel/SUMOFF_ndigis_Barrel"; 
00393     if(digiCounterBarrel/192 > 0.5) digiStatsBarrel = true;
00394     if(digiCounterEndcap/96 > 0.5) digiStatsEndcap = true;
00395   }
00396   me = bei->get(meName0);
00397   if(me){
00398     NDigisBarrel = bei->get("Pixel/Barrel/BarrelNDigisCut");
00399    // cout<<"NDigis: "<<NDigisBarrel<<" , "<<digiStatsBarrel<<" , "<<me->hasError()<<endl;
00400     if(NDigisBarrel && digiStatsBarrel){
00401       if(me->hasError()) NDigisBarrel->Fill(0);
00402       else NDigisBarrel->Fill(1); 
00403     }
00404   }
00405   if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMDIG_ndigis_Endcap";
00406   else meName0 = "Pixel/Endcap/SUMOFF_ndigis_Endcap"; 
00407   me = bei->get(meName0);
00408   if(me){
00409     NDigisEndcap = bei->get("Pixel/Endcap/EndcapNDigisCut");
00410     if(NDigisEndcap && digiStatsEndcap){
00411       if(me->hasError()) NDigisEndcap->Fill(0);
00412       else NDigisEndcap->Fill(1);
00413     }
00414   }
00415   if(!Tier0Flag) meName0 = "Pixel/Barrel/SUMDIG_adc_Barrel";
00416   else meName0 = "Pixel/Barrel/SUMOFF_adc_Barrel"; 
00417   me = bei->get(meName0);
00418   if(me){
00419     DigiChargeBarrel = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
00420     if(DigiChargeBarrel && digiStatsBarrel){
00421       if(me->hasError()) DigiChargeBarrel->Fill(0);
00422       else DigiChargeBarrel->Fill(1);
00423     }
00424   }
00425   if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMDIG_adc_Endcap";
00426   else meName0 = "Pixel/Endcap/SUMOFF_adc_Endcap"; 
00427   me = bei->get(meName0);
00428   if(me){
00429     DigiChargeEndcap = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
00430     if(DigiChargeEndcap && digiStatsEndcap){
00431       if(me->hasError()) DigiChargeEndcap->Fill(0);
00432       else DigiChargeEndcap->Fill(1);
00433     }
00434   }
00435      
00436      
00437     // Fill the Cluster flags:
00438   if(!Tier0Flag){
00439     meName0 = "Pixel/Barrel/SUMCLU_size_Barrel";
00440     if(clusterCounterBarrel/768 > 0.5) clusterStatsBarrel = true;
00441     if(clusterCounterEndcap/672 > 0.5) clusterStatsEndcap = true;
00442   }else{
00443     meName0 = "Pixel/Barrel/SUMOFF_size_OnTrack_Barrel"; 
00444     if(clusterCounterBarrel/192 > 0.5) clusterStatsBarrel = true;
00445     if(clusterCounterEndcap/96 > 0.5) clusterStatsEndcap = true;
00446   }
00447   me = bei->get(meName0);
00448   if(me){
00449     ClusterSizeBarrel = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
00450     if(ClusterSizeBarrel && clusterStatsBarrel){
00451       if(me->hasError()) ClusterSizeBarrel->Fill(0);
00452       else ClusterSizeBarrel->Fill(1);
00453     }
00454   }
00455   if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMCLU_size_Endcap";
00456   else meName0 = "Pixel/Endcap/SUMOFF_size_OnTrack_Endcap"; 
00457   me = bei->get(meName0);
00458   if(me){
00459     ClusterSizeEndcap = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
00460     if(ClusterSizeEndcap && clusterStatsEndcap){
00461       if(me->hasError()) ClusterSizeEndcap->Fill(0);
00462       else ClusterSizeEndcap->Fill(1);
00463     }
00464   }
00465   if(!Tier0Flag) meName0 = "Pixel/Barrel/SUMCLU_charge_Barrel";
00466   else meName0 = "Pixel/Barrel/SUMOFF_charge_OnTrack_Barrel"; 
00467   me = bei->get(meName0);
00468   if(me){
00469     ClusterChargeBarrel = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
00470     if(ClusterChargeBarrel && clusterStatsBarrel){
00471       if(me->hasError()) ClusterChargeBarrel->Fill(0);
00472       else ClusterChargeBarrel->Fill(1);
00473     }
00474   }
00475   if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMCLU_charge_Endcap";
00476   else meName0 = "Pixel/Endcap/SUMOFF_charge_OnTrack_Endcap"; 
00477   me = bei->get(meName0);
00478   if(me){
00479     ClusterChargeEndcap = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
00480     if(ClusterChargeEndcap && clusterStatsEndcap){
00481       if(me->hasError()) ClusterChargeEndcap->Fill(0);
00482       else ClusterChargeEndcap->Fill(1);
00483     }
00484   }
00485   if(!Tier0Flag) meName0 = "Pixel/Barrel/SUMCLU_nclusters_Barrel";
00486   else meName0 = "Pixel/Barrel/SUMOFF_nclusters_OnTrack_Barrel"; 
00487   me = bei->get(meName0);
00488   if(me){
00489     NClustersBarrel = bei->get("Pixel/Barrel/BarrelNClustersCut");
00490     if(NClustersBarrel && clusterStatsBarrel){
00491       if(me->hasError()) NClustersBarrel->Fill(0);
00492       else NClustersBarrel->Fill(1);
00493     }
00494   }
00495   if(!Tier0Flag) meName0 = "Pixel/Endcap/SUMCLU_nclusters_Endcap";
00496   else meName0 = "Pixel/Endcap/SUMOFF_nclusters_OnTrack_Endcap"; 
00497   me = bei->get(meName0);
00498   if(me){
00499     NClustersEndcap = bei->get("Pixel/Endcap/EndcapNClustersCut");
00500     if(NClustersEndcap && clusterStatsEndcap){
00501       if(me->hasError()) NClustersEndcap->Fill(0);
00502       else NClustersEndcap->Fill(1);
00503     }
00504   }
00505   // Pixel Track multiplicity / Pixel hit efficiency
00506   meName0 = "Pixel/Tracks/ntracks_generalTracks";
00507   me = bei->get(meName0);
00508   if(me){
00509     NPixelTracks = bei->get("Pixel/Tracks/PixelTracksCut");
00510     if(NPixelTracks && me->getBinContent(1)>1000){
00511       if((float)me->getBinContent(2)/(float)me->getBinContent(1)<0.01){
00512         NPixelTracks->Fill(0);
00513       }else{ 
00514         NPixelTracks->Fill(1);
00515       }
00516     }
00517   }
00518   
00519   
00520 //********************************************************************************************************  
00521   
00522   // Final combination of all Data Quality results:
00523   float pixelFlag = -1., barrelFlag = -1., endcapFlag = -1.;
00524   float barrel_errors_temp[1]={-1.}; int barrel_cuts_temp[5]={5*-1}; 
00525   float endcap_errors_temp[1]={-1.}; int endcap_cuts_temp[5]={5*-1}; 
00526   int pixel_cuts_temp[1]={-1};
00527   float combinedCuts = 1.; int numerator = 0, denominator = 0;
00528 
00529   // Barrel results:
00530   me = bei->get("Pixel/Barrel/BarrelNErrorsCut");
00531   if(me) barrel_errors_temp[0] = me->getFloatValue();
00532   me = bei->get("Pixel/Barrel/BarrelNDigisCut");
00533   if(me) barrel_cuts_temp[0] = me->getIntValue();
00534   me = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
00535   if(me) barrel_cuts_temp[1] = me->getIntValue();
00536   me = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
00537   if(me) barrel_cuts_temp[2] = me->getIntValue();
00538   me = bei->get("Pixel/Barrel/BarrelNClustersCut");
00539   if(me) barrel_cuts_temp[3] = me->getIntValue();
00540   me = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
00541   if(me) barrel_cuts_temp[4] = me->getIntValue();
00542   for(int k=0; k!=5; k++){
00543     if(barrel_cuts_temp[k]>=0){
00544       numerator = numerator + barrel_cuts_temp[k];
00545       denominator++;
00546       //cout<<"cut flag, Barrel: "<<k<<","<<barrel_cuts_temp[k]<<","<<numerator<<","<<denominator<<endl;
00547     }
00548   } 
00549   if(denominator!=0) combinedCuts = float(numerator)/float(denominator);  
00550   barrelFlag = barrel_errors_temp[0] * combinedCuts;
00551   
00552   
00553   //cout<<" the resulting barrel flag is: "<<barrel_errors_temp[0]<<"*"<<combinedCuts<<"="<<barrelFlag<<endl;
00554   
00555   // Endcap results:
00556   combinedCuts = 1.; numerator = 0; denominator = 0;
00557   me = bei->get("Pixel/Endcap/EndcapNErrorsCut");
00558   if(me) endcap_errors_temp[0] = me->getFloatValue();
00559   me = bei->get("Pixel/Endcap/EndcapNDigisCut");
00560   if(me) endcap_cuts_temp[0] = me->getIntValue();
00561   me = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
00562   if(me) endcap_cuts_temp[1] = me->getIntValue();
00563   me = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
00564   if(me) endcap_cuts_temp[2] = me->getIntValue();
00565   me = bei->get("Pixel/Endcap/EndcapNClustersCut");
00566   if(me) endcap_cuts_temp[3] = me->getIntValue();
00567   me = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
00568   if(me) endcap_cuts_temp[4] = me->getIntValue();
00569   for(int k=0; k!=5; k++){
00570     if(endcap_cuts_temp[k]>=0){
00571       numerator = numerator + endcap_cuts_temp[k];
00572       denominator++;
00573       //cout<<"cut flag, Endcap: "<<k<<","<<endcap_cuts_temp[k]<<","<<numerator<<","<<denominator<<endl;
00574     }
00575   } 
00576   if(denominator!=0) combinedCuts = float(numerator)/float(denominator);  
00577   endcapFlag = endcap_errors_temp[0] * combinedCuts;
00578   //cout<<" the resulting endcap flag is: "<<endcap_errors_temp[0]<<"*"<<combinedCuts<<"="<<endcapFlag<<endl;
00579   
00580   // Track results:
00581   combinedCuts = 1.; numerator = 0; denominator = 0;
00582   me = bei->get("Pixel/Tracks/PixelTracksCut");
00583   if(me) pixel_cuts_temp[0] = me->getIntValue();
00584 
00585   //Combination of all:
00586   combinedCuts = 1.; numerator = 0; denominator = 0;
00587   for(int k=0; k!=5; k++){
00588     if(barrel_cuts_temp[k]>=0){
00589       numerator = numerator + barrel_cuts_temp[k];
00590       denominator++;
00591     }
00592     //cout<<"after barrel: num="<<numerator<<" , den="<<denominator<<endl;
00593     if(endcap_cuts_temp[k]>=0){
00594       numerator = numerator + endcap_cuts_temp[k];
00595       denominator++;
00596     }
00597     if(k<1 && pixel_cuts_temp[k]>=0){
00598       numerator = numerator + pixel_cuts_temp[k];
00599       denominator++;
00600     }
00601     //cout<<"after both: num="<<numerator<<" , den="<<denominator<<endl;
00602   } 
00603   if(denominator!=0) combinedCuts = float(numerator)/float(denominator); 
00604   pixelFlag = float(pixel_error_flag_) * float(combinedCuts);
00605   
00606   
00607   //cout<<"barrel, endcap, pixel flags: "<<barrelFlag<<","<<endcapFlag<<","<<pixelFlag<<endl;
00608   SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00609   if(SummaryPixel) SummaryPixel->Fill(pixelFlag);
00610   SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00611   if(SummaryBarrel) SummaryBarrel->Fill(barrelFlag);
00612   SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00613   if(SummaryEndcap)   SummaryEndcap->Fill(endcapFlag);
00614   }
00615 }
00616 
00617 //**********************************************************************************************
00618 
00619 void SiPixelDataQuality::computeGlobalQualityFlagByLumi(DQMStore * bei, 
00620                                                            bool init,
00621                                                            int nFEDs,
00622                                                            bool Tier0Flag,
00623                                                            int nEvents_lastLS_,
00624                                                            int nErrorsBarrel_lastLS_,
00625                                                            int nErrorsEndcap_lastLS_){
00626 //cout<<"entering SiPixelDataQuality::ComputeGlobalQualityFlagByLumi"<<endl;
00627 //   cout << ACRed << ACBold
00628 //        << "[SiPixelDataQuality::ComputeGlobalQualityFlag]"
00629 //        << ACPlain
00630 //        << " Enter" 
00631 //        << endl ;
00632 
00633   if(nFEDs==0) return;  
00634   
00635   // evaluate fatal FED errors for data quality:
00636   float BarrelRate_LS = 1.;
00637   float EndcapRate_LS = 1.;
00638   float PixelRate_LS = 1.;
00639   MonitorElement * me = bei->get("Pixel/AdditionalPixelErrors/byLumiErrors");
00640   if(me){
00641     //cout<<"NENTRIES: "<<me->getEntries()<<" "<<nEvents_lastLS_<<" "<<nErrorsBarrel_lastLS_<<" "<<nErrorsEndcap_lastLS_<<endl;
00642     double nBarrelErrors_LS = me->getBinContent(1) - nErrorsBarrel_lastLS_;
00643     double nEndcapErrors_LS = me->getBinContent(2) - nErrorsEndcap_lastLS_;
00644     double nEvents_LS = me->getBinContent(0) - nEvents_lastLS_;
00645     //cout<<"BINS: "<<me->getBinContent(0)<<" "<<me->getBinContent(1)<<" "<<me->getBinContent(2)<<endl;
00646     if(nBarrelErrors_LS/nEvents_LS>0.5) BarrelRate_LS=0.;
00647     if(nEndcapErrors_LS/nEvents_LS>0.5) EndcapRate_LS=0.;
00648     if((nBarrelErrors_LS + nEndcapErrors_LS)/nEvents_LS>0.5) PixelRate_LS=0.;
00649     //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;
00650   }
00651   
00652   // evaluate mean cluster charge on tracks for data quality:
00653   float BarrelClusterCharge = 1.;
00654   float EndcapClusterCharge = 1.;
00655   float PixelClusterCharge = 1.;
00656   MonitorElement * me1 = bei->get("Pixel/Clusters/OnTrack/charge_siPixelClusters_Barrel");
00657   if(me1 && me1->getMean()<12.) BarrelClusterCharge = 0.;
00658   //if(me1) cout<<"Mean cluster charge in Barrel: "<<me1->getMean()<<endl;
00659   MonitorElement * me2 = bei->get("Pixel/Clusters/OnTrack/charge_siPixelClusters_Endcap");
00660   if(me2 && me2->getMean()<12.) EndcapClusterCharge = 0.;
00661   //if(me2) cout<<"Mean cluster charge in Endcap: "<<me2->getMean()<<endl;
00662   MonitorElement * me3 = bei->get("Pixel/Clusters/OnTrack/charge_siPixelClusters");
00663   if(me3 && me3->getMean()<12.) PixelClusterCharge = 0.;
00664   //if(me3) cout<<"Mean cluster charge in Pixel: "<<me3->getMean()<<endl;
00665   
00666   // evaluate average FED occupancy for data quality:
00667   float BarrelOccupancy = 1.;
00668   float EndcapOccupancy = 1.;
00669   float PixelOccupancy = 1.;
00670   MonitorElement * me4 = bei->get("Pixel/averageDigiOccupancy");
00671   if(me4){
00672     double minBarrelOcc = 999999.; 
00673     double maxBarrelOcc = -1.; 
00674     double meanBarrelOcc = 0.;
00675     double minEndcapOcc = 999999.;
00676     double maxEndcapOcc = -1.;
00677     double meanEndcapOcc = 0.;
00678     for(int i=1; i!=41; i++){
00679       if(i<=32 && me4->getBinContent(i)<minBarrelOcc) minBarrelOcc=me4->getBinContent(i); 
00680       if(i<=32 && me4->getBinContent(i)>maxBarrelOcc) maxBarrelOcc=me4->getBinContent(i);
00681       if(i<=32) meanBarrelOcc+=me4->getBinContent(i);
00682       if(i>32 && me4->getBinContent(i)<minEndcapOcc) minEndcapOcc=me4->getBinContent(i); 
00683       if(i>32 && me4->getBinContent(i)>maxEndcapOcc) maxEndcapOcc=me4->getBinContent(i); 
00684       if(i>32) meanEndcapOcc+=me4->getBinContent(i);
00685       //cout<<"OCCUPANCY: "<<i<<" "<<me4->getBinContent(i)<<" : "<<minBarrelOcc<<" "<<maxBarrelOcc<<" "<<minEndcapOcc<<" "<<maxEndcapOcc<<endl;
00686     } 
00687     meanBarrelOcc = meanBarrelOcc/32.;
00688     meanEndcapOcc = meanEndcapOcc/8.;
00689     //cout<<"MEANS: "<<meanBarrelOcc<<" "<<meanEndcapOcc<<endl;
00690     if(minBarrelOcc<0.1*meanBarrelOcc || maxBarrelOcc>2.5*meanBarrelOcc) BarrelOccupancy=0.;
00691     if(minEndcapOcc<0.2*meanEndcapOcc || maxEndcapOcc>1.8*meanEndcapOcc) EndcapOccupancy=0.;
00692     PixelOccupancy=BarrelOccupancy*EndcapOccupancy;
00693     //cout<<"Occupancies: "<<meanBarrelOcc<<" "<<meanEndcapOcc<<endl;
00694   }
00695   
00696   float pixelFlag = PixelRate_LS * PixelClusterCharge * PixelOccupancy;
00697   float barrelFlag = BarrelRate_LS * BarrelClusterCharge * BarrelOccupancy;
00698   float endcapFlag = EndcapRate_LS * EndcapClusterCharge * EndcapOccupancy;
00699   //cout<<"barrel, endcap, pixel flags: "<<barrelFlag<<","<<endcapFlag<<","<<pixelFlag<<endl;
00700   SummaryPixel = bei->get("Pixel/EventInfo/reportSummary");
00701   if(SummaryPixel) SummaryPixel->Fill(pixelFlag);
00702   SummaryBarrel = bei->get("Pixel/EventInfo/reportSummaryContents/PixelBarrelFraction");
00703   if(SummaryBarrel) SummaryBarrel->Fill(barrelFlag);
00704   SummaryEndcap = bei->get("Pixel/EventInfo/reportSummaryContents/PixelEndcapFraction");
00705   if(SummaryEndcap)   SummaryEndcap->Fill(endcapFlag);
00706   
00707 }
00708 
00709 //**********************************************************************************************
00710 
00711 void SiPixelDataQuality::fillGlobalQualityPlot(DQMStore * bei, bool init, edm::EventSetup const& eSetup, int nFEDs, bool Tier0Flag, int lumisec){
00712 //std::cout<<"Entering SiPixelDataQuality::fillGlobalQualityPlot: "<<nFEDs<<std::endl;
00713   //calculate eta and phi of the modules and fill a 2D plot:
00714   //if(lastLS_<lumisec){ cout<<"lastLS_="<<lastLS_<<" ,lumisec="<<lumisec<<endl; lastLS_=lumisec; init=true; cout<<"init="<<init<<endl; }
00715   if(init){
00716     count=0; errcount=0;
00717     init=false;
00718     count1=0;
00719     count2=0;
00720     count3=0;
00721     count4=0;
00722     count5=0;
00723     count6=0;
00724     modCounter_=0;
00725   if(!Tier0Flag){
00726     //cout<<"RESETS"<<endl;
00727     //The plots that these Vecs are integrated throughout a run
00728     //So at each lumi section I save their last values (lastmods)
00729     //And then subtract them out later when filling the SummaryMap
00730     for(int j=1; j!=41; j++){
00731       if(allmodsVec) lastallmods_[j-1] = allmodsVec->GetBinContent(j);
00732       if(errmodsVec) lasterrmods_[j-1] = errmodsVec->GetBinContent(j);
00733       if(allmodsVec) allmodsVec->SetBinContent(j,0.);
00734       if(errmodsVec) errmodsVec->SetBinContent(j,0.);
00735       if(goodmodsVec) goodmodsVec->SetBinContent(j,0.);
00736     }
00737   }
00738   if(Tier0Flag){
00739     for(int i=1; i!=3; i++) for(int j=1; j!=8; j++){
00740       if(allmodsMap) allmodsMap->SetBinContent(i,j,0.);
00741       if(errmodsMap) errmodsMap->SetBinContent(i,j,0.);
00742       if(goodmodsMap) goodmodsMap->SetBinContent(i,j,0.);
00743     }
00744   }
00745   }
00746   
00747 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
00748 // Fill Maps:
00749   // Online:    
00750   if(nFEDs==0) return;
00751 /*  if(!Tier0Flag){
00752     eSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap);
00753     string currDir = bei->pwd();
00754     if(currDir.find("Reference")!=string::npos) return;
00755     //cout<<"currDir="<<currDir<<endl;
00756     string dname = currDir.substr(currDir.find_last_of("/")+1);
00757     // find a detId for Blades and Ladders (first of the contained Modules!):
00758     ifstream infile(edm::FileInPath("DQM/SiPixelMonitorClient/test/detId.dat").fullPath().c_str(),ios::in);
00759     string I_name[1440];
00760     int I_detId[1440];
00761     int I_fedId[1440];
00762     int I_linkId[1440];
00763     int nModsInFile=0;
00764     while(!infile.eof()) {
00765       infile >> I_name[nModsInFile] >> I_detId[nModsInFile] >> I_fedId[nModsInFile] >> I_linkId[nModsInFile] ;
00766       //cout<<I_name<<" "<<I_detId<<" "<<I_fedId<<" "<<I_linkId ;
00767       //getline(infile,dummys); //necessary to reach end of record
00768       infile.close();
00769       nModsInFile++;
00770     }
00771     if(dname.find("Module_")!=string::npos && currDir.find("Reference")==string::npos){
00772       vector<string> meVec = bei->getMEs();
00773       int detId=-1; int fedId=-1; int linkId=-1;
00774       for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
00775         //checking for any digis or FED errors to decide if this module is in DAQ:  
00776         string full_path = currDir + "/" + (*it);
00777         //cout<<"path: "<<full_path<<" , detId= "<<detId<<endl;
00778         if(detId==-1 && full_path.find("SUMOFF")==string::npos &&
00779            (full_path.find("ndigis")!=string::npos && full_path.find("SUMDIG")==string::npos) && 
00780            (getDetId(bei->get(full_path)) > 100)){
00781           //cout<<"Got into the first ndigis or NErrors histogram!"<<endl;
00782           MonitorElement * me = bei->get(full_path);
00783           if (!me) continue;
00784           if((full_path.find("ndigis")!=string::npos)){ 
00785             modCounter_++;
00786             detId = getDetId(me);
00787             for(int fedid=0; fedid!=40; ++fedid){
00788               SiPixelFrameConverter converter(theCablingMap.product(),fedid);
00789               uint32_t newDetId = detId;
00790               if(converter.hasDetUnit(newDetId)){
00791                 fedId=fedid;
00792                 break;   
00793               }
00794             }
00795             if(fedId==-1) continue; 
00796             sipixelobjects::ElectronicIndex cabling; 
00797             SiPixelFrameConverter formatter(theCablingMap.product(),fedId);
00798             sipixelobjects::DetectorIndex detector = {detId, 1, 1};      
00799             formatter.toCabling(cabling,detector);
00800             linkId = cabling.link;
00801             //cout<<"it has this FED ID and channel ID: "<<fedId<<" , "<<linkId<<endl;
00802             int NDigis = 0;
00803             if(full_path.find("ndigis")!=string::npos) NDigis = me->getEntries(); 
00804             float weight = (allmodsMap->GetBinContent(fedId+1,linkId))+NDigis;
00805             allmodsMap->Fill(fedId,linkId,weight);
00806             static const char buf[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
00807             char fedplot[sizeof(buf)+4]; 
00808             sprintf(fedplot,buf,fedId,linkId);
00809             me = bei->get(fedplot);
00810             int NErrors = 0;
00811             if(me) NErrors = me->getIntValue();
00812             //if(fedId==37&&linkId==5) std::cout<<"THIS CHANNEL: "<<fedplot<<" , "<<NErrors<<" , "<<bei->pwd()<<std::endl;
00813             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;}
00814           }
00815         }
00816       }//end loop over MEs
00817     }//end of module dir's
00818     vector<string> subDirVec = bei->getSubdirs();  
00819     for (vector<string>::const_iterator ic = subDirVec.begin();
00820          ic != subDirVec.end(); ic++) {
00821       bei->cd(*ic);
00822       init=false;
00823       fillGlobalQualityPlot(bei,init,eSetup,nFEDs,Tier0Flag);
00824       bei->goUp();
00825     }
00826     if(modCounter_==1440){
00827       bei->cd("Pixel/EventInfo/reportSummaryContents");
00828       //cout<<"B: Loop over all modules is done, now I am in    "<<bei->pwd()<<"     and currDir is    "<<currDir<<endl;
00829       if(bei->pwd()=="Pixel/EventInfo/reportSummaryContents"){
00830         SummaryReportMap = bei->get("Pixel/EventInfo/reportSummaryMap");
00831         if(SummaryReportMap){ 
00832           float contents=0.;
00833           for(int i=0; i!=40; i++)for(int j=1; j!=37; j++){
00834             //cout<<"bin: "<<i<<","<<j<<endl;
00835             if((allmodsMap->GetBinContent(i+1,j)) + (errmodsMap->GetBinContent(i+1,j)) > 0){
00836               contents = (allmodsMap->GetBinContent(i+1,j))/((allmodsMap->GetBinContent(i+1,j))+(errmodsMap->GetBinContent(i+1,j)));
00837             }else{
00838               contents = -1.;
00839             }
00840             //if(contents>=0.&&contents<0.8) std::cout<<"HERE: "<<i<<" , "<<j<<" , "<<allmodsMap->GetBinContent(i+1,j)<<" , "<<errmodsMap->GetBinContent(i+1,j)<<std::endl;
00841             if(i==13&&j==17&&contents>0) count1++;
00842             if(i==13&&j==18&&contents>0) count2++;
00843             if(i==15&&j==5&&contents>0) count3++;
00844             if(i==15&&j==6&&contents>0) count4++;
00845             //cout<<"\t\t MAP: "<<i<<","<<j<<","<<contents<<endl;
00846             if(((i==0||i==2||i==3||i==5||i==11||i==8)&&(j==1||j==8||j==13||j==17||j==20))||
00847                ((i==1||i==9||i==10||i==13)&&(j==1||j==5||j==8||j==20||j==22))||
00848                ((i==4||i==12)&&(j==5||j==10||j==13||j==17||j==22))||
00849                ((i==2||i==5||i==6||i==7||i==14)&&(j==5||j==10||j==22))||
00850                ((i==7||i==10)&&(j==13||j==17))||
00851                ((i==6||i==14)&&(j==1||j==20))||
00852                ((i==10||i==13)&&(j==10))||
00853                ((i==4||i==12)&&(j==2))||
00854                ((i==14)&&(j==15))){
00855               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+1));
00856             }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))||
00857                ((i==17||i==18||i==25)&&(j==2||j==6||j==9||j==21||j==23))||
00858                ((i==20||i==23||i==28||i==31)&&(j==6||j==11||j==14||j==18||j==23))||
00859                ((i==21||i==22||i==26||i==29||i==30)&&(j==6||j==11||j==23))||
00860                ((i==18)&&(j==14||j==18))||
00861                ((i==22||i==30)&&(j==2||j==21))||
00862                ((i==18)&&(j==11))||
00863                ((i==17||i==25)&&(j==16))||
00864                ((i==19||i==27)&&(j==5))){
00865               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-1));
00866             }else if(i==6&&(j==14||j==15)){
00867               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+2));
00868             }else if((i==14)&&j==14){
00869               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+3));
00870             }else if((i==17||i==25)&&j==17){
00871               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-3));
00872             }else if(((i==0||i==2||i==3||i==5||i==8||i==10||i==11||i==13)&&(j==3||j==15))||
00873                      ((i==1||i==9)&&j==3)||
00874                      ((i==7||i==12||i==15)&&j==15)){
00875               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+4));
00876             }else if(((i==16||i==18||i==19||i==21||i==24||i==26||i==27||i==29)&&(j==7||j==19))||
00877                      ((i==17||i==25)&&j==7)||
00878                      ((i==20||i==23||i==28||i==31)&&j==19)){
00879               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-4));
00880             }else if((i==6||i==14)&&(j==13||j==19)){
00881               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+5));
00882             }else if((i==17||i==25)&&(j==18||j==24)){
00883               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-5));
00884             }else if(((i==4||i==12)&&j==1)||
00885                      ((i==3||i==11)&&j==6)){
00886               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+6));
00887             }else if((i==9||i==1)&&j==4){
00888               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+8));
00889             }else if((i==17||i==25)&&j==12){
00890               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-8));
00891             }else if(((i==20||i==28)&&j==20)||
00892                      ((i==19||i==27)&&j==22)){
00893               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-11));
00894             }else if(((i==20||i==28)&&j==21)||
00895                      ((i==19||i==27)&&j==23)){
00896               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-13));
00897             }else{
00898               SummaryReportMap->setBinContent(i+1,j,contents);
00899             }
00900           }//end for loop over summaryReportMap bins
00901           for(int i=0; i!=40; i++)for(int j=1; j!=37; j++){ // catch the last few holes...
00902             if(((i==2||i==4||i==5||i==6||i==7||i==10||i==12||i==13||i==14||i==15)&&j==12)||
00903                ((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)){
00904               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-8));
00905             }else if(((i==18||i==20||i==21||i==22||i==23||i==26||i==28||i==29||i==30||i==31)&&j==4)||
00906                ((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)){
00907               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+8));
00908             }else if(((i==6||i==14)&&j==9)||
00909                      ((i==3||i==11)&&j==5)||
00910                      ((i==1||i==9)&&(j==11||j==16))){
00911               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-1));
00912             }else if(((i==17||i==25)&&j==10)||
00913                      ((i==22||i==30)&&(j==8||j==15))||
00914                      ((i==20||i==28)&&(j==2))){
00915               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+1));
00916             }else if((i==1||i==9)&&j==17){
00917               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-3));
00918             }else if((i==22||i==30)&&j==14){
00919               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+3));
00920             }else if((i==6||i==14)&&j==7){
00921               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-4));
00922             }else if((i==22||i==30)&&j==3){
00923               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+4));
00924             }else if((i==1||i==9)&&(j==18||j==24)){
00925               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-5));
00926             }else if((i==22||i==30)&&(j==13||j==19)){
00927               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+5));
00928             }else if(((i==20||i==28)&&j==1)||
00929                      ((i==19||i==27)&&j==6)){
00930               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j+6));
00931             }else if(((i==4||i==12)&&j==20)||
00932                      ((i==3||i==11)&&j==22)){
00933               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-11));
00934             }else if(((i==4||i==12)&&j==21)||
00935                      ((i==3||i==11)&&j==23)){
00936               SummaryReportMap->setBinContent(i+1,j,SummaryReportMap->getBinContent(i+1,j-13));
00937             }
00938           }//end of loop over bins
00939           //std::cout<<"COUNTERS: "<<count1<<" , "<<count2<<" , "<<count3<<" , "<<count4<<" , "<<count5<<" , "<<count6<<std::endl;
00940         }//end if reportSummaryMap ME exists
00941       }//end if in summary directory
00942     }//end if modCounter_  
00943 */
00944 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
00945   if(!Tier0Flag){
00946     eSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap);
00947     string currDir = bei->pwd();
00948     if(currDir.find("Reference")!=string::npos || currDir.find("Additional")!=string::npos) return;
00949     //cout<<"currDir="<<currDir<<endl;
00950     string dname = currDir.substr(currDir.find_last_of("/")+1);
00951     if(dname.find("Module_")!=string::npos && currDir.find("Reference")==string::npos){
00952       vector<string> meVec = bei->getMEs();
00953       int detId=-1; int fedId=-1;
00954       for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++){//loop over all modules and fill ndigis into allmodsMap
00955         //checking for any digis or FED errors to decide if this module is in DAQ:  
00956         string full_path = currDir + "/" + (*it);
00957         if(detId==-1 && full_path.find("SUMOFF")==string::npos &&
00958            (full_path.find("ndigis")!=string::npos && full_path.find("SUMDIG")==string::npos) && 
00959            (getDetId(bei->get(full_path)) > 100)){
00960           MonitorElement * me = bei->get(full_path);
00961           if (!me) continue;
00962           if((full_path.find("ndigis")!=string::npos)){ 
00963             modCounter_++;
00964             detId = getDetId(me);
00965             for(int fedid=0; fedid!=40; ++fedid){
00966               SiPixelFrameConverter converter(theCablingMap.product(),fedid);
00967               uint32_t newDetId = detId;
00968               if(converter.hasDetUnit(newDetId)){
00969                 fedId=fedid;
00970                 break;   
00971               }
00972             }
00973             double NDigis = 0;
00974             if(full_path.find("ndigis")!=string::npos) NDigis = me->getEntries(); 
00975             float weight = (allmodsVec->GetBinContent(fedId+1))+NDigis;
00976             //cout<<"DIGIS: "<<currDir<<" , "<<fedId<<" , "<<weight<<" , "<<NDigis<<endl;
00977             allmodsVec->SetBinContent(fedId+1,weight);
00978             //cout<<"\t filled: "<<allmodsVec->GetBinContent(fedId+1,weight)<<endl;
00979           }
00980         }
00981       }//end loop over MEs
00982     }//end of module dir's
00983     //if(currDir.find("FED_")!=std::string::npos){
00984       //fillGlobalQualityPlot(bei,init,eSetup,nFEDs,Tier0Flag,lumisec);
00985       //bei->goUp();
00986     //}
00987     vector<string> subDirVec = bei->getSubdirs();  
00988     for (vector<string>::const_iterator ic = subDirVec.begin();
00989          ic != subDirVec.end(); ic++) {
00990       bei->cd(*ic);
00991       init=false;
00992       fillGlobalQualityPlot(bei,init,eSetup,nFEDs,Tier0Flag,lumisec);
00993       bei->goUp();
00994     }
00995     //cout<<"modCounter_: "<<modCounter_<<" , "<<bei->pwd()<<endl;
00996     if(modCounter_==1440){
00997       bei->cd("Pixel/EventInfo/reportSummaryContents");
00998       if(bei->pwd()=="Pixel/EventInfo/reportSummaryContents"){
00999         for(int i=0; i!=40; i++){//loop over FEDs to fetch the errors
01000           static const char buf[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
01001           char fedplot[sizeof(buf)+4]; 
01002           int NErrors = 0;
01003           for(int j=0; j!=37; j++){//loop over FED channels within a FED
01004             sprintf(fedplot,buf,i,j);
01005             MonitorElement * me = bei->get(fedplot);
01006             if(me) NErrors = NErrors + me->getIntValue();
01007           }
01008           //If I fill, then I end up majorly overcounting the numbers of errors...
01009           //if(NErrors>0){ errmodsVec->Fill(i,NErrors); } 
01010           if(NErrors>0){ errmodsVec->SetBinContent(i+1,NErrors); } 
01011         }
01012         SummaryReportMap = bei->get("Pixel/EventInfo/reportSummaryMap");
01013         if(SummaryReportMap){ 
01014           float contents=0.;
01015           for(int i=1; i!=41; i++){
01016             //Dynamically subtracting previous (integrated) lumi section values
01017             //in order to only show current lumi section's numbers
01018             float mydigis = allmodsVec->GetBinContent(i) - lastallmods_[i-1];
01019             float myerrs  = errmodsVec->GetBinContent(i) - lasterrmods_[i-1];
01020             if ((mydigis + myerrs) > 0.){
01021               contents = mydigis/(mydigis + myerrs);
01022               //std::cout<<"Fed: "<<i-1<<" , nevents: "<<nevents<<" , ndigis: "<< mydigis <<" , nerrors: "<< myerrs << " , contents: " << contents << std::endl;
01023             }else{
01024               //Changed so that dynamic zooming will still
01025               //advance over these bins(in renderplugins)
01026               contents = -0.5;
01027             }
01028             SummaryReportMap->setBinContent(lumisec+1,i,contents);
01029           }//end for loop over summaryReportMap bins
01030         }//end if reportSummaryMap ME exists
01031       }//end if in summary directory
01032     }//end if modCounter_  
01033   }else{ // Offline
01034     float barrel_errors_temp[1]={-1.}; int barrel_cuts_temp[6]={6*-1}; 
01035     float endcap_errors_temp[1]={-1.}; int endcap_cuts_temp[6]={6*-1}; 
01036     int pixel_cuts_temp[1]={-1};
01037     // Barrel results:
01038     MonitorElement * me;
01039     me = bei->get("Pixel/Barrel/BarrelNErrorsCut");
01040     if(me) barrel_errors_temp[0] = me->getFloatValue();
01041     me = bei->get("Pixel/Endcap/EndcapNErrorsCut");
01042     if(me) endcap_errors_temp[0] = me->getFloatValue();
01043     SummaryReportMap->setBinContent(1,1,barrel_errors_temp[0]);
01044     SummaryReportMap->setBinContent(2,1,endcap_errors_temp[0]);
01045     me = bei->get("Pixel/Barrel/BarrelNDigisCut");
01046     if(me) barrel_cuts_temp[0] = me->getIntValue();
01047     me = bei->get("Pixel/Barrel/BarrelDigiChargeCut");
01048     if(me) barrel_cuts_temp[1] = me->getIntValue();
01049     me = bei->get("Pixel/Barrel/BarrelClusterSizeCut");
01050     if(me) barrel_cuts_temp[2] = me->getIntValue();
01051     me = bei->get("Pixel/Barrel/BarrelNClustersCut");
01052     if(me) barrel_cuts_temp[3] = me->getIntValue();
01053     me = bei->get("Pixel/Barrel/BarrelClusterChargeCut");
01054     if(me) barrel_cuts_temp[4] = me->getIntValue();  
01055     me = bei->get("Pixel/Endcap/EndcapNDigisCut");
01056     if(me) endcap_cuts_temp[0] = me->getIntValue();
01057     me = bei->get("Pixel/Endcap/EndcapDigiChargeCut");
01058     if(me) endcap_cuts_temp[1] = me->getIntValue();
01059     me = bei->get("Pixel/Endcap/EndcapClusterSizeCut");
01060     if(me) endcap_cuts_temp[2] = me->getIntValue();
01061     me = bei->get("Pixel/Endcap/EndcapNClustersCut");
01062     if(me) endcap_cuts_temp[3] = me->getIntValue();
01063     me = bei->get("Pixel/Endcap/EndcapClusterChargeCut");
01064     if(me) endcap_cuts_temp[4] = me->getIntValue();  
01065     for(int j=2; j!=7; j++){
01066       SummaryReportMap->setBinContent(1,j,barrel_cuts_temp[j-2]);
01067       SummaryReportMap->setBinContent(2,j,endcap_cuts_temp[j-2]);
01068       //cout<<"error cut values: "<<j<<" , "<<barrel_cuts_temp[j-2]<<" , "<<endcap_cuts_temp[j-2]<<endl;
01069     }
01070     me = bei->get("Pixel/Tracks/PixelTracksCut");
01071     if(me) pixel_cuts_temp[0] = me->getIntValue();  
01072     SummaryReportMap->setBinContent(1,7,pixel_cuts_temp[0]);
01073     SummaryReportMap->setBinContent(2,7,pixel_cuts_temp[0]);
01074   }//end of offline map
01075   if(allmodsMap) allmodsMap->Clear();
01076   if(goodmodsMap) goodmodsMap->Clear();
01077   if(errmodsMap) errmodsMap->Clear();
01078 }
01079 
01080 //**********************************************************************************************
01081