HcalPedestalWidthContainer

HcalPedestalWidthsDiff

HcalPedestalWidthsEtaDiff

HcalPedestalWidthsEtaPlot

HcalPedestalWidthsPhiDiff

HcalPedestalWidthsPhiPlot

HcalPedestalWidthsPlot

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
#include "CondCore/Utilities/interface/PayloadInspectorModule.h"
#include "CondCore/Utilities/interface/PayloadInspector.h"
#include "CondCore/CondDB/interface/Time.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "CondCore/HcalPlugins/interface/HcalObjRepresent.h"

// the data format of the condition to be inspected
#include "CondFormats/HcalObjects/interface/HcalPedestalWidths.h"

#include "TH2F.h"
#include "TCanvas.h"
#include "TLine.h"
#include "TStyle.h"
#include "TLatex.h"
#include "TPave.h"
#include "TPaveStats.h"
#include <string>
#include <fstream>

namespace {

  class HcalPedestalWidthContainer : public HcalObjRepresent::HcalDataContainer<HcalPedestalWidths, HcalPedestalWidth> {
  public:
    HcalPedestalWidthContainer(std::shared_ptr<HcalPedestalWidths> payload, unsigned int run)
        : HcalObjRepresent::HcalDataContainer<HcalPedestalWidths, HcalPedestalWidth>(payload, run) {}
    float getValue(const HcalPedestalWidth* ped) override {
      return (ped->getWidth(0) + ped->getWidth(1) + ped->getWidth(2) + ped->getWidth(3)) / 4;
    }
  };

  /******************************************
     2d plot of HCAL PedestalWidth of 1 IOV
  ******************************************/
  class HcalPedestalWidthsPlot : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
  public:
    HcalPedestalWidthsPlot()
        : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios - map ") {
      setSingleIov(true);
    }

    bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
      auto iov = iovs.front();
      std::shared_ptr<HcalPedestalWidths> payload = fetchPayload(std::get<1>(iov));
      if (payload.get()) {
        HcalPedestalWidthContainer* objContainer = new HcalPedestalWidthContainer(payload, std::get<0>(iov));
        std::string ImageName(m_imageFileName);
        objContainer->getCanvasAll()->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;
    }  // fill method
  };

  /**********************************************************
     2d plot of HCAL PedestalWidth difference between 2 IOVs
  **********************************************************/
  class HcalPedestalWidthsDiff : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
  public:
    HcalPedestalWidthsDiff()
        : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios difference") {
      setSingleIov(false);
    }

    bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
      auto iov1 = iovs.front();
      auto iov2 = iovs.back();

      std::shared_ptr<HcalPedestalWidths> payload1 = fetchPayload(std::get<1>(iov1));
      std::shared_ptr<HcalPedestalWidths> payload2 = fetchPayload(std::get<1>(iov2));

      if (payload1.get() && payload2.get()) {
        HcalPedestalWidthContainer* objContainer1 = new HcalPedestalWidthContainer(payload1, std::get<0>(iov1));
        HcalPedestalWidthContainer* objContainer2 = new HcalPedestalWidthContainer(payload2, std::get<0>(iov2));
        objContainer2->Subtract(objContainer1);
        std::string ImageName(m_imageFileName);
        objContainer2->getCanvasAll()->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;
    }  // fill method
  };
  /******************************************
     2d plot of HCAL PedestalWidth of 1 IOV
  ******************************************/
  class HcalPedestalWidthsEtaPlot : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
  public:
    HcalPedestalWidthsEtaPlot()
        : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios - map ") {
      setSingleIov(true);
    }

    bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
      auto iov = iovs.front();
      std::shared_ptr<HcalPedestalWidths> payload = fetchPayload(std::get<1>(iov));
      if (payload.get()) {
        HcalPedestalWidthContainer* objContainer = new HcalPedestalWidthContainer(payload, std::get<0>(iov));
        std::string ImageName(m_imageFileName);
        objContainer->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;
    }  // fill method
  };

  /**********************************************************
     2d plot of HCAL PedestalWidth difference between 2 IOVs
  **********************************************************/
  class HcalPedestalWidthsEtaDiff : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
  public:
    HcalPedestalWidthsEtaDiff()
        : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios difference") {
      setSingleIov(false);
    }

    bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
      auto iov1 = iovs.front();
      auto iov2 = iovs.back();

      std::shared_ptr<HcalPedestalWidths> payload1 = fetchPayload(std::get<1>(iov1));
      std::shared_ptr<HcalPedestalWidths> payload2 = fetchPayload(std::get<1>(iov2));

      if (payload1.get() && payload2.get()) {
        HcalPedestalWidthContainer* objContainer1 = new HcalPedestalWidthContainer(payload1, std::get<0>(iov1));
        HcalPedestalWidthContainer* objContainer2 = new HcalPedestalWidthContainer(payload2, std::get<0>(iov2));
        objContainer2->Subtract(objContainer1);
        std::string ImageName(m_imageFileName);
        objContainer2->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;
    }  // fill method
  };
  /******************************************
     2d plot of HCAL PedestalWidth of 1 IOV
  ******************************************/
  class HcalPedestalWidthsPhiPlot : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
  public:
    HcalPedestalWidthsPhiPlot()
        : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios - map ") {
      setSingleIov(true);
    }

    bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
      auto iov = iovs.front();
      std::shared_ptr<HcalPedestalWidths> payload = fetchPayload(std::get<1>(iov));
      if (payload.get()) {
        HcalPedestalWidthContainer* objContainer = new HcalPedestalWidthContainer(payload, std::get<0>(iov));
        std::string ImageName(m_imageFileName);
        objContainer->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;
    }  // fill method
  };

  /**********************************************************
     2d plot of HCAL PedestalWidth difference between 2 IOVs
  **********************************************************/
  class HcalPedestalWidthsPhiDiff : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
  public:
    HcalPedestalWidthsPhiDiff()
        : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios difference") {
      setSingleIov(false);
    }

    bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
      auto iov1 = iovs.front();
      auto iov2 = iovs.back();

      std::shared_ptr<HcalPedestalWidths> payload1 = fetchPayload(std::get<1>(iov1));
      std::shared_ptr<HcalPedestalWidths> payload2 = fetchPayload(std::get<1>(iov2));

      if (payload1.get() && payload2.get()) {
        HcalPedestalWidthContainer* objContainer1 = new HcalPedestalWidthContainer(payload1, std::get<0>(iov1));
        HcalPedestalWidthContainer* objContainer2 = new HcalPedestalWidthContainer(payload2, std::get<0>(iov2));
        objContainer2->Subtract(objContainer1);
        std::string ImageName(m_imageFileName);
        objContainer2->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;
    }  // fill method
  };
}  // namespace

// Register the classes as boost python plugin
PAYLOAD_INSPECTOR_MODULE(HcalPedestalWidths) {
  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsPlot);
  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsDiff);
  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsPhiPlot);
  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsPhiDiff);
  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsEtaPlot);
  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsEtaDiff);
}