Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 
0002 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0003 #include "CondCore/Utilities/interface/PayloadInspector.h"
0004 #include "CondCore/CondDB/interface/Time.h"
0005 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0006 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0007 #include "CondCore/HcalPlugins/interface/HcalObjRepresent.h"
0008 
0009 // the data format of the condition to be inspected
0010 #include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
0011 
0012 #include "TH2F.h"
0013 #include "TCanvas.h"
0014 #include "TLine.h"
0015 #include "TStyle.h"
0016 #include "TLatex.h"
0017 #include "TPave.h"
0018 #include "TPaveStats.h"
0019 #include <string>
0020 #include <fstream>
0021 
0022 namespace {
0023 
0024   class HcalRespCorrContainer : public HcalObjRepresent::HcalDataContainer<HcalRespCorrs, HcalRespCorr> {
0025   public:
0026     HcalRespCorrContainer(std::shared_ptr<HcalRespCorrs> payload, unsigned int run)
0027         : HcalObjRepresent::HcalDataContainer<HcalRespCorrs, HcalRespCorr>(payload, run) {}
0028     float getValue(HcalRespCorr* rCor) override { return rCor->getValue(); }
0029   };
0030 
0031   /******************************************
0032      2d plot of HCAL RespCorr of 1 IOV
0033   ******************************************/
0034   class HcalRespCorrsPlotAll : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0035   public:
0036     HcalRespCorrsPlotAll() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios - map ") {
0037       setSingleIov(true);
0038     }
0039 
0040     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0041       auto iov = iovs.front();
0042       std::shared_ptr<HcalRespCorrs> payload = fetchPayload(std::get<1>(iov));
0043       if (payload.get()) {
0044         HcalRespCorrContainer* objContainer = new HcalRespCorrContainer(payload, std::get<0>(iov));
0045         std::string ImageName(m_imageFileName);
0046         objContainer->getCanvasAll()->SaveAs(ImageName.c_str());
0047         return true;
0048       } else
0049         return false;
0050     }  // fill method
0051   };
0052 
0053   /**********************************************************
0054      2d plot of HCAL RespCorrs difference between 2 IOVs
0055   **********************************************************/
0056   class HcalRespCorrsRatioAll : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0057   public:
0058     HcalRespCorrsRatioAll() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios difference") {
0059       setSingleIov(false);
0060     }
0061 
0062     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0063       auto iov1 = iovs.front();
0064       auto iov2 = iovs.back();
0065 
0066       std::shared_ptr<HcalRespCorrs> payload1 = fetchPayload(std::get<1>(iov1));
0067       std::shared_ptr<HcalRespCorrs> payload2 = fetchPayload(std::get<1>(iov2));
0068 
0069       if (payload1.get() && payload2.get()) {
0070         HcalRespCorrContainer* objContainer1 = new HcalRespCorrContainer(payload1, std::get<0>(iov1));
0071         HcalRespCorrContainer* objContainer2 = new HcalRespCorrContainer(payload2, std::get<0>(iov2));
0072         objContainer2->Divide(objContainer1);
0073         std::string ImageName(m_imageFileName);
0074         objContainer2->getCanvasAll()->SaveAs(ImageName.c_str());
0075         return true;
0076       } else
0077         return false;
0078     }  // fill method
0079   };
0080   /******************************************
0081      2d plot of HCAL RespCorr of 1 IOV
0082   ******************************************/
0083   class HcalRespCorrsEtaPlotAll : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0084   public:
0085     HcalRespCorrsEtaPlotAll() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios - map ") {
0086       setSingleIov(true);
0087     }
0088 
0089     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0090       auto iov = iovs.front();
0091       std::shared_ptr<HcalRespCorrs> payload = fetchPayload(std::get<1>(iov));
0092       if (payload.get()) {
0093         HcalRespCorrContainer* objContainer = new HcalRespCorrContainer(payload, std::get<0>(iov));
0094         std::string ImageName(m_imageFileName);
0095         objContainer->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
0096         return true;
0097       } else
0098         return false;
0099     }  // fill method
0100   };
0101 
0102   /**********************************************************
0103      2d plot of HCAL RespCorrs difference between 2 IOVs
0104   **********************************************************/
0105   class HcalRespCorrsEtaRatioAll : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0106   public:
0107     HcalRespCorrsEtaRatioAll() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios difference") {
0108       setSingleIov(false);
0109     }
0110 
0111     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0112       auto iov1 = iovs.front();
0113       auto iov2 = iovs.back();
0114 
0115       std::shared_ptr<HcalRespCorrs> payload1 = fetchPayload(std::get<1>(iov1));
0116       std::shared_ptr<HcalRespCorrs> payload2 = fetchPayload(std::get<1>(iov2));
0117 
0118       if (payload1.get() && payload2.get()) {
0119         HcalRespCorrContainer* objContainer1 = new HcalRespCorrContainer(payload1, std::get<0>(iov1));
0120         HcalRespCorrContainer* objContainer2 = new HcalRespCorrContainer(payload2, std::get<0>(iov2));
0121         objContainer2->Divide(objContainer1);
0122         std::string ImageName(m_imageFileName);
0123         objContainer2->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
0124         return true;
0125       } else
0126         return false;
0127     }  // fill method
0128   };
0129   /******************************************
0130      2d plot of HCAL RespCorr of 1 IOV
0131   ******************************************/
0132   class HcalRespCorrsPhiPlotAll : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0133   public:
0134     HcalRespCorrsPhiPlotAll() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios - map ") {
0135       setSingleIov(true);
0136     }
0137 
0138     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0139       auto iov = iovs.front();
0140       std::shared_ptr<HcalRespCorrs> payload = fetchPayload(std::get<1>(iov));
0141       if (payload.get()) {
0142         HcalRespCorrContainer* objContainer = new HcalRespCorrContainer(payload, std::get<0>(iov));
0143         std::string ImageName(m_imageFileName);
0144         objContainer->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
0145         return true;
0146       } else
0147         return false;
0148     }  // fill method
0149   };
0150 
0151   /**********************************************************
0152      2d plot of HCAL RespCorrs difference between 2 IOVs
0153   **********************************************************/
0154   class HcalRespCorrsPhiRatioAll : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0155   public:
0156     HcalRespCorrsPhiRatioAll() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios difference") {
0157       setSingleIov(false);
0158     }
0159 
0160     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0161       auto iov1 = iovs.front();
0162       auto iov2 = iovs.back();
0163 
0164       std::shared_ptr<HcalRespCorrs> payload1 = fetchPayload(std::get<1>(iov1));
0165       std::shared_ptr<HcalRespCorrs> payload2 = fetchPayload(std::get<1>(iov2));
0166 
0167       if (payload1.get() && payload2.get()) {
0168         HcalRespCorrContainer* objContainer1 = new HcalRespCorrContainer(payload1, std::get<0>(iov1));
0169         HcalRespCorrContainer* objContainer2 = new HcalRespCorrContainer(payload2, std::get<0>(iov2));
0170         objContainer2->Divide(objContainer1);
0171         std::string ImageName(m_imageFileName);
0172         objContainer2->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
0173         return true;
0174       } else
0175         return false;
0176     }  // fill method
0177   };
0178   /******************************************
0179      2d plot of HCAL RespCorrs of 1 IOV
0180   ******************************************/
0181   class HcalRespCorrsPlotHBHO : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0182   public:
0183     HcalRespCorrsPlotHBHO() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios - map ") {
0184       setSingleIov(true);
0185     }
0186 
0187     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0188       auto iov = iovs.front();
0189       std::shared_ptr<HcalRespCorrs> payload = fetchPayload(std::get<1>(iov));
0190       if (payload.get()) {
0191         HcalRespCorrContainer* objContainer = new HcalRespCorrContainer(payload, std::get<0>(iov));
0192         std::string ImageName(m_imageFileName);
0193         objContainer->getCanvasHBHO()->SaveAs(ImageName.c_str());
0194         return true;
0195       } else
0196         return false;
0197     }  // fill method
0198   };
0199 
0200   /**********************************************************
0201      2d plot of HCAL RespCorr difference between 2 IOVs
0202   **********************************************************/
0203   class HcalRespCorrsRatioHBHO : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0204   public:
0205     HcalRespCorrsRatioHBHO() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios difference") {
0206       setSingleIov(false);
0207     }
0208 
0209     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0210       auto iov1 = iovs.front();
0211       auto iov2 = iovs.back();
0212 
0213       std::shared_ptr<HcalRespCorrs> payload1 = fetchPayload(std::get<1>(iov1));
0214       std::shared_ptr<HcalRespCorrs> payload2 = fetchPayload(std::get<1>(iov2));
0215 
0216       if (payload1.get() && payload2.get()) {
0217         HcalRespCorrContainer* objContainer1 = new HcalRespCorrContainer(payload1, std::get<0>(iov1));
0218         HcalRespCorrContainer* objContainer2 = new HcalRespCorrContainer(payload2, std::get<0>(iov2));
0219         objContainer2->Divide(objContainer1);
0220         std::string ImageName(m_imageFileName);
0221         objContainer2->getCanvasHBHO()->SaveAs(ImageName.c_str());
0222         return true;
0223       } else
0224         return false;
0225     }  // fill method
0226   };
0227   /******************************************
0228      2d plot of HCAL RespCorr of 1 IOV
0229   ******************************************/
0230   class HcalRespCorrsPlotHE : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0231   public:
0232     HcalRespCorrsPlotHE() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios - map ") {
0233       setSingleIov(true);
0234     }
0235 
0236     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0237       auto iov = iovs.front();
0238       std::shared_ptr<HcalRespCorrs> payload = fetchPayload(std::get<1>(iov));
0239       if (payload.get()) {
0240         HcalRespCorrContainer* objContainer = new HcalRespCorrContainer(payload, std::get<0>(iov));
0241         std::string ImageName(m_imageFileName);
0242         objContainer->getCanvasHE()->SaveAs(ImageName.c_str());
0243         return true;
0244       } else
0245         return false;
0246     }  // fill method
0247   };
0248 
0249   /**********************************************************
0250      2d plot of HCAL RespCorr difference between 2 IOVs
0251   **********************************************************/
0252   class HcalRespCorrsRatioHE : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0253   public:
0254     HcalRespCorrsRatioHE() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios difference") {
0255       setSingleIov(false);
0256     }
0257 
0258     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0259       auto iov1 = iovs.front();
0260       auto iov2 = iovs.back();
0261 
0262       std::shared_ptr<HcalRespCorrs> payload1 = fetchPayload(std::get<1>(iov1));
0263       std::shared_ptr<HcalRespCorrs> payload2 = fetchPayload(std::get<1>(iov2));
0264 
0265       if (payload1.get() && payload2.get()) {
0266         HcalRespCorrContainer* objContainer1 = new HcalRespCorrContainer(payload1, std::get<0>(iov1));
0267         HcalRespCorrContainer* objContainer2 = new HcalRespCorrContainer(payload2, std::get<0>(iov2));
0268         objContainer2->Divide(objContainer1);
0269         std::string ImageName(m_imageFileName);
0270         objContainer2->getCanvasHE()->SaveAs(ImageName.c_str());
0271         return true;
0272       } else
0273         return false;
0274     }  // fill method
0275   };
0276   /******************************************
0277      2d plot of HCAL RespCorr of 1 IOV
0278   ******************************************/
0279   class HcalRespCorrsPlotHF : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0280   public:
0281     HcalRespCorrsPlotHF() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios - map ") {
0282       setSingleIov(true);
0283     }
0284 
0285     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0286       auto iov = iovs.front();
0287       std::shared_ptr<HcalRespCorrs> payload = fetchPayload(std::get<1>(iov));
0288       if (payload.get()) {
0289         HcalRespCorrContainer* objContainer = new HcalRespCorrContainer(payload, std::get<0>(iov));
0290         std::string ImageName(m_imageFileName);
0291         objContainer->getCanvasHF()->SaveAs(ImageName.c_str());
0292         return true;
0293       } else
0294         return false;
0295     }  // fill method
0296   };
0297 
0298   /**********************************************************
0299      2d plot of HCAL RespCorrRatios difference between 2 IOVs
0300   **********************************************************/
0301   class HcalRespCorrsRatioHF : public cond::payloadInspector::PlotImage<HcalRespCorrs> {
0302   public:
0303     HcalRespCorrsRatioHF() : cond::payloadInspector::PlotImage<HcalRespCorrs>("HCAL RespCorr Ratios difference") {
0304       setSingleIov(false);
0305     }
0306 
0307     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0308       auto iov1 = iovs.front();
0309       auto iov2 = iovs.back();
0310 
0311       std::shared_ptr<HcalRespCorrs> payload1 = fetchPayload(std::get<1>(iov1));
0312       std::shared_ptr<HcalRespCorrs> payload2 = fetchPayload(std::get<1>(iov2));
0313 
0314       if (payload1.get() && payload2.get()) {
0315         HcalRespCorrContainer* objContainer1 = new HcalRespCorrContainer(payload1, std::get<0>(iov1));
0316         HcalRespCorrContainer* objContainer2 = new HcalRespCorrContainer(payload2, std::get<0>(iov2));
0317         objContainer2->Divide(objContainer1);
0318         std::string ImageName(m_imageFileName);
0319         objContainer2->getCanvasHF()->SaveAs(ImageName.c_str());
0320         return true;
0321       } else
0322         return false;
0323     }  // fill method
0324   };
0325 }  // namespace
0326 
0327 // Register the classes as boost python plugin
0328 PAYLOAD_INSPECTOR_MODULE(HcalRespCorrs) {
0329   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsPlotAll);
0330   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsRatioAll);
0331   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsEtaPlotAll);
0332   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsEtaRatioAll);
0333   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsPhiPlotAll);
0334   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsPhiRatioAll);
0335   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsPlotHBHO);
0336   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsRatioHBHO);
0337   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsPlotHE);
0338   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsRatioHE);
0339   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsPlotHF);
0340   PAYLOAD_INSPECTOR_CLASS(HcalRespCorrsRatioHF);
0341 }