Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:25

0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0005 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0006 #include "CondCore/EcalPlugins/plugins/EcalDrawUtils.h"
0007 #include "CondCore/EcalPlugins/plugins/EcalBadCrystalsCount.h"
0008 // the data format of the condition to be inspected
0009 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
0010 
0011 #include <memory>
0012 #include <sstream>
0013 
0014 #include "TStyle.h"
0015 #include "TH2F.h"
0016 #include "TCanvas.h"
0017 #include "TLine.h"
0018 #include "TLatex.h"
0019 
0020 namespace {
0021   static constexpr int kEBChannels = 61200, kEEChannels = 14648, NRGBs = 5, NCont = 255;
0022   // barrel lower and upper bounds on eta and phi
0023   static constexpr int MAX_IETA = 85, MAX_IPHI = 360;
0024   // endcaps lower and upper bounds on x and y
0025   static constexpr int IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100;
0026 
0027   /*******************************************************
0028         2d plot of ECAL barrel channel status of 1 IOV
0029   *******************************************************/
0030   class EcalChannelStatusEBMap : public cond::payloadInspector::PlotImage<EcalChannelStatus> {
0031   public:
0032     EcalChannelStatusEBMap() : cond::payloadInspector::PlotImage<EcalChannelStatus>("ECAL Barrel channel status") {
0033       setSingleIov(true);
0034     }
0035     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
0036       TH2F *ebmap = new TH2F("ebmap", "", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
0037       TH2F *ebmap_coarse = new TH2F("ebmap_coarse", "", MAX_IPHI / 20, 0, MAX_IPHI, 2, -MAX_IETA, MAX_IETA);
0038       Int_t ebcount = 0;
0039       unsigned int run = 0;
0040       //      for ( auto const & iov: iovs) {
0041       auto iov = iovs.front();
0042       std::shared_ptr<EcalChannelStatus> payload = fetchPayload(std::get<1>(iov));
0043       run = std::get<0>(iov);
0044       if (payload.get()) {
0045         // looping over the EB channels, via the dense-index, mapped into EBDetId's
0046         if (payload->barrelItems().empty())
0047           return false;
0048         for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0049           uint32_t rawid = EBDetId::unhashIndex(cellid);
0050           // check the existence of ECAL channel status, for a given ECAL barrel channel
0051           if (payload->find(rawid) == payload->end())
0052             continue;
0053           //        if (!(*payload)[rawid].getEncodedStatusCode()) continue;
0054           Double_t weight = (Double_t)(*payload)[rawid].getEncodedStatusCode();
0055           Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
0056           Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
0057           if (eta > 0.)
0058             eta = eta - 0.5;  //   0.5 to 84.5
0059           else
0060             eta = eta + 0.5;  //  -84.5 to -0.5
0061           ebmap->Fill(phi, eta, weight);
0062           if (weight > 0) {
0063             ebcount++;
0064             ebmap_coarse->Fill(phi, eta);
0065           }
0066         }  // loop over cellid
0067       }  // if payload.get()
0068       else
0069         return false;
0070 
0071       gStyle->SetOptStat(0);
0072       //set the background color to white
0073       gStyle->SetFillColor(10);
0074       gStyle->SetFrameFillColor(10);
0075       gStyle->SetCanvasColor(10);
0076       gStyle->SetPadColor(10);
0077       gStyle->SetTitleFillColor(0);
0078       gStyle->SetStatColor(10);
0079       //dont put a colored frame around the plots
0080       gStyle->SetFrameBorderMode(0);
0081       gStyle->SetCanvasBorderMode(0);
0082       gStyle->SetPadBorderMode(0);
0083       //use the primary color palette
0084       gStyle->SetPalette(1);
0085 
0086       Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
0087       Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
0088       Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
0089       Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
0090       TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
0091       gStyle->SetNumberContours(NCont);
0092 
0093       TCanvas c1("c1", "c1", 1200, 700);
0094       c1.SetGridx(1);
0095       c1.SetGridy(1);
0096 
0097       TLatex t1;
0098       t1.SetNDC();
0099       t1.SetTextAlign(26);
0100       t1.SetTextSize(0.06);
0101 
0102       ebmap->SetXTitle("i#phi");
0103       ebmap->SetYTitle("i#eta");
0104       ebmap->GetXaxis()->SetNdivisions(-418, kFALSE);
0105       ebmap->GetYaxis()->SetNdivisions(-1702, kFALSE);
0106       ebmap->GetXaxis()->SetLabelSize(0.03);
0107       ebmap->GetYaxis()->SetLabelSize(0.03);
0108       ebmap->GetXaxis()->SetTickLength(0.01);
0109       ebmap->GetYaxis()->SetTickLength(0.01);
0110       ebmap->SetMaximum(15);
0111 
0112       c1.cd();
0113       ebmap->Draw("colz");
0114 
0115       ebmap_coarse->SetMarkerSize(1.3);
0116       ebmap_coarse->Draw("text,same");
0117 
0118       t1.SetTextSize(0.05);
0119       t1.DrawLatex(0.5, 0.96, Form("EB Channel Status Masks, IOV %i", run));
0120 
0121       char txt[80];
0122       Double_t prop = (Double_t)ebcount / kEBChannels * 100.;
0123       sprintf(txt, "%d/61200 (%4.3f%%)", ebcount, prop);
0124       t1.SetTextColor(2);
0125       t1.SetTextSize(0.045);
0126       t1.DrawLatex(0.5, 0.91, txt);
0127 
0128       std::string ImageName(m_imageFileName);
0129       c1.SaveAs(ImageName.c_str());
0130       return true;
0131     }
0132   };
0133 
0134   /*********************************************************
0135        2d plot of ECAL endcaps channel status of 1 IOV
0136   *********************************************************/
0137   class EcalChannelStatusEEMap : public cond::payloadInspector::PlotImage<EcalChannelStatus> {
0138   public:
0139     EcalChannelStatusEEMap() : cond::payloadInspector::PlotImage<EcalChannelStatus>("ECAL Barrel channel status") {
0140       setSingleIov(true);
0141     }
0142     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
0143       //      TH2F *eemap = new TH2F("eemap","", 2*IX_MAX, IX_MIN, 2*IX_MAX+1, IY_MAX, IY_MIN, IY_MAX+IY_MIN);
0144       TH2F *eemap = new TH2F("eemap", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
0145       TH2F *eemap_coarse = new TH2F("eemap_coarse", "", 2, 0, 2 * IX_MAX, 1, 0, IY_MAX);
0146       TH2F *eetemp = new TH2F("eetemp", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
0147       Int_t eecount = 0;
0148       unsigned int run = 0;
0149       auto iov = iovs.front();
0150       std::shared_ptr<EcalChannelStatus> payload = fetchPayload(std::get<1>(iov));
0151       run = std::get<0>(iov);
0152       if (payload.get()) {
0153         if (payload->endcapItems().empty())
0154           return false;
0155 
0156         // looping over the EE channels
0157         for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
0158           for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
0159             for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
0160               if (EEDetId::validDetId(ix, iy, iz)) {
0161                 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
0162                 uint32_t rawid = myEEId.rawId();
0163                 // check the existence of ECAL channel status, for a given ECAL endcap channel
0164                 if (payload->find(rawid) == payload->end())
0165                   continue;
0166                 //          if (!(*payload)[rawid].getEncodedStatusCode()) continue;
0167                 float weight = (float)(*payload)[rawid].getEncodedStatusCode();
0168                 if (iz == -1) {
0169                   //              eemap->Fill(ix, iy, weight);
0170                   eemap->Fill(ix - 1, iy - 1, weight);
0171                   if (weight > 0) {
0172                     eecount++;
0173                     eemap_coarse->Fill(ix - 1, iy - 1);
0174                   }
0175                 } else {
0176                   //              eemap->Fill(ix+IX_MAX, iy, weight);
0177                   eemap->Fill(ix + IX_MAX - 1, iy - 1, weight);
0178                   if (weight > 0) {
0179                     eecount++;
0180                     eemap_coarse->Fill(ix + IX_MAX - 1, iy - 1);
0181                   }
0182                 }
0183               }  // validDetId
0184       }  // payload
0185 
0186       gStyle->SetOptStat(0);
0187       //set the background color to white
0188       gStyle->SetFillColor(10);
0189       gStyle->SetFrameFillColor(10);
0190       gStyle->SetCanvasColor(10);
0191       gStyle->SetPadColor(10);
0192       gStyle->SetTitleFillColor(0);
0193       gStyle->SetStatColor(10);
0194       //dont put a colored frame around the plots
0195       gStyle->SetFrameBorderMode(0);
0196       gStyle->SetCanvasBorderMode(0);
0197       gStyle->SetPadBorderMode(0);
0198       //use the primary color palette
0199       gStyle->SetPalette(1);
0200 
0201       Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
0202       Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
0203       Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
0204       Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
0205       TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
0206       gStyle->SetNumberContours(NCont);
0207 
0208       // set the EE contours
0209       for (Int_t i = 1; i <= IX_MAX; i++) {
0210         for (Int_t j = 1; j <= IY_MAX; j++) {
0211           if (EEDetId::validDetId(i, j, 1)) {
0212             //      eetemp->SetBinContent(i + 1, j + 1, 2);
0213             //      eetemp->SetBinContent(i + IX_MAX + 1, j +1, 2);
0214             eetemp->SetBinContent(i, j, 2);
0215             eetemp->SetBinContent(i + IX_MAX, j, 2);
0216           }
0217         }
0218       }
0219 
0220       eetemp->SetFillColor(920);
0221       TCanvas c1("c1", "c1", 1200, 600);
0222       c1.SetGridx(1);
0223       c1.SetGridy(1);
0224 
0225       TLatex t1;
0226       t1.SetNDC();
0227       t1.SetTextAlign(26);
0228       t1.SetTextSize(0.06);
0229 
0230       eetemp->GetXaxis()->SetNdivisions(40, kFALSE);
0231       eetemp->GetYaxis()->SetNdivisions(20, kFALSE);
0232       eetemp->GetXaxis()->SetLabelSize(0.00);
0233       eetemp->GetYaxis()->SetLabelSize(0.00);
0234       eetemp->GetXaxis()->SetTickLength(0.01);
0235       eetemp->GetYaxis()->SetTickLength(0.01);
0236       eetemp->SetMaximum(1.15);
0237 
0238       eemap->GetXaxis()->SetNdivisions(40, kFALSE);
0239       eemap->GetYaxis()->SetNdivisions(20, kFALSE);
0240       eemap->GetXaxis()->SetLabelSize(0.00);
0241       eemap->GetYaxis()->SetLabelSize(0.00);
0242       eemap->GetXaxis()->SetTickLength(0.01);
0243       eemap->GetYaxis()->SetTickLength(0.01);
0244       eemap->SetMaximum(15);
0245 
0246       eetemp->Draw("box");
0247       eemap->Draw("same,colz");
0248 
0249       eemap_coarse->SetMarkerSize(2);
0250       eemap_coarse->Draw("same,text");
0251 
0252       t1.SetTextColor(1);
0253       t1.SetTextSize(0.055);
0254       t1.DrawLatex(0.5, 0.96, Form("EE Channel Status Masks, IOV %i", run));
0255 
0256       char txt[80];
0257       Double_t prop = (Double_t)eecount / kEEChannels * 100.;
0258       sprintf(txt, "%d/14648 (%4.3f%%)", eecount, prop);
0259       t1.SetTextColor(2);
0260       t1.SetTextSize(0.045);
0261       t1.DrawLatex(0.5, 0.91, txt);
0262       t1.SetTextColor(1);
0263       t1.SetTextSize(0.05);
0264       t1.DrawLatex(0.14, 0.84, "EE-");
0265       t1.DrawLatex(0.86, 0.84, "EE+");
0266 
0267       std::string ImageName(m_imageFileName);
0268       c1.SaveAs(ImageName.c_str());
0269       return true;
0270     }  // fill method
0271   };
0272 
0273   /**********************************************************************
0274      2d plot of ECAL barrel channel status difference between 2 IOVs
0275   ***********************************************************************/
0276   template <cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
0277   class EcalChannelStatusEBDiffBase : public cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags> {
0278   public:
0279     EcalChannelStatusEBDiffBase()
0280         : cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags>("ECAL Barrel channel status difference") {}
0281     bool fill() override {
0282       TH2F *ebmap = new TH2F("ebmap", "", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
0283       TH2F *ebmap_coarse = new TH2F("ebmap_coarse", "", MAX_IPHI / 20, 0, MAX_IPHI, 2, -MAX_IETA, MAX_IETA);
0284       Int_t ebcount = 0;
0285       unsigned int run[2] = {0, 0}, status[kEBChannels];
0286       std::string l_tagname[2];
0287       auto iovs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
0288       l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().name;
0289       auto firstiov = iovs.front();
0290       run[0] = std::get<0>(firstiov);
0291       std::tuple<cond::Time_t, cond::Hash> lastiov;
0292       if (ntags == 2) {
0293         auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
0294         l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().name;
0295         lastiov = tag2iovs.front();
0296       } else {
0297         lastiov = iovs.back();
0298         l_tagname[1] = l_tagname[0];
0299       }
0300       run[1] = std::get<0>(lastiov);
0301       for (int irun = 0; irun < nIOVs; irun++) {
0302         std::shared_ptr<EcalChannelStatus> payload;
0303         if (irun == 0) {
0304           payload = this->fetchPayload(std::get<1>(firstiov));
0305         } else {
0306           payload = this->fetchPayload(std::get<1>(lastiov));
0307         }
0308         if (payload.get()) {
0309           // looping over the EB channels, via the dense-index, mapped into EBDetId's
0310           if (payload->barrelItems().empty())
0311             return false;
0312           for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0313             uint32_t rawid = EBDetId::unhashIndex(cellid);
0314             // check the existence of ECAL channel status, for a given ECAL barrel channel
0315             if (payload->find(rawid) == payload->end())
0316               continue;
0317             //      if (!(*payload)[rawid].getEncodedStatusCode()) continue;
0318             if (irun == 0) {
0319               status[cellid] = (*payload)[rawid].getEncodedStatusCode();
0320             } else {
0321               unsigned int new_status = (*payload)[rawid].getEncodedStatusCode();
0322               if (new_status != status[cellid]) {
0323                 int tmp3 = 0;
0324                 if (new_status > status[cellid])
0325                   tmp3 = 1;
0326                 else
0327                   tmp3 = -1;
0328                 Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
0329                 Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
0330                 if (eta > 0.)
0331                   eta = eta - 0.5;  //   0.5 to 84.5
0332                 else
0333                   eta = eta + 0.5;  //  -84.5 to -0.5
0334                 ebmap->Fill(phi, eta, 0.05 + 0.95 * (tmp3 > 0));
0335                 ebcount++;
0336                 ebmap_coarse->Fill(phi, eta, tmp3);
0337               }
0338             }
0339           }  // loop over cellid
0340         }  // if payload.get()
0341         else
0342           return false;
0343       }  // loop over IOV's
0344 
0345       gStyle->SetOptStat(0);
0346       //set the background color to white
0347       gStyle->SetFillColor(10);
0348       gStyle->SetFrameFillColor(10);
0349       gStyle->SetCanvasColor(10);
0350       gStyle->SetPadColor(10);
0351       gStyle->SetTitleFillColor(0);
0352       gStyle->SetStatColor(10);
0353       //dont put a colored frame around the plots
0354       gStyle->SetFrameBorderMode(0);
0355       gStyle->SetCanvasBorderMode(0);
0356       gStyle->SetPadBorderMode(0);
0357       //use the primary color palette
0358       gStyle->SetPalette(1);
0359 
0360       Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
0361       Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
0362       Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
0363       Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
0364       TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
0365       gStyle->SetNumberContours(NCont);
0366 
0367       TCanvas c1("c1", "c1", 1200, 700);
0368       c1.SetGridx(1);
0369       c1.SetGridy(1);
0370 
0371       TLatex t1;
0372       t1.SetNDC();
0373       t1.SetTextAlign(26);
0374       t1.SetTextSize(0.06);
0375 
0376       ebmap->SetXTitle("i#phi");
0377       ebmap->SetYTitle("i#eta");
0378       ebmap->GetXaxis()->SetNdivisions(-418, kFALSE);
0379       ebmap->GetYaxis()->SetNdivisions(-1702, kFALSE);
0380       ebmap->GetXaxis()->SetLabelSize(0.03);
0381       ebmap->GetYaxis()->SetLabelSize(0.03);
0382       ebmap->GetXaxis()->SetTickLength(0.01);
0383       ebmap->GetYaxis()->SetTickLength(0.01);
0384       ebmap->SetMaximum(1.15);
0385 
0386       c1.cd();
0387       ebmap->Draw("colz");
0388 
0389       ebmap_coarse->SetMarkerSize(1.3);
0390       ebmap_coarse->Draw("text,same");
0391 
0392       int len = l_tagname[0].length() + l_tagname[1].length();
0393       if (ntags == 2) {
0394         if (len < 60) {
0395           t1.SetTextSize(0.03);
0396           t1.DrawLatex(
0397               0.5, 0.96, Form("%s IOV %i - %s  IOV %i", l_tagname[1].c_str(), run[1], l_tagname[0].c_str(), run[0]));
0398         } else
0399           t1.SetTextSize(0.05);
0400         t1.DrawLatex(0.5, 0.96, Form("EB Channel Status Masks (Diff), IOV %i - IOV %i", run[1], run[0]));
0401       } else {
0402         t1.SetTextSize(0.05);
0403         t1.DrawLatex(0.5, 0.96, Form("%s IOV: %i - %i", l_tagname[0].c_str(), run[1], run[0]));
0404       }
0405 
0406       char txt[80];
0407       sprintf(txt, "Net difference: %d channel(s)", ebcount);
0408       t1.SetTextColor(2);
0409       t1.SetTextSize(0.045);
0410       t1.DrawLatex(0.5, 0.91, txt);
0411 
0412       std::string ImageName(this->m_imageFileName);
0413       c1.SaveAs(ImageName.c_str());
0414       return true;
0415     }  // fill method
0416   };
0417   using EcalChannelStatusEBDiffOneTag = EcalChannelStatusEBDiffBase<cond::payloadInspector::SINGLE_IOV, 1>;
0418   using EcalChannelStatusEBDiffTwoTags = EcalChannelStatusEBDiffBase<cond::payloadInspector::SINGLE_IOV, 2>;
0419 
0420   /************************************************************************
0421        2d plot of ECAL endcaps channel status difference between 2 IOVs
0422   ************************************************************************/
0423   template <cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
0424   class EcalChannelStatusEEDiffBase : public cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags> {
0425   public:
0426     EcalChannelStatusEEDiffBase()
0427         : cond::payloadInspector::PlotImage<EcalChannelStatus, nIOVs, ntags>("ECAL Endcaps channel status difference") {
0428     }
0429     bool fill() override {
0430       TH2F *eemap = new TH2F("eemap", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
0431       TH2F *eemap_coarse = new TH2F("eemap_coarse", "", 2, 0, 2 * IX_MAX, 1, 0, IY_MAX);
0432       TH2F *eetemp = new TH2F("eetemp", "", 2 * IX_MAX, 0, 2 * IX_MAX, IY_MAX, 0, IY_MAX);
0433       Int_t eecount = 0;
0434       unsigned int run[2]{0, 0}, status[kEEChannels];
0435       std::string l_tagname[2];
0436       auto iovs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
0437       l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().name;
0438       auto firstiov = iovs.front();
0439       run[0] = std::get<0>(firstiov);
0440       std::tuple<cond::Time_t, cond::Hash> lastiov;
0441       if (ntags == 2) {
0442         auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
0443         l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().name;
0444         lastiov = tag2iovs.front();
0445         lastiov = tag2iovs.front();
0446       } else {
0447         lastiov = iovs.back();
0448         l_tagname[1] = l_tagname[0];
0449       }
0450       run[1] = std::get<0>(lastiov);
0451       for (int irun = 0; irun < nIOVs; irun++) {
0452         std::shared_ptr<EcalChannelStatus> payload;
0453         if (irun == 0) {
0454           payload = this->fetchPayload(std::get<1>(firstiov));
0455         } else {
0456           payload = this->fetchPayload(std::get<1>(lastiov));
0457         }
0458         if (payload.get()) {
0459           if (payload->endcapItems().empty())
0460             return false;
0461 
0462           // looping over the EE channels
0463           for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
0464             for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
0465               for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
0466                 if (EEDetId::validDetId(ix, iy, iz)) {
0467                   EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
0468                   uint32_t rawid = myEEId.rawId();
0469                   int channel = myEEId.hashedIndex();
0470                   // check the existence of ECAL channel status, for a given ECAL endcap channel
0471                   if (payload->find(rawid) == payload->end())
0472                     continue;
0473                   if (irun == 0) {
0474                     status[channel] = (*payload)[rawid].getEncodedStatusCode();
0475                   } else {
0476                     unsigned int new_status = (*payload)[rawid].getEncodedStatusCode();
0477                     if (new_status != status[channel]) {
0478                       int tmp3 = 0;
0479                       if (new_status > status[channel])
0480                         tmp3 = 1;
0481                       else
0482                         tmp3 = -1;
0483                       if (iz == -1) {
0484                         eemap->Fill(ix - 1, iy - 1, 0.05 + 0.95 * (tmp3 > 0));
0485                         eecount++;
0486                         eemap_coarse->Fill(ix - 1, iy - 1, tmp3);
0487                       } else {
0488                         eemap->Fill(ix + IX_MAX - 1, iy - 1, 0.05 + 0.95 * (tmp3 > 0));
0489                         eecount++;
0490                         eemap_coarse->Fill(ix + IX_MAX - 1, iy - 1, tmp3);
0491                       }  // z side
0492                     }  //  any difference ?
0493                   }  //   2nd IOV, fill the plots
0494                 }  //    validDetId
0495         }  //     get the payload
0496       }  //      loop over payloads
0497 
0498       gStyle->SetOptStat(0);
0499       //set the background color to white
0500       gStyle->SetFillColor(10);
0501       gStyle->SetFrameFillColor(10);
0502       gStyle->SetCanvasColor(10);
0503       gStyle->SetPadColor(10);
0504       gStyle->SetTitleFillColor(0);
0505       gStyle->SetStatColor(10);
0506       //dont put a colored frame around the plots
0507       gStyle->SetFrameBorderMode(0);
0508       gStyle->SetCanvasBorderMode(0);
0509       gStyle->SetPadBorderMode(0);
0510       //use the primary color palette
0511       gStyle->SetPalette(1);
0512 
0513       Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
0514       Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
0515       Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
0516       Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
0517       TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
0518       gStyle->SetNumberContours(NCont);
0519 
0520       // set the EE contours
0521       for (Int_t i = 1; i <= IX_MAX; i++) {
0522         for (Int_t j = 1; j <= IY_MAX; j++) {
0523           if (EEDetId::validDetId(i, j, 1)) {
0524             eetemp->SetBinContent(i, j, 2);
0525             eetemp->SetBinContent(i + IX_MAX, j, 2);
0526           }
0527         }
0528       }
0529 
0530       eetemp->SetFillColor(920);
0531       TCanvas c1("c1", "c1", 1200, 600);
0532       c1.SetGridx(1);
0533       c1.SetGridy(1);
0534 
0535       TLatex t1;
0536       t1.SetNDC();
0537       t1.SetTextAlign(26);
0538       t1.SetTextSize(0.06);
0539 
0540       eetemp->GetXaxis()->SetNdivisions(40, kFALSE);
0541       eetemp->GetYaxis()->SetNdivisions(20, kFALSE);
0542       eetemp->GetXaxis()->SetLabelSize(0.00);
0543       eetemp->GetYaxis()->SetLabelSize(0.00);
0544       eetemp->GetXaxis()->SetTickLength(0.01);
0545       eetemp->GetYaxis()->SetTickLength(0.01);
0546       eetemp->SetMaximum(1.15);
0547 
0548       eemap->GetXaxis()->SetNdivisions(40, kFALSE);
0549       eemap->GetYaxis()->SetNdivisions(20, kFALSE);
0550       eemap->GetXaxis()->SetLabelSize(0.00);
0551       eemap->GetYaxis()->SetLabelSize(0.00);
0552       eemap->GetXaxis()->SetTickLength(0.01);
0553       eemap->GetYaxis()->SetTickLength(0.01);
0554       eemap->SetMaximum(1.15);
0555 
0556       eetemp->Draw("box");
0557       eemap->Draw("same,colz");
0558 
0559       eemap_coarse->SetMarkerSize(2);
0560       eemap_coarse->Draw("same,text");
0561 
0562       t1.SetTextColor(1);
0563       int len = l_tagname[0].length() + l_tagname[1].length();
0564       if (ntags == 2) {
0565         if (len < 60) {
0566           t1.SetTextSize(0.03);
0567           t1.DrawLatex(
0568               0.5, 0.96, Form("%s IOV %i - %s  IOV %i", l_tagname[1].c_str(), run[1], l_tagname[0].c_str(), run[0]));
0569         } else {
0570           t1.SetTextSize(0.05);
0571           t1.DrawLatex(0.5, 0.96, Form("EE Channel Status Masks (Diff), IOV %i - IOV %i", run[1], run[0]));
0572         }
0573       } else {
0574         t1.SetTextSize(0.05);
0575         t1.DrawLatex(0.5, 0.96, Form("%s IOV: %i - %i", l_tagname[0].c_str(), run[1], run[0]));
0576       }
0577 
0578       char txt[80];
0579       sprintf(txt, "Net difference: %d channel(s)", eecount);
0580       t1.SetTextColor(2);
0581       t1.SetTextSize(0.045);
0582       t1.DrawLatex(0.5, 0.91, txt);
0583       t1.SetTextColor(1);
0584       t1.SetTextSize(0.05);
0585       t1.DrawLatex(0.14, 0.84, "EE-");
0586       t1.DrawLatex(0.86, 0.84, "EE+");
0587 
0588       std::string ImageName(this->m_imageFileName);
0589       c1.SaveAs(ImageName.c_str());
0590       return true;
0591     }  // fill method
0592   };
0593   using EcalChannelStatusEEDiffOneTag = EcalChannelStatusEEDiffBase<cond::payloadInspector::SINGLE_IOV, 1>;
0594   using EcalChannelStatusEEDiffTwoTags = EcalChannelStatusEEDiffBase<cond::payloadInspector::SINGLE_IOV, 2>;
0595 
0596   /********************************************************
0597      2d plot of EcalChannelStatus Error Summary of 1 IOV
0598    ********************************************************/
0599   class EcalChannelStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalChannelStatus> {
0600   public:
0601     EcalChannelStatusSummaryPlot()
0602         : cond::payloadInspector::PlotImage<EcalChannelStatus>("Ecal Channel Status Error Summary - map ") {
0603       setSingleIov(true);
0604     }
0605 
0606     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
0607       auto iov = iovs.front();  //get reference to 1st element in the vector iovs
0608       std::shared_ptr<EcalChannelStatus> payload =
0609           fetchPayload(std::get<1>(iov));   //std::get<1>(iov) refers to the Hash in the tuple iov
0610       unsigned int run = std::get<0>(iov);  //referes to Time_t in iov.
0611       TH2F *align;                          //pointer to align which is a 2D histogram
0612 
0613       int NbRows = 3;
0614       int NbColumns = 3;
0615 
0616       if (payload.get()) {  //payload is an iov retrieved from payload using hash.
0617 
0618         align = new TH2F("Ecal Channel Status Error Summary",
0619                          "EB/EE-/EE+            ErrorCount            Total Number",
0620                          NbColumns,
0621                          0,
0622                          NbColumns,
0623                          NbRows,
0624                          0,
0625                          NbRows);
0626 
0627         long unsigned int ebErrorCount = 0;
0628         long unsigned int ee1ErrorCount = 0;
0629         long unsigned int ee2ErrorCount = 0;
0630 
0631         long unsigned int ebTotal = (payload->barrelItems()).size();
0632         long unsigned int ee1Total = 0;
0633         long unsigned int ee2Total = 0;
0634 
0635         getBarrelErrorSummary<EcalChannelStatusCode>(payload->barrelItems(), ebErrorCount);
0636         getEndCapErrorSummary<EcalChannelStatusCode>(
0637             payload->endcapItems(), ee1ErrorCount, ee2ErrorCount, ee1Total, ee2Total);
0638 
0639         double row = NbRows - 0.5;
0640 
0641         //EB summary values
0642         align->Fill(0.5, row, 1);
0643         align->Fill(1.5, row, ebErrorCount);
0644         align->Fill(2.5, row, ebTotal);
0645 
0646         row--;
0647 
0648         align->Fill(0.5, row, 2);
0649         align->Fill(1.5, row, ee1ErrorCount);
0650         align->Fill(2.5, row, ee1Total);
0651 
0652         row--;
0653 
0654         align->Fill(0.5, row, 3);
0655         align->Fill(1.5, row, ee2ErrorCount);
0656         align->Fill(2.5, row, ee2Total);
0657 
0658       }  // if payload.get()
0659       else
0660         return false;
0661 
0662       gStyle->SetPalette(1);
0663       gStyle->SetOptStat(0);
0664       TCanvas canvas("CC map", "CC map", 1000, 1000);
0665       TLatex t1;
0666       t1.SetNDC();
0667       t1.SetTextAlign(26);
0668       t1.SetTextSize(0.045);
0669       t1.SetTextColor(2);
0670       t1.DrawLatex(0.5, 0.96, Form("EcalChannelStatus Error Summary, IOV %i", run));
0671 
0672       TPad *pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
0673       pad->Draw();
0674       pad->cd();
0675       align->Draw("TEXT");
0676 
0677       drawTable(NbRows, NbColumns);
0678 
0679       align->GetXaxis()->SetTickLength(0.);
0680       align->GetXaxis()->SetLabelSize(0.);
0681       align->GetYaxis()->SetTickLength(0.);
0682       align->GetYaxis()->SetLabelSize(0.);
0683 
0684       std::string ImageName(m_imageFileName);
0685       canvas.SaveAs(ImageName.c_str());
0686       return true;
0687     }  // fill method
0688   };
0689 
0690 }  // namespace
0691 
0692 // Register the classes as boost python plugin
0693 PAYLOAD_INSPECTOR_MODULE(EcalChannelStatus) {
0694   PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEBMap);
0695   PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEEMap);
0696   PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEBDiffOneTag);
0697   PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEBDiffTwoTags);
0698   PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEEDiffOneTag);
0699   PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusEEDiffTwoTags);
0700   PAYLOAD_INSPECTOR_CLASS(EcalChannelStatusSummaryPlot);
0701 }