File indexing completed on 2024-07-02 00:53:27
0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004
0005
0006 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0007
0008 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0009 #include "CondCore/HcalPlugins/interface/HcalObjRepresent.h"
0010
0011
0012 #include "CondFormats/HcalObjects/interface/HcalL1TriggerObjects.h" //or L1TriggerObject.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 HcalL1TriggerObjectContainer
0027 : public HcalObjRepresent::HcalDataContainer<HcalL1TriggerObjects, HcalL1TriggerObject> {
0028 public:
0029 HcalL1TriggerObjectContainer(std::shared_ptr<HcalL1TriggerObjects> payload, unsigned int run)
0030 : HcalObjRepresent::HcalDataContainer<HcalL1TriggerObjects, HcalL1TriggerObject>(payload, run) {}
0031 float getValue(const HcalL1TriggerObject* trig) override { return trig->getRespGain(); }
0032 };
0033
0034
0035
0036
0037 class HcalL1TriggerObjectsPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
0038 public:
0039 HcalL1TriggerObjectsPlot()
0040 : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios - map ") {
0041 setSingleIov(true);
0042 }
0043
0044 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0045 auto iov = iovs.front();
0046 std::shared_ptr<HcalL1TriggerObjects> payload = fetchPayload(std::get<1>(iov));
0047 if (payload.get()) {
0048 HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(payload, std::get<0>(iov));
0049 std::string ImageName(m_imageFileName);
0050 objContainer->getCanvasAll()->SaveAs(ImageName.c_str());
0051 return true;
0052 } else
0053 return false;
0054 }
0055 };
0056
0057
0058
0059
0060 class HcalL1TriggerObjectsRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
0061 public:
0062 HcalL1TriggerObjectsRatio()
0063 : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios difference") {
0064 setSingleIov(false);
0065 }
0066
0067 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0068 auto iov1 = iovs.front();
0069 auto iov2 = iovs.back();
0070
0071 std::shared_ptr<HcalL1TriggerObjects> payload1 = fetchPayload(std::get<1>(iov1));
0072 std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload(std::get<1>(iov2));
0073
0074 if (payload1.get() && payload2.get()) {
0075 HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
0076 HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));
0077
0078 objContainer2->Divide(objContainer1);
0079
0080 std::string ImageName(m_imageFileName);
0081 objContainer2->getCanvasAll()->SaveAs(ImageName.c_str());
0082 return true;
0083 } else
0084 return false;
0085
0086 }
0087 };
0088
0089
0090
0091 class HcalL1TriggerObjectsEtaPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
0092 public:
0093 HcalL1TriggerObjectsEtaPlot()
0094 : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios - map ") {
0095 setSingleIov(true);
0096 }
0097
0098 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0099 auto iov = iovs.front();
0100 std::shared_ptr<HcalL1TriggerObjects> payload = fetchPayload(std::get<1>(iov));
0101 if (payload.get()) {
0102 HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(payload, std::get<0>(iov));
0103 std::string ImageName(m_imageFileName);
0104 objContainer->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
0105 return true;
0106 } else
0107 return false;
0108 }
0109 };
0110
0111
0112
0113
0114 class HcalL1TriggerObjectsEtaRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
0115 public:
0116 HcalL1TriggerObjectsEtaRatio()
0117 : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios difference") {
0118 setSingleIov(false);
0119 }
0120
0121 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0122 auto iov1 = iovs.front();
0123 auto iov2 = iovs.back();
0124
0125 std::shared_ptr<HcalL1TriggerObjects> payload1 = fetchPayload(std::get<1>(iov1));
0126 std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload(std::get<1>(iov2));
0127
0128 if (payload1.get() && payload2.get()) {
0129 HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
0130 HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));
0131
0132 objContainer2->Divide(objContainer1);
0133
0134 std::string ImageName(m_imageFileName);
0135 objContainer2->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
0136 return true;
0137 } else
0138 return false;
0139
0140 }
0141 };
0142
0143
0144
0145 class HcalL1TriggerObjectsPhiPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
0146 public:
0147 HcalL1TriggerObjectsPhiPlot()
0148 : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios - map ") {
0149 setSingleIov(true);
0150 }
0151
0152 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0153 auto iov = iovs.front();
0154 std::shared_ptr<HcalL1TriggerObjects> payload = fetchPayload(std::get<1>(iov));
0155 if (payload.get()) {
0156 HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(payload, std::get<0>(iov));
0157 std::string ImageName(m_imageFileName);
0158 objContainer->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
0159 return true;
0160 } else
0161 return false;
0162 }
0163 };
0164
0165
0166
0167
0168 class HcalL1TriggerObjectsPhiRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
0169 public:
0170 HcalL1TriggerObjectsPhiRatio()
0171 : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios difference") {
0172 setSingleIov(false);
0173 }
0174
0175 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0176 auto iov1 = iovs.front();
0177 auto iov2 = iovs.back();
0178
0179 std::shared_ptr<HcalL1TriggerObjects> payload1 = fetchPayload(std::get<1>(iov1));
0180 std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload(std::get<1>(iov2));
0181
0182 if (payload1.get() && payload2.get()) {
0183 HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
0184 HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));
0185
0186 objContainer2->Divide(objContainer1);
0187
0188 std::string ImageName(m_imageFileName);
0189 objContainer2->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
0190 return true;
0191 } else
0192 return false;
0193
0194 }
0195 };
0196 }
0197
0198
0199 PAYLOAD_INSPECTOR_MODULE(HcalL1TriggerObjects) {
0200 PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPlot);
0201 PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsRatio);
0202 PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsEtaPlot);
0203 PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsEtaRatio);
0204 PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPhiPlot);
0205 PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPhiRatio);
0206 }