File indexing completed on 2024-09-07 04:35:29
0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0004 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0005 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0006 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
0007 #include "CondCore/EcalPlugins/plugins/EcalDrawUtils.h"
0008
0009 #include "CondFormats/EcalObjects/interface/EcalTPGWeightGroup.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 <string>
0018
0019 namespace {
0020
0021 enum { kEBTotalTowers = 2448, kEETotalTowers = 1584 };
0022 enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 17, MAX_IPHI = 72 };
0023 enum {
0024 IX_MIN = 1,
0025 IY_MIN = 1,
0026 IX_MAX = 100,
0027 IY_MAX = 100,
0028 EEhistXMax = 220
0029 };
0030
0031
0032
0033 class EcalTPGWeightGroupPlot : public cond::payloadInspector::PlotImage<EcalTPGWeightGroup> {
0034 public:
0035 EcalTPGWeightGroupPlot() : cond::payloadInspector::PlotImage<EcalTPGWeightGroup>("EcalTPGWeightGroup - map ") {
0036 setSingleIov(true);
0037 }
0038
0039 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0040 uint32_t minEB = 0;
0041 uint32_t maxEB = 2;
0042 uint32_t minEE = 0;
0043 uint32_t maxEE = 2;
0044
0045 TH2F* barrel = new TH2F("EB", "EB Tower Status", 72, 0, 72, 34, -17, 17);
0046 TH2F* endc_p = new TH2F("EE+", "EE+ Tower Status", 22, 0, 22, 22, 0, 22);
0047 TH2F* endc_m = new TH2F("EE-", "EE- Tower Status", 22, 0, 22, 22, 0, 22);
0048
0049 auto iov = iovs.front();
0050 std::shared_ptr<EcalTPGWeightGroup> payload = fetchPayload(std::get<1>(iov));
0051 unsigned int run = std::get<0>(iov);
0052
0053 if (payload.get()) {
0054 const EcalTPGWeightGroup::EcalTPGGroupsMap& map = (*payload).getMap();
0055 EcalTPGWeightGroup::EcalTPGGroupsMapItr it;
0056
0057 for (it = map.begin(); it != map.end(); it++) {
0058 EcalTrigTowerDetId rawid = EcalTrigTowerDetId::detIdFromDenseIndex((*it).first);
0059 EcalTrigTowerDetId ttId_eb(rawid);
0060
0061
0062
0063 if (ttId_eb.subDet() == 1) {
0064
0065 int ieta = ttId_eb.ieta();
0066 if (ieta < 0)
0067 ieta--;
0068 int iphi = ttId_eb.iphi() - 1;
0069
0070 if (minEB > (*it).second)
0071 minEB = (*it).second;
0072
0073 if (maxEB < (*it).second)
0074 maxEB = (*it).second;
0075
0076 barrel->Fill(iphi, ieta, (*it).second);
0077 }
0078
0079 if (EcalScDetId::validHashIndex((*it).first)) {
0080 EcalScDetId rawid_ee = EcalScDetId::unhashIndex((*it).first);
0081 EcalScDetId ttId_ee(rawid_ee);
0082
0083
0084
0085 int ix = ttId_ee.ix();
0086 int iy = ttId_ee.iy();
0087 int zside = ttId_ee.zside();
0088
0089 if (minEE > (*it).second)
0090 minEE = (*it).second;
0091
0092 if (maxEE < (*it).second)
0093 maxEE = (*it).second;
0094
0095 if (zside == 1) {
0096 endc_p->Fill(ix, iy, (*it).second);
0097 } else {
0098 endc_m->Fill(ix, iy, (*it).second);
0099 }
0100 }
0101 }
0102
0103 }
0104
0105 TCanvas canvas("CC map", "CC map", 800, 800);
0106 TLatex t1;
0107 t1.SetNDC();
0108 t1.SetTextAlign(26);
0109 t1.SetTextSize(0.05);
0110 t1.DrawLatex(0.5, 0.96, Form("Ecal TPG WeightGroup, IOV %i", run));
0111
0112
0113 TPad* padb = new TPad("padb", "padb", 0., 0.45, 1., 0.9);
0114 padb->Draw();
0115 TPad* padem = new TPad("padem", "padem", 0., 0., 0.45, 0.45);
0116 padem->Draw();
0117 TPad* padep = new TPad("padep", "padep", 0.55, 0., 1., 0.45);
0118 padep->Draw();
0119
0120 TLine* l = new TLine(0., 0., 0., 0.);
0121 l->SetLineWidth(1);
0122 padb->cd();
0123 barrel->SetStats(false);
0124 barrel->SetMaximum(maxEB);
0125 barrel->SetMinimum(minEB);
0126 barrel->Draw("colz");
0127
0128
0129 for (int i = 0; i < 17; i++) {
0130 Double_t x = 4. + (i * 4);
0131 l = new TLine(x, -17., x, 17.);
0132 l->Draw();
0133 }
0134
0135 l = new TLine(0., 0., 72., 0.);
0136 l->Draw();
0137
0138 padem->cd();
0139 DrawEE_Tower(endc_m, l, minEE, maxEE);
0140
0141 padep->cd();
0142 DrawEE_Tower(endc_p, l, minEE, maxEE);
0143
0144 std::string ImageName(m_imageFileName);
0145 canvas.SaveAs(ImageName.c_str());
0146 return true;
0147 }
0148 };
0149
0150 }
0151
0152
0153 PAYLOAD_INSPECTOR_MODULE(EcalTPGWeightGroup) { PAYLOAD_INSPECTOR_CLASS(EcalTPGWeightGroupPlot); }