CMS 3D CMS Logo

SiStripLatency_PayloadInspector.cc
Go to the documentation of this file.
1 
12 
13 // the data format of the condition to be inspected
18 
19 // needed for the tracker map
21 
22 // auxilliary functions
25 
26 #include <memory>
27 #include <sstream>
28 #include <iostream>
29 
30 // include ROOT
31 #include "TProfile.h"
32 #include "TH2F.h"
33 #include "TLegend.h"
34 #include "TCanvas.h"
35 #include "TLine.h"
36 #include "TStyle.h"
37 #include "TLatex.h"
38 #include "TPave.h"
39 #include "TPaveStats.h"
40 
41 namespace {
42 
43  using namespace cond::payloadInspector;
44 
45  /************************************************
46  // test class
47  *************************************************/
48  class SiStripLatencyTest : public Histogram1D<SiStripLatency, SINGLE_IOV> {
49  public:
50  SiStripLatencyTest()
51  : Histogram1D<SiStripLatency, SINGLE_IOV>("SiStripLatency values", "SiStripLatency values", 5, 0.0, 5.0) {}
52 
53  bool fill() override {
54  auto tag = PlotBase::getTag<0>();
55  for (auto const& iov : tag.iovs) {
56  std::shared_ptr<SiStripLatency> payload = Base::fetchPayload(std::get<1>(iov));
57  if (payload.get()) {
58  std::vector<SiStripLatency::Latency> lat = payload->allLatencyAndModes();
59  fillWithValue(lat.size());
60  }
61  }
62  return true;
63  } // fill
64  };
65 
66  /***********************************************
67  // 1d histogram of mode of 1 IOV
68  ************************************************/
69  class SiStripLatencyMode : public Histogram1D<SiStripLatency, SINGLE_IOV> {
70  public:
71  SiStripLatencyMode() : Histogram1D<SiStripLatency>("SiStripLatency mode", "SiStripLatency mode", 70, -10, 60) {}
72 
73  bool fill() override {
74  auto tag = PlotBase::getTag<0>();
75  for (auto const& iov : tag.iovs) {
76  std::shared_ptr<SiStripLatency> payload = Base::fetchPayload(std::get<1>(iov));
77  if (payload.get()) {
78  std::vector<uint16_t> modes;
79  payload->allModes(modes);
80 
81  for (const auto& mode : modes) {
82  if (mode != 0)
83  fillWithValue(mode);
84  else
85  fillWithValue(-1);
86  }
87  }
88  }
89  return true;
90  }
91  };
92 
93  /************************************************
94  // historic trend plot of mode as a function of the run
95  ************************************************/
96  class SiStripLatencyModeHistory : public HistoryPlot<SiStripLatency, uint16_t> {
97  public:
98  SiStripLatencyModeHistory() : HistoryPlot<SiStripLatency, uint16_t>("Mode vs run number", "Mode vs run number") {}
99 
100  uint16_t getFromPayload(SiStripLatency& payload) override {
101  uint16_t singlemode = payload.singleMode();
102  return singlemode;
103  }
104  };
105 
106  /************************************************
107  // historic trend plot of mode as a function of the run
108  ************************************************/
109  class SiStripIsPeakModeHistory : public HistoryPlot<SiStripLatency, int16_t> {
110  public:
111  SiStripIsPeakModeHistory() : HistoryPlot<SiStripLatency, int16_t>("Mode vs run number", "Mode vs run number") {}
112  int16_t getFromPayload(SiStripLatency& payload) override {
113  uint16_t mode = payload.singleReadOutMode();
114  return mode;
115  }
116  };
117 
118  /************************************************
119  // historic trend plot of number of modes per run
120  ************************************************/
121  class SiStripLatencyNumbOfModeHistory : public HistoryPlot<SiStripLatency, int> {
122  public:
123  SiStripLatencyNumbOfModeHistory()
124  : HistoryPlot<SiStripLatency, int>("Number of modes vs run ", "Number of modes vs run") {}
125 
126  int getFromPayload(SiStripLatency& payload) override {
127  std::vector<uint16_t> modes;
128  payload.allModes(modes);
129 
130  return modes.size();
131  }
132  };
133 } // namespace
134 
135 // Register the classes as boost python plugin
137  PAYLOAD_INSPECTOR_CLASS(SiStripLatencyTest);
138  PAYLOAD_INSPECTOR_CLASS(SiStripLatencyMode);
139  PAYLOAD_INSPECTOR_CLASS(SiStripLatencyModeHistory);
140  PAYLOAD_INSPECTOR_CLASS(SiStripIsPeakModeHistory);
141  PAYLOAD_INSPECTOR_CLASS(SiStripLatencyNumbOfModeHistory);
142 }
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)