Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:06

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author G. Mila - INFN Torino
0005  *
0006  *  threadsafe version (//-) oct/nov 2014 - WATWanAbdullah -ncpp-um-my
0007  *
0008  */
0009 
0010 #include "DQM/DTMonitorClient/src/DTSummaryClients.h"
0011 
0012 // Framework
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 #include "DQMServices/Core/interface/DQMStore.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 
0020 #include <string>
0021 
0022 using namespace edm;
0023 using namespace std;
0024 
0025 DTSummaryClients::DTSummaryClients(const ParameterSet& ps) : nevents(0) {
0026   LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients") << "[DTSummaryClients]: Constructor";
0027 
0028   bookingdone = false;
0029 }
0030 
0031 DTSummaryClients::~DTSummaryClients() {
0032   LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients") << "DTSummaryClients: analyzed " << nevents << " events";
0033 }
0034 
0035 void DTSummaryClients::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0036   LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients") << "[DTSummaryClients]: endJob";
0037 }
0038 
0039 void DTSummaryClients::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0040                                              DQMStore::IGetter& igetter,
0041                                              edm::LuminosityBlock const& lumiSeg,
0042                                              edm::EventSetup const& context) {
0043   if (!bookingdone) {
0044     // book the summary histos
0045 
0046     ibooker.setCurrentFolder("DT/EventInfo");
0047 
0048     summaryReport = ibooker.bookFloat("reportSummary");
0049     // Initialize to 1 so that no alarms are thrown at the beginning of the run
0050     summaryReport->Fill(1.);
0051 
0052     summaryReportMap = ibooker.book2D("reportSummaryMap", "DT Report Summary Map", 12, 1, 13, 5, -2, 3);
0053     summaryReportMap->setAxisTitle("sector", 1);
0054     summaryReportMap->setAxisTitle("wheel", 2);
0055 
0056     ibooker.setCurrentFolder("DT/EventInfo/reportSummaryContents");
0057 
0058     for (int wheel = -2; wheel != 3; ++wheel) {
0059       stringstream streams;
0060       streams << "DT_Wheel" << wheel;
0061       string meName = streams.str();
0062 
0063       theSummaryContents.push_back(ibooker.bookFloat(meName));
0064       // Initialize to 1 so that no alarms are thrown at the beginning of the run
0065       theSummaryContents[wheel + 2]->Fill(1.);
0066     }
0067   }
0068   bookingdone = true;
0069 
0070   LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients")
0071       << "[DTSummaryClients]: End of LS transition, performing the DQM client operation" << endl;
0072 
0073   // reset the monitor elements
0074   summaryReportMap->Reset();
0075   summaryReport->Reset();
0076   for (int ii = 0; ii != 5; ++ii) {
0077     theSummaryContents[ii]->Reset();
0078   }
0079 
0080   bool noDTData = false;
0081 
0082   // Check if DT data in each ROS have been read out and set the SummaryContents and the ErrorSummary
0083   // accordignly
0084   MonitorElement* dataIntegritySummary = igetter.get("DT/00-DataIntegrity/DataIntegritySummary");
0085   if (dataIntegritySummary != nullptr) {
0086     int nDisabledFED = 0;
0087     for (int wheel = 1; wheel != 6; ++wheel) {  // loop over the wheels
0088       int nDisablesROS = 0;
0089       for (int sect = 1; sect != 13; ++sect) {  // loop over sectors
0090         if (dataIntegritySummary->getBinContent(sect, wheel) == 0) {
0091           nDisablesROS++;
0092         }
0093       }
0094       if (nDisablesROS == 12) {
0095         nDisabledFED++;
0096         theSummaryContents[wheel - 1]->Fill(0);
0097       }
0098     }
0099 
0100     if (nDisabledFED == 5) {
0101       noDTData = true;
0102       summaryReport->Fill(-1);
0103     }
0104 
0105   } else {
0106     LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients")
0107         << "Data Integrity Summary not found with name: DT/00-DataIntegrity/DataIntegritySummary" << endl;
0108   }
0109 
0110   double totalStatus = 0;
0111   // protection
0112   bool occupancyFound = true;
0113 
0114   // Fill the map using, at the moment, only the information from DT occupancy
0115   // problems at a granularity smaller than the chamber are ignored
0116   for (int wheel = -2; wheel <= 2; wheel++) {  // loop over wheels
0117     // retrieve the occupancy summary
0118     stringstream str;
0119     str << "DT/01-Digi/OccupancySummary_W" << wheel;
0120     MonitorElement* wheelOccupancySummary = igetter.get(str.str());
0121     if (wheelOccupancySummary != nullptr) {
0122       int nFailingChambers = 0;
0123       for (int sector = 1; sector <= 12; sector++) {      // loop over sectors
0124         for (int station = 1; station != 5; ++station) {  // loop over stations
0125           double chamberStatus = wheelOccupancySummary->getBinContent(sector, station);
0126           LogTrace("DTDQM|DTMonitorClient|DTSummaryClients")
0127               << "Wheel: " << wheel << " Stat: " << station << " Sect: " << sector << " status: " << chamberStatus
0128               << endl;
0129           if (chamberStatus != 4) {
0130             summaryReportMap->Fill(sector, wheel, 0.25);
0131           } else {
0132             nFailingChambers++;
0133           }
0134           LogTrace("DTDQM|DTMonitorClient|DTSummaryClients")
0135               << " sector (" << sector
0136               << ") status on the map is: " << summaryReportMap->getBinContent(sector, wheel + 3) << endl;
0137         }
0138       }
0139       theSummaryContents[wheel + 2]->Fill((48. - nFailingChambers) / 48.);
0140       totalStatus += (48. - nFailingChambers) / 48.;
0141     } else {
0142       occupancyFound = false;
0143       LogVerbatim("DTDQM|DTMonitorClient|DTSummaryClients")
0144           << " Wheel Occupancy Summary not found with name: " << str.str() << endl;
0145     }
0146   }
0147 
0148   if (occupancyFound && !noDTData)
0149     summaryReport->Fill(totalStatus / 5.);
0150 }