CMS 3D CMS Logo

BasicP_PayloadInspector.cc
Go to the documentation of this file.
6 #include <memory>
7 #include <sstream>
8 
9 #include "TH2D.h"
10 #include "TCanvas.h"
11 #include "TLine.h"
12 #include "TLatex.h"
13 
14 namespace {
15 
16  class BasicPayload_data0 : public cond::payloadInspector::HistoryPlot<cond::BasicPayload, float> {
17  public:
18  BasicPayload_data0() : cond::payloadInspector::HistoryPlot<cond::BasicPayload, float>("Example Trend", "data0") {}
19  ~BasicPayload_data0() override = default;
20  float getFromPayload(cond::BasicPayload& payload) override { return payload.m_data0; }
21  };
22 
23  class BasicPayload_data0_withInput : public cond::payloadInspector::HistoryPlot<cond::BasicPayload, float> {
24  public:
25  BasicPayload_data0_withInput()
26  : cond::payloadInspector::HistoryPlot<cond::BasicPayload, float>("Example Trend", "data0") {
30  }
31  ~BasicPayload_data0_withInput() override = default;
32  float getFromPayload(cond::BasicPayload& payload) override {
33  float v = payload.m_data0;
35  auto ip = paramValues.find("Factor");
36  if (ip != paramValues.end()) {
37  v = v * boost::lexical_cast<float>(ip->second);
38  }
39  ip = paramValues.find("Offset");
40  if (ip != paramValues.end()) {
41  v = v + boost::lexical_cast<float>(ip->second);
42  }
43  ip = paramValues.find("Scale");
44  if (ip != paramValues.end()) {
45  v = v * boost::lexical_cast<float>(ip->second);
46  }
47  return v;
48  }
49  };
50 
51  class BasicPayload_data1 : public cond::payloadInspector::RunHistoryPlot<cond::BasicPayload, float> {
52  public:
53  BasicPayload_data1()
54  : cond::payloadInspector::RunHistoryPlot<cond::BasicPayload, float>("Example Run-based Trend", "data0") {}
55  ~BasicPayload_data1() override = default;
56  float getFromPayload(cond::BasicPayload& payload) override { return payload.m_data0; }
57  };
58 
59  class BasicPayload_data2 : public cond::payloadInspector::TimeHistoryPlot<cond::BasicPayload, float> {
60  public:
61  BasicPayload_data2()
62  : cond::payloadInspector::TimeHistoryPlot<cond::BasicPayload, float>("Example Time-based Trend", "data0") {}
63  ~BasicPayload_data2() override = default;
64 
65  float getFromPayload(cond::BasicPayload& payload) override { return payload.m_data0; }
66  };
67 
68  class BasicPayload_data3 : public cond::payloadInspector::ScatterPlot<cond::BasicPayload, float, float> {
69  public:
70  BasicPayload_data3()
71  : cond::payloadInspector::ScatterPlot<cond::BasicPayload, float, float>("Example Scatter", "data0", "data1") {}
72  ~BasicPayload_data3() override = default;
73 
74  std::tuple<float, float> getFromPayload(cond::BasicPayload& payload) override {
75  return std::make_tuple(payload.m_data0, payload.m_data1);
76  }
77  };
78 
79  class BasicPayload_data4 : public cond::payloadInspector::Histogram1D<cond::BasicPayload> {
80  public:
81  BasicPayload_data4() : cond::payloadInspector::Histogram1D<cond::BasicPayload>("Example Histo1d", "x", 10, 0, 10) {
82  Base::setSingleIov(true);
83  }
84  ~BasicPayload_data4() override = default;
85 
86  bool fill() override {
87  auto tag = PlotBase::getTag<0>();
88  for (auto iov : tag.iovs) {
89  std::shared_ptr<cond::BasicPayload> payload = Base::fetchPayload(std::get<1>(iov));
90  if (payload.get()) {
91  for (size_t j = 0; j < 100; j++) {
92  fillWithValue(j, payload->m_vec[j]);
93  }
94  }
95  }
96  return true;
97  }
98  };
99 
100  class BasicPayload_data5
101  : public cond::payloadInspector::Histogram2D<cond::BasicPayload, cond::payloadInspector::SINGLE_IOV> {
102  public:
103  BasicPayload_data5()
104  : cond::payloadInspector::Histogram2D<cond::BasicPayload, cond::payloadInspector::SINGLE_IOV>(
105  "Example Histo2d", "x", 10, 0, 10, "y", 10, 0, 10) {}
106  ~BasicPayload_data5() override = default;
107 
108  bool fill() override {
109  auto tag = PlotBase::getTag<0>();
110  for (auto iov : tag.iovs) {
111  std::shared_ptr<cond::BasicPayload> payload = Base::fetchPayload(std::get<1>(iov));
112  if (payload.get()) {
113  for (size_t i = 0; i < 10; i++)
114  for (size_t j = 0; j < 10; j++) {
115  fillWithValue(j, i, payload->m_vec[i * 10 + j]);
116  }
117  }
118  }
119  return true;
120  }
121  };
122 
123  class BasicPayload_data6
124  : public cond::payloadInspector::PlotImage<cond::BasicPayload, cond::payloadInspector::SINGLE_IOV> {
125  public:
126  BasicPayload_data6()
127  : cond::payloadInspector::PlotImage<cond::BasicPayload, cond::payloadInspector::SINGLE_IOV>(
128  "Example delivery picture") {}
129 
130  bool fill() override {
131  auto tag = PlotBase::getTag<0>();
132  auto iov = tag.iovs.front();
133  std::shared_ptr<cond::BasicPayload> payload = fetchPayload(std::get<1>(iov));
134 
135  double xmax(100.), ymax(100.);
136 
137  TH2D h2D("h2D", "Example", 100, 0., xmax, 100, 0., ymax);
138 
139  if (payload.get()) {
140  if (payload->m_vec.size() == 10000) {
141  for (size_t i = 0; i < 100; i++)
142  for (size_t j = 0; j < 100; j++) {
143  h2D.Fill(i, j, payload->m_vec[i * 100 + j]);
144  }
145  h2D.SetStats(false);
146  }
147  }
148 
149  TCanvas c("c", "", 10, 10, 900, 500);
150  c.cd();
151  c.SetLogz();
152  h2D.SetNdivisions(18, "X");
153  h2D.GetXaxis()->SetTickLength(0.00);
154  h2D.GetYaxis()->SetTickLength(0.00);
155  h2D.GetXaxis()->SetTitle("iphi");
156  h2D.GetYaxis()->SetTitle("ieta");
157  h2D.Draw("col");
158 
159  //======= drawing lines ========
161 
162  TLine l;
163  l.SetLineStyle(2);
164  l.DrawLine(0., ymax / 2., xmax, ymax / 2.);
165  for (int m = 0; m < int(xmax); m += 10) {
166  l.DrawLine(m, 0., m, 100.);
167  }
168 
169  c.RedrawAxis();
170 
171  //========== writing text in the canvas==============
173 
174  TLatex Tl;
175  TLatex Tll;
176  Tl.SetTextAlign(23);
177  Tl.SetTextSize(0.04);
178 
179  Tll.SetTextAlign(23);
180  Tll.SetTextSize(0.04);
181 
182  int j = 0;
183  for (int i = 1; i <= 10; i++) {
184  std::string s = "+" + std::to_string(i);
185  char const* pchar = s.c_str();
186  j += 10;
187  Tl.DrawLatex(j - 5, int(ymax) / 1.33, pchar);
188  }
189 
190  int z = 0;
191  for (int g = -10; g < 0; g++) {
192  std::string ss = std::to_string(g);
193  char const* pchar1 = ss.c_str();
194  z += 10;
195  Tll.DrawLatex(z - 5, int(ymax) / 4, pchar1);
196  }
197  //=========================
198 
199  std::string fileName(m_imageFileName);
200  c.SaveAs(fileName.c_str());
201 
202  return true;
203  }
204  };
205 
206  class BasicPayload_data7 : public cond::payloadInspector::PlotImage<cond::BasicPayload> {
207  public:
208  BasicPayload_data7() : cond::payloadInspector::PlotImage<cond::BasicPayload>("Example delivery picture") {
209  setTwoTags(true);
210  }
211 
212  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs) override {
213  auto iov0 = iovs.front();
214  auto iov1 = iovs.back();
215  std::shared_ptr<cond::BasicPayload> payload0 = fetchPayload(std::get<1>(iov0));
216  std::shared_ptr<cond::BasicPayload> payload1 = fetchPayload(std::get<1>(iov1));
217 
218  double xmax(100.), ymax(100.);
219 
220  TH2D h2D("h2D", "Example", 100, 0., xmax, 100, 0., ymax);
221 
222  if (payload0.get() && payload1.get()) {
223  if (payload0->m_vec.size() == 10000 && payload1->m_vec.size() == 10000) {
224  for (size_t i = 0; i < 100; i++)
225  for (size_t j = 0; j < 100; j++) {
226  auto diff = abs(payload0->m_vec[i * 100 + j] - payload1->m_vec[i * 100 + j]);
227  h2D.Fill(i, j, diff);
228  }
229  h2D.SetStats(false);
230  }
231  }
232 
233  TCanvas c("c", "", 20, 20, 900, 500);
234  c.cd();
235  c.SetLogz();
236  h2D.SetNdivisions(18, "X");
237  h2D.GetXaxis()->SetTickLength(0.00);
238  h2D.GetYaxis()->SetTickLength(0.00);
239  h2D.GetXaxis()->SetTitle("iphi");
240  h2D.GetYaxis()->SetTitle("ieta");
241  h2D.Draw("col");
242 
243  //======= drawing lines ========
245 
246  TLine l;
247  l.SetLineStyle(2);
248  l.DrawLine(0., ymax / 2., xmax, ymax / 2.);
249  for (int m = 0; m < int(xmax); m += 10) {
250  l.DrawLine(m, 0., m, 100.);
251  }
252 
253  c.RedrawAxis();
254 
255  //========== writing text in the canvas==============
257 
258  TLatex Tl;
259  TLatex Tll;
260  Tl.SetTextAlign(23);
261  Tl.SetTextSize(0.04);
262 
263  Tll.SetTextAlign(23);
264  Tll.SetTextSize(0.04);
265 
266  int j = 0;
267  for (int i = 1; i <= 10; i++) {
268  std::string s = "+" + std::to_string(i);
269  char const* pchar = s.c_str();
270  j += 10;
271  Tl.DrawLatex(j - 5, int(ymax) / 1.33, pchar);
272  }
273 
274  int z = 0;
275  for (int g = -10; g < 0; g++) {
276  std::string ss = std::to_string(g);
277  char const* pchar1 = ss.c_str();
278  z += 10;
279  Tll.DrawLatex(z - 5, int(ymax) / 4, pchar1);
280  }
281  //=========================
282 
283  std::string fileName(m_imageFileName);
284  c.SaveAs(fileName.c_str());
285 
286  return true;
287  }
288  };
289 
290 } // namespace
291 
293  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data0);
294  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data0_withInput);
295  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data1);
296  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data2);
297  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data3);
298  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data4);
299  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data5);
300  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data6);
301  PAYLOAD_INSPECTOR_CLASS(BasicPayload_data7);
302 }
change_name.diff
diff
Definition: change_name.py:13
ScatterPlot
Definition: trackSplitPlot.h:33
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
cond::payloadInspector::Histogram1D
Histogram1< float, PayloadType, UNSPECIFIED_IOV > Histogram1D
Definition: PayloadInspector.h:790
cond::payloadInspector::Histogram1
Definition: PayloadInspector.h:711
PayloadReader.h
PayloadInspector.h
cond::payloadInspector::PlotBase::inputParamValues
const std::map< std::string, std::string > & inputParamValues() const
Definition: PayloadInspector.cc:139
cond::payloadInspector::Plot3D< PayloadType, float, float, float, IOV_M, 1 >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:521
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
findQualityFiles.v
v
Definition: findQualityFiles.py:179
PayloadInspectorModule.h
cond::payloadInspector::TimeHistoryPlot::getFromPayload
virtual Y getFromPayload(PayloadType &payload)=0
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cond::payloadInspector::ScatterPlot
Definition: PayloadInspector.h:686
cond::BasicPayload
Definition: BasicPayload.h:11
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
cond::payloadInspector::ScatterPlot::getFromPayload
virtual std::tuple< X, Y > getFromPayload(PayloadType &payload)=0
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DDAxes::z
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
cond::payloadInspector::HistoryPlot
Definition: PayloadInspector.h:530
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
cond::payloadInspector::Histogram2D
Definition: PayloadInspector.h:797
Time.h
cond::payloadInspector::Histogram2D::fillWithValue
void fillWithValue(float xvalue, float yvalue, float weight=1)
Definition: PayloadInspector.h:852
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:905
cond::payloadInspector::RunHistoryPlot
Definition: PayloadInspector.h:553
BasicPayload.h
createfilelist.int
int
Definition: createfilelist.py:10
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
cond::payloadInspector::TimeHistoryPlot
Definition: PayloadInspector.h:627
cond::payloadInspector::RunHistoryPlot::getFromPayload
virtual Y getFromPayload(PayloadType &payload)=0
cond::payloadInspector::HistoryPlot::getFromPayload
virtual Y getFromPayload(PayloadType &payload)=0
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
cond::payloadInspector::Histogram1::fill
bool fill() override
Definition: PayloadInspector.h:763
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:894
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
cond::payloadInspector::Histogram1::fillWithValue
void fillWithValue(AxisType value, AxisType weight=1)
Definition: PayloadInspector.h:747
cond::payloadInspector::PlotBase::addInputParam
void addInputParam(const std::string &paramName)
Definition: PayloadInspector.cc:35
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
cond::payloadInspector::SINGLE_IOV
Definition: PayloadInspector.h:295
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
cond::payloadInspector::Histogram2D::fill
bool fill() override
Definition: PayloadInspector.h:862