Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:00

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