Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:09:37

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author C. Battilana - CIEMAT
0005  *  \author P. Bellan - INFN PD
0006  *  \author A. Branca = INFN PD
0007  */
0008 
0009 #include "DQM/DTMonitorClient/src/DTDCSByLumiSummary.h"
0010 #include "DQM/DTMonitorModule/interface/DTTimeEvolutionHisto.h"
0011 
0012 #include "FWCore/ServiceRegistry/interface/Service.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 
0017 #include "DQMServices/Core/interface/DQMStore.h"
0018 
0019 #include <string>
0020 
0021 using namespace std;
0022 using namespace edm;
0023 
0024 DTDCSByLumiSummary::DTDCSByLumiSummary(const ParameterSet& pset) { bookingdone = false; }
0025 
0026 DTDCSByLumiSummary::~DTDCSByLumiSummary() {}
0027 
0028 void DTDCSByLumiSummary::beginRun(const edm::Run& r, const edm::EventSetup& setup) {}
0029 
0030 void DTDCSByLumiSummary::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0031                                                DQMStore::IGetter& igetter,
0032                                                edm::LuminosityBlock const& lumi,
0033                                                edm::EventSetup const& setup) {
0034   if (!bookingdone) {
0035     ibooker.setCurrentFolder("DT/EventInfo/DCSContents");
0036 
0037     globalHVSummary = ibooker.book2D("HVGlbSummary", "HV Status Summary", 1, 1, 13, 5, -2, 3);
0038     globalHVSummary->setAxisTitle("Sectors", 1);
0039     globalHVSummary->setAxisTitle("Wheel", 2);
0040 
0041     {
0042       auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
0043       totalDCSFraction = ibooker.bookFloat("DTDCSSummary");
0044       for (int wh = -2; wh <= 2; wh++) {
0045         stringstream wheel_str;
0046         wheel_str << wh;
0047 
0048         MonitorElement* FractionWh = ibooker.bookFloat("DT_Wheel" + wheel_str.str());
0049 
0050         totalDCSFractionWh.push_back(FractionWh);
0051       }
0052     }
0053 
0054     globalHVSummary->Reset();
0055 
0056     // CB LumiFlag marked products are reset on LS boundaries
0057     totalDCSFraction->Reset();
0058 
0059     for (int wh = -2; wh <= 2; wh++) {
0060       totalDCSFractionWh[wh + 2]->Reset();
0061     }
0062   }
0063   bookingdone = true;
0064 
0065   // Get the by lumi product plot from the task
0066   int lumiNumber = lumi.id().luminosityBlock();
0067 
0068   bool null_pointer_histo(false);
0069 
0070   std::vector<float> wh_activeFrac;
0071 
0072   for (int wh = -2; wh <= 2; wh++) {
0073     stringstream wheel_str;
0074     wheel_str << wh;
0075 
0076     string hActiveUnitsPath = "DT/EventInfo/DCSContents/hActiveUnits" + wheel_str.str();
0077 
0078     MonitorElement* hActiveUnits = igetter.get(hActiveUnitsPath);
0079 
0080     if (hActiveUnits) {
0081       float activeFrac = static_cast<float>(hActiveUnits->getBinContent(2)) /  // CB 2nd bin is # of active channels
0082                          hActiveUnits->getBinContent(1);  // first bin is overall number of channels
0083 
0084       if (activeFrac < 0.)
0085         activeFrac = -1;
0086 
0087       wh_activeFrac.push_back(activeFrac);
0088 
0089       // Fill by lumi Certification ME
0090       totalDCSFraction->Fill(activeFrac);
0091       totalDCSFractionWh[wh + 2]->Fill(activeFrac);
0092 
0093     } else {
0094       LogTrace("DTDQM|DTMonitorClient|DTDCSByLumiSummary")
0095           << "[DTDCSByLumiSummary]: got null pointer retrieving histo at :" << hActiveUnitsPath << " for lumi # "
0096           << lumiNumber << "client operation not performed." << endl;
0097 
0098       null_pointer_histo = true;
0099     }
0100 
0101   }  // end loop on wheels
0102 
0103   if (!null_pointer_histo)
0104     dcsFracPerLumi[lumiNumber] = wh_activeFrac;  // Fill map to be used to compute trend plots
0105 
0106   // CB LumiFlag marked products are reset on LS boundaries
0107   totalDCSFraction->Reset();
0108 
0109   for (int wh = -2; wh <= 2; wh++) {
0110     totalDCSFractionWh[wh + 2]->Reset();
0111   }
0112 }
0113 
0114 void DTDCSByLumiSummary::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0115   // Book trend plots ME & loop on map to fill it with by lumi info
0116   map<int, std::vector<float> >::const_iterator fracPerLumiIt = dcsFracPerLumi.begin();
0117   map<int, std::vector<float> >::const_iterator fracPerLumiEnd = dcsFracPerLumi.end();
0118 
0119   if (fracPerLumiIt != fracPerLumiEnd) {
0120     int fLumi = dcsFracPerLumi.begin()->first;
0121     int lLumi = dcsFracPerLumi.rbegin()->first;
0122 
0123     ibooker.setCurrentFolder("DT/EventInfo/DCSContents");
0124 
0125     int nLumis = lLumi - fLumi + 1.;
0126 
0127     // trend plots
0128     for (int wh = -2; wh <= 2; wh++) {
0129       stringstream wheel_str;
0130       wheel_str << wh;
0131 
0132       DTTimeEvolutionHisto* trend;
0133 
0134       trend = new DTTimeEvolutionHisto(ibooker,
0135                                        "hDCSFracTrendWh" + wheel_str.str(),
0136                                        "Fraction of DT-HV ON Wh" + wheel_str.str(),
0137                                        nLumis,
0138                                        fLumi,
0139                                        1,
0140                                        false,
0141                                        2);
0142 
0143       hDCSFracTrend.push_back(trend);
0144     }
0145   }
0146 
0147   float goodLSperWh[5] = {0, 0, 0, 0, 0};
0148   float badLSperWh[5] = {0, 0, 0, 0, 0};
0149 
0150   // fill trend plots and save infos for summaryPlot
0151   for (; fracPerLumiIt != fracPerLumiEnd; ++fracPerLumiIt) {
0152     for (int wh = -2; wh <= 2; wh++) {
0153       std::vector<float> activeFracPerWh;
0154       activeFracPerWh = fracPerLumiIt->second;
0155 
0156       hDCSFracTrend[wh + 2]->setTimeSlotValue(activeFracPerWh[wh + 2], fracPerLumiIt->first);
0157 
0158       if (activeFracPerWh[wh + 2] > 0) {  // we do not count the lumi were the DTs are off (no real problem),
0159         // even if this can happen in the middle of a run (real problem: to be fixed)
0160         if (activeFracPerWh[wh + 2] > 0.9)
0161           goodLSperWh[wh + 2]++;
0162         else {
0163           badLSperWh[wh + 2]++;
0164         }
0165       } else {  // there is no HV value OR all channels OFF
0166         if (activeFracPerWh[wh + 2] < 0)
0167           badLSperWh[wh + 2] = -1;  // if there were no HV values, activeFrac returning -1
0168       }
0169     }
0170   }
0171 
0172   // fill summaryPlot
0173   for (int wh = -2; wh <= 2; wh++) {
0174     if (goodLSperWh[wh + 2] != 0 || badLSperWh[wh + 2] == -1) {
0175       float r = badLSperWh[wh + 2] / fabs(goodLSperWh[wh + 2] + badLSperWh[wh + 2]);
0176       if (r > 0.5)
0177         globalHVSummary->Fill(1, wh, 0);
0178       else
0179         globalHVSummary->Fill(1, wh, 1);
0180       if (r == -1)
0181         globalHVSummary->Fill(1, wh, -1);
0182 
0183     } else {
0184       globalHVSummary->Fill(1, wh, 0);
0185     }
0186   }
0187 }