Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:33

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 // the data format of the condition to be inspected
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 };  // barrel lower and upper bounds on eta and phi
0023 
0024   /***********************************************
0025      2d plot of EcalTPGFineGrainEBGroup of 1 IOV
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           //EcalTrigTowerDetId ttId = EcalTrigTowerDetId::detIdFromDenseIndex((*it).first);
0049           EcalTrigTowerDetId ttId((*it).first);
0050           int ieta = ttId.ieta();
0051           //ieta--;
0052           if (ieta > 0)
0053             ieta--;                    // -1 to -17
0054           int iphi = ttId.iphi() - 1;  // 0 to 71
0055           // std::cout << " sub det " << ttId.subDet() << " phi " << iphi << " eta " << ieta << std::endl;
0056           // ieta goes from -18 to -2 and 1 to 17. Change it to -17/-1 and 0/16
0057 
0058           //std::cout <<(*it).first<<std::endl;
0059           //std::cout << " ieta " << ieta << " phi " << iphi << " value " << (*it).second << std::endl;
0060 
0061           if (ttId.subDet() == 1) {  // barrel
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       }  // payload
0074 
0075       gStyle->SetPalette(1);
0076       gStyle->SetOptStat(0);
0077       //      TCanvas canvas("CC map","CC map", 1600, 450);
0078       Double_t w = 1400;
0079       Double_t h = 1200;
0080       TCanvas canvas("c", "c", w, h);
0081       //      canvas.SetWindowSize(w + (w - canvas.GetWw()), h + (h - canvas.GetWh()));
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       //      canvas.cd();
0097       pad[0]->cd();
0098       //barrel->SetStats(0);
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     }  // fill method
0116   };
0117 
0118 }  // namespace
0119 
0120 // Register the classes as boost python plugin
0121 PAYLOAD_INSPECTOR_MODULE(EcalTPGFineGrainEBGroup) { PAYLOAD_INSPECTOR_CLASS(EcalTPGFineGrainEBGroupPlot); }