CMS 3D CMS Logo

SiPixelQuality_PayloadInspector.cc
Go to the documentation of this file.
1 
10 
17 
18 // the data format of the condition to be inspected
24 
25 #include <memory>
26 #include <sstream>
27 #include <iostream>
28 
29 // include ROOT
30 #include "TH2F.h"
31 #include "TLegend.h"
32 #include "TCanvas.h"
33 #include "TLine.h"
34 #include "TGraph.h"
35 #include "TStyle.h"
36 #include "TLatex.h"
37 #include "TPave.h"
38 #include "TPaveStats.h"
39 
40 namespace {
41 
42  /************************************************
43  test class
44  *************************************************/
45 
46  class SiPixelQualityTest
47  : public cond::payloadInspector::Histogram1D<SiPixelQuality, cond::payloadInspector::SINGLE_IOV> {
48  public:
49  SiPixelQualityTest()
50  : cond::payloadInspector::Histogram1D<SiPixelQuality, cond::payloadInspector::SINGLE_IOV>(
51  "SiPixelQuality test", "SiPixelQuality test", 10, 0.0, 10.0) {}
52 
53  bool fill() override {
54  auto tag = PlotBase::getTag<0>();
55  for (auto const& iov : tag.iovs) {
56  std::shared_ptr<SiPixelQuality> payload = Base::fetchPayload(std::get<1>(iov));
57  if (payload.get()) {
58  fillWithValue(1.);
59 
60  auto theDisabledModules = payload->getBadComponentList();
61  for (const auto& mod : theDisabledModules) {
62  int BadRocCount(0);
63  for (unsigned short n = 0; n < 16; n++) {
64  unsigned short mask = 1 << n; // 1 << n = 2^{n} using bitwise shift
65  if (mod.BadRocs & mask)
66  BadRocCount++;
67  }
68  COUT << "detId:" << mod.DetID << " error type:" << mod.errorType << " BadRocs:" << BadRocCount << std::endl;
69  }
70  } // payload
71  } // iovs
72  return true;
73  } // fill
74  };
75 
76  /************************************************
77  summary class
78  *************************************************/
79 
80  class SiPixelQualityBadRocsSummary
81  : public cond::payloadInspector::PlotImage<SiPixelQuality, cond::payloadInspector::MULTI_IOV, 1> {
82  public:
83  SiPixelQualityBadRocsSummary()
84  : cond::payloadInspector::PlotImage<SiPixelQuality, cond::payloadInspector::MULTI_IOV, 1>(
85  "SiPixel Quality Summary") {}
86 
87  bool fill() override {
88  auto tag = PlotBase::getTag<0>();
89  for (const auto& iov : tag.iovs) {
90  std::shared_ptr<SiPixelQuality> payload = fetchPayload(std::get<1>(iov));
91  auto unpacked = SiPixelPI::unpack(std::get<0>(iov));
92 
93  COUT << "======================= " << unpacked.first << " : " << unpacked.second << std::endl;
94  auto theDisabledModules = payload->getBadComponentList();
95  for (const auto& mod : theDisabledModules) {
96  COUT << "detId: " << mod.DetID << " |error type: " << mod.errorType << " |BadRocs: " << mod.BadRocs
97  << std::endl;
98  }
99  }
100 
101  //=========================
102  TCanvas canvas("Partion summary", "partition summary", 1200, 1000);
104  canvas.cd();
105  canvas.SetBottomMargin(0.11);
106  canvas.SetLeftMargin(0.13);
107  canvas.SetRightMargin(0.05);
108  canvas.Modified();
109 
110  std::string fileName(m_imageFileName);
111  canvas.SaveAs(fileName.c_str());
112 
113  return true;
114  }
115  };
116 
117  /************************************************
118  time history class
119  *************************************************/
120 
121  class SiPixelQualityBadRocsTimeHistory
122  : public cond::payloadInspector::TimeHistoryPlot<SiPixelQuality, std::pair<double, double> > {
123  public:
124  SiPixelQualityBadRocsTimeHistory()
125  : cond::payloadInspector::TimeHistoryPlot<SiPixelQuality, std::pair<double, double> >("bad ROCs count vs time",
126  "bad ROCs count") {}
127 
128  std::pair<double, double> getFromPayload(SiPixelQuality& payload) override {
129  return std::make_pair(extractBadRocCount(payload), 0.);
130  }
131 
132  unsigned int extractBadRocCount(SiPixelQuality& payload) {
133  unsigned int BadRocCount(0);
134  auto theDisabledModules = payload.getBadComponentList();
135  for (const auto& mod : theDisabledModules) {
136  for (unsigned short n = 0; n < 16; n++) {
137  unsigned short mask = 1 << n; // 1 << n = 2^{n} using bitwise shift
138  if (mod.BadRocs & mask)
139  BadRocCount++;
140  }
141  }
142  return BadRocCount;
143  }
144  };
145 
146  /************************************************
147  occupancy style map BPix
148  *************************************************/
149 
150  class SiPixelBPixQualityMap
151  : public cond::payloadInspector::PlotImage<SiPixelQuality, cond::payloadInspector::SINGLE_IOV> {
152  public:
153  SiPixelBPixQualityMap()
154  : cond::payloadInspector::PlotImage<SiPixelQuality, cond::payloadInspector::SINGLE_IOV>(
155  "SiPixelQuality Barrel Pixel Map"),
157  edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {}
158 
159  bool fill() override {
160  auto tag = PlotBase::getTag<0>();
161  auto iov = tag.iovs.front();
162  std::shared_ptr<SiPixelQuality> payload = fetchPayload(std::get<1>(iov));
163 
164  Phase1PixelROCMaps theBPixMap("");
165 
166  auto theDisabledModules = payload->getBadComponentList();
167  for (const auto& mod : theDisabledModules) {
168  int subid = DetId(mod.DetID).subdetId();
169  std::bitset<16> bad_rocs(mod.BadRocs);
170  if (subid == PixelSubdetector::PixelBarrel) {
171  if (payload->IsModuleBad(mod.DetID)) {
172  theBPixMap.fillWholeModule(mod.DetID, 1.);
173  } else {
174  theBPixMap.fillSelectedRocs(mod.DetID, bad_rocs, 1.);
175  }
176  }
177  }
178 
179  gStyle->SetOptStat(0);
180  //=========================
181  TCanvas canvas("Summary", "Summary", 1200, 1200);
182  theBPixMap.drawBarrelMaps(canvas);
183 
184  auto unpacked = SiPixelPI::unpack(std::get<0>(iov));
185 
186  for (unsigned int lay = 1; lay <= 4; lay++) {
187  canvas.cd(lay);
188  auto ltx = TLatex();
189  ltx.SetTextFont(62);
190  ltx.SetTextColor(kBlue);
191  ltx.SetTextSize(0.055);
192  ltx.SetTextAlign(11);
193  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
194  1 - gPad->GetTopMargin() + 0.01,
195  unpacked.first == 0
196  ? ("IOV:" + std::to_string(unpacked.second)).c_str()
197  : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str());
198  }
199 
200  std::string fileName(m_imageFileName);
201  canvas.SaveAs(fileName.c_str());
202 #ifdef MMDEBUG
203  canvas.SaveAs("outBPix.root");
204 #endif
205 
206  return true;
207  }
208 
209  private:
210  TrackerTopology m_trackerTopo;
211  };
212 
213  /************************************************
214  occupancy style map FPix
215  *************************************************/
216 
217  class SiPixelFPixQualityMap
218  : public cond::payloadInspector::PlotImage<SiPixelQuality, cond::payloadInspector::SINGLE_IOV> {
219  public:
220  SiPixelFPixQualityMap()
221  : cond::payloadInspector::PlotImage<SiPixelQuality, cond::payloadInspector::SINGLE_IOV>(
222  "SiPixelQuality Forward Pixel Map"),
224  edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {}
225 
226  bool fill() override {
227  auto tag = PlotBase::getTag<0>();
228  auto iov = tag.iovs.front();
229  std::shared_ptr<SiPixelQuality> payload = fetchPayload(std::get<1>(iov));
230 
231  Phase1PixelROCMaps theFPixMap("");
232 
233  auto theDisabledModules = payload->getBadComponentList();
234  for (const auto& mod : theDisabledModules) {
235  int subid = DetId(mod.DetID).subdetId();
236  std::bitset<16> bad_rocs(mod.BadRocs);
237  if (subid == PixelSubdetector::PixelEndcap) {
238  if (payload->IsModuleBad(mod.DetID)) {
239  theFPixMap.fillWholeModule(mod.DetID, 1.);
240  } else {
241  theFPixMap.fillSelectedRocs(mod.DetID, bad_rocs, 1.);
242  }
243  } // if it's endcap
244  } // loop on disable moduels
245 
246  gStyle->SetOptStat(0);
247  //=========================
248  TCanvas canvas("Summary", "Summary", 1200, 600);
249  theFPixMap.drawForwardMaps(canvas);
250 
251  auto unpacked = SiPixelPI::unpack(std::get<0>(iov));
252 
253  for (unsigned int ring = 1; ring <= 2; ring++) {
254  canvas.cd(ring);
255  auto ltx = TLatex();
256  ltx.SetTextFont(62);
257  ltx.SetTextColor(kBlue);
258  ltx.SetTextSize(0.050);
259  ltx.SetTextAlign(11);
260  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
261  1 - gPad->GetTopMargin() + 0.01,
262  unpacked.first == 0
263  ? ("IOV:" + std::to_string(unpacked.second)).c_str()
264  : (std::to_string(unpacked.first) + "," + std::to_string(unpacked.second)).c_str());
265  }
266 
267  std::string fileName(m_imageFileName);
268  canvas.SaveAs(fileName.c_str());
269 #ifdef MMDEBUG
270  canvas.SaveAs("outFPix.root");
271 #endif
272  return true;
273  }
274 
275  private:
276  TrackerTopology m_trackerTopo;
277  };
278 
279 } // namespace
280 
281 // Register the classes as boost python plugin
283  PAYLOAD_INSPECTOR_CLASS(SiPixelQualityTest);
284  PAYLOAD_INSPECTOR_CLASS(SiPixelQualityBadRocsSummary);
285  PAYLOAD_INSPECTOR_CLASS(SiPixelQualityBadRocsTimeHistory);
286  PAYLOAD_INSPECTOR_CLASS(SiPixelBPixQualityMap);
287  PAYLOAD_INSPECTOR_CLASS(SiPixelFPixQualityMap);
288 }
SiPixelPI::unpack
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
Definition: SiPixelPayloadInspectorHelper.h:114
Phase1PixelROCMaps
Definition: Phase1PixelROCMaps.h:80
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
PixelSubdetector.h
MessageLogger.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
cond::payloadInspector::Histogram1D
Histogram1< float, PayloadType, UNSPECIFIED_IOV > Histogram1D
Definition: PayloadInspector.h:790
cond::payloadInspector::Histogram1
Definition: PayloadInspector.h:711
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
TrackerTopology
Definition: TrackerTopology.h:16
PayloadInspector.h
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
SiPixelPI::displayNotSupported
void displayNotSupported(TCanvas &canv, const unsigned int size)
Definition: SiPixelPayloadInspectorHelper.h:781
PayloadInspectorModule.h
FileInPath.h
cond::payloadInspector::TimeHistoryPlot::getFromPayload
virtual Y getFromPayload(PayloadType &payload)=0
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:64
StandaloneTrackerTopology.h
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
jets_cff.payload
payload
Definition: jets_cff.py:32
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
cond::payloadInspector::Plot2D< PayloadType, AxisType, AxisType, IOV_M, 1 >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:490
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
Time.h
SiPixelQuality
Definition: SiPixelQuality.h:27
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:905
cond::payloadInspector::MULTI_IOV
Definition: PayloadInspector.h:295
cond::payloadInspector::TimeHistoryPlot
Definition: PayloadInspector.h:627
Phase1PixelROCMaps.h
COUT
#define COUT
Definition: PVValidationHelpers.h:13
std
Definition: JetResolutionObject.h:76
DetId.h
cond::payloadInspector::Histogram1::fill
bool fill() override
Definition: PayloadInspector.h:763
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:894
SiPixelQuality.h
SiPixelPayloadInspectorHelper.h
cond::payloadInspector::Histogram1::fillWithValue
void fillWithValue(AxisType value, AxisType weight=1)
Definition: PayloadInspector.h:747
cond::payloadInspector::SINGLE_IOV
Definition: PayloadInspector.h:295
StandaloneTrackerTopology::fromTrackerParametersXMLFile
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Definition: StandaloneTrackerTopology.cc:168