Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-10 02:53:48

0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004 
0005 // the data format of the condition to be inspected
0006 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0007 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0008 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0009 #include "CondCore/EcalPlugins/plugins/EcalDrawUtils.h"
0010 
0011 #include "TH2F.h"
0012 #include "TCanvas.h"
0013 #include "TStyle.h"
0014 #include "TLine.h"
0015 #include "TLatex.h"
0016 
0017 #include <memory>
0018 #include <sstream>
0019 
0020 namespace {
0021   enum { kEBChannels = 61200, kEEChannels = 14648, kGains = 3, kRMS = 5 };
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      1d plot of ECAL pedestal of 1 IOV
0027   ***************************************/
0028   class EcalPedestalsHist : public cond::payloadInspector::PlotImage<EcalPedestals> {
0029   public:
0030     EcalPedestalsHist() : cond::payloadInspector::PlotImage<EcalPedestals>("ECAL pedestal map") { setSingleIov(true); }
0031     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0032       uint32_t gainValues[kGains] = {12, 6, 1};
0033       TH1F** barrel_m = new TH1F*[kGains];
0034       TH1F** endcap_m = new TH1F*[kGains];
0035       TH1F** barrel_r = new TH1F*[kGains];
0036       TH1F** endcap_r = new TH1F*[kGains];
0037       float bmin[kGains] = {0.7, 0.5, 0.4};
0038       float bmax[kGains] = {2.2, 1.3, 0.7};
0039       float emin[kGains] = {1.5, 0.8, 0.4};
0040       float emax[kGains] = {2.5, 1.5, 0.8};
0041       for (int gainId = 0; gainId < kGains; gainId++) {
0042         barrel_m[gainId] = new TH1F(Form("EBm%i", gainId), Form("mean %i EB", gainValues[gainId]), 100, 150., 250.);
0043         endcap_m[gainId] = new TH1F(Form("EEm%i", gainId), Form("mean %i EE", gainValues[gainId]), 100, 150., 250.);
0044         barrel_r[gainId] =
0045             new TH1F(Form("EBr%i", gainId), Form("rms %i EB", gainValues[gainId]), 100, bmin[gainId], bmax[gainId]);
0046         endcap_r[gainId] =
0047             new TH1F(Form("EEr%i", gainId), Form("rms %i EE", gainValues[gainId]), 100, emin[gainId], emax[gainId]);
0048       }
0049       auto iov = iovs.front();
0050       std::shared_ptr<EcalPedestals> payload = fetchPayload(std::get<1>(iov));
0051       unsigned int run = std::get<0>(iov);
0052       if (payload.get()) {
0053         // looping over the EB channels, via the dense-index, mapped into EBDetId's
0054         if (payload->barrelItems().empty())
0055           return false;
0056         for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0057           uint32_t rawid = EBDetId::unhashIndex(cellid);
0058           if (payload->find(rawid) == payload->end())
0059             continue;
0060           barrel_m[0]->Fill((*payload)[rawid].mean_x12);
0061           barrel_r[0]->Fill((*payload)[rawid].rms_x12);
0062           barrel_m[1]->Fill((*payload)[rawid].mean_x6);
0063           barrel_r[1]->Fill((*payload)[rawid].rms_x6);
0064           barrel_m[2]->Fill((*payload)[rawid].mean_x1);
0065           barrel_r[2]->Fill((*payload)[rawid].rms_x1);
0066         }  // loop over cellid
0067         if (payload->endcapItems().empty())
0068           return false;
0069 
0070         // looping over the EE channels
0071         for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
0072           for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
0073             for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
0074               if (EEDetId::validDetId(ix, iy, iz)) {
0075                 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
0076                 uint32_t rawid = myEEId.rawId();
0077                 if (payload->find(rawid) == payload->end())
0078                   continue;
0079                 endcap_m[0]->Fill((*payload)[rawid].mean_x12);
0080                 endcap_r[0]->Fill((*payload)[rawid].rms_x12);
0081                 endcap_m[1]->Fill((*payload)[rawid].mean_x6);
0082                 endcap_r[1]->Fill((*payload)[rawid].rms_x6);
0083                 endcap_m[2]->Fill((*payload)[rawid].mean_x1);
0084                 endcap_r[2]->Fill((*payload)[rawid].rms_x1);
0085               }  // validDetId
0086       }          // if payload.get()
0087       else
0088         return false;
0089 
0090       gStyle->SetPalette(1);
0091       gStyle->SetOptStat(111110);
0092       TCanvas canvas("CC map", "CC map", 1600, 2600);
0093       TLatex t1;
0094       t1.SetNDC();
0095       t1.SetTextAlign(26);
0096       t1.SetTextSize(0.05);
0097       t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i", run));
0098 
0099       float xmi[2] = {0.0, 0.50};
0100       float xma[2] = {0.50, 1.00};
0101       TPad*** pad = new TPad**[6];
0102       for (int gId = 0; gId < 6; gId++) {
0103         pad[gId] = new TPad*[2];
0104         for (int obj = 0; obj < 2; obj++) {
0105           //      float yma = 1.- (0.17 * gId);
0106           //      float ymi = yma - 0.15;
0107           float yma = 0.94 - (0.16 * gId);
0108           float ymi = yma - 0.14;
0109           pad[gId][obj] = new TPad(Form("p_%i_%i", obj, gId), Form("p_%i_%i", obj, gId), xmi[obj], ymi, xma[obj], yma);
0110           pad[gId][obj]->Draw();
0111         }
0112       }
0113       for (int gId = 0; gId < kGains; gId++) {
0114         pad[gId][0]->cd();
0115         barrel_m[gId]->Draw();
0116         pad[gId + kGains][0]->cd();
0117         barrel_r[gId]->Draw();
0118         pad[gId][1]->cd();
0119         endcap_m[gId]->Draw();
0120         pad[gId + kGains][1]->cd();
0121         endcap_r[gId]->Draw();
0122       }
0123 
0124       std::string ImageName(m_imageFileName);
0125       canvas.SaveAs(ImageName.c_str());
0126       return true;
0127     }  // fill method
0128   };   //   class EcalPedestalsHist
0129 
0130   /**************************************
0131      2d plot of ECAL pedestal of 1 IOV
0132   ***************************************/
0133 
0134   class EcalPedestalsPlot : public cond::payloadInspector::PlotImage<EcalPedestals> {
0135   public:
0136     EcalPedestalsPlot() : cond::payloadInspector::PlotImage<EcalPedestals>("ECAL pedestal map") { setSingleIov(true); }
0137     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0138       uint32_t gainValues[kGains] = {12, 6, 1};
0139       TH2F** barrel_m = new TH2F*[kGains];
0140       TH2F** endc_p_m = new TH2F*[kGains];
0141       TH2F** endc_m_m = new TH2F*[kGains];
0142       TH2F** barrel_r = new TH2F*[kGains];
0143       TH2F** endc_p_r = new TH2F*[kGains];
0144       TH2F** endc_m_r = new TH2F*[kGains];
0145       double EBmean[kGains], EBrms[kGains], EEmean[kGains], EErms[kGains], pEBmin[kGains], pEBmax[kGains],
0146           pEEmin[kGains], pEEmax[kGains];
0147       int EBtot[kGains], EEtot[kGains];
0148       for (int gId = 0; gId < kGains; gId++) {
0149         barrel_m[gId] = new TH2F(Form("EBm%i", gId),
0150                                  Form("mean %i EB", gainValues[gId]),
0151                                  MAX_IPHI,
0152                                  0,
0153                                  MAX_IPHI,
0154                                  2 * MAX_IETA,
0155                                  -MAX_IETA,
0156                                  MAX_IETA);
0157         endc_p_m[gId] = new TH2F(Form("EE+m%i", gId),
0158                                  Form("mean %i EE+", gainValues[gId]),
0159                                  IX_MAX,
0160                                  IX_MIN,
0161                                  IX_MAX + 1,
0162                                  IY_MAX,
0163                                  IY_MIN,
0164                                  IY_MAX + 1);
0165         endc_m_m[gId] = new TH2F(Form("EE-m%i", gId),
0166                                  Form("mean %i EE-", gainValues[gId]),
0167                                  IX_MAX,
0168                                  IX_MIN,
0169                                  IX_MAX + 1,
0170                                  IY_MAX,
0171                                  IY_MIN,
0172                                  IY_MAX + 1);
0173         barrel_r[gId] = new TH2F(Form("EBr%i", gId),
0174                                  Form("rms %i EB", gainValues[gId]),
0175                                  MAX_IPHI,
0176                                  0,
0177                                  MAX_IPHI,
0178                                  2 * MAX_IETA,
0179                                  -MAX_IETA,
0180                                  MAX_IETA);
0181         endc_p_r[gId] = new TH2F(Form("EE+r%i", gId),
0182                                  Form("rms %i EE+", gainValues[gId]),
0183                                  IX_MAX,
0184                                  IX_MIN,
0185                                  IX_MAX + 1,
0186                                  IY_MAX,
0187                                  IY_MIN,
0188                                  IY_MAX + 1);
0189         endc_m_r[gId] = new TH2F(Form("EE-r%i", gId),
0190                                  Form("rms %i EE-", gainValues[gId]),
0191                                  IX_MAX,
0192                                  IX_MIN,
0193                                  IX_MAX + 1,
0194                                  IY_MAX,
0195                                  IY_MIN,
0196                                  IY_MAX + 1);
0197         EBmean[gId] = 0.;
0198         EBrms[gId] = 0.;
0199         EEmean[gId] = 0.;
0200         EErms[gId] = 0.;
0201         EBtot[gId] = 0;
0202         EEtot[gId] = 0;
0203       }
0204       auto iov = iovs.front();
0205       std::shared_ptr<EcalPedestals> payload = fetchPayload(std::get<1>(iov));
0206       unsigned int run = std::get<0>(iov);
0207       if (payload.get()) {
0208         // looping over the EB channels, via the dense-index, mapped into EBDetId's
0209         if (payload->barrelItems().empty())
0210           return false;
0211         for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {  // loop on EE cells
0212           uint32_t rawid = EBDetId::unhashIndex(cellid);
0213           if (payload->find(rawid) == payload->end())
0214             continue;
0215           Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
0216           Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
0217           if (eta > 0.)
0218             eta = eta - 0.5;  //   0.5 to 84.5
0219           else
0220             eta = eta + 0.5;  //  -84.5 to -0.5
0221           barrel_m[0]->Fill(phi, eta, (*payload)[rawid].mean_x12);
0222           Double_t val = (*payload)[rawid].rms_x12;
0223           barrel_r[0]->Fill(phi, eta, val);
0224           if (val < 10) {
0225             EBmean[0] = EBmean[0] + val;
0226             EBrms[0] = EBrms[0] + val * val;
0227             EBtot[0]++;
0228           }
0229           //      else std::cout << " gain 12 chan " << cellid << " val " << val << std::endl;
0230           barrel_m[1]->Fill(phi, eta, (*payload)[rawid].mean_x6);
0231           val = (*payload)[rawid].rms_x6;
0232           barrel_r[1]->Fill(phi, eta, val);
0233           if (val < 10) {
0234             EBmean[1] = EBmean[1] + val;
0235             EBrms[1] = EBrms[1] + val * val;
0236             EBtot[1]++;
0237           }
0238           //      else std::cout << " gain 6 chan " << cellid << " val " << val << std::endl;
0239           barrel_m[2]->Fill(phi, eta, (*payload)[rawid].mean_x1);
0240           val = (*payload)[rawid].rms_x1;
0241           barrel_r[2]->Fill(phi, eta, val);
0242           if (val < 10) {
0243             EBmean[2] = EBmean[2] + val;
0244             EBrms[2] = EBrms[2] + val * val;
0245             EBtot[2]++;
0246           }
0247           //      else std::cout << " gain 1 chan " << cellid << " val " << val << std::endl;
0248         }  // loop over cellid
0249         if (payload->endcapItems().empty())
0250           return false;
0251 
0252         // looping over the EE channels
0253         for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
0254           for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
0255             for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
0256               if (EEDetId::validDetId(ix, iy, iz)) {
0257                 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
0258                 uint32_t rawid = myEEId.rawId();
0259                 if (payload->find(rawid) == payload->end())
0260                   continue;
0261                 if (iz == 1) {
0262                   endc_p_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12);
0263                   Double_t val = (*payload)[rawid].rms_x12;
0264                   endc_p_r[0]->Fill(ix, iy, val);
0265                   if (val < 10) {
0266                     EEmean[0] = EEmean[0] + val;
0267                     EErms[0] = EErms[0] + val * val;
0268                     EEtot[0]++;
0269                   }
0270                   endc_p_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6);
0271                   val = (*payload)[rawid].rms_x6;
0272                   endc_p_r[1]->Fill(ix, iy, val);
0273                   if (val < 10) {
0274                     EEmean[1] = EEmean[1] + val;
0275                     EErms[1] = EErms[1] + val * val;
0276                     EEtot[1]++;
0277                   }
0278                   endc_p_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1);
0279                   val = (*payload)[rawid].rms_x1;
0280                   endc_p_r[2]->Fill(ix, iy, val);
0281                   if (val < 10) {
0282                     EEmean[2] = EEmean[2] + val;
0283                     EErms[2] = EErms[2] + val * val;
0284                     EEtot[2]++;
0285                   }
0286                 } else {
0287                   endc_m_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12);
0288                   Double_t val = (*payload)[rawid].rms_x12;
0289                   endc_m_r[0]->Fill(ix, iy, val);
0290                   if (val < 10) {
0291                     EEmean[0] = EEmean[0] + val;
0292                     EErms[0] = EErms[0] + val * val;
0293                     EEtot[0]++;
0294                   }
0295                   endc_m_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6);
0296                   val = (*payload)[rawid].rms_x6;
0297                   endc_m_r[1]->Fill(ix, iy, val);
0298                   if (val < 10) {
0299                     EEmean[1] = EEmean[1] + val;
0300                     EErms[1] = EErms[1] + val * val;
0301                     EEtot[1]++;
0302                   }
0303                   endc_m_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1);
0304                   val = (*payload)[rawid].rms_x1;
0305                   endc_m_r[2]->Fill(ix, iy, val);
0306                   if (val < 10) {
0307                     EEmean[2] = EEmean[2] + val;
0308                     EErms[2] = EErms[2] + val * val;
0309                     EEtot[2]++;
0310                   }
0311                 }
0312               }  // validDetId
0313       }          // if payload.get()
0314       else
0315         return false;
0316 
0317       gStyle->SetPalette(1);
0318       gStyle->SetOptStat(0);
0319       TCanvas canvas("CC map", "CC map", 1600, 2600);
0320       TLatex t1;
0321       t1.SetNDC();
0322       t1.SetTextAlign(26);
0323       t1.SetTextSize(0.05);
0324       t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i", run));
0325 
0326       float xmi[3] = {0.0, 0.24, 0.76};
0327       float xma[3] = {0.24, 0.76, 1.00};
0328       TPad*** pad = new TPad**[6];
0329       int view = 0;
0330       for (int gId = 0; gId < kGains; gId++) {
0331         for (int val = 0; val < 2; val++) {  //  mean and sigma
0332           pad[view] = new TPad*[3];
0333           for (int obj = 0; obj < 3; obj++) {
0334             float yma = 0.94 - (0.16 * view);
0335             float ymi = yma - 0.14;
0336             pad[view][obj] =
0337                 new TPad(Form("p_%i_%i", obj, view), Form("p_%i_%i", obj, view), xmi[obj], ymi, xma[obj], yma);
0338             pad[view][obj]->Draw();
0339           }
0340           view++;
0341         }
0342         double vt = (double)EBtot[gId];
0343         EBmean[gId] = EBmean[gId] / vt;
0344         EBrms[gId] = (EBrms[gId] / vt) - (EBmean[gId] * EBmean[gId]);
0345         EBrms[gId] = sqrt(EBrms[gId]);
0346         if (EBrms[gId] == 0.)
0347           EBrms[gId] = 0.001;
0348         pEBmin[gId] = EBmean[gId] - kRMS * EBrms[gId];
0349         pEBmax[gId] = EBmean[gId] + kRMS * EBrms[gId];
0350         //  std::cout << " mean " << EBmean[gId] << " rms " << EBrms[gId] << " entries " << EBtot[gId] << " min " << pEBmin[gId]
0351         //        << " max " << pEBmax[gId] << std::endl;
0352         if (pEBmin[gId] < 0.)
0353           pEBmin[gId] = 0.;
0354         vt = (double)EEtot[gId];
0355         EEmean[gId] = EEmean[gId] / vt;
0356         EErms[gId] = (EErms[gId] / vt) - (EEmean[gId] * EEmean[gId]);
0357         EErms[gId] = sqrt(EErms[gId]);
0358         if (EErms[gId] == 0.)
0359           EErms[gId] = 0.001;
0360         pEEmin[gId] = EEmean[gId] - kRMS * EErms[gId];
0361         pEEmax[gId] = EEmean[gId] + kRMS * EErms[gId];
0362         //  std::cout << " mean " << EEmean[gId] << " rms " << EErms[gId] << " entries " << EEtot[gId] << " min " << pEEmin[gId]
0363         //        << " max " << pEEmax[gId] << std::endl;
0364         if (pEEmin[gId] < 0.)
0365           pEEmin[gId] = 0.;
0366       }
0367       //float bmin[kGains] ={0.7, 0.5, 0.4};
0368       //float bmax[kGains] ={2.2, 1.3, 0.7};
0369       //float emin[kGains] ={1.5, 0.8, 0.4};
0370       //float emax[kGains] ={2.5, 1.5, 0.8};
0371       //      TLine* l = new TLine(0., 0., 0., 0.);
0372       //      l->SetLineWidth(1);
0373       for (int gId = 0; gId < kGains; gId++) {
0374         pad[gId][0]->cd();
0375         DrawEE(endc_m_m[gId], 175., 225.);
0376         pad[gId + kGains][0]->cd();
0377         DrawEE(endc_m_r[gId], pEEmin[gId], pEEmax[gId]);
0378         pad[gId][1]->cd();
0379         DrawEB(barrel_m[gId], 175., 225.);
0380         pad[gId + kGains][1]->cd();
0381         DrawEB(barrel_r[gId], pEBmin[gId], pEBmax[gId]);
0382         pad[gId][2]->cd();
0383         DrawEE(endc_p_m[gId], 175., 225.);
0384         pad[gId + kGains][2]->cd();
0385         DrawEE(endc_p_r[gId], pEEmin[gId], pEEmax[gId]);
0386       }
0387 
0388       std::string ImageName(m_imageFileName);
0389       canvas.SaveAs(ImageName.c_str());
0390       return true;
0391     }  // fill method
0392 
0393   };  // class EcalPedestalsPlot
0394 
0395   /*****************************************************************
0396      2d plot of ECAL pedestals difference or ratio between 2 IOVs
0397   ******************************************************************/
0398   template <cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, int method>
0399   class EcalPedestalsBase : public cond::payloadInspector::PlotImage<EcalPedestals, nIOVs, ntags> {
0400   public:
0401     EcalPedestalsBase() : cond::payloadInspector::PlotImage<EcalPedestals, nIOVs, ntags>("ECAL pedestals comparison") {}
0402     bool fill() override {
0403       uint32_t gainValues[kGains] = {12, 6, 1};
0404       TH2F** barrel_m = new TH2F*[kGains];
0405       TH2F** endc_p_m = new TH2F*[kGains];
0406       TH2F** endc_m_m = new TH2F*[kGains];
0407       TH2F** barrel_r = new TH2F*[kGains];
0408       TH2F** endc_p_r = new TH2F*[kGains];
0409       TH2F** endc_m_r = new TH2F*[kGains];
0410       double EBmean[kGains], EBrms[kGains], EEmean[kGains], EErms[kGains], pEBmin[kGains], pEBmax[kGains],
0411           pEEmin[kGains], pEEmax[kGains];
0412       int EBtot[kGains], EEtot[kGains];
0413       for (int gId = 0; gId < kGains; gId++) {
0414         barrel_m[gId] = new TH2F(Form("EBm%i", gId),
0415                                  Form("mean %i EB", gainValues[gId]),
0416                                  MAX_IPHI,
0417                                  0,
0418                                  MAX_IPHI,
0419                                  2 * MAX_IETA,
0420                                  -MAX_IETA,
0421                                  MAX_IETA);
0422         endc_p_m[gId] = new TH2F(Form("EE+m%i", gId),
0423                                  Form("mean %i EE+", gainValues[gId]),
0424                                  IX_MAX,
0425                                  IX_MIN,
0426                                  IX_MAX + 1,
0427                                  IY_MAX,
0428                                  IY_MIN,
0429                                  IY_MAX + 1);
0430         endc_m_m[gId] = new TH2F(Form("EE-m%i", gId),
0431                                  Form("mean %i EE-", gainValues[gId]),
0432                                  IX_MAX,
0433                                  IX_MIN,
0434                                  IX_MAX + 1,
0435                                  IY_MAX,
0436                                  IY_MIN,
0437                                  IY_MAX + 1);
0438         barrel_r[gId] = new TH2F(Form("EBr%i", gId),
0439                                  Form("rms %i EB", gainValues[gId]),
0440                                  MAX_IPHI,
0441                                  0,
0442                                  MAX_IPHI,
0443                                  2 * MAX_IETA,
0444                                  -MAX_IETA,
0445                                  MAX_IETA);
0446         endc_p_r[gId] = new TH2F(Form("EE+r%i", gId),
0447                                  Form("rms %i EE+", gainValues[gId]),
0448                                  IX_MAX,
0449                                  IX_MIN,
0450                                  IX_MAX + 1,
0451                                  IY_MAX,
0452                                  IY_MIN,
0453                                  IY_MAX + 1);
0454         endc_m_r[gId] = new TH2F(Form("EE-r%i", gId),
0455                                  Form("rms %i EE-", gainValues[gId]),
0456                                  IX_MAX,
0457                                  IX_MIN,
0458                                  IX_MAX + 1,
0459                                  IY_MAX,
0460                                  IY_MIN,
0461                                  IY_MAX + 1);
0462         EBmean[gId] = 0.;
0463         EBrms[gId] = 0.;
0464         EEmean[gId] = 0.;
0465         EErms[gId] = 0.;
0466         EBtot[gId] = 0;
0467         EEtot[gId] = 0;
0468       }
0469       unsigned int run[2] = {0, 0};
0470       std::string l_tagname[2];
0471       double meanEB[kGains][kEBChannels], rmsEB[kGains][kEBChannels], meanEE[kGains][kEEChannels],
0472           rmsEE[kGains][kEEChannels];
0473 
0474       //     std::cout << " running with " << nIOVs << " IOVs and " << ntags << " tags " << std::endl;
0475       auto iovs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
0476       l_tagname[0] = cond::payloadInspector::PlotBase::getTag<0>().name;
0477       auto firstiov = iovs.front();
0478       run[0] = std::get<0>(firstiov);
0479       std::tuple<cond::Time_t, cond::Hash> lastiov;
0480       if (ntags == 2) {
0481         auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
0482         l_tagname[1] = cond::payloadInspector::PlotBase::getTag<1>().name;
0483         lastiov = tag2iovs.front();
0484       } else {
0485         lastiov = iovs.back();
0486         l_tagname[1] = l_tagname[0];
0487       }
0488       run[1] = std::get<0>(lastiov);
0489       for (int irun = 0; irun < nIOVs; irun++) {
0490         std::shared_ptr<EcalPedestals> payload;
0491         if (irun == 0) {
0492           payload = this->fetchPayload(std::get<1>(firstiov));
0493         } else {
0494           payload = this->fetchPayload(std::get<1>(lastiov));
0495         }
0496         //  std::cout << " irun " << irun << " tag " << l_tagname[irun] << " IOV " << run[irun] << std ::endl;
0497         if (payload.get()) {
0498           if (!payload->barrelItems().empty()) {
0499             for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0500               uint32_t rawid = EBDetId::unhashIndex(cellid);
0501               if (payload->find(rawid) == payload->end())
0502                 continue;
0503 
0504               if (irun == 0) {
0505                 meanEB[0][cellid] = (*payload)[rawid].mean_x12;
0506                 rmsEB[0][cellid] = (*payload)[rawid].rms_x12;
0507                 meanEB[1][cellid] = (*payload)[rawid].mean_x6;
0508                 rmsEB[1][cellid] = (*payload)[rawid].rms_x6;
0509                 meanEB[2][cellid] = (*payload)[rawid].mean_x1;
0510                 rmsEB[2][cellid] = (*payload)[rawid].rms_x1;
0511               } else {
0512                 Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
0513                 Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
0514                 if (eta > 0.)
0515                   eta = eta - 0.5;  //   0.5 to 84.5
0516                 else
0517                   eta = eta + 0.5;  //  -84.5 to -0.5
0518                 double dr, drms;
0519                 //  gain 12
0520                 float val = (*payload)[rawid].mean_x12;
0521                 float valr = (*payload)[rawid].rms_x12;
0522                 if (method == 0) {
0523                   dr = val - meanEB[0][cellid];
0524                   drms = valr - rmsEB[0][cellid];
0525                 } else {  // ratio
0526                   if (meanEB[0][cellid] == 0) {
0527                     if (val == 0.)
0528                       dr = 1.;
0529                     else
0530                       dr = 9999.;  // use a large value
0531                   } else
0532                     dr = val / meanEB[0][cellid];
0533                   if (rmsEB[0][cellid] == 0) {
0534                     if (valr == 0.)
0535                       drms = 1.;
0536                     else
0537                       drms = 9999.;  // use a large value
0538                   } else
0539                     drms = valr / rmsEB[0][cellid];
0540                 }
0541                 barrel_m[0]->Fill(phi, eta, dr);
0542                 barrel_r[0]->Fill(phi, eta, drms);
0543                 if (std::abs(drms) < 1.) {
0544                   EBmean[0] = EBmean[0] + drms;
0545                   EBrms[0] = EBrms[0] + drms * drms;
0546                   EBtot[0]++;
0547                 }
0548                 //  gain 6
0549                 val = (*payload)[rawid].mean_x6;
0550                 valr = (*payload)[rawid].rms_x6;
0551                 if (method == 0) {
0552                   dr = val - meanEB[1][cellid];
0553                   drms = valr - rmsEB[1][cellid];
0554                 } else {  // ratio
0555                   if (meanEB[1][cellid] == 0) {
0556                     if (val == 0.)
0557                       dr = 1.;
0558                     else
0559                       dr = 9999.;  // use a large value
0560                   } else
0561                     dr = val / meanEB[1][cellid];
0562                   if (rmsEB[1][cellid] == 0) {
0563                     if (valr == 0.)
0564                       drms = 1.;
0565                     else
0566                       drms = 9999.;  // use a large value
0567                   } else
0568                     drms = valr / rmsEB[1][cellid];
0569                 }
0570                 barrel_m[1]->Fill(phi, eta, dr);
0571                 barrel_r[1]->Fill(phi, eta, drms);
0572                 if (std::abs(drms) < 1.) {
0573                   EBmean[1] = EBmean[1] + drms;
0574                   EBrms[1] = EBrms[1] + drms * drms;
0575                   EBtot[1]++;
0576                 }
0577                 //  gain 1
0578                 val = (*payload)[rawid].mean_x1;
0579                 valr = (*payload)[rawid].rms_x1;
0580                 if (method == 0) {
0581                   dr = val - meanEB[2][cellid];
0582                   drms = valr - rmsEB[2][cellid];
0583                 } else {  // ratio
0584                   if (meanEB[2][cellid] == 0) {
0585                     if (val == 0.)
0586                       dr = 1.;
0587                     else
0588                       dr = 9999.;  // use a large value
0589                   } else
0590                     dr = val / meanEB[2][cellid];
0591                   if (rmsEB[2][cellid] == 0) {
0592                     if (valr == 0.)
0593                       drms = 1.;
0594                     else
0595                       drms = 9999.;  // use a large value
0596                   } else
0597                     drms = valr / rmsEB[2][cellid];
0598                 }
0599                 barrel_m[2]->Fill(phi, eta, dr);
0600                 barrel_r[2]->Fill(phi, eta, drms);
0601                 if (std::abs(drms) < 1.) {
0602                   EBmean[2] = EBmean[2] + drms;
0603                   EBrms[2] = EBrms[2] + drms * drms;
0604                   EBtot[2]++;
0605                 }
0606               }
0607             }  // loop over cellid
0608           }    //  barrel data present
0609           if (payload->endcapItems().empty()) {
0610             // looping over the EE channels
0611             for (int iz = -1; iz < 2; iz = iz + 2) {  // -1 or +1
0612               for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++) {
0613                 for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++) {
0614                   if (EEDetId::validDetId(ix, iy, iz)) {
0615                     EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
0616                     uint32_t rawid = myEEId.rawId();
0617                     uint32_t index = myEEId.hashedIndex();
0618                     if (payload->find(rawid) == payload->end())
0619                       continue;
0620                     if (irun == 0) {
0621                       meanEE[0][index] = (*payload)[rawid].mean_x12;
0622                       rmsEE[0][index] = (*payload)[rawid].rms_x12;
0623                       meanEE[1][index] = (*payload)[rawid].mean_x6;
0624                       rmsEE[1][index] = (*payload)[rawid].rms_x6;
0625                       meanEE[2][index] = (*payload)[rawid].mean_x1;
0626                       rmsEE[2][index] = (*payload)[rawid].rms_x1;
0627                     }  // fist run
0628                     else {
0629                       double dr, drms;
0630                       //  gain 12
0631                       float val = (*payload)[rawid].mean_x12;
0632                       float valr = (*payload)[rawid].rms_x12;
0633                       if (method == 0) {
0634                         dr = val - meanEE[0][index];
0635                         drms = valr - rmsEE[0][index];
0636                       } else {  // ratio
0637                         if (meanEE[0][index] == 0) {
0638                           if (val == 0.)
0639                             dr = 1.;
0640                           else
0641                             dr = 9999.;  // use a large value
0642                         } else
0643                           dr = val / meanEE[0][index];
0644                         if (rmsEE[0][index] == 0) {
0645                           if (valr == 0.)
0646                             drms = 1.;
0647                           else
0648                             drms = 9999.;  // use a large value
0649                         } else
0650                           drms = valr / rmsEE[0][index];
0651                       }
0652                       if (iz == 1) {  // EE+
0653                         endc_p_m[0]->Fill(ix, iy, dr);
0654                         endc_p_r[0]->Fill(ix, iy, drms);
0655                       } else {  // EE-
0656                         endc_m_m[0]->Fill(ix, iy, dr);
0657                         endc_m_r[0]->Fill(ix, iy, drms);
0658                       }
0659                       if (std::abs(drms) < 1.) {
0660                         EEmean[0] = EEmean[0] + drms;
0661                         EErms[0] = EErms[0] + drms * drms;
0662                         EEtot[0]++;
0663                       }
0664                       //  gain 6
0665                       val = (*payload)[rawid].mean_x6;
0666                       valr = (*payload)[rawid].rms_x6;
0667                       if (method == 0) {
0668                         dr = val - meanEE[1][index];
0669                         drms = valr - rmsEE[1][index];
0670                       } else {  // ratio
0671                         if (meanEE[1][index] == 0) {
0672                           if (val == 0.)
0673                             dr = 1.;
0674                           else
0675                             dr = 9999.;  // use a large value
0676                         } else
0677                           dr = val / meanEE[1][index];
0678                         if (rmsEE[1][index] == 0) {
0679                           if (valr == 0.)
0680                             drms = 1.;
0681                           else
0682                             drms = 9999.;  // use a large value
0683                         } else
0684                           drms = valr / rmsEE[1][index];
0685                       }
0686                       if (iz == 1) {  // EE+
0687                         endc_p_m[1]->Fill(ix, iy, dr);
0688                         endc_p_r[1]->Fill(ix, iy, drms);
0689                       } else {  // EE-
0690                         endc_m_m[1]->Fill(ix, iy, dr);
0691                         endc_m_r[1]->Fill(ix, iy, drms);
0692                       }
0693                       if (std::abs(drms) < 1.) {
0694                         EEmean[1] = EEmean[1] + drms;
0695                         EErms[1] = EErms[1] + drms * drms;
0696                         EEtot[1]++;
0697                       }
0698                       //  gain 1
0699                       val = (*payload)[rawid].mean_x1;
0700                       valr = (*payload)[rawid].rms_x1;
0701                       if (method == 0) {
0702                         dr = val - meanEE[2][index];
0703                         drms = valr - rmsEE[2][index];
0704                       } else {  // ratio
0705                         if (meanEE[2][index] == 0) {
0706                           if (val == 0.)
0707                             dr = 1.;
0708                           else
0709                             dr = 9999.;  // use a large value
0710                         } else
0711                           dr = val / meanEE[2][index];
0712                         if (rmsEE[2][index] == 0) {
0713                           if (valr == 0.)
0714                             drms = 1.;
0715                           else
0716                             drms = 9999.;  // use a large value
0717                         } else
0718                           drms = valr / rmsEE[2][index];
0719                       }
0720                       if (iz == 1) {  // EE+
0721                         endc_p_m[2]->Fill(ix, iy, dr);
0722                         endc_p_r[2]->Fill(ix, iy, drms);
0723                       } else {  // EE-
0724                         endc_m_m[2]->Fill(ix, iy, dr);
0725                         endc_m_r[2]->Fill(ix, iy, drms);
0726                       }
0727                       if (std::abs(drms) < 1.) {
0728                         EEmean[2] = EEmean[2] + drms;
0729                         EErms[2] = EErms[2] + drms * drms;
0730                         EEtot[2]++;
0731                       }
0732                     }  // second run
0733                   }    // validDetId
0734                 }      //   loop over ix
0735               }        //  loop over iy
0736             }          //  loop over iz
0737           }            //  endcap data present
0738         }              //  if payload.get()
0739         else
0740           return false;
0741       }  // loop over IOVs
0742 
0743       gStyle->SetPalette(1);
0744       gStyle->SetOptStat(0);
0745       TCanvas canvas("CC map", "CC map", 1600, 2600);
0746       TLatex t1;
0747       t1.SetNDC();
0748       t1.SetTextAlign(26);
0749       int len = l_tagname[0].length() + l_tagname[1].length();
0750       std::string dr[2] = {"-", "/"};
0751       if (ntags == 2) {
0752         if (len < 58) {
0753           t1.SetTextSize(0.025);
0754           t1.DrawLatex(0.5,
0755                        0.96,
0756                        Form("%s IOV %i %s %s  IOV %i",
0757                             l_tagname[1].c_str(),
0758                             run[1],
0759                             dr[method].c_str(),
0760                             l_tagname[0].c_str(),
0761                             run[0]));
0762         } else {
0763           t1.SetTextSize(0.05);
0764           t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i %s %i", run[1], dr[method].c_str(), run[0]));
0765         }
0766       } else {
0767         t1.SetTextSize(0.05);
0768         t1.DrawLatex(0.5, 0.96, Form("%s, IOV %i %s %i", l_tagname[0].c_str(), run[1], dr[method].c_str(), run[0]));
0769       }
0770       float xmi[3] = {0.0, 0.24, 0.76};
0771       float xma[3] = {0.24, 0.76, 1.00};
0772       TPad*** pad = new TPad**[6];
0773       int view = 0;
0774       for (int gId = 0; gId < kGains; gId++) {
0775         for (int val = 0; val < 2; val++) {  //  mean and sigma
0776           pad[view] = new TPad*[3];
0777           for (int obj = 0; obj < 3; obj++) {
0778             float yma = 0.94 - (0.16 * view);
0779             float ymi = yma - 0.14;
0780             pad[view][obj] =
0781                 new TPad(Form("p_%i_%i", obj, view), Form("p_%i_%i", obj, view), xmi[obj], ymi, xma[obj], yma);
0782             pad[view][obj]->Draw();
0783           }
0784           view++;
0785         }
0786         double vt = (double)EBtot[gId];
0787         EBmean[gId] = EBmean[gId] / vt;
0788         EBrms[gId] = (EBrms[gId] / vt) - (EBmean[gId] * EBmean[gId]);
0789         EBrms[gId] = sqrt(EBrms[gId]);
0790         if (EBrms[gId] == 0.)
0791           EBrms[gId] = 0.001;
0792         pEBmin[gId] = EBmean[gId] - kRMS * EBrms[gId];
0793         pEBmax[gId] = EBmean[gId] + kRMS * EBrms[gId];
0794         //  std::cout << " mean " << EBmean[gId] << " rms " << EBrms[gId] << " entries " << EBtot[gId] << " min " << pEBmin[gId]
0795         //        << " max " << pEBmax[gId] << std::endl;
0796         vt = (double)EEtot[gId];
0797         EEmean[gId] = EEmean[gId] / vt;
0798         EErms[gId] = (EErms[gId] / vt) - (EEmean[gId] * EEmean[gId]);
0799         EErms[gId] = sqrt(EErms[gId]);
0800         if (EErms[gId] == 0.)
0801           EErms[gId] = 0.001;
0802         pEEmin[gId] = EEmean[gId] - kRMS * EErms[gId];
0803         pEEmax[gId] = EEmean[gId] + kRMS * EErms[gId];
0804         //  std::cout << " mean " << EEmean[gId] << " rms " << EErms[gId] << " entries " << EEtot[gId] << " min " << pEEmin[gId]
0805         //        << " max " << pEEmax[gId] << std::endl;
0806       }
0807       for (int gId = 0; gId < kGains; gId++) {
0808         pad[gId][0]->cd();
0809         DrawEE(endc_m_m[gId], -2., 2.);
0810         pad[gId + kGains][0]->cd();
0811         DrawEE(endc_m_r[gId], pEEmin[gId], pEEmax[gId]);
0812         pad[gId][1]->cd();
0813         DrawEB(barrel_m[gId], -2., 2.);
0814         pad[gId + kGains][1]->cd();
0815         DrawEB(barrel_r[gId], pEBmin[gId], pEBmax[gId]);
0816         pad[gId][2]->cd();
0817         DrawEE(endc_p_m[gId], -2., 2.);
0818         pad[gId + kGains][2]->cd();
0819         DrawEE(endc_p_r[gId], pEEmin[gId], pEEmax[gId]);
0820       }
0821 
0822       std::string ImageName(this->m_imageFileName);
0823       canvas.SaveAs(ImageName.c_str());
0824       return true;
0825     }  // fill method
0826   };   // class EcalPedestalsBase
0827   using EcalPedestalsDiffOneTag = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 0>;
0828   using EcalPedestalsDiffTwoTags = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 2, 0>;
0829   using EcalPedestalsRatioOneTag = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 1>;
0830   using EcalPedestalsRatioTwoTags = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 2, 1>;
0831 
0832   /*************************************************  
0833      2d histogram of ECAL barrel pedestal of 1 IOV 
0834   *************************************************/
0835 
0836   // inherit from one of the predefined plot class: Histogram2D
0837   class EcalPedestalsEBMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
0838   public:
0839     EcalPedestalsEBMean12Map()
0840         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain12 - map",
0841                                                              "iphi",
0842                                                              MAX_IPHI,
0843                                                              MIN_IPHI,
0844                                                              MAX_IPHI + MIN_IPHI,
0845                                                              "ieta",
0846                                                              2 * MAX_IETA + 1,
0847                                                              -1 * MAX_IETA,
0848                                                              MAX_IETA + 1) {
0849       Base::setSingleIov(true);
0850     }
0851 
0852     // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
0853     bool fill() override {
0854       auto tag = PlotBase::getTag<0>();
0855       for (auto const& iov : tag.iovs) {
0856         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
0857         if (payload.get()) {
0858           // looping over the EB channels, via the dense-index, mapped into EBDetId's
0859           if (payload->barrelItems().empty())
0860             return false;
0861           for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0862             uint32_t rawid = EBDetId::unhashIndex(cellid);
0863 
0864             // check the existence of ECAL pedestal, for a given ECAL barrel channel
0865             if (payload->find(rawid) == payload->end())
0866               continue;
0867             if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
0868               continue;
0869 
0870             // there's no ieta==0 in the EB numbering
0871             //      int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
0872             // fill the Histogram2D here
0873             //      fillWithValue(  (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
0874             // set min and max on 2d plots
0875             float valped = (*payload)[rawid].mean_x12;
0876             if (valped > 250.)
0877               valped = 250.;
0878             //      if(valped < 150.) valped = 150.;
0879             fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
0880           }  // loop over cellid
0881         }    // if payload.get()
0882       }      // loop over IOV's (1 in this case)
0883       return true;
0884     }  // fill method
0885   };
0886 
0887   class EcalPedestalsEBMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
0888   public:
0889     EcalPedestalsEBMean6Map()
0890         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain6 - map",
0891                                                              "iphi",
0892                                                              MAX_IPHI,
0893                                                              MIN_IPHI,
0894                                                              MAX_IPHI + MIN_IPHI,
0895                                                              "ieta",
0896                                                              2 * MAX_IETA + 1,
0897                                                              -MAX_IETA,
0898                                                              MAX_IETA + 1) {
0899       Base::setSingleIov(true);
0900     }
0901 
0902     bool fill() override {
0903       auto tag = PlotBase::getTag<0>();
0904       for (auto const& iov : tag.iovs) {
0905         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
0906         if (payload.get()) {
0907           // looping over the EB channels, via the dense-index, mapped into EBDetId's
0908           if (payload->barrelItems().empty())
0909             return false;
0910           for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0911             uint32_t rawid = EBDetId::unhashIndex(cellid);
0912 
0913             // check the existence of ECAL pedestal, for a given ECAL barrel channel
0914             if (payload->find(rawid) == payload->end())
0915               continue;
0916             if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
0917               continue;
0918 
0919             // set min and max on 2d plots
0920             float valped = (*payload)[rawid].mean_x6;
0921             if (valped > 250.)
0922               valped = 250.;
0923             //      if(valped < 150.) valped = 150.;
0924             fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
0925           }  // loop over cellid
0926         }    // if payload.get()
0927       }      // loop over IOV's (1 in this case)
0928       return true;
0929     }  // fill method
0930   };
0931 
0932   class EcalPedestalsEBMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
0933   public:
0934     EcalPedestalsEBMean1Map()
0935         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain1 - map",
0936                                                              "iphi",
0937                                                              MAX_IPHI,
0938                                                              MIN_IPHI,
0939                                                              MAX_IPHI + MIN_IPHI,
0940                                                              "ieta",
0941                                                              2 * MAX_IETA + 1,
0942                                                              -MAX_IETA,
0943                                                              MAX_IETA + 1) {
0944       Base::setSingleIov(true);
0945     }
0946 
0947     bool fill() override {
0948       auto tag = PlotBase::getTag<0>();
0949       for (auto const& iov : tag.iovs) {
0950         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
0951         if (payload.get()) {
0952           // looping over the EB channels, via the dense-index, mapped into EBDetId's
0953           if (payload->barrelItems().empty())
0954             return false;
0955           for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0956             uint32_t rawid = EBDetId::unhashIndex(cellid);
0957 
0958             // check the existence of ECAL pedestal, for a given ECAL barrel channel
0959             if (payload->find(rawid) == payload->end())
0960               continue;
0961             if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
0962               continue;
0963 
0964             // set min and max on 2d plots
0965             float valped = (*payload)[rawid].mean_x1;
0966             if (valped > 250.)
0967               valped = 250.;
0968             //      if(valped < 150.) valped = 150.;
0969             fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
0970           }  // loop over cellid
0971         }    // if payload.get()
0972       }      // loop over IOV's (1 in this case)
0973       return true;
0974     }  // fill method
0975   };
0976 
0977   class EcalPedestalsEEMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
0978   public:
0979     EcalPedestalsEEMean12Map()
0980         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain12 - map",
0981                                                              "ix",
0982                                                              2.2 * IX_MAX,
0983                                                              IX_MIN,
0984                                                              2.2 * IX_MAX + 1,
0985                                                              "iy",
0986                                                              IY_MAX,
0987                                                              IY_MIN,
0988                                                              IY_MAX + IY_MIN) {
0989       Base::setSingleIov(true);
0990     }
0991 
0992     // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
0993     bool fill() override {
0994       auto tag = PlotBase::getTag<0>();
0995       for (auto const& iov : tag.iovs) {
0996         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
0997         if (payload.get()) {
0998           if (payload->endcapItems().empty())
0999             return false;
1000 
1001           // looping over the EE channels
1002           for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
1003             for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1004               for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1005                 if (EEDetId::validDetId(ix, iy, iz)) {
1006                   EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1007                   uint32_t rawid = myEEId.rawId();
1008                   // check the existence of ECAL pedestal, for a given ECAL endcap channel
1009                   if (payload->find(rawid) == payload->end())
1010                     continue;
1011                   if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1012                     continue;
1013                   // set min and max on 2d plots
1014                   float valped = (*payload)[rawid].mean_x12;
1015                   if (valped > 250.)
1016                     valped = 250.;
1017                   //            if(valped < 150.) valped = 150.;
1018                   if (iz == -1)
1019                     fillWithValue(ix, iy, valped);
1020                   else
1021                     fillWithValue(ix + IX_MAX + 20, iy, valped);
1022 
1023                 }  // validDetId
1024         }          // payload
1025       }            // loop over IOV's (1 in this case)
1026       return true;
1027     }  // fill method
1028   };
1029 
1030   class EcalPedestalsEEMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1031   public:
1032     EcalPedestalsEEMean6Map()
1033         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain6 - map",
1034                                                              "ix",
1035                                                              2.2 * IX_MAX,
1036                                                              IX_MIN,
1037                                                              2.2 * IX_MAX + 1,
1038                                                              "iy",
1039                                                              IY_MAX,
1040                                                              IY_MIN,
1041                                                              IY_MAX + IY_MIN) {
1042       Base::setSingleIov(true);
1043     }
1044 
1045     bool fill() override {
1046       auto tag = PlotBase::getTag<0>();
1047       for (auto const& iov : tag.iovs) {
1048         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1049         if (payload.get()) {
1050           if (payload->endcapItems().empty())
1051             return false;
1052 
1053           // looping over the EE channels
1054           for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
1055             for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1056               for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1057                 if (EEDetId::validDetId(ix, iy, iz)) {
1058                   EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1059                   uint32_t rawid = myEEId.rawId();
1060                   // check the existence of ECAL pedestal, for a given ECAL endcap channel
1061                   if (payload->find(rawid) == payload->end())
1062                     continue;
1063                   if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1064                     continue;
1065                   // set min and max on 2d plots
1066                   float valped = (*payload)[rawid].mean_x6;
1067                   if (valped > 250.)
1068                     valped = 250.;
1069                   //            if(valped < 150.) valped = 150.;
1070                   if (iz == -1)
1071                     fillWithValue(ix, iy, valped);
1072                   else
1073                     fillWithValue(ix + IX_MAX + 20, iy, valped);
1074                 }  // validDetId
1075         }          // payload
1076       }            // loop over IOV's (1 in this case)
1077       return true;
1078     }  // fill method
1079   };
1080 
1081   class EcalPedestalsEEMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1082   public:
1083     EcalPedestalsEEMean1Map()
1084         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain1 - map",
1085                                                              "ix",
1086                                                              2.2 * IX_MAX,
1087                                                              IX_MIN,
1088                                                              2.2 * IX_MAX + 1,
1089                                                              "iy",
1090                                                              IY_MAX,
1091                                                              IY_MIN,
1092                                                              IY_MAX + IY_MIN) {
1093       Base::setSingleIov(true);
1094     }
1095 
1096     bool fill() override {
1097       auto tag = PlotBase::getTag<0>();
1098       for (auto const& iov : tag.iovs) {
1099         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1100         if (payload.get()) {
1101           if (payload->endcapItems().empty())
1102             return false;
1103 
1104           // looping over the EE channels
1105           for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
1106             for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1107               for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1108                 if (EEDetId::validDetId(ix, iy, iz)) {
1109                   EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1110                   uint32_t rawid = myEEId.rawId();
1111                   // check the existence of ECAL pedestal, for a given ECAL endcap channel
1112                   if (payload->find(rawid) == payload->end())
1113                     continue;
1114                   if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
1115                     continue;
1116                   // set min and max on 2d plots
1117                   float valped = (*payload)[rawid].mean_x1;
1118                   if (valped > 250.)
1119                     valped = 250.;
1120                   //            if(valped < 150.) valped = 150.;
1121                   if (iz == -1)
1122                     fillWithValue(ix, iy, valped);
1123                   else
1124                     fillWithValue(ix + IX_MAX + 20, iy, valped);
1125                 }  // validDetId
1126         }          // if payload.get()
1127       }            // loop over IOV's (1 in this case)
1128       return true;
1129     }  // fill method
1130   };
1131 
1132   class EcalPedestalsEBRMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1133   public:
1134     EcalPedestalsEBRMS12Map()
1135         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain12 - map",
1136                                                              "iphi",
1137                                                              MAX_IPHI,
1138                                                              MIN_IPHI,
1139                                                              MAX_IPHI + MIN_IPHI,
1140                                                              "ieta",
1141                                                              2 * MAX_IETA + 1,
1142                                                              -1 * MAX_IETA,
1143                                                              MAX_IETA + 1) {
1144       Base::setSingleIov(true);
1145     }
1146 
1147     // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
1148     bool fill() override {
1149       auto tag = PlotBase::getTag<0>();
1150       for (auto const& iov : tag.iovs) {
1151         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1152         if (payload.get()) {
1153           // looping over the EB channels, via the dense-index, mapped into EBDetId's
1154           if (payload->barrelItems().empty())
1155             return false;
1156           for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1157             uint32_t rawid = EBDetId::unhashIndex(cellid);
1158 
1159             // check the existence of ECAL pedestal, for a given ECAL barrel channel
1160             if (payload->find(rawid) == payload->end())
1161               continue;
1162             if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1163               continue;
1164 
1165             // there's no ieta==0 in the EB numbering
1166             //      int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
1167             // fill the Histogram2D here
1168             //      fillWithValue(  (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
1169             // set max on noise 2d plots
1170             float valrms = (*payload)[rawid].rms_x12;
1171             if (valrms > 2.2)
1172               valrms = 2.2;
1173             fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1174           }  // loop over cellid
1175         }    // if payload.get()
1176       }      // loop over IOV's (1 in this case)
1177       return true;
1178     }  // fill method
1179   };
1180 
1181   class EcalPedestalsEBRMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1182   public:
1183     EcalPedestalsEBRMS6Map()
1184         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain6 - map",
1185                                                              "iphi",
1186                                                              MAX_IPHI,
1187                                                              MIN_IPHI,
1188                                                              MAX_IPHI + MIN_IPHI,
1189                                                              "ieta",
1190                                                              2 * MAX_IETA + 1,
1191                                                              -1 * MAX_IETA,
1192                                                              MAX_IETA + 1) {
1193       Base::setSingleIov(true);
1194     }
1195 
1196     bool fill() override {
1197       auto tag = PlotBase::getTag<0>();
1198       for (auto const& iov : tag.iovs) {
1199         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1200         if (payload.get()) {
1201           // looping over the EB channels, via the dense-index, mapped into EBDetId's
1202           if (payload->barrelItems().empty())
1203             return false;
1204           for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1205             uint32_t rawid = EBDetId::unhashIndex(cellid);
1206 
1207             // check the existence of ECAL pedestal, for a given ECAL barrel channel
1208             if (payload->find(rawid) == payload->end())
1209               continue;
1210             if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1211               continue;
1212 
1213             // set max on noise 2d plots
1214             float valrms = (*payload)[rawid].rms_x6;
1215             if (valrms > 1.5)
1216               valrms = 1.5;
1217             fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1218           }  // loop over cellid
1219         }    // if payload.get()
1220       }      // loop over IOV's (1 in this case)
1221       return true;
1222     }  // fill method
1223   };
1224 
1225   class EcalPedestalsEBRMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1226   public:
1227     EcalPedestalsEBRMS1Map()
1228         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain1 - map",
1229                                                              "iphi",
1230                                                              MAX_IPHI,
1231                                                              MIN_IPHI,
1232                                                              MAX_IPHI + MIN_IPHI,
1233                                                              "ieta",
1234                                                              2 * MAX_IETA + 1,
1235                                                              -1 * MAX_IETA,
1236                                                              MAX_IETA + 1) {
1237       Base::setSingleIov(true);
1238     }
1239 
1240     bool fill() override {
1241       auto tag = PlotBase::getTag<0>();
1242       for (auto const& iov : tag.iovs) {
1243         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1244         if (payload.get()) {
1245           // looping over the EB channels, via the dense-index, mapped into EBDetId's
1246           if (payload->barrelItems().empty())
1247             return false;
1248           for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1249             uint32_t rawid = EBDetId::unhashIndex(cellid);
1250 
1251             // check the existence of ECAL pedestal, for a given ECAL barrel channel
1252             if (payload->find(rawid) == payload->end())
1253               continue;
1254             if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
1255               continue;
1256 
1257             // set max on noise 2d plots
1258             float valrms = (*payload)[rawid].rms_x1;
1259             if (valrms > 1.0)
1260               valrms = 1.0;
1261             fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1262           }  // loop over cellid
1263         }    // if payload.get()
1264       }      // loop over IOV's (1 in this case)
1265       return true;
1266     }  // fill method
1267   };
1268 
1269   class EcalPedestalsEERMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1270   public:
1271     EcalPedestalsEERMS12Map()
1272         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain12 - map",
1273                                                              "ix",
1274                                                              2.2 * IX_MAX,
1275                                                              IX_MIN,
1276                                                              2.2 * IX_MAX + 1,
1277                                                              "iy",
1278                                                              IY_MAX,
1279                                                              IY_MIN,
1280                                                              IY_MAX + IY_MIN) {
1281       Base::setSingleIov(true);
1282     }
1283 
1284     // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
1285     bool fill() override {
1286       auto tag = PlotBase::getTag<0>();
1287       for (auto const& iov : tag.iovs) {
1288         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1289         if (payload.get()) {
1290           if (payload->endcapItems().empty())
1291             return false;
1292 
1293           // looping over the EE channels
1294           for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
1295             for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1296               for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1297                 if (EEDetId::validDetId(ix, iy, iz)) {
1298                   EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1299                   uint32_t rawid = myEEId.rawId();
1300                   // check the existence of ECAL pedestal, for a given ECAL endcap channel
1301                   if (payload->find(rawid) == payload->end())
1302                     continue;
1303                   if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1304                     continue;
1305                   // set max on noise 2d plots
1306                   float valrms = (*payload)[rawid].rms_x12;
1307                   if (valrms > 3.5)
1308                     valrms = 3.5;
1309                   if (iz == -1)
1310                     fillWithValue(ix, iy, valrms);
1311                   else
1312                     fillWithValue(ix + IX_MAX + 20, iy, valrms);
1313 
1314                 }  // validDetId
1315         }          // payload
1316       }            // loop over IOV's (1 in this case)
1317       return true;
1318     }  // fill method
1319   };
1320 
1321   class EcalPedestalsEERMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1322   public:
1323     EcalPedestalsEERMS6Map()
1324         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain6 - map",
1325                                                              "ix",
1326                                                              2.2 * IX_MAX,
1327                                                              IX_MIN,
1328                                                              2.2 * IX_MAX + 1,
1329                                                              "iy",
1330                                                              IY_MAX,
1331                                                              IY_MIN,
1332                                                              IY_MAX + IY_MIN) {
1333       Base::setSingleIov(true);
1334     }
1335 
1336     bool fill() override {
1337       auto tag = PlotBase::getTag<0>();
1338       for (auto const& iov : tag.iovs) {
1339         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1340         if (payload.get()) {
1341           if (payload->endcapItems().empty())
1342             return false;
1343 
1344           // looping over the EE channels
1345           for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
1346             for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1347               for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1348                 if (EEDetId::validDetId(ix, iy, iz)) {
1349                   EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1350                   uint32_t rawid = myEEId.rawId();
1351                   // check the existence of ECAL pedestal, for a given ECAL endcap channel
1352                   if (payload->find(rawid) == payload->end())
1353                     continue;
1354                   if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1355                     continue;
1356                   // set max on noise 2d plots
1357                   float valrms = (*payload)[rawid].rms_x6;
1358                   if (valrms > 2.0)
1359                     valrms = 2.0;
1360                   if (iz == -1)
1361                     fillWithValue(ix, iy, valrms);
1362                   else
1363                     fillWithValue(ix + IX_MAX + 20, iy, valrms);
1364                 }  // validDetId
1365         }          // payload
1366       }            // loop over IOV's (1 in this case)
1367       return true;
1368     }  // fill method
1369   };
1370 
1371   class EcalPedestalsEERMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1372   public:
1373     EcalPedestalsEERMS1Map()
1374         : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain1 - map",
1375                                                              "ix",
1376                                                              2.2 * IX_MAX,
1377                                                              IX_MIN,
1378                                                              2.2 * IX_MAX + 1,
1379                                                              "iy",
1380                                                              IY_MAX,
1381                                                              IY_MIN,
1382                                                              IY_MAX + IY_MIN) {
1383       Base::setSingleIov(true);
1384     }
1385 
1386     bool fill() override {
1387       auto tag = PlotBase::getTag<0>();
1388       for (auto const& iov : tag.iovs) {
1389         std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1390         if (payload.get()) {
1391           if (payload->endcapItems().empty())
1392             return false;
1393 
1394           // looping over the EE channels
1395           for (int iz = -1; iz < 2; iz = iz + 2)  // -1 or +1
1396             for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1397               for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1398                 if (EEDetId::validDetId(ix, iy, iz)) {
1399                   EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1400                   uint32_t rawid = myEEId.rawId();
1401                   // check the existence of ECAL pedestal, for a given ECAL endcap channel
1402                   if (payload->find(rawid) == payload->end())
1403                     continue;
1404                   if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
1405                     continue;
1406                   // set max on noise 2d plots
1407                   float valrms = (*payload)[rawid].rms_x1;
1408                   if (valrms > 1.5)
1409                     valrms = 1.5;
1410                   if (iz == -1)
1411                     fillWithValue(ix, iy, valrms);
1412                   else
1413                     fillWithValue(ix + IX_MAX + 20, iy, valrms);
1414                 }  // validDetId
1415         }          // if payload.get()
1416       }            // loop over IOV's (1 in this case)
1417       return true;
1418     }  // fill method
1419   };
1420 
1421   /*****************************************
1422  2d plot of Ecal Pedestals Summary of 1 IOV
1423  ******************************************/
1424   class EcalPedestalsSummaryPlot : public cond::payloadInspector::PlotImage<EcalPedestals> {
1425   public:
1426     EcalPedestalsSummaryPlot() : cond::payloadInspector::PlotImage<EcalPedestals>("Ecal Pedestals Summary - map ") {
1427       setSingleIov(true);
1428     }
1429 
1430     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
1431       auto iov = iovs.front();  //get reference to 1st element in the vector iovs
1432       std::shared_ptr<EcalPedestals> payload =
1433           fetchPayload(std::get<1>(iov));   //std::get<1>(iov) refers to the Hash in the tuple iov
1434       unsigned int run = std::get<0>(iov);  //referes to Time_t in iov.
1435       TH2F* align;                          //pointer to align which is a 2D histogram
1436 
1437       int NbRows = 6;
1438       int NbColumns = 5;
1439 
1440       if (payload.get()) {  //payload is an iov retrieved from payload using hash.
1441 
1442         align = new TH2F("Ecal Pedestals Summary",
1443                          "EB/EE      Gain                   Mean               RMS            Total Items",
1444                          NbColumns,
1445                          0,
1446                          NbColumns,
1447                          NbRows,
1448                          0,
1449                          NbRows);
1450 
1451         float ebVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1452         float eeVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1453 
1454         long unsigned int ebTotal = (payload->barrelItems()).size();
1455         long unsigned int eeTotal = (payload->endcapItems()).size();
1456 
1457         pedestalsSummary(payload->barrelItems(), ebVals, ebTotal);
1458         pedestalsSummary(payload->endcapItems(), eeVals, eeTotal);
1459 
1460         double row = NbRows - 0.5;
1461 
1462         //EB summary values
1463         align->Fill(1.5, row, 12);         //Gain
1464         align->Fill(2.5, row, ebVals[0]);  //mean12
1465         align->Fill(3.5, row, ebVals[1]);  //rms12
1466 
1467         row--;
1468 
1469         align->Fill(0.5, row, 1);
1470         align->Fill(1.5, row, 6);          //Gain
1471         align->Fill(2.5, row, ebVals[2]);  //mean6
1472         align->Fill(3.5, row, ebVals[3]);  //rms6
1473         align->Fill(4.5, row, ebTotal);
1474 
1475         row--;
1476 
1477         align->Fill(1.5, row, 1);          //Gain
1478         align->Fill(2.5, row, ebVals[4]);  //mean1
1479         align->Fill(3.5, row, ebVals[5]);  //rms1
1480 
1481         row--;
1482 
1483         //EE summary values
1484         align->Fill(1.5, row, 12);         //Gain
1485         align->Fill(2.5, row, eeVals[0]);  //mean12
1486         align->Fill(3.5, row, eeVals[1]);  //rms12
1487 
1488         row--;
1489 
1490         align->Fill(0.5, row, 2);
1491         align->Fill(1.5, row, 6);          //Gain
1492         align->Fill(2.5, row, eeVals[2]);  //mean6
1493         align->Fill(3.5, row, eeVals[3]);  //rms6
1494         align->Fill(4.5, row, eeTotal);
1495 
1496         row--;
1497 
1498         align->Fill(1.5, row, 1);          //Gain
1499         align->Fill(2.5, row, eeVals[4]);  //mean1
1500         align->Fill(3.5, row, eeVals[5]);  //rms1
1501 
1502       }  // if payload.get()
1503       else
1504         return false;
1505 
1506       gStyle->SetPalette(1);
1507       gStyle->SetOptStat(0);
1508       TCanvas canvas("CC map", "CC map", 1000, 1000);
1509       TLatex t1;
1510       t1.SetNDC();
1511       t1.SetTextAlign(26);
1512       t1.SetTextSize(0.05);
1513       t1.SetTextColor(2);
1514       t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals Summary, IOV %i", run));
1515 
1516       TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
1517       pad->Draw();
1518       pad->cd();
1519       align->Draw("TEXT");
1520       TLine* l = new TLine;
1521       l->SetLineWidth(1);
1522 
1523       for (int i = 1; i < NbRows; i++) {
1524         double y = (double)i;
1525         if (i == NbRows / 2)
1526           l = new TLine(0., y, NbColumns, y);
1527         else
1528           l = new TLine(1., y, NbColumns - 1, y);
1529         l->Draw();
1530       }
1531 
1532       for (int i = 1; i < NbColumns; i++) {
1533         double x = (double)i;
1534         double y = (double)NbRows;
1535         l = new TLine(x, 0., x, y);
1536         l->Draw();
1537       }
1538 
1539       align->GetXaxis()->SetTickLength(0.);
1540       align->GetXaxis()->SetLabelSize(0.);
1541       align->GetYaxis()->SetTickLength(0.);
1542       align->GetYaxis()->SetLabelSize(0.);
1543 
1544       std::string ImageName(m_imageFileName);
1545       canvas.SaveAs(ImageName.c_str());
1546       return true;
1547     }  // fill method
1548 
1549     void pedestalsSummary(std::vector<EcalPedestal> vItems, float vals[], long unsigned int& total) {
1550       for (std::vector<EcalPedestal>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems) {
1551         //vals[0]=100;
1552         vals[0] += iItems->mean(1);  //G12
1553         vals[1] += iItems->rms(1);
1554         vals[2] += iItems->mean(2);  //G6
1555         vals[3] += iItems->rms(2);
1556         vals[4] += iItems->mean(3);  //G1
1557         vals[5] += iItems->rms(3);
1558       }
1559 
1560       vals[0] = vals[0] / total;
1561       vals[1] = vals[1] / total;
1562       vals[2] = vals[2] / total;
1563       vals[3] = vals[3] / total;
1564       vals[4] = vals[4] / total;
1565       vals[5] = vals[5] / total;
1566     }
1567   };
1568 
1569 }  // namespace
1570 
1571 // Register the classes as boost python plugin
1572 PAYLOAD_INSPECTOR_MODULE(EcalPedestals) {
1573   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsHist);
1574   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsPlot);
1575   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsDiffOneTag);
1576   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsDiffTwoTags);
1577   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsRatioOneTag);
1578   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsRatioTwoTags);
1579   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean12Map);
1580   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean6Map);
1581   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean1Map);
1582   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean12Map);
1583   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean6Map);
1584   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean1Map);
1585   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS12Map);
1586   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS6Map);
1587   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS1Map);
1588   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS12Map);
1589   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS6Map);
1590   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS1Map);
1591   PAYLOAD_INSPECTOR_CLASS(EcalPedestalsSummaryPlot);
1592 }