CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQM/DTMonitorClient/src/DTOfflineSummaryClients.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2011/11/24 09:17:30 $
00005  *  $Revision: 1.9 $
00006  *  \author M. Pelliccioni - INFN Torino
00007  */
00008 
00009 
00010 #include <DQM/DTMonitorClient/src/DTOfflineSummaryClients.h>
00011 
00012 // Framework
00013 #include <FWCore/Framework/interface/Event.h>
00014 #include <FWCore/Framework/interface/EventSetup.h>
00015 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00016 #include "FWCore/ServiceRegistry/interface/Service.h"
00017 
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019 #include "DQMServices/Core/interface/MonitorElement.h"
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021 
00022 #include <string>
00023 #include <cmath>
00024 
00025 using namespace edm;
00026 using namespace std;
00027 
00028 
00029 DTOfflineSummaryClients::DTOfflineSummaryClients(const ParameterSet& ps) : nevents(0) {
00030 
00031   LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients") << "[DTOfflineSummaryClients]: Constructor";
00032   
00033   
00034   dbe = Service<DQMStore>().operator->();
00035 
00036 }
00037 
00038 DTOfflineSummaryClients::~DTOfflineSummaryClients(){
00039   LogVerbatim ("DTDQM|DTMonitorClient|DTOfflineSummaryClients") << "DTOfflineSummaryClients: analyzed " << nevents << " events";
00040   
00041 }
00042 
00043 void DTOfflineSummaryClients::beginRun(Run const& run, EventSetup const& eSetup) {
00044 
00045   LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients") <<"[DTOfflineSummaryClients]: BeginRun"; 
00046 
00047   // book the summary histos
00048   dbe->setCurrentFolder("DT/EventInfo"); 
00049   summaryReport = dbe->bookFloat("reportSummary");
00050   // Initialize to 1 so that no alarms are thrown at the beginning of the run
00051   summaryReport->Fill(1.);
00052 
00053   summaryReportMap = dbe->book2D("reportSummaryMap","DT Report Summary Map",12,1,13,5,-2,3);
00054   summaryReportMap->setAxisTitle("sector",1);
00055   summaryReportMap->setAxisTitle("wheel",2);
00056 
00057   dbe->setCurrentFolder("DT/EventInfo/reportSummaryContents");
00058 
00059   for(int wheel = -2; wheel != 3; ++wheel) {
00060     stringstream streams;
00061     streams << "DT_Wheel" << wheel;
00062     string meName = streams.str();    
00063     theSummaryContents.push_back(dbe->bookFloat(meName));
00064     // Initialize to 1 so that no alarms are thrown at the beginning of the run
00065     theSummaryContents[wheel+2]->Fill(1.);
00066   }
00067 
00068 
00069 
00070 
00071 }
00072 
00073 
00074 void DTOfflineSummaryClients::endJob(void){
00075   
00076   LogVerbatim ("DTDQM|DTMonitorClient|DTOfflineSummaryClients") <<"[DTOfflineSummaryClients]: endJob"; 
00077 
00078 }
00079 
00080 
00081 void DTOfflineSummaryClients::analyze(const Event& event, const EventSetup& context){
00082 
00083    nevents++;
00084    if(nevents%1000 == 0) {
00085      LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients") << "[DTOfflineSummaryClients] Analyze #Run: " << event.id().run()
00086                                          << " #Event: " << event.id().event()
00087                                          << " LS: " << event.luminosityBlock()  
00088                                          << endl;
00089    }
00090 }
00091 
00092 
00093 void DTOfflineSummaryClients::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00094 
00095   LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
00096     << "[DTOfflineSummaryClients]: End of LS transition" << endl;
00097 
00098 }
00099 
00100 
00101 void DTOfflineSummaryClients::endRun(Run const& run, EventSetup const& context) {
00102 
00103   LogVerbatim ("DTDQM|DTMonitorClient|DTOfflineSummaryClients") <<"[DTOfflineSummaryClients]: endRun. Performin client operation"; 
00104 
00105   
00106   // reset the monitor elements
00107   summaryReportMap->Reset();
00108   summaryReport->Fill(0.);
00109   for(int ii = 0; ii != 5; ++ii) {
00110     theSummaryContents[ii]->Fill(0.);
00111   }
00112 
00113   // Fill the map using, at the moment, only the information from DT chamber efficiency
00114   // problems at a granularity smaller than the chamber are ignored
00115   for(int wheel=-2; wheel<=2; wheel++) { // loop over wheels
00116     // retrieve the chamber efficiency summary
00117     stringstream str;
00118     str << "DT/05-ChamberEff/EfficiencyMap_All_W" << wheel;
00119     MonitorElement * segmentWheelSummary =  dbe->get(str.str());
00120     if(segmentWheelSummary != 0) {
00121 
00122       float nFailingChambers = 0.;
00123 
00124       for(int sector=1; sector<=12; sector++) { // loop over sectors
00125 
00126         double meaneff = 0.;
00127         double errorsum = 0.;
00128 
00129         for(int station = 1; station != 5; ++station) { // loop over stations
00130 
00131           const double tmpefficiency = segmentWheelSummary->getBinContent(sector, station);
00132           const double tmpvariance = pow(segmentWheelSummary->getBinError(sector, station),2);
00133 
00134           if(tmpefficiency == 0 || tmpvariance == 0){
00135             nFailingChambers++;
00136             continue;
00137           }
00138 
00139           meaneff += tmpefficiency/tmpvariance;
00140           errorsum += 1./tmpvariance;
00141 
00142           if(tmpefficiency < 0.2) nFailingChambers++;
00143 
00144           LogTrace("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
00145             << "Wheel: " << wheel << " Stat: " << station << " Sect: " << sector << " status: " << meaneff/errorsum << endl;
00146         }
00147 
00148         const double eff_result = meaneff/errorsum;
00149 
00150         if(eff_result > 0.7) summaryReportMap->Fill(sector,wheel,1.);
00151         else if(eff_result < 0.7 && eff_result > 0.5) summaryReportMap->Fill(sector,wheel,0.6);
00152         else if(eff_result < 0.5 && eff_result > 0.3) summaryReportMap->Fill(sector,wheel,0.4);
00153         else if(eff_result < 0.3 && eff_result > 0.) summaryReportMap->Fill(sector,wheel,0.15);
00154 
00155       }
00156       theSummaryContents[wheel+2]->Fill((48.-nFailingChambers)/48.);
00157       summaryReport->Fill(summaryReport->getFloatValue() + theSummaryContents[wheel+2]->getFloatValue()/5.);
00158     } else {
00159       LogWarning("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
00160         << " [DTOfflineSummaryClients] Segment Summary not found with name: " << str.str() << endl;
00161     }
00162   }
00163 
00164 }
00165 
00166