CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQM/DTMonitorClient/src/DTSummaryClients.cc

Go to the documentation of this file.
00001 
00002 
00003 /*
00004  *  See header file for a description of this class.
00005  *
00006  *  $Date: 2008/10/09 09:38:44 $
00007  *  $Revision: 1.11 $
00008  *  \author G. Mila - INFN Torino
00009  */
00010 
00011 
00012 #include <DQM/DTMonitorClient/src/DTSummaryClients.h>
00013 
00014 // Framework
00015 #include <FWCore/Framework/interface/Event.h>
00016 #include <FWCore/Framework/interface/EventSetup.h>
00017 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00018 
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 #include "DQMServices/Core/interface/MonitorElement.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 
00023 #include <string>
00024 
00025 using namespace edm;
00026 using namespace std;
00027 
00028 
00029 DTSummaryClients::DTSummaryClients(const ParameterSet& ps) : nevents(0) {
00030 
00031   LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients") << "[DTSummaryClients]: Constructor";
00032   
00033   
00034   dbe = Service<DQMStore>().operator->();
00035 
00036 }
00037 
00038 DTSummaryClients::~DTSummaryClients(){
00039   LogVerbatim ("DTDQM|DTMonitorClient|DTSummaryClients") << "DTSummaryClients: analyzed " << nevents << " events";
00040   
00041 }
00042 
00043 void DTSummaryClients::beginRun(Run const& run, EventSetup const& eSetup) {
00044 
00045   LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients") <<"[DTSummaryClients]: 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 DTSummaryClients::endJob(void){
00075   
00076   LogVerbatim ("DTDQM|DTMonitorClient|DTSummaryClients") <<"[DTSummaryClients]: endJob"; 
00077 
00078 }
00079 
00080 
00081 void DTSummaryClients::endRun(Run const& run, EventSetup const& eSetup) {
00082   
00083   LogVerbatim ("DTDQM|DTMonitorClient|DTSummaryClients") <<"[DTSummaryClients]: endRun"; 
00084 
00085 }
00086 
00087 
00088 void DTSummaryClients::analyze(const Event& event, const EventSetup& context){
00089 
00090    nevents++;
00091    if(nevents%1000 == 0) {
00092      LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients") << "[DTSummaryClients] Analyze #Run: " << event.id().run()
00093                                          << " #Event: " << event.id().event()
00094                                          << " LS: " << event.luminosityBlock()  
00095                                          << endl;
00096    }
00097 }
00098 
00099 
00100 void DTSummaryClients::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00101   
00102   LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients")
00103     << "[DTSummaryClients]: End of LS transition, performing the DQM client operation" << endl;
00104 
00105   // reset the monitor elements
00106   summaryReportMap->Reset();
00107   summaryReport->Reset();
00108   for(int ii = 0; ii != 5; ++ii) {
00109     theSummaryContents[ii]->Reset();
00110   }
00111 
00112   bool noDTData = false;
00113 
00114   // Check if DT data in each ROS have been read out and set the SummaryContents and the ErrorSummary
00115   // accordignly
00116   MonitorElement * dataIntegritySummary = dbe->get("DT/00-DataIntegrity/DataIntegritySummary");
00117   if(dataIntegritySummary != 0) {
00118   int nDisabledFED = 0;
00119   for(int wheel = 1; wheel != 6; ++wheel) { // loop over the wheels
00120     int nDisablesROS = 0;
00121     for(int sect = 1; sect != 13; ++sect) { // loop over sectors
00122       if(dataIntegritySummary->getBinContent(sect,wheel) == 1) {
00123         nDisablesROS++;
00124       }
00125     }
00126     if(nDisablesROS == 12) {
00127       nDisabledFED++;
00128       theSummaryContents[wheel-1]->Fill(0);
00129     }
00130   }
00131   
00132   if(nDisabledFED == 5) {
00133     noDTData = true;
00134     summaryReport->Fill(-1);
00135   }
00136   
00137   } else {
00138     LogError("DTDQM|DTMonitorClient|DTSummaryClients")
00139       << "Data Integrity Summary not found with name: DT/00-DataIntegrity/DataIntegritySummary" <<endl;
00140   }
00141 
00142   double totalStatus = 0;
00143   // protection 
00144   bool occupancyFound = true;
00145 
00146   // Fill the map using, at the moment, only the information from DT occupancy
00147   // problems at a granularity smaller than the chamber are ignored
00148   for(int wheel=-2; wheel<=2; wheel++){ // loop over wheels
00149     // retrieve the occupancy summary
00150     stringstream str;
00151     str << "DT/01-Digi/OccupancySummary_W" << wheel;
00152     MonitorElement * wheelOccupancySummary =  dbe->get(str.str());
00153     if(wheelOccupancySummary != 0) {
00154       int nFailingChambers = 0;
00155       for(int sector=1; sector<=12; sector++){ // loop over sectors
00156         for(int station = 1; station != 5; ++station) { // loop over stations
00157           double chamberStatus = wheelOccupancySummary->getBinContent(sector, station);
00158           LogTrace("DTDQM|DTMonitorClient|DTSummaryClients")
00159             << "Wheel: " << wheel << " Stat: " << station << " Sect: " << sector << " status: " << chamberStatus << endl;
00160           if(chamberStatus != 4) {
00161             summaryReportMap->Fill(sector, wheel, 0.25);
00162           } else {
00163             nFailingChambers++;
00164           }
00165           LogTrace("DTDQM|DTMonitorClient|DTSummaryClients") << " sector (" << sector << ") status on the map is: "
00166                                                              << summaryReportMap->getBinContent(sector, wheel+3) << endl;
00167         }
00168 
00169       }
00170       theSummaryContents[wheel+2]->Fill((48.-nFailingChambers)/48.);
00171       totalStatus += (48.-nFailingChambers)/48.;
00172     } else {
00173       occupancyFound = false;
00174       LogError("DTDQM|DTMonitorClient|DTSummaryClients")<< " Wheel Occupancy Summary not found with name: " << str.str() << endl;
00175     }
00176   }
00177 
00178 
00179   if(occupancyFound && !noDTData)
00180     summaryReport->Fill(totalStatus/5.);
00181 
00182 //   cout << "-----------------------------------------------------------------------------" << endl;
00183 //   cout << " In the endLuminosityBlock: " << endl;
00184 //   for(int wheel = -2; wheel != 3; ++wheel) {
00185 //     for(int sector = 1; sector != 13; sector++) {
00186 //       cout << " wheel: " << wheel << " sector: " << sector << " status on the map is: "
00187 //         << summaryReportMap->getBinContent(sector, wheel+3) << endl;
00188 //     }
00189 //   }
00190 //   cout << "-----------------------------------------------------------------------------" << endl;
00191 
00192 
00193 }
00194 
00195