HcalL1TriggerObjectContainer

HcalL1TriggerObjectsEtaPlot

HcalL1TriggerObjectsEtaRatio

HcalL1TriggerObjectsPhiPlot

HcalL1TriggerObjectsPhiRatio

HcalL1TriggerObjectsPlot

HcalL1TriggerObjectsRatio

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 196 197 198 199 200 201 202 203 204 205 206
#include "CondCore/Utilities/interface/PayloadInspectorModule.h"
#include "CondCore/Utilities/interface/PayloadInspector.h"
#include "CondCore/CondDB/interface/Time.h"
//#include "DataFormats/EcalDetId/interface/EBDetId.h"
//#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
//#include "Geometry/HcalCommonData/interface/HcalTopologyMode.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/HcalL1TriggerObjects.h"  //or L1TriggerObject.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 HcalL1TriggerObjectContainer
      : public HcalObjRepresent::HcalDataContainer<HcalL1TriggerObjects, HcalL1TriggerObject> {
  public:
    HcalL1TriggerObjectContainer(std::shared_ptr<HcalL1TriggerObjects> payload, unsigned int run)
        : HcalObjRepresent::HcalDataContainer<HcalL1TriggerObjects, HcalL1TriggerObject>(payload, run) {}
    float getValue(const HcalL1TriggerObject* trig) override { return trig->getRespGain(); }
  };

  /******************************************
     2d plot of HCAL L1TriggerObject of 1 IOV
  ******************************************/
  class HcalL1TriggerObjectsPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
  public:
    HcalL1TriggerObjectsPlot()
        : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload = fetchPayload(std::get<1>(iov));
      if (payload.get()) {
        HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(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 L1TriggerObject difference between 2 IOVs
  **********************************************************/
  class HcalL1TriggerObjectsRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
  public:
    HcalL1TriggerObjectsRatio()
        : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload1 = fetchPayload(std::get<1>(iov1));
      std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload(std::get<1>(iov2));

      if (payload1.get() && payload2.get()) {
        HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
        HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));

        objContainer2->Divide(objContainer1);

        std::string ImageName(m_imageFileName);
        objContainer2->getCanvasAll()->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;

    }  // fill method
  };
  /******************************************
     2d plot of HCAL L1TriggerObject of 1 IOV
  ******************************************/
  class HcalL1TriggerObjectsEtaPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
  public:
    HcalL1TriggerObjectsEtaPlot()
        : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload = fetchPayload(std::get<1>(iov));
      if (payload.get()) {
        HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(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 L1TriggerObject difference between 2 IOVs
  **********************************************************/
  class HcalL1TriggerObjectsEtaRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
  public:
    HcalL1TriggerObjectsEtaRatio()
        : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload1 = fetchPayload(std::get<1>(iov1));
      std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload(std::get<1>(iov2));

      if (payload1.get() && payload2.get()) {
        HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
        HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));

        objContainer2->Divide(objContainer1);

        std::string ImageName(m_imageFileName);
        objContainer2->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
        return true;
      } else
        return false;

    }  // fill method
  };
  /******************************************
     2d plot of HCAL L1TriggerObject of 1 IOV
  ******************************************/
  class HcalL1TriggerObjectsPhiPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
  public:
    HcalL1TriggerObjectsPhiPlot()
        : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload = fetchPayload(std::get<1>(iov));
      if (payload.get()) {
        HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(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 L1TriggerObject difference between 2 IOVs
  **********************************************************/
  class HcalL1TriggerObjectsPhiRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
  public:
    HcalL1TriggerObjectsPhiRatio()
        : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload1 = fetchPayload(std::get<1>(iov1));
      std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload(std::get<1>(iov2));

      if (payload1.get() && payload2.get()) {
        HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
        HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));

        objContainer2->Divide(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(HcalL1TriggerObjects) {
  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPlot);
  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsRatio);
  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsEtaPlot);
  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsEtaRatio);
  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPhiPlot);
  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPhiRatio);
}