Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:40

0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/CondDB/interface/Time.h"
0004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0005 #include "CondCore/HcalPlugins/interface/HcalObjRepresent.h"
0006 
0007 // the data format of the condition to be inspected
0008 #include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristics.h"
0009 
0010 #include "TH2F.h"
0011 #include "TCanvas.h"
0012 #include "TLine.h"
0013 #include "TStyle.h"
0014 #include "TLatex.h"
0015 #include "TPave.h"
0016 #include "TPaveStats.h"
0017 #include <string>
0018 #include <fstream>
0019 
0020 namespace {
0021 
0022   /********************************************
0023      printing float values of reco paramters
0024   *********************************************/
0025   class HcalSiPMCharacteristicsSummary : public cond::payloadInspector::PlotImage<HcalSiPMCharacteristics> {
0026   public:
0027     HcalSiPMCharacteristicsSummary()
0028         : cond::payloadInspector::PlotImage<HcalSiPMCharacteristics>("HCAL RecoParam Ratios - map ") {
0029       setSingleIov(true);
0030     }
0031 
0032     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
0033       auto iov = iovs.front();
0034       std::shared_ptr<HcalSiPMCharacteristics> payload = fetchPayload(std::get<1>(iov));
0035       if (payload.get()) {
0036         std::string subDetName;
0037         std::vector<HcalSiPMCharacteristics> itemsVec;
0038         std::pair<std::string, int> valMap;
0039 
0040         //TODO: Abstract into a function that takes valMap as the argument
0041 
0042         TLatex label, val;
0043         TLine* ll;
0044         TCanvas* can = new TCanvas("RecoParamsSummary", "RecoParamsSummary", 2400, 1680);
0045         can->cd();
0046         //HcalObjRepresent::drawTable(2,2);
0047 
0048         label.SetNDC();
0049         label.SetTextAlign(26);
0050         label.SetTextSize(0.05);
0051         label.SetTextColor(2);
0052         label.DrawLatex(0.5, 0.96, Form("Hcal SiPM Characteristics"));
0053         std::vector<float> line;
0054         HcalObjRepresent::drawTable(7, 6);
0055 
0056         int nTypes = payload->getTypes();
0057         float startPosY = 0.9, endPosY = 0.1;
0058         float startPosX = 0.03, endPosX = 0.92;
0059         int type;
0060         std::vector<float>::iterator linEle;
0061         std::vector<std::string>::iterator linStrEle;
0062         int j = 0;
0063         float xDiff, yDiff;
0064         // Header line
0065         std::vector<std::string> lblline = {
0066             "Type", "Pixels", "parLin1", "parLin2", "parLin3", "crossTalk"};  //, aux1, aux2};
0067         xDiff = (endPosX - startPosX) / (lblline.size() - 1);
0068         yDiff = (startPosY - endPosY) / nTypes;
0069 
0070         label.SetTextAlign(12);
0071         label.SetTextSize(0.05);
0072         label.SetTextColor(1);
0073         ll = new TLine(
0074             startPosX - 0.2 * xDiff, startPosY + 0.5 * yDiff, startPosX - 0.2 * xDiff, startPosY - 0.5 * yDiff);
0075         ll->Draw();
0076         for (linStrEle = lblline.begin(); linStrEle != lblline.end(); ++linStrEle) {
0077           ll = new TLine(startPosX + (j + 0.5) * xDiff,
0078                          startPosY + 0.5 * yDiff,
0079                          startPosX + (j + 0.5) * xDiff,
0080                          startPosY - 0.5 * yDiff);
0081           label.DrawLatex(startPosX + (j == 0 ? -0.1 : (j - 0.4)) * xDiff, startPosY, (*linStrEle).c_str());
0082           ll->Draw();
0083           j++;
0084         }
0085         ll = new TLine(0, startPosY - 0.5 * yDiff, 1, startPosY - 0.5 * yDiff);
0086         ll->Draw();
0087 
0088         val.SetNDC();
0089         val.SetTextAlign(26);
0090         val.SetTextSize(0.035);
0091         for (int i = 0; i < nTypes; i++) {
0092           type = payload->getType(i);
0093 
0094           line = {(float)type,
0095                   (float)payload->getPixels(type),
0096                   payload->getNonLinearities(type).at(0),
0097                   payload->getNonLinearities(type).at(1),
0098                   payload->getNonLinearities(type).at(2),
0099                   payload->getCrossTalk(type)};
0100           ll = new TLine(startPosX - 0.2 * xDiff,
0101                          startPosY - (i + 0.5) * yDiff,
0102                          startPosX - 0.2 * xDiff,
0103                          startPosY - (i + 1.5) * yDiff);
0104           ll->Draw();
0105           j = 0;
0106 
0107           for (linEle = line.begin(); linEle != line.end(); ++linEle) {
0108             ll = new TLine(startPosX + (j + 0.5) * xDiff,
0109                            startPosY - (i + 0.5) * yDiff,
0110                            startPosX + (j + 0.5) * xDiff,
0111                            startPosY - (i + 1.5) * yDiff);
0112             val.DrawLatex(
0113                 startPosX + j * xDiff, startPosY - (i + 1) * yDiff, HcalObjRepresent::SciNotatStr((*linEle)).c_str());
0114             ll->Draw();
0115             j++;
0116           }
0117         }
0118 
0119         std::string ImageName(m_imageFileName);
0120         can->SaveAs(ImageName.c_str());
0121         return false;
0122       } else
0123         return false;
0124     }  // fill method
0125   };
0126   //TODO: Add a Change Summary?
0127 
0128 }  // namespace
0129 
0130 // Register the classes as boost python plugin
0131 PAYLOAD_INSPECTOR_MODULE(HcalSiPMCharacteristics) { PAYLOAD_INSPECTOR_CLASS(HcalSiPMCharacteristicsSummary); }