Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:07

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/EcalTPGFineGrainTowerEE.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 
0022   /***********************************************
0023    2d plot of EcalTPGFineGrainTowerEE of 1 IOV
0024 ************************************************/
0025   class EcalTPGFineGrainTowerEEPlot : public cond::payloadInspector::PlotImage<EcalTPGFineGrainTowerEE> {
0026   public:
0027     EcalTPGFineGrainTowerEEPlot()
0028         : cond::payloadInspector::PlotImage<EcalTPGFineGrainTowerEE>("EcalTPGFineGrainTowerEE - map ") {
0029       setSingleIov(true);
0030     }
0031 
0032     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0033       TH2F* endc_p = new TH2F("EE+", "EE+ Tower TPG FineGrain", 22, 0, 22, 22, 0, 22);
0034       TH2F* endc_m = new TH2F("EE-", "EE- Tower TPG FineGrain", 22, 0, 22, 22, 0, 22);
0035 
0036       auto iov = iovs.front();
0037       std::shared_ptr<EcalTPGFineGrainTowerEE> payload = fetchPayload(std::get<1>(iov));
0038       unsigned int run = std::get<0>(iov);
0039       double minEE = 0, maxEE = 1;
0040 
0041       if (payload.get()) {
0042         const EcalTPGFineGrainTowerEEMap& towerMap = (*payload).getMap();
0043 
0044         EcalTPGFineGrainTowerEEMapIterator it;
0045         for (it = towerMap.begin(); it != towerMap.end(); ++it) {
0046           if (EcalScDetId::validHashIndex((*it).first)) {
0047             EcalScDetId ttId = EcalScDetId::unhashIndex((*it).first);
0048 
0049             int ix = ttId.ix();
0050             int iy = ttId.iy();
0051             int zside = ttId.zside();
0052 
0053             uint32_t weight = (uint32_t)((*it).second);
0054 
0055             if (zside == -1)
0056               endc_m->Fill(ix, iy, weight);
0057             else
0058               endc_p->Fill(ix, iy, weight);
0059 
0060             if (maxEE < weight)
0061               maxEE = weight;
0062 
0063             if (minEE > weight)
0064               minEE = weight;
0065           }
0066         }  //tower map
0067       }    //payload
0068 
0069       TCanvas canvas("CC map", "CC map", 800, 800);
0070       TLatex t1;
0071       t1.SetNDC();
0072       t1.SetTextAlign(26);
0073       t1.SetTextSize(0.05);
0074       t1.DrawLatex(0.5, 0.96, Form("Ecal TPGFineGrain Tower EE, IOV %i", run));
0075 
0076       TPad* padem = new TPad("padem", "padem", 0., 0.3, 0.45, 0.75);
0077       padem->Draw();
0078       TPad* padep = new TPad("padep", "padep", 0.55, 0.3, 1., 0.75);
0079       padep->Draw();
0080 
0081       TLine* l = new TLine(0., 0., 72., 0.);
0082       l->Draw();
0083 
0084       padem->cd();
0085       DrawEE_Tower(endc_m, l, minEE, maxEE);
0086 
0087       padep->cd();
0088       DrawEE_Tower(endc_p, l, minEE, maxEE);
0089 
0090       std::string ImageName(m_imageFileName);
0091       canvas.SaveAs(ImageName.c_str());
0092 
0093       return true;
0094     }  // fill method
0095   };
0096 
0097 }  // namespace
0098 
0099 // Register the classes as boost python plugin
0100 PAYLOAD_INSPECTOR_MODULE(EcalTPGFineGrainTowerEE) { PAYLOAD_INSPECTOR_CLASS(EcalTPGFineGrainTowerEEPlot); }