File indexing completed on 2024-08-09 23:47:03
0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/EcalPlugins/plugins/EcalDrawUtils.h"
0004
0005
0006 #include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"
0007
0008 #include "TProfile.h"
0009 #include "TCanvas.h"
0010 #include "TStyle.h"
0011 #include "TLine.h"
0012 #include "TLatex.h"
0013 #include "TMarker.h"
0014
0015 #include <string>
0016
0017 namespace {
0018
0019
0020
0021 class EcalSimPulseShapeProfile : public cond::payloadInspector::PlotImage<EcalSimPulseShape> {
0022 public:
0023 EcalSimPulseShapeProfile() : cond::payloadInspector::PlotImage<EcalSimPulseShape>("ECAL SimPulseShape - Profile ") {
0024 setSingleIov(true);
0025 }
0026
0027 bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
0028 auto iov = iovs.front();
0029 std::shared_ptr<EcalSimPulseShape> payload = fetchPayload(std::get<1>(iov));
0030 unsigned int run = std::get<0>(iov);
0031 TProfile *barrel, *endcap, *apd;
0032 int EBnbin = 0, EEnbin = 0, APDnbin = 0;
0033 double EBxmax, EExmax, APDxmax, EBth, EEth, APDth;
0034 if (payload.get()) {
0035 EBth = (*payload).barrel_thresh;
0036 EEth = (*payload).endcap_thresh;
0037 APDth = (*payload).apd_thresh;
0038 double time = (*payload).time_interval;
0039 std::vector<double> EBshape = (*payload).barrel_shape;
0040 std::vector<double> EEshape = (*payload).endcap_shape;
0041 std::vector<double> APDshape = (*payload).apd_shape;
0042 EBnbin = EBshape.size();
0043 EBxmax = EBnbin * time;
0044 EEnbin = EBshape.size();
0045 EExmax = EEnbin * time;
0046 APDnbin = APDshape.size();
0047 APDxmax = APDnbin * time;
0048
0049
0050
0051
0052
0053 barrel = new TProfile("EBshape", "", EBnbin, 0, EBxmax);
0054 endcap = new TProfile("EEshape", "", EEnbin, 0, EExmax);
0055 apd = new TProfile("APDshape", "", APDnbin, 0, APDxmax);
0056 for (int s = 0; s < EBnbin; s++) {
0057 double val = EBshape[s];
0058 barrel->Fill(s * time, val);
0059 }
0060 for (int s = 0; s < EEnbin; s++) {
0061 double val = EEshape[s];
0062 endcap->Fill(s * time, val);
0063 }
0064 for (int s = 0; s < APDnbin; s++) {
0065 double val = APDshape[s];
0066 apd->Fill(s * time, val);
0067 }
0068 }
0069 else
0070 return false;
0071
0072
0073 gStyle->SetOptStat(0);
0074 TCanvas canvas("ESPS", "ESPS", 1000, 500);
0075 TLatex t1;
0076 t1.SetNDC();
0077 t1.SetTextAlign(26);
0078 t1.SetTextSize(0.05);
0079 t1.DrawLatex(0.5, 0.96, Form("Sim Pulse Shape, IOV %i", run));
0080
0081 if (EBnbin == EEnbin && EBnbin == APDnbin) {
0082 TPad *pad = new TPad("p_0", "p_0", 0.0, 0.0, 1.0, 0.95);
0083 pad->Draw();
0084 pad->cd();
0085 barrel->SetXTitle("time (ns)");
0086 barrel->SetYTitle("normalized amplitude (ADC#)");
0087 barrel->SetMarkerColor(kBlack);
0088 barrel->SetMarkerStyle(24);
0089
0090 barrel->Draw("P");
0091 TMarker *EBMarker = new TMarker(0.58, 0.85, 24);
0092 EBMarker->SetNDC();
0093 EBMarker->SetMarkerSize(1.0);
0094 EBMarker->SetMarkerColor(kBlack);
0095 EBMarker->Draw();
0096 t1.SetTextAlign(12);
0097 t1.DrawLatex(0.59, 0.85, Form("EB pulse, threshold %f", EBth));
0098
0099 endcap->SetMarkerColor(kRed);
0100 endcap->SetMarkerStyle(24);
0101
0102 endcap->Draw("PSAME");
0103 TMarker *EEMarker = new TMarker(0.58, 0.78, 24);
0104 EEMarker->SetNDC();
0105 EEMarker->SetMarkerSize(1.0);
0106 EEMarker->SetMarkerColor(kRed);
0107 EEMarker->Draw();
0108 t1.SetTextColor(kRed);
0109 t1.DrawLatex(0.59, 0.78, Form("EE pulse, threshold %f", EEth));
0110
0111 apd->SetMarkerColor(kBlue);
0112 apd->SetMarkerStyle(24);
0113
0114 apd->Draw("PSAME");
0115 TMarker *APDMarker = new TMarker(0.58, 0.71, 24);
0116 APDMarker->SetNDC();
0117 APDMarker->SetMarkerSize(1.0);
0118 APDMarker->SetMarkerColor(kBlue);
0119 APDMarker->Draw();
0120 t1.SetTextColor(kBlue);
0121 t1.DrawLatex(0.59, 0.71, Form("APD pulse, threshold %f", APDth));
0122 } else {
0123 canvas.SetCanvasSize(1000, 1000);
0124 TPad **pad = new TPad *[3];
0125 for (int s = 0; s < 3; s++) {
0126 float yma = 0.94 - (0.31 * s);
0127 float ymi = yma - 0.29;
0128 pad[s] = new TPad(Form("p_%i", s), Form("p_%i", s), 0.0, ymi, 1.0, yma);
0129 pad[s]->Draw();
0130 }
0131 pad[0]->cd();
0132 barrel->Draw("P");
0133 barrel->SetXTitle("time (ns)");
0134 barrel->SetYTitle("normalized amplitude (ADC#)");
0135 barrel->SetMarkerColor(kBlack);
0136 barrel->SetMarkerStyle(24);
0137 TMarker *EBMarker = new TMarker(0.58, 0.80, 24);
0138 EBMarker->SetNDC();
0139 EBMarker->Draw();
0140 EBMarker->SetMarkerSize(1.0);
0141 EBMarker->SetMarkerColor(kBlack);
0142 t1.SetTextAlign(12);
0143 t1.DrawLatex(0.59, 0.80, Form("EB pulse, threshold %f", EBth));
0144
0145 pad[1]->cd();
0146 endcap->SetMarkerStyle(24);
0147 endcap->SetMarkerColor(kRed);
0148 endcap->Draw("P");
0149 endcap->SetXTitle("time (ns)");
0150 endcap->SetYTitle("normalized amplitude (ADC#)");
0151 TMarker *EEMarker = new TMarker(0.58, 0.8, 24);
0152 EEMarker->SetNDC();
0153 EEMarker->Draw();
0154 EEMarker->SetMarkerSize(1.0);
0155 EEMarker->SetMarkerColor(kRed);
0156 t1.SetTextColor(kRed);
0157 t1.DrawLatex(0.59, 0.80, Form("EE pulse, threshold %f", EEth));
0158
0159 pad[2]->cd();
0160 apd->SetMarkerStyle(24);
0161 apd->Draw("P");
0162 apd->SetMarkerColor(kBlue);
0163 apd->SetXTitle("time (ns)");
0164 apd->SetYTitle("normalized amplitude (ADC#)");
0165 TMarker *APDMarker = new TMarker(0.58, 0.8, 24);
0166 APDMarker->SetNDC();
0167 APDMarker->Draw();
0168 APDMarker->SetMarkerSize(1.0);
0169 APDMarker->SetMarkerColor(kBlue);
0170 t1.SetTextColor(kBlue);
0171 t1.DrawLatex(0.59, 0.80, Form("APD pulse, threshold %f", APDth));
0172 }
0173 std::string ImageName(m_imageFileName);
0174 canvas.SaveAs(ImageName.c_str());
0175 return true;
0176 }
0177 };
0178
0179 }
0180
0181
0182 PAYLOAD_INSPECTOR_MODULE(EcalSimPulseShape) { PAYLOAD_INSPECTOR_CLASS(EcalSimPulseShapeProfile); }