File indexing completed on 2024-04-06 12:01:36
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
0010 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBGroup.h"
0011
0012 #include "TH2F.h"
0013 #include "TCanvas.h"
0014 #include "TStyle.h"
0015 #include "TLine.h"
0016 #include "TLatex.h"
0017
0018 #include <string>
0019
0020 namespace {
0021 enum { kEBTotalTowers = 2448, kEETotalTowers = 1584 };
0022 enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 17, MAX_IPHI = 72 };
0023
0024
0025
0026
0027 class EcalTPGFineGrainEBGroupPlot : public cond::payloadInspector::PlotImage<EcalTPGFineGrainEBGroup> {
0028 public:
0029 EcalTPGFineGrainEBGroupPlot()
0030 : cond::payloadInspector::PlotImage<EcalTPGFineGrainEBGroup>("EcalTPGFineGrainEBGroup - map ") {
0031 setSingleIov(true);
0032 }
0033
0034 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0035 TH2F* barrel =
0036 new TH2F("EB", "Ecal TPGFineGrain EB Group", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
0037 int EBcount = 0;
0038 double minEB = 0, maxEB = 1;
0039
0040 auto iov = iovs.front();
0041 std::shared_ptr<EcalTPGFineGrainEBGroup> payload = fetchPayload(std::get<1>(iov));
0042 unsigned int run = std::get<0>(iov);
0043 if (payload.get()) {
0044 const EcalTPGFineGrainEBGroup::EcalTPGGroupsMap& towerMap = (*payload).getMap();
0045
0046 EcalTPGFineGrainEBGroup::EcalTPGGroupsMapItr it;
0047 for (it = towerMap.begin(); it != towerMap.end(); ++it) {
0048
0049 EcalTrigTowerDetId ttId((*it).first);
0050 int ieta = ttId.ieta();
0051
0052 if (ieta > 0)
0053 ieta--;
0054 int iphi = ttId.iphi() - 1;
0055
0056
0057
0058
0059
0060
0061 if (ttId.subDet() == 1) {
0062
0063 barrel->Fill(iphi, ieta, (*it).second);
0064
0065 if (maxEB < (*it).second)
0066 maxEB = (*it).second;
0067 if (minEB > (*it).second)
0068 minEB = (*it).second;
0069
0070 EBcount++;
0071 }
0072 }
0073 }
0074
0075 gStyle->SetPalette(1);
0076 gStyle->SetOptStat(0);
0077
0078 Double_t w = 1400;
0079 Double_t h = 1200;
0080 TCanvas canvas("c", "c", w, h);
0081
0082
0083 TLatex t1;
0084 t1.SetNDC();
0085 t1.SetTextAlign(26);
0086 t1.SetTextSize(0.05);
0087 t1.DrawLatex(0.5, 0.96, Form("Ecal TPGFine GrainEBGroup, IOV %i", run));
0088
0089 TPad** pad = new TPad*;
0090 for (int obj = 0; obj < 1; obj++) {
0091 pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), 0.0, 0.04, 1.0, 0.94);
0092 pad[obj]->Draw();
0093 }
0094 t1.SetTextSize(0.03);
0095 t1.DrawLatex(0.2, 0.88, Form("%i towers", EBcount));
0096
0097 pad[0]->cd();
0098
0099 barrel->SetMinimum(minEB);
0100 barrel->SetMaximum(maxEB);
0101 barrel->Draw("colz");
0102 TLine* l = new TLine(0., 0., 0., 0.);
0103 l->SetLineWidth(1);
0104 for (int i = 0; i < MAX_IETA; i++) {
0105 Double_t x = 4. + (i * 4);
0106 l = new TLine(x, -MAX_IETA, x, MAX_IETA);
0107 l->Draw();
0108 }
0109 l = new TLine(0., 0., 72., 0.);
0110 l->Draw();
0111
0112 std::string ImageName(m_imageFileName);
0113 canvas.SaveAs(ImageName.c_str());
0114 return true;
0115 }
0116 };
0117
0118 }
0119
0120
0121 PAYLOAD_INSPECTOR_MODULE(EcalTPGFineGrainEBGroup) { PAYLOAD_INSPECTOR_CLASS(EcalTPGFineGrainEBGroupPlot); }