CMS 3D CMS Logo

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