Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004 //#include "DataFormats/EcalDetId/interface/EBDetId.h"
0005 //#include "DataFormats/EcalDetId/interface/EEDetId.h"
0006 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0007 //#include "Geometry/HcalCommonData/interface/HcalTopologyMode.h"
0008 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0009 #include "CondCore/HcalPlugins/interface/HcalObjRepresent.h"
0010 
0011 // the data format of the condition to be inspected
0012 #include "CondFormats/HcalObjects/interface/HcalGains.h"  //or Gain.h???
0013 
0014 #include "TH2F.h"
0015 #include "TCanvas.h"
0016 #include "TLine.h"
0017 #include "TStyle.h"
0018 #include "TLatex.h"
0019 #include "TPave.h"
0020 #include "TPaveStats.h"
0021 #include <string>
0022 #include <fstream>
0023 
0024 namespace {
0025 
0026   class HcalGainContainer : public HcalObjRepresent::HcalDataContainer<HcalGains, HcalGain> {
0027   public:
0028     HcalGainContainer(std::shared_ptr<HcalGains> payload, unsigned int run)
0029         : HcalObjRepresent::HcalDataContainer<HcalGains, HcalGain>(payload, run) {}
0030     float getValue(HcalGain* gain) override {
0031       return gain->getValue(0) + gain->getValue(1) + gain->getValue(2) + gain->getValue(3);
0032     }
0033   };
0034 
0035   /******************************************
0036      2d plot of HCAL Gain of 1 IOV
0037   ******************************************/
0038   class HcalGainsPlot : public cond::payloadInspector::PlotImage<HcalGains> {
0039   public:
0040     HcalGainsPlot() : cond::payloadInspector::PlotImage<HcalGains>("HCAL Gain Ratios - map ") { setSingleIov(true); }
0041 
0042     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0043       auto iov = iovs.front();
0044       std::shared_ptr<HcalGains> payload = fetchPayload(std::get<1>(iov));
0045       if (payload.get()) {
0046         HcalGainContainer* objContainer = new HcalGainContainer(payload, std::get<0>(iov));
0047         std::string ImageName(m_imageFileName);
0048         objContainer->getCanvasAll()->SaveAs(ImageName.c_str());
0049         return true;
0050       } else
0051         return false;
0052     }  // fill method
0053   };
0054 
0055   /**********************************************************
0056      2d plot of HCAL Gain ratios between 2 IOVs
0057   **********************************************************/
0058   class HcalGainsRatio : public cond::payloadInspector::PlotImage<HcalGains> {
0059   public:
0060     HcalGainsRatio() : cond::payloadInspector::PlotImage<HcalGains>("HCAL Gain Ratios difference") {
0061       setSingleIov(false);
0062     }
0063 
0064     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0065       auto iov1 = iovs.front();
0066       auto iov2 = iovs.back();
0067 
0068       std::shared_ptr<HcalGains> payload1 = fetchPayload(std::get<1>(iov1));
0069       std::shared_ptr<HcalGains> payload2 = fetchPayload(std::get<1>(iov2));
0070 
0071       if (payload1.get() && payload2.get()) {
0072         HcalGainContainer* objContainer1 = new HcalGainContainer(payload1, std::get<0>(iov1));
0073         HcalGainContainer* objContainer2 = new HcalGainContainer(payload2, std::get<0>(iov2));
0074 
0075         objContainer2->Divide(objContainer1);
0076 
0077         std::string ImageName(m_imageFileName);
0078         objContainer2->getCanvasAll()->SaveAs(ImageName.c_str());
0079         return true;
0080       } else
0081         return false;
0082 
0083     }  // fill method
0084   };
0085   /******************************************
0086      2d plot of HCAL Gain of 1 IOV, projected along iphi
0087   ******************************************/
0088   class HcalGainsPhiPlot : public cond::payloadInspector::PlotImage<HcalGains> {
0089   public:
0090     HcalGainsPhiPlot() : cond::payloadInspector::PlotImage<HcalGains>("HCAL Gain Ratios - map ") { setSingleIov(true); }
0091 
0092     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0093       auto iov = iovs.front();
0094       std::shared_ptr<HcalGains> payload = fetchPayload(std::get<1>(iov));
0095       if (payload.get()) {
0096         HcalGainContainer* objContainer = new HcalGainContainer(payload, std::get<0>(iov));
0097         std::string ImageName(m_imageFileName);
0098         objContainer->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
0099         return true;
0100       } else
0101         return false;
0102     }  // fill method
0103   };
0104 
0105   /**********************************************************
0106      2d plot of HCAL Gain ratios between 2 IOVs, projected along iphi
0107   **********************************************************/
0108   class HcalGainsPhiRatio : public cond::payloadInspector::PlotImage<HcalGains> {
0109   public:
0110     HcalGainsPhiRatio() : cond::payloadInspector::PlotImage<HcalGains>("HCAL Gain Ratios difference") {
0111       setSingleIov(false);
0112     }
0113 
0114     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0115       auto iov1 = iovs.front();
0116       auto iov2 = iovs.back();
0117 
0118       std::shared_ptr<HcalGains> payload1 = fetchPayload(std::get<1>(iov1));
0119       std::shared_ptr<HcalGains> payload2 = fetchPayload(std::get<1>(iov2));
0120 
0121       if (payload1.get() && payload2.get()) {
0122         HcalGainContainer* objContainer1 = new HcalGainContainer(payload1, std::get<0>(iov1));
0123         HcalGainContainer* objContainer2 = new HcalGainContainer(payload2, std::get<0>(iov2));
0124 
0125         objContainer2->Divide(objContainer1);
0126 
0127         std::string ImageName(m_imageFileName);
0128         objContainer2->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
0129         return true;
0130       } else
0131         return false;
0132 
0133     }  // fill method
0134   };
0135   /******************************************
0136      2d plot of HCAL Gain of 1 IOV, projected along ieta
0137   ******************************************/
0138   class HcalGainsEtaPlot : public cond::payloadInspector::PlotImage<HcalGains> {
0139   public:
0140     HcalGainsEtaPlot() : cond::payloadInspector::PlotImage<HcalGains>("HCAL Gain Ratios - map ") { setSingleIov(true); }
0141 
0142     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0143       auto iov = iovs.front();
0144       std::shared_ptr<HcalGains> payload = fetchPayload(std::get<1>(iov));
0145       if (payload.get()) {
0146         HcalGainContainer* objContainer = new HcalGainContainer(payload, std::get<0>(iov));
0147         std::string ImageName(m_imageFileName);
0148         objContainer->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
0149         return true;
0150       } else
0151         return false;
0152     }  // fill method
0153   };
0154 
0155   /**********************************************************
0156      2d plot of HCAL Gain ratios between 2 IOVs
0157   **********************************************************/
0158   class HcalGainsEtaRatio : public cond::payloadInspector::PlotImage<HcalGains> {
0159   public:
0160     HcalGainsEtaRatio() : cond::payloadInspector::PlotImage<HcalGains>("HCAL Gain Ratios difference") {
0161       setSingleIov(false);
0162     }
0163 
0164     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0165       auto iov1 = iovs.front();
0166       auto iov2 = iovs.back();
0167 
0168       std::shared_ptr<HcalGains> payload1 = fetchPayload(std::get<1>(iov1));
0169       std::shared_ptr<HcalGains> payload2 = fetchPayload(std::get<1>(iov2));
0170 
0171       if (payload1.get() && payload2.get()) {
0172         HcalGainContainer* objContainer1 = new HcalGainContainer(payload1, std::get<0>(iov1));
0173         HcalGainContainer* objContainer2 = new HcalGainContainer(payload2, std::get<0>(iov2));
0174 
0175         objContainer2->Divide(objContainer1);
0176 
0177         std::string ImageName(m_imageFileName);
0178         objContainer2->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
0179         return true;
0180       } else
0181         return false;
0182 
0183     }  // fill method
0184   };
0185 }  // namespace
0186 
0187 // Register the classes as boost python plugin
0188 PAYLOAD_INSPECTOR_MODULE(HcalGains) {
0189   PAYLOAD_INSPECTOR_CLASS(HcalGainsPlot);
0190   PAYLOAD_INSPECTOR_CLASS(HcalGainsRatio);
0191   PAYLOAD_INSPECTOR_CLASS(HcalGainsEtaPlot);
0192   PAYLOAD_INSPECTOR_CLASS(HcalGainsPhiPlot);
0193   PAYLOAD_INSPECTOR_CLASS(HcalGainsPhiRatio);
0194   PAYLOAD_INSPECTOR_CLASS(HcalGainsEtaRatio);
0195 }