CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/DQMServices/Components/src/DQMFEDIntegrityClient.cc

Go to the documentation of this file.
00001 
00002 /*
00003  * \file DQMFEDIntegrityClient.cc
00004  * \author M. Marienfeld
00005  * Last Update:
00006  * $Date: 2010/03/29 18:34:06 $
00007  * $Revision: 1.19 $
00008  * $Author: ameyer $
00009  *
00010  * Description: Summing up FED entries from all subdetectors.
00011  *
00012 */
00013 
00014 #include "DQMServices/Components/src/DQMFEDIntegrityClient.h"
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 
00017 // -----------------------------
00018 //  constructors and destructor
00019 // -----------------------------
00020 
00021 DQMFEDIntegrityClient::DQMFEDIntegrityClient( const edm::ParameterSet& ps ) {
00022 
00023   parameters_ = ps;
00024   initialize();
00025   fillInEventloop = ps.getUntrackedParameter<bool>("fillInEventloop",false);
00026   fillOnEndRun = ps.getUntrackedParameter<bool>("fillOnEndRun",false);
00027   fillOnEndJob = ps.getUntrackedParameter<bool>("fillOnEndJob",false);
00028   fillOnEndLumi = ps.getUntrackedParameter<bool>("fillOnEndLumi",true);
00029   moduleName = ps.getUntrackedParameter<std::string>("moduleName", "FED");
00030   fedFolderName = ps.getUntrackedParameter<std::string>("fedFolderName", "FEDIntegrity");
00031 
00032 }
00033 
00034 DQMFEDIntegrityClient::~DQMFEDIntegrityClient() {
00035 
00036 }
00037 
00038 
00039 void DQMFEDIntegrityClient::initialize() {
00040 
00041   // get back-end interface
00042   dbe_ = edm::Service<DQMStore>().operator->();
00043 
00044 }
00045 
00046 
00047 void DQMFEDIntegrityClient::beginJob() {
00048 
00049   NBINS = 850;
00050   XMIN  =   0.;
00051   XMAX  = 850.;
00052 
00053   dbe_ = edm::Service<DQMStore>().operator->();
00054 
00055   // ----------------------------------------------------------------------------------
00056   std::string currentFolder = moduleName + "/" + fedFolderName ;
00057   dbe_->setCurrentFolder(currentFolder.c_str());
00058 
00059   FedEntries  = dbe_->book1D("FedEntries",  "FED Entries",          NBINS, XMIN, XMAX);
00060   FedFatal    = dbe_->book1D("FedFatal",    "FED Fatal Errors",     NBINS, XMIN, XMAX);
00061   FedNonFatal = dbe_->book1D("FedNonFatal", "FED Non Fatal Errors", NBINS, XMIN, XMAX);
00062 
00063   FedEntries->setAxisTitle( "", 1);
00064   FedFatal->setAxisTitle(   "", 1);
00065   FedNonFatal->setAxisTitle("", 1);
00066 
00067   FedEntries->setAxisTitle( "", 2);
00068   FedFatal->setAxisTitle(   "", 2);
00069   FedNonFatal->setAxisTitle("", 2);
00070 
00071   FedEntries->setBinLabel(11,  "PIXEL", 1);
00072   FedEntries->setBinLabel(221, "SIST",  1);
00073   FedEntries->setBinLabel(606, "EE",    1);
00074   FedEntries->setBinLabel(628, "EB",    1);
00075   FedEntries->setBinLabel(651, "EE",    1);
00076   FedEntries->setBinLabel(550, "ES",    1);
00077   FedEntries->setBinLabel(716, "HCAL",  1);
00078   FedEntries->setBinLabel(754, "CSC",   1);
00079   FedEntries->setBinLabel(772, "DT",    1);
00080   FedEntries->setBinLabel(791, "RPC",   1);
00081   FedEntries->setBinLabel(804, "L1T",   1);
00082 
00083   FedFatal->setBinLabel(11,  "PIXEL", 1);
00084   FedFatal->setBinLabel(221, "SIST",  1);
00085   FedFatal->setBinLabel(606, "EE",    1);
00086   FedFatal->setBinLabel(628, "EB",    1);
00087   FedFatal->setBinLabel(651, "EE",    1);
00088   FedFatal->setBinLabel(550, "ES",    1);
00089   FedFatal->setBinLabel(716, "HCAL",  1);
00090   FedFatal->setBinLabel(754, "CSC",   1);
00091   FedFatal->setBinLabel(772, "DT",    1);
00092   FedFatal->setBinLabel(791, "RPC",   1);
00093   FedFatal->setBinLabel(804, "L1T",   1);
00094 
00095   FedNonFatal->setBinLabel(11,  "PIXEL", 1);
00096   FedNonFatal->setBinLabel(221, "SIST",  1);
00097   FedNonFatal->setBinLabel(606, "EE",    1);
00098   FedNonFatal->setBinLabel(628, "EB",    1);
00099   FedNonFatal->setBinLabel(651, "EE",    1);
00100   FedNonFatal->setBinLabel(550, "ES",    1);
00101   FedNonFatal->setBinLabel(716, "HCAL",  1);
00102   FedNonFatal->setBinLabel(754, "CSC",   1);
00103   FedNonFatal->setBinLabel(772, "DT",    1);
00104   FedNonFatal->setBinLabel(791, "RPC",   1);
00105   FedNonFatal->setBinLabel(804, "L1T",   1);
00106 
00107   //-----------------------------------------------------------------------------------
00108   currentFolder = moduleName + "/EventInfo";
00109   dbe_->setCurrentFolder(currentFolder.c_str());
00110 
00111   reportSummary = dbe_->bookFloat("reportSummary");
00112 
00113   int nSubsystems = 10;
00114 
00115   if(reportSummary) reportSummary->Fill(1.);
00116 
00117   currentFolder = moduleName + "/EventInfo/reportSummaryContents";
00118   dbe_->setCurrentFolder(currentFolder.c_str());
00119 
00120   reportSummaryContent[0]  = dbe_->bookFloat("CSC FEDs");
00121   reportSummaryContent[1]  = dbe_->bookFloat("DT FEDs");
00122   reportSummaryContent[2]  = dbe_->bookFloat("EB FEDs");
00123   reportSummaryContent[3]  = dbe_->bookFloat("EE FEDs");
00124   reportSummaryContent[4]  = dbe_->bookFloat("ES FEDs");
00125   reportSummaryContent[5]  = dbe_->bookFloat("Hcal FEDs");
00126   reportSummaryContent[6]  = dbe_->bookFloat("L1T FEDs");
00127   reportSummaryContent[7]  = dbe_->bookFloat("Pixel FEDs");
00128   reportSummaryContent[8]  = dbe_->bookFloat("RPC FEDs");
00129   reportSummaryContent[9] = dbe_->bookFloat("SiStrip FEDs");
00130 
00131   // initialize reportSummaryContents to 1
00132   for (int i = 0; i < nSubsystems; ++i) {
00133     SummaryContent[i] = 1.;
00134     reportSummaryContent[i]->Fill(1.);
00135   }
00136 
00137   currentFolder = moduleName + "/EventInfo";
00138   dbe_->setCurrentFolder(currentFolder.c_str());
00139 
00140   reportSummaryMap = dbe_->book2D("reportSummaryMap",
00141                       "FED Report Summary Map", 1, 1, 2, 10, 1, 11);
00142 
00143   reportSummaryMap->setAxisTitle("", 1);
00144   reportSummaryMap->setAxisTitle("", 2);
00145 
00146   reportSummaryMap->setBinLabel( 1, " ",       1);
00147   reportSummaryMap->setBinLabel(10, "CSC",     2);
00148   reportSummaryMap->setBinLabel( 9, "DT",      2);
00149   reportSummaryMap->setBinLabel( 8, "EB",      2);
00150   reportSummaryMap->setBinLabel( 7, "EE",      2);
00151   reportSummaryMap->setBinLabel( 6, "ES",      2);
00152   reportSummaryMap->setBinLabel( 5, "Hcal",    2);
00153   reportSummaryMap->setBinLabel( 4, "L1T",     2);
00154   reportSummaryMap->setBinLabel( 3, "Pixel",   2);
00155   reportSummaryMap->setBinLabel( 2, "RPC",     2);
00156   reportSummaryMap->setBinLabel( 1, "SiStrip", 2);
00157 
00158 }
00159 
00160 void DQMFEDIntegrityClient::beginRun(const edm::Run& r, const edm::EventSetup& context) {
00161 
00162 }
00163 
00164 void DQMFEDIntegrityClient::analyze(const edm::Event& e, const edm::EventSetup& context)  {
00165   if (fillInEventloop) fillHistograms();
00166 }
00167 
00168 void DQMFEDIntegrityClient::endLuminosityBlock(const edm::LuminosityBlock&  lumiBlock, const  edm::EventSetup& context){
00169   if (fillOnEndLumi) fillHistograms();
00170 }
00171 
00172 void DQMFEDIntegrityClient::fillHistograms(void){
00173   // FED Entries
00174   
00175   // dbe_->showDirStructure();
00176 
00177   std::vector<std::string> entries;
00178   entries.push_back("CSC/" + fedFolderName + "/FEDEntries");
00179   entries.push_back("DT/" + fedFolderName + "/FEDEntries");
00180   entries.push_back("EcalBarrel/" + fedFolderName + "/FEDEntries");
00181   entries.push_back("EcalEndcap/" + fedFolderName + "/FEDEntries");
00182   entries.push_back("EcalPreshower/" + fedFolderName + "/FEDEntries");
00183   entries.push_back("Hcal/" + fedFolderName + "/FEDEntries");
00184   entries.push_back("L1T/" + fedFolderName + "/FEDEntries");
00185   entries.push_back("Pixel/" + fedFolderName + "/FEDEntries");
00186   entries.push_back("RPC/" + fedFolderName + "/FEDEntries");
00187   entries.push_back("SiStrip/" + fedFolderName + "/FEDEntries");
00188 
00189   for(std::vector<std::string>::const_iterator ent = entries.begin();
00190                                       ent != entries.end(); ++ent) {
00191 
00192     if( !(dbe_->get(*ent)) ) {
00193       //      cout << ">> Endluminosity No histogram! <<" << endl;
00194       continue;
00195     }
00196 
00197     MonitorElement * me = dbe_->get(*ent);
00198 
00199     if (TH1F * rootHisto = me->getTH1F()) {
00200 
00201       int xmin  = 0;
00202       int Nbins = me->getNbinsX();
00203 
00204       float entry = 0.;
00205 
00206       xmin = (int)rootHisto->GetXaxis()->GetXmin();
00207       if(*ent == "L1T/" + fedFolderName +"/FEDEntries")  xmin = xmin + 800;
00208 
00209       for(int bin = 1; bin <= Nbins ; ++bin) {
00210         int id = xmin+bin;
00211         entry = rootHisto->GetBinContent(bin);
00212         if(entry > 0.)  FedEntries->setBinContent(id, entry);
00213       }
00214 
00215     }
00216 
00217   }
00218 
00219   // FED Fatal
00220 
00221   int nSubsystems = 10;
00222 
00223   std::vector<std::string> fatal;
00224   fatal.push_back("CSC/" + fedFolderName + "/FEDFatal");
00225   fatal.push_back("DT/" + fedFolderName + "/FEDFatal");
00226   fatal.push_back("EcalBarrel/" + fedFolderName + "/FEDFatal");
00227   fatal.push_back("EcalEndcap/" + fedFolderName + "/FEDFatal");
00228   fatal.push_back("EcalPreshower/" + fedFolderName + "/FEDFatal");
00229   fatal.push_back("Hcal/" + fedFolderName + "/FEDFatal");
00230   fatal.push_back("L1T/" + fedFolderName + "/FEDFatal");
00231   fatal.push_back("Pixel/" + fedFolderName + "/FEDFatal");
00232   fatal.push_back("RPC/" + fedFolderName + "/FEDFatal");
00233   fatal.push_back("SiStrip/" + fedFolderName + "/FEDFatal");
00234 
00235   int k = 0, count = 0;
00236 
00237   float sum = 0.;
00238 
00239   std::vector<std::string>::const_iterator ent = entries.begin();
00240   for(std::vector<std::string>::const_iterator fat = fatal.begin(); 
00241                                       fat != fatal.end(); ++fat) {
00242 
00243     if( !(dbe_->get(*fat)) ) {
00244       //      cout << ">> No histogram! <<" << endl;
00245       reportSummaryContent[k]->Fill(-1);
00246       reportSummaryMap->setBinContent(1, nSubsystems-k, -1);
00247       k++;
00248       ent++;
00249       continue;
00250     }
00251 
00252     MonitorElement * me = dbe_->get(*fat);
00253     MonitorElement * meNorm = dbe_->get(*ent);
00254       //      cout << "Path : " << me->getFullname() << endl;
00255 
00256     int Nbins  = me->getNbinsX();
00257 
00258     float entry = 0.;
00259     float norm = 0.;
00260 
00261     if (TH1F * rootHisto = me->getTH1F()) {
00262       if (TH1F * rootHistoNorm = meNorm->getTH1F()) {
00263 
00264         int xmin   = 0;
00265         int xmax   = 0;
00266 
00267         xmin = (int)rootHisto->GetXaxis()->GetXmin();
00268         if(*fat == "L1T/" + fedFolderName + "/FEDFatal") xmin = xmin + 800;
00269 
00270         xmax = (int)rootHisto->GetXaxis()->GetXmax();
00271         if(*fat == "L1T/" + fedFolderName + "/FEDFatal") xmax = xmax + 800;
00272 
00273         //      cout << "FED ID range : " << xmin << " - " << xmax << endl;
00274 
00275         for(int bin = 1; bin <= Nbins ; ++bin) {
00276           int id = xmin+bin;
00277           entry += rootHisto->GetBinContent(bin);
00278           norm += rootHistoNorm->GetBinContent(bin);
00279           //      cout << *fat << "errors = " << entry << "\tnorm = " << norm << endl;
00280           //      cout << "Bin content : " << entry << endl;
00281           if(entry > 0.) FedFatal->setBinContent(id, entry);
00282         }
00283 
00284       }
00285     }
00286 
00287     if (norm > 0) SummaryContent[k] = 1.0 - entry/norm;
00288     //      cout << "Summary Content : " << SummaryContent[k] << endl;
00289     reportSummaryContent[k]->Fill(SummaryContent[k]);
00290     float threshold = 1.;
00291     if (k==2 || k==3)          // for EE and EB only show yellow when more than 1% errors.
00292          threshold = 0.99;
00293     if (SummaryContent[k] < threshold && SummaryContent[k] >=0.95) 
00294          SummaryContent[k] = 0.949;
00295     reportSummaryMap->setBinContent(1, nSubsystems-k, SummaryContent[k]);
00296     sum = sum + SummaryContent[k];
00297 
00298     k++;
00299     ent++;
00300     count++;
00301 
00302   }
00303 
00304   if (count > 0) reportSummary->Fill( sum/(float)count );
00305 
00306   // FED Non Fatal
00307 
00308   std::vector<std::string> nonfatal;
00309   nonfatal.push_back("CSC/" + fedFolderName + "/FEDNonFatal");
00310   nonfatal.push_back("DT/" + fedFolderName + "/FEDNonFatal");
00311   nonfatal.push_back("EcalBarrel/" + fedFolderName + "/FEDNonFatal");
00312   nonfatal.push_back("EcalEndcap/" + fedFolderName + "/FEDNonFatal");
00313   nonfatal.push_back("EcalPreshower/" + fedFolderName + "/FEDNonFatal");
00314   nonfatal.push_back("Hcal/" + fedFolderName + "/FEDNonFatal");
00315   nonfatal.push_back("L1T/" + fedFolderName + "/FEDNonFatal");
00316   nonfatal.push_back("Pixel/" + fedFolderName + "/FEDNonFatal");
00317   nonfatal.push_back("RPC/" + fedFolderName + "/FEDNonFatal");
00318   nonfatal.push_back("SiStrip/" + fedFolderName + "/FEDNonFatal");
00319 
00320   for(std::vector<std::string>::const_iterator non = nonfatal.begin(); 
00321                                       non != nonfatal.end(); ++non) {
00322 
00323     if( !(dbe_->get(*non)) ) {
00324       //      cout << ">> No histogram! <<" << endl;
00325       continue;
00326     }
00327 
00328     MonitorElement * me = dbe_->get(*non);
00329 
00330     if (TH1F * rootHisto = me->getTH1F()) {
00331 
00332       int xmin  = 0;
00333       int Nbins = me->getNbinsX();
00334 
00335       float entry = 0.;
00336 
00337       xmin = (int)rootHisto->GetXaxis()->GetXmin();
00338       if(*non == "L1T/" + fedFolderName + "/FEDNonFatal") xmin = xmin + 800;
00339 
00340       for(int bin = 1; bin <= Nbins ; ++bin) {
00341         int id = xmin+bin;
00342         entry = rootHisto->GetBinContent(bin);
00343         if(entry > 0.)  FedNonFatal->setBinContent(id, entry);
00344       }
00345 
00346     }
00347 
00348   }
00349 
00350 }
00351 
00352 
00353 void DQMFEDIntegrityClient::endRun(const edm::Run& r, const edm::EventSetup& context) {
00354   if (fillOnEndRun) fillHistograms();
00355 }
00356 
00357 
00358 void DQMFEDIntegrityClient::endJob() {
00359   if (fillOnEndJob) fillHistograms();
00360 
00361 }