File indexing completed on 2024-09-07 04:35:27
0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004
0005
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 constexpr int kEBChannels = 61200, kEEChannels = 14648, kGains = 3, kRMS = 5;
0022 constexpr int MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360;
0023 constexpr int IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100;
0024
0025
0026
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] = {3.6, 2.0, 1.0};
0039 float emin[kGains] = {1.5, 0.8, 0.4};
0040 float emax[kGains] = {3.0, 2.0, 1.0};
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
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 }
0067 if (payload->endcapItems().empty())
0068 return false;
0069
0070
0071 for (int iz = -1; iz < 2; iz = iz + 2)
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 }
0086 }
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
0106
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 }
0128 };
0129
0130
0131
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
0209 if (payload->barrelItems().empty())
0210 return false;
0211 for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
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;
0219 else
0220 eta = eta + 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
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
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
0248 }
0249 if (payload->endcapItems().empty())
0250 return false;
0251
0252
0253 for (int iz = -1; iz < 2; iz = iz + 2)
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 }
0313 }
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++) {
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
0351
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
0363
0364 if (pEEmin[gId] < 0.)
0365 pEEmin[gId] = 0.;
0366 }
0367
0368
0369
0370
0371
0372
0373 for (int gId = 0; gId < kGains; gId++) {
0374 pad[gId][0]->cd();
0375 DrawEE(endc_m_m[gId], 180., 300.);
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], 180., 240.);
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], 180., 300.);
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 }
0392
0393 };
0394
0395
0396
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
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
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;
0516 else
0517 eta = eta + 0.5;
0518 double dr, drms;
0519
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 {
0526 if (meanEB[0][cellid] == 0) {
0527 if (val == 0.)
0528 dr = 1.;
0529 else
0530 dr = 9999.;
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.;
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
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 {
0555 if (meanEB[1][cellid] == 0) {
0556 if (val == 0.)
0557 dr = 1.;
0558 else
0559 dr = 9999.;
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.;
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
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 {
0584 if (meanEB[2][cellid] == 0) {
0585 if (val == 0.)
0586 dr = 1.;
0587 else
0588 dr = 9999.;
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.;
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 }
0608 }
0609 if (payload->endcapItems().empty()) {
0610
0611 for (int iz = -1; iz < 2; iz = iz + 2) {
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 }
0628 else {
0629 double dr, drms;
0630
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 {
0637 if (meanEE[0][index] == 0) {
0638 if (val == 0.)
0639 dr = 1.;
0640 else
0641 dr = 9999.;
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.;
0649 } else
0650 drms = valr / rmsEE[0][index];
0651 }
0652 if (iz == 1) {
0653 endc_p_m[0]->Fill(ix, iy, dr);
0654 endc_p_r[0]->Fill(ix, iy, drms);
0655 } else {
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
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 {
0671 if (meanEE[1][index] == 0) {
0672 if (val == 0.)
0673 dr = 1.;
0674 else
0675 dr = 9999.;
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.;
0683 } else
0684 drms = valr / rmsEE[1][index];
0685 }
0686 if (iz == 1) {
0687 endc_p_m[1]->Fill(ix, iy, dr);
0688 endc_p_r[1]->Fill(ix, iy, drms);
0689 } else {
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
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 {
0705 if (meanEE[2][index] == 0) {
0706 if (val == 0.)
0707 dr = 1.;
0708 else
0709 dr = 9999.;
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.;
0717 } else
0718 drms = valr / rmsEE[2][index];
0719 }
0720 if (iz == 1) {
0721 endc_p_m[2]->Fill(ix, iy, dr);
0722 endc_p_r[2]->Fill(ix, iy, drms);
0723 } else {
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 }
0733 }
0734 }
0735 }
0736 }
0737 }
0738 }
0739 else
0740 return false;
0741 }
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++) {
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
0795
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
0805
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 }
0826 };
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
0834
0835
0836
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
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
0859 if (payload->barrelItems().empty())
0860 return false;
0861
0862 for (int iphi = MIN_IPHI; iphi < MAX_IPHI + 1; iphi++)
0863 fillWithValue(iphi, 0, 200);
0864 for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0865 uint32_t rawid = EBDetId::unhashIndex(cellid);
0866
0867
0868 if (payload->find(rawid) == payload->end())
0869 continue;
0870 if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
0871 continue;
0872
0873
0874
0875
0876
0877
0878 float valped = (*payload)[rawid].mean_x12;
0879 if (valped > 250.)
0880 valped = 250.;
0881
0882 fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
0883 }
0884 }
0885 }
0886 return true;
0887 }
0888 };
0889
0890 class EcalPedestalsEBMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
0891 public:
0892 EcalPedestalsEBMean6Map()
0893 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain6 - map",
0894 "iphi",
0895 MAX_IPHI,
0896 MIN_IPHI,
0897 MAX_IPHI + MIN_IPHI,
0898 "ieta",
0899 2 * MAX_IETA + 1,
0900 -MAX_IETA,
0901 MAX_IETA + 1) {
0902 Base::setSingleIov(true);
0903 }
0904
0905 bool fill() override {
0906 auto tag = PlotBase::getTag<0>();
0907 for (auto const& iov : tag.iovs) {
0908 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
0909 if (payload.get()) {
0910
0911 if (payload->barrelItems().empty())
0912 return false;
0913
0914 for (int iphi = MIN_IPHI; iphi < MAX_IPHI + 1; iphi++)
0915 fillWithValue(iphi, 0, 200);
0916 for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0917 uint32_t rawid = EBDetId::unhashIndex(cellid);
0918
0919
0920 if (payload->find(rawid) == payload->end())
0921 continue;
0922 if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
0923 continue;
0924
0925
0926 float valped = (*payload)[rawid].mean_x6;
0927 if (valped > 250.)
0928 valped = 250.;
0929
0930 fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
0931 }
0932 }
0933 }
0934 return true;
0935 }
0936 };
0937
0938 class EcalPedestalsEBMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
0939 public:
0940 EcalPedestalsEBMean1Map()
0941 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel pedestal gain1 - map",
0942 "iphi",
0943 MAX_IPHI,
0944 MIN_IPHI,
0945 MAX_IPHI + MIN_IPHI,
0946 "ieta",
0947 2 * MAX_IETA + 1,
0948 -MAX_IETA,
0949 MAX_IETA + 1) {
0950 Base::setSingleIov(true);
0951 }
0952
0953 bool fill() override {
0954 auto tag = PlotBase::getTag<0>();
0955 for (auto const& iov : tag.iovs) {
0956 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
0957 if (payload.get()) {
0958
0959 if (payload->barrelItems().empty())
0960 return false;
0961
0962 for (int iphi = MIN_IPHI; iphi < MAX_IPHI + 1; iphi++)
0963 fillWithValue(iphi, 0, 200);
0964 for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
0965 uint32_t rawid = EBDetId::unhashIndex(cellid);
0966
0967
0968 if (payload->find(rawid) == payload->end())
0969 continue;
0970 if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
0971 continue;
0972
0973
0974 float valped = (*payload)[rawid].mean_x1;
0975 if (valped > 250.)
0976 valped = 250.;
0977
0978 fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
0979 }
0980 }
0981 }
0982 return true;
0983 }
0984 };
0985
0986 class EcalPedestalsEEMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
0987 public:
0988 EcalPedestalsEEMean12Map()
0989 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain12 - map",
0990 "ix",
0991 2.2 * IX_MAX,
0992 IX_MIN,
0993 2.2 * IX_MAX + 1,
0994 "iy",
0995 IY_MAX,
0996 IY_MIN,
0997 IY_MAX + IY_MIN) {
0998 Base::setSingleIov(true);
0999 }
1000
1001
1002 bool fill() override {
1003 auto tag = PlotBase::getTag<0>();
1004 for (auto const& iov : tag.iovs) {
1005 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1006 if (payload.get()) {
1007 if (payload->endcapItems().empty())
1008 return false;
1009
1010
1011 for (int iz = -1; iz < 2; iz = iz + 2)
1012 for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1013 for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1014 if (EEDetId::validDetId(ix, iy, iz)) {
1015 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1016 uint32_t rawid = myEEId.rawId();
1017
1018 if (payload->find(rawid) == payload->end())
1019 continue;
1020 if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1021 continue;
1022
1023 float valped = (*payload)[rawid].mean_x12;
1024 if (valped > 250.)
1025 valped = 250.;
1026
1027 if (iz == -1)
1028 fillWithValue(ix, iy, valped);
1029 else
1030 fillWithValue(ix + IX_MAX + 20, iy, valped);
1031
1032 }
1033 }
1034 }
1035 return true;
1036 }
1037 };
1038
1039 class EcalPedestalsEEMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1040 public:
1041 EcalPedestalsEEMean6Map()
1042 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain6 - map",
1043 "ix",
1044 2.2 * IX_MAX,
1045 IX_MIN,
1046 2.2 * IX_MAX + 1,
1047 "iy",
1048 IY_MAX,
1049 IY_MIN,
1050 IY_MAX + IY_MIN) {
1051 Base::setSingleIov(true);
1052 }
1053
1054 bool fill() override {
1055 auto tag = PlotBase::getTag<0>();
1056 for (auto const& iov : tag.iovs) {
1057 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1058 if (payload.get()) {
1059 if (payload->endcapItems().empty())
1060 return false;
1061
1062
1063 for (int iz = -1; iz < 2; iz = iz + 2)
1064 for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1065 for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1066 if (EEDetId::validDetId(ix, iy, iz)) {
1067 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1068 uint32_t rawid = myEEId.rawId();
1069
1070 if (payload->find(rawid) == payload->end())
1071 continue;
1072 if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1073 continue;
1074
1075 float valped = (*payload)[rawid].mean_x6;
1076 if (valped > 250.)
1077 valped = 250.;
1078
1079 if (iz == -1)
1080 fillWithValue(ix, iy, valped);
1081 else
1082 fillWithValue(ix + IX_MAX + 20, iy, valped);
1083 }
1084 }
1085 }
1086 return true;
1087 }
1088 };
1089
1090 class EcalPedestalsEEMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1091 public:
1092 EcalPedestalsEEMean1Map()
1093 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap pedestal gain1 - map",
1094 "ix",
1095 2.2 * IX_MAX,
1096 IX_MIN,
1097 2.2 * IX_MAX + 1,
1098 "iy",
1099 IY_MAX,
1100 IY_MIN,
1101 IY_MAX + IY_MIN) {
1102 Base::setSingleIov(true);
1103 }
1104
1105 bool fill() override {
1106 auto tag = PlotBase::getTag<0>();
1107 for (auto const& iov : tag.iovs) {
1108 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1109 if (payload.get()) {
1110 if (payload->endcapItems().empty())
1111 return false;
1112
1113
1114 for (int iz = -1; iz < 2; iz = iz + 2)
1115 for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1116 for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1117 if (EEDetId::validDetId(ix, iy, iz)) {
1118 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1119 uint32_t rawid = myEEId.rawId();
1120
1121 if (payload->find(rawid) == payload->end())
1122 continue;
1123 if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
1124 continue;
1125
1126 float valped = (*payload)[rawid].mean_x1;
1127 if (valped > 250.)
1128 valped = 250.;
1129
1130 if (iz == -1)
1131 fillWithValue(ix, iy, valped);
1132 else
1133 fillWithValue(ix + IX_MAX + 20, iy, valped);
1134 }
1135 }
1136 }
1137 return true;
1138 }
1139 };
1140
1141 class EcalPedestalsEBRMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1142 public:
1143 EcalPedestalsEBRMS12Map()
1144 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain12 - map",
1145 "iphi",
1146 MAX_IPHI,
1147 MIN_IPHI,
1148 MAX_IPHI + MIN_IPHI,
1149 "ieta",
1150 2 * MAX_IETA + 1,
1151 -1 * MAX_IETA,
1152 MAX_IETA + 1) {
1153 Base::setSingleIov(true);
1154 }
1155
1156
1157 bool fill() override {
1158 auto tag = PlotBase::getTag<0>();
1159 for (auto const& iov : tag.iovs) {
1160 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1161 if (payload.get()) {
1162
1163 if (payload->barrelItems().empty())
1164 return false;
1165
1166 for (int iphi = MIN_IPHI; iphi < MAX_IPHI + 1; iphi++)
1167 fillWithValue(iphi, 0, 2);
1168 for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1169 uint32_t rawid = EBDetId::unhashIndex(cellid);
1170
1171
1172 if (payload->find(rawid) == payload->end())
1173 continue;
1174 if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1175 continue;
1176
1177
1178
1179
1180
1181
1182 float valrms = (*payload)[rawid].rms_x12;
1183 if (valrms > 4.0)
1184 valrms = 4.0;
1185 fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1186 }
1187 }
1188 }
1189 return true;
1190 }
1191 };
1192
1193 class EcalPedestalsEBRMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1194 public:
1195 EcalPedestalsEBRMS6Map()
1196 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain6 - map",
1197 "iphi",
1198 MAX_IPHI,
1199 MIN_IPHI,
1200 MAX_IPHI + MIN_IPHI,
1201 "ieta",
1202 2 * MAX_IETA + 1,
1203 -1 * MAX_IETA,
1204 MAX_IETA + 1) {
1205 Base::setSingleIov(true);
1206 }
1207
1208 bool fill() override {
1209 auto tag = PlotBase::getTag<0>();
1210 for (auto const& iov : tag.iovs) {
1211 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1212 if (payload.get()) {
1213
1214 if (payload->barrelItems().empty())
1215 return false;
1216
1217 for (int iphi = MIN_IPHI; iphi < MAX_IPHI + 1; iphi++)
1218 fillWithValue(iphi, 0, 1);
1219 for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1220 uint32_t rawid = EBDetId::unhashIndex(cellid);
1221
1222
1223 if (payload->find(rawid) == payload->end())
1224 continue;
1225 if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1226 continue;
1227
1228
1229 float valrms = (*payload)[rawid].rms_x6;
1230 if (valrms > 2.5)
1231 valrms = 2.5;
1232 fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1233 }
1234 }
1235 }
1236 return true;
1237 }
1238 };
1239
1240 class EcalPedestalsEBRMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1241 public:
1242 EcalPedestalsEBRMS1Map()
1243 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Barrel noise gain1 - map",
1244 "iphi",
1245 MAX_IPHI,
1246 MIN_IPHI,
1247 MAX_IPHI + MIN_IPHI,
1248 "ieta",
1249 2 * MAX_IETA + 1,
1250 -1 * MAX_IETA,
1251 MAX_IETA + 1) {
1252 Base::setSingleIov(true);
1253 }
1254
1255 bool fill() override {
1256 auto tag = PlotBase::getTag<0>();
1257 for (auto const& iov : tag.iovs) {
1258 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1259 if (payload.get()) {
1260
1261 if (payload->barrelItems().empty())
1262 return false;
1263
1264 for (int iphi = MIN_IPHI; iphi < MAX_IPHI + 1; iphi++)
1265 fillWithValue(iphi, 0, 0.5);
1266 for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
1267 uint32_t rawid = EBDetId::unhashIndex(cellid);
1268
1269
1270 if (payload->find(rawid) == payload->end())
1271 continue;
1272 if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1)
1273 continue;
1274
1275
1276 float valrms = (*payload)[rawid].rms_x1;
1277 if (valrms > 1.2)
1278 valrms = 1.2;
1279 fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
1280 }
1281 }
1282 }
1283 return true;
1284 }
1285 };
1286
1287 class EcalPedestalsEERMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1288 public:
1289 EcalPedestalsEERMS12Map()
1290 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain12 - map",
1291 "ix",
1292 2.2 * IX_MAX,
1293 IX_MIN,
1294 2.2 * IX_MAX + 1,
1295 "iy",
1296 IY_MAX,
1297 IY_MIN,
1298 IY_MAX + IY_MIN) {
1299 Base::setSingleIov(true);
1300 }
1301
1302
1303 bool fill() override {
1304 auto tag = PlotBase::getTag<0>();
1305 for (auto const& iov : tag.iovs) {
1306 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1307 if (payload.get()) {
1308 if (payload->endcapItems().empty())
1309 return false;
1310
1311
1312 for (int iz = -1; iz < 2; iz = iz + 2)
1313 for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1314 for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1315 if (EEDetId::validDetId(ix, iy, iz)) {
1316 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1317 uint32_t rawid = myEEId.rawId();
1318
1319 if (payload->find(rawid) == payload->end())
1320 continue;
1321 if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12)
1322 continue;
1323
1324 float valrms = (*payload)[rawid].rms_x12;
1325 if (valrms > 4.0)
1326 valrms = 4.0;
1327 if (iz == -1)
1328 fillWithValue(ix, iy, valrms);
1329 else
1330 fillWithValue(ix + IX_MAX + 20, iy, valrms);
1331
1332 }
1333 }
1334 }
1335 return true;
1336 }
1337 };
1338
1339 class EcalPedestalsEERMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1340 public:
1341 EcalPedestalsEERMS6Map()
1342 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain6 - map",
1343 "ix",
1344 2.2 * IX_MAX,
1345 IX_MIN,
1346 2.2 * IX_MAX + 1,
1347 "iy",
1348 IY_MAX,
1349 IY_MIN,
1350 IY_MAX + IY_MIN) {
1351 Base::setSingleIov(true);
1352 }
1353
1354 bool fill() override {
1355 auto tag = PlotBase::getTag<0>();
1356 for (auto const& iov : tag.iovs) {
1357 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1358 if (payload.get()) {
1359 if (payload->endcapItems().empty())
1360 return false;
1361
1362
1363 for (int iz = -1; iz < 2; iz = iz + 2)
1364 for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1365 for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1366 if (EEDetId::validDetId(ix, iy, iz)) {
1367 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1368 uint32_t rawid = myEEId.rawId();
1369
1370 if (payload->find(rawid) == payload->end())
1371 continue;
1372 if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6)
1373 continue;
1374
1375 float valrms = (*payload)[rawid].rms_x6;
1376 if (valrms > 2.5)
1377 valrms = 2.5;
1378 if (iz == -1)
1379 fillWithValue(ix, iy, valrms);
1380 else
1381 fillWithValue(ix + IX_MAX + 20, iy, valrms);
1382 }
1383 }
1384 }
1385 return true;
1386 }
1387 };
1388
1389 class EcalPedestalsEERMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1390 public:
1391 EcalPedestalsEERMS1Map()
1392 : cond::payloadInspector::Histogram2D<EcalPedestals>("ECAL Endcap noise gain1 - map",
1393 "ix",
1394 2.2 * IX_MAX,
1395 IX_MIN,
1396 2.2 * IX_MAX + 1,
1397 "iy",
1398 IY_MAX,
1399 IY_MIN,
1400 IY_MAX + IY_MIN) {
1401 Base::setSingleIov(true);
1402 }
1403
1404 bool fill() override {
1405 auto tag = PlotBase::getTag<0>();
1406 for (auto const& iov : tag.iovs) {
1407 std::shared_ptr<EcalPedestals> payload = Base::fetchPayload(std::get<1>(iov));
1408 if (payload.get()) {
1409 if (payload->endcapItems().empty())
1410 return false;
1411
1412
1413 for (int iz = -1; iz < 2; iz = iz + 2)
1414 for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
1415 for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
1416 if (EEDetId::validDetId(ix, iy, iz)) {
1417 EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1418 uint32_t rawid = myEEId.rawId();
1419
1420 if (payload->find(rawid) == payload->end())
1421 continue;
1422 if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12)
1423 continue;
1424
1425 float valrms = (*payload)[rawid].rms_x1;
1426 if (valrms > 1.2)
1427 valrms = 1.2;
1428 if (iz == -1)
1429 fillWithValue(ix, iy, valrms);
1430 else
1431 fillWithValue(ix + IX_MAX + 20, iy, valrms);
1432 }
1433 }
1434 }
1435 return true;
1436 }
1437 };
1438
1439
1440
1441
1442 class EcalPedestalsSummaryPlot : public cond::payloadInspector::PlotImage<EcalPedestals> {
1443 public:
1444 EcalPedestalsSummaryPlot() : cond::payloadInspector::PlotImage<EcalPedestals>("Ecal Pedestals Summary - map ") {
1445 setSingleIov(true);
1446 }
1447
1448 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
1449 auto iov = iovs.front();
1450 std::shared_ptr<EcalPedestals> payload =
1451 fetchPayload(std::get<1>(iov));
1452 unsigned int run = std::get<0>(iov);
1453 TH2F* align;
1454
1455 int NbRows = 6;
1456 int NbColumns = 5;
1457
1458 if (payload.get()) {
1459
1460 align = new TH2F("Ecal Pedestals Summary",
1461 "EB/EE Gain Mean RMS Total Items",
1462 NbColumns,
1463 0,
1464 NbColumns,
1465 NbRows,
1466 0,
1467 NbRows);
1468
1469 float ebVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1470 float eeVals[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
1471
1472 long unsigned int ebTotal = (payload->barrelItems()).size();
1473 long unsigned int eeTotal = (payload->endcapItems()).size();
1474
1475 pedestalsSummary(payload->barrelItems(), ebVals, ebTotal);
1476 pedestalsSummary(payload->endcapItems(), eeVals, eeTotal);
1477
1478 double row = NbRows - 0.5;
1479
1480
1481 align->Fill(1.5, row, 12);
1482 align->Fill(2.5, row, ebVals[0]);
1483 align->Fill(3.5, row, ebVals[1]);
1484
1485 row--;
1486
1487 align->Fill(0.5, row, 1);
1488 align->Fill(1.5, row, 6);
1489 align->Fill(2.5, row, ebVals[2]);
1490 align->Fill(3.5, row, ebVals[3]);
1491 align->Fill(4.5, row, ebTotal);
1492
1493 row--;
1494
1495 align->Fill(1.5, row, 1);
1496 align->Fill(2.5, row, ebVals[4]);
1497 align->Fill(3.5, row, ebVals[5]);
1498
1499 row--;
1500
1501
1502 align->Fill(1.5, row, 12);
1503 align->Fill(2.5, row, eeVals[0]);
1504 align->Fill(3.5, row, eeVals[1]);
1505
1506 row--;
1507
1508 align->Fill(0.5, row, 2);
1509 align->Fill(1.5, row, 6);
1510 align->Fill(2.5, row, eeVals[2]);
1511 align->Fill(3.5, row, eeVals[3]);
1512 align->Fill(4.5, row, eeTotal);
1513
1514 row--;
1515
1516 align->Fill(1.5, row, 1);
1517 align->Fill(2.5, row, eeVals[4]);
1518 align->Fill(3.5, row, eeVals[5]);
1519
1520 }
1521 else
1522 return false;
1523
1524 gStyle->SetPalette(1);
1525 gStyle->SetOptStat(0);
1526 TCanvas canvas("CC map", "CC map", 1000, 1000);
1527 TLatex t1;
1528 t1.SetNDC();
1529 t1.SetTextAlign(26);
1530 t1.SetTextSize(0.05);
1531 t1.SetTextColor(2);
1532 t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals Summary, IOV %i", run));
1533
1534 TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
1535 pad->Draw();
1536 pad->cd();
1537 align->Draw("TEXT");
1538 TLine* l = new TLine;
1539 l->SetLineWidth(1);
1540
1541 for (int i = 1; i < NbRows; i++) {
1542 double y = (double)i;
1543 if (i == NbRows / 2)
1544 l = new TLine(0., y, NbColumns, y);
1545 else
1546 l = new TLine(1., y, NbColumns - 1, y);
1547 l->Draw();
1548 }
1549
1550 for (int i = 1; i < NbColumns; i++) {
1551 double x = (double)i;
1552 double y = (double)NbRows;
1553 l = new TLine(x, 0., x, y);
1554 l->Draw();
1555 }
1556
1557 align->GetXaxis()->SetTickLength(0.);
1558 align->GetXaxis()->SetLabelSize(0.);
1559 align->GetYaxis()->SetTickLength(0.);
1560 align->GetYaxis()->SetLabelSize(0.);
1561
1562 std::string ImageName(m_imageFileName);
1563 canvas.SaveAs(ImageName.c_str());
1564 return true;
1565 }
1566
1567 void pedestalsSummary(std::vector<EcalPedestal> vItems, float vals[], long unsigned int& total) {
1568 for (std::vector<EcalPedestal>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems) {
1569
1570 vals[0] += iItems->mean(1);
1571 vals[1] += iItems->rms(1);
1572 vals[2] += iItems->mean(2);
1573 vals[3] += iItems->rms(2);
1574 vals[4] += iItems->mean(3);
1575 vals[5] += iItems->rms(3);
1576 }
1577
1578 vals[0] = vals[0] / total;
1579 vals[1] = vals[1] / total;
1580 vals[2] = vals[2] / total;
1581 vals[3] = vals[3] / total;
1582 vals[4] = vals[4] / total;
1583 vals[5] = vals[5] / total;
1584 }
1585 };
1586
1587 }
1588
1589
1590 PAYLOAD_INSPECTOR_MODULE(EcalPedestals) {
1591 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsHist);
1592 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsPlot);
1593 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsDiffOneTag);
1594 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsDiffTwoTags);
1595 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsRatioOneTag);
1596 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsRatioTwoTags);
1597 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean12Map);
1598 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean6Map);
1599 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBMean1Map);
1600 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean12Map);
1601 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean6Map);
1602 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEEMean1Map);
1603 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS12Map);
1604 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS6Map);
1605 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEBRMS1Map);
1606 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS12Map);
1607 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS6Map);
1608 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsEERMS1Map);
1609 PAYLOAD_INSPECTOR_CLASS(EcalPedestalsSummaryPlot);
1610 }