File indexing completed on 2024-09-07 04:35:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0010 #include "CondCore/Utilities/interface/PayloadInspector.h"
0011 #include "CondCore/CondDB/interface/Time.h"
0012
0013 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0014 #include "CondFormats/SiStripObjects/interface/SiStripBackPlaneCorrection.h"
0015
0016 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0017 #include "CondCore/SiStripPlugins/interface/SiStripPayloadInspectorHelper.h"
0018 #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"
0019
0020 #include <memory>
0021 #include <sstream>
0022
0023
0024 #include "TH2F.h"
0025 #include "TLegend.h"
0026 #include "TCanvas.h"
0027 #include "TLine.h"
0028 #include "TStyle.h"
0029 #include "TLatex.h"
0030 #include "TPave.h"
0031 #include "TPaveStats.h"
0032 #include "TGaxis.h"
0033
0034 namespace {
0035
0036 using namespace cond::payloadInspector;
0037
0038
0039
0040
0041
0042
0043 class SiStripBackPlaneCorrectionValue : public Histogram1D<SiStripBackPlaneCorrection, SINGLE_IOV> {
0044 public:
0045 SiStripBackPlaneCorrectionValue()
0046 : Histogram1D<SiStripBackPlaneCorrection, SINGLE_IOV>(
0047 "SiStrip BackPlaneCorrection values", "SiStrip BackPlaneCorrection values", 100, 0.0, 0.1) {}
0048
0049 bool fill() override {
0050 auto tag = PlotBase::getTag<0>();
0051 for (auto const &iov : tag.iovs) {
0052 std::shared_ptr<SiStripBackPlaneCorrection> payload = Base::fetchPayload(std::get<1>(iov));
0053 if (payload.get()) {
0054 std::map<uint32_t, float> BPMap_ = payload->getBackPlaneCorrections();
0055
0056 for (const auto &element : BPMap_) {
0057 fillWithValue(element.second);
0058 }
0059 }
0060 }
0061 return true;
0062 }
0063 };
0064
0065
0066
0067
0068 class SiStripBackPlaneCorrection_TrackerMap : public PlotImage<SiStripBackPlaneCorrection, SINGLE_IOV> {
0069 public:
0070 SiStripBackPlaneCorrection_TrackerMap()
0071 : PlotImage<SiStripBackPlaneCorrection, SINGLE_IOV>("Tracker Map SiStrip Backplane correction") {}
0072
0073 bool fill() override {
0074 auto tag = PlotBase::getTag<0>();
0075 auto iov = tag.iovs.front();
0076 std::shared_ptr<SiStripBackPlaneCorrection> payload = fetchPayload(std::get<1>(iov));
0077
0078 std::unique_ptr<TrackerMap> tmap = std::make_unique<TrackerMap>("SiStripBackPlaneCorrection");
0079 tmap->setPalette(1);
0080 std::string titleMap = "TrackerMap of SiStrip BP correction per module, payload : " + std::get<1>(iov);
0081 tmap->setTitle(titleMap);
0082
0083 std::map<uint32_t, float> BPMap_ = payload->getBackPlaneCorrections();
0084
0085 for (const auto &element : BPMap_) {
0086 tmap->fill(element.first, element.second);
0087 }
0088
0089 std::pair<float, float> extrema = tmap->getAutomaticRange();
0090
0091 std::string fileName(m_imageFileName);
0092
0093
0094 if (extrema.first != extrema.second) {
0095 tmap->save(true, 0, 0, fileName);
0096 } else {
0097 tmap->save(true, extrema.first * 0.95, extrema.first * 1.05, fileName);
0098 }
0099
0100 return true;
0101 }
0102 };
0103
0104
0105
0106
0107
0108 class SiStripBackPlaneCorrectionByRegion : public PlotImage<SiStripBackPlaneCorrection, SINGLE_IOV> {
0109 public:
0110 SiStripBackPlaneCorrectionByRegion()
0111 : PlotImage<SiStripBackPlaneCorrection, SINGLE_IOV>("SiStripBackPlaneCorrection By Region"),
0112 m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
0113 edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())} {}
0114
0115 bool fill() override {
0116 auto tag = PlotBase::getTag<0>();
0117 auto iov = tag.iovs.front();
0118 std::shared_ptr<SiStripBackPlaneCorrection> payload = fetchPayload(std::get<1>(iov));
0119
0120 SiStripDetSummary summaryBP{&m_trackerTopo};
0121
0122 std::map<uint32_t, float> BPMap_ = payload->getBackPlaneCorrections();
0123
0124 for (const auto &element : BPMap_) {
0125 summaryBP.add(element.first, element.second);
0126 }
0127
0128 std::map<unsigned int, SiStripDetSummary::Values> map = summaryBP.getCounts();
0129
0130
0131 TCanvas canvas("Partion summary", "partition summary", 1200, 1000);
0132 canvas.cd();
0133 auto h1 = std::make_unique<TH1F>(
0134 "byRegion",
0135 "SiStrip Backplane correction average by partition;; average SiStrip BackPlane Correction",
0136 map.size(),
0137 0.,
0138 map.size());
0139 h1->SetStats(false);
0140 canvas.SetBottomMargin(0.18);
0141 canvas.SetLeftMargin(0.17);
0142 canvas.SetRightMargin(0.05);
0143 canvas.Modified();
0144
0145 std::vector<int> boundaries;
0146 unsigned int iBin = 0;
0147
0148 std::string detector;
0149 std::string currentDetector;
0150
0151 for (const auto &element : map) {
0152 iBin++;
0153 int count = element.second.count;
0154 double mean = (element.second.mean) / count;
0155
0156 if (currentDetector.empty())
0157 currentDetector = "TIB";
0158
0159 switch ((element.first) / 1000) {
0160 case 1:
0161 detector = "TIB";
0162 break;
0163 case 2:
0164 detector = "TOB";
0165 break;
0166 case 3:
0167 detector = "TEC";
0168 break;
0169 case 4:
0170 detector = "TID";
0171 break;
0172 }
0173
0174 h1->SetBinContent(iBin, mean);
0175 h1->GetXaxis()->SetBinLabel(iBin, SiStripPI::regionType(element.first).second);
0176 h1->GetXaxis()->LabelsOption("v");
0177
0178 if (detector != currentDetector) {
0179 boundaries.push_back(iBin);
0180 currentDetector = detector;
0181 }
0182 }
0183
0184 h1->GetYaxis()->SetRangeUser(0., h1->GetMaximum() * 1.30);
0185 h1->SetMarkerStyle(20);
0186 h1->SetMarkerSize(1);
0187 h1->Draw("HIST");
0188 h1->Draw("Psame");
0189
0190 canvas.Update();
0191
0192 TLine l[boundaries.size()];
0193 unsigned int i = 0;
0194 for (const auto &line : boundaries) {
0195 l[i] = TLine(h1->GetBinLowEdge(line), canvas.GetUymin(), h1->GetBinLowEdge(line), canvas.GetUymax());
0196 l[i].SetLineWidth(1);
0197 l[i].SetLineStyle(9);
0198 l[i].SetLineColor(2);
0199 l[i].Draw("same");
0200 i++;
0201 }
0202
0203 TLegend legend = TLegend(0.52, 0.82, 0.95, 0.9);
0204 legend.SetHeader((std::get<1>(iov)).c_str(), "C");
0205 legend.AddEntry(h1.get(), ("IOV: " + std::to_string(std::get<0>(iov))).c_str(), "PL");
0206 legend.SetTextSize(0.025);
0207 legend.Draw("same");
0208
0209 std::string fileName(m_imageFileName);
0210 canvas.SaveAs(fileName.c_str());
0211
0212 return true;
0213 }
0214
0215 private:
0216 TrackerTopology m_trackerTopo;
0217 };
0218
0219 }
0220
0221 PAYLOAD_INSPECTOR_MODULE(SiStripBackPlaneCorrection) {
0222 PAYLOAD_INSPECTOR_CLASS(SiStripBackPlaneCorrectionValue);
0223 PAYLOAD_INSPECTOR_CLASS(SiStripBackPlaneCorrection_TrackerMap);
0224 PAYLOAD_INSPECTOR_CLASS(SiStripBackPlaneCorrectionByRegion);
0225 }