CMS 3D CMS Logo

RunInfo_PayloadInspector.cc
Go to the documentation of this file.
1 
12 
13 // the data format of the condition to be inspected
16 
17 // helper
19 
20 // system includes
21 #include <memory>
22 #include <sstream>
23 #include <iostream>
24 
25 // include ROOT
26 #include "TProfile.h"
27 #include "TH2F.h"
28 #include "TLegend.h"
29 #include "TCanvas.h"
30 #include "TLine.h"
31 #include "TStyle.h"
32 #include "TLatex.h"
33 #include "TPave.h"
34 #include "TPaveStats.h"
35 #include "TPaletteAxis.h"
36 
37 namespace {
38 
39  /************************************************
40  RunInfo Payload Inspector of 1 IOV
41  *************************************************/
42  class RunInfoTest : public cond::payloadInspector::Histogram1D<RunInfo> {
43  public:
44  RunInfoTest() : cond::payloadInspector::Histogram1D<RunInfo>("Test RunInfo", "Test RunInfo", 10, 0.0, 10.0) {
45  Base::setSingleIov(true);
46  }
47 
48  bool fill() override {
49  auto tag = PlotBase::getTag<0>();
50  for (auto const& iov : tag.iovs) {
51  std::shared_ptr<RunInfo> payload = Base::fetchPayload(std::get<1>(iov));
52 
53  if (payload.get()) {
54  payload->printAllValues();
55  }
56  }
57  return true;
58  }
59  };
60 
61  /************************************************
62  Summary of RunInfo of 1 IOV
63  *************************************************/
64  class RunInfoParameters : public cond::payloadInspector::PlotImage<RunInfo> {
65  public:
66  RunInfoParameters() : cond::payloadInspector::PlotImage<RunInfo>("Display of RunInfo parameters") {
67  setSingleIov(true);
68  }
69 
70  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
71  auto iov = iovs.front();
72  std::shared_ptr<RunInfo> payload = fetchPayload(std::get<1>(iov));
73 
74  TCanvas canvas("Beam Spot Parameters Summary", "RunInfo Parameters summary", 1000, 1000);
75  canvas.cd();
76 
77  gStyle->SetHistMinimumZero();
78 
79  canvas.SetTopMargin(0.08);
80  canvas.SetBottomMargin(0.06);
81  canvas.SetLeftMargin(0.3);
82  canvas.SetRightMargin(0.02);
83  canvas.Modified();
84  canvas.SetGrid();
85 
86  auto h2_RunInfoParameters = std::unique_ptr<TH2F>(new TH2F("Parameters", "", 1, 0.0, 1.0, 11, 0, 11.));
87  auto h2_RunInfoState = std::unique_ptr<TH2F>(new TH2F("State", "", 1, 0.0, 1.0, 11, 0, 11.));
88  h2_RunInfoParameters->SetStats(false);
89  h2_RunInfoState->SetStats(false);
90 
91  float fieldIntensity = RunInfoPI::theBField(payload->m_avg_current);
92 
94  fieldIntensity](RunInfoPI::parameters my_param) {
95  float ret(-999.);
96  switch (my_param) {
97  case RunInfoPI::m_run:
98  return float(payload->m_run);
100  return float(payload->m_start_time_ll);
102  return float(payload->m_stop_time_ll);
104  return payload->m_start_current;
106  return payload->m_stop_current;
108  return payload->m_avg_current;
110  return payload->m_max_current;
112  return payload->m_min_current;
114  return payload->m_run_intervall_micros;
115  case RunInfoPI::m_BField:
116  return fieldIntensity;
117  case RunInfoPI::m_fedIN:
118  return float((payload->m_fed_in).size());
120  return ret;
121  default:
122  return ret;
123  }
124  };
125 
126  h2_RunInfoParameters->GetXaxis()->SetBinLabel(1, "Value");
127  h2_RunInfoState->GetXaxis()->SetBinLabel(1, "Value");
128 
129  unsigned int yBin = 11;
130  for (int foo = RunInfoPI::m_run; foo != RunInfoPI::END_OF_TYPES; foo++) {
131  RunInfoPI::parameters param = static_cast<RunInfoPI::parameters>(foo);
133  h2_RunInfoState->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
134  h2_RunInfoParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
135  h2_RunInfoParameters->SetBinContent(1, yBin, cutFunctor(param));
136  // non-fake payload
137  if ((payload->m_run) != -1) {
138  if ((payload->m_avg_current) <= -1) {
139  // go in error state
140  h2_RunInfoState->SetBinContent(1, yBin, 0.);
141  } else {
142  // all is OK
143  h2_RunInfoState->SetBinContent(1, yBin, 1.);
144  }
145  } else {
146  // this is a fake payload
147  h2_RunInfoState->SetBinContent(1, yBin, 0.9);
148  }
149  yBin--;
150  }
151 
152  h2_RunInfoParameters->GetXaxis()->LabelsOption("h");
153  h2_RunInfoParameters->GetYaxis()->SetLabelSize(0.05);
154  h2_RunInfoParameters->GetXaxis()->SetLabelSize(0.05);
155  h2_RunInfoParameters->SetMarkerSize(1.5);
156 
157  h2_RunInfoState->GetXaxis()->LabelsOption("h");
158  h2_RunInfoState->GetYaxis()->SetLabelSize(0.05);
159  h2_RunInfoState->GetXaxis()->SetLabelSize(0.05);
160  h2_RunInfoState->SetMarkerSize(1.5);
161 
162  RunInfoPI::reportSummaryMapPalette(h2_RunInfoState.get());
163  h2_RunInfoState->Draw("col");
164 
165  h2_RunInfoParameters->Draw("TEXTsame");
166 
167  TLatex t1;
168  t1.SetNDC();
169  t1.SetTextAlign(12);
170  t1.SetTextSize(0.03);
171  t1.DrawLatex(0.1, 0.98, "RunInfo parameters:");
172  t1.DrawLatex(0.1, 0.95, "payload:");
173 
174  t1.SetTextFont(42);
175  t1.SetTextColor(4);
176  t1.DrawLatex(0.37, 0.982, Form("IOV %s", std::to_string(+std::get<0>(iov)).c_str()));
177  t1.DrawLatex(0.21, 0.952, Form(" %s", (std::get<1>(iov)).c_str()));
178 
179  std::string fileName(m_imageFileName);
180  canvas.SaveAs(fileName.c_str());
181 
182  return true;
183  }
184  };
185 
186  /************************************************
187  time history of Magnet currents from RunInfo
188  *************************************************/
189 
190  template <RunInfoPI::parameters param>
191  class RunInfoCurrentHistory : public cond::payloadInspector::HistoryPlot<RunInfo, float> {
192  public:
193  RunInfoCurrentHistory()
194  : cond::payloadInspector::HistoryPlot<RunInfo, float>(getStringFromTypeEnum(param),
195  getStringFromTypeEnum(param) + " value") {}
196  ~RunInfoCurrentHistory() override = default;
197 
198  float getFromPayload(RunInfo& payload) override {
199  float fieldIntensity = RunInfoPI::theBField(payload.m_avg_current);
200 
201  switch (param) {
203  return payload.m_start_current;
205  return payload.m_stop_current;
207  return payload.m_avg_current;
209  return payload.m_max_current;
211  return payload.m_min_current;
212  case RunInfoPI::m_BField:
213  return fieldIntensity;
214  default:
215  edm::LogWarning("LogicError") << "Unknown parameter: " << param;
216  break;
217  }
218 
219  } // payload
220 
221  /************************************************/
223  switch (parameter) {
225  return "Magent start current [A]";
227  return "Magnet stop current [A]";
229  return "Magnet average current [A]";
231  return "Magnet max current [A]";
233  return "Magnet min current [A]";
234  case RunInfoPI::m_BField:
235  return "B-field intensity [T]";
236  default:
237  return "should never be here";
238  }
239  }
240  };
241 
242  typedef RunInfoCurrentHistory<RunInfoPI::m_start_current> RunInfoStartCurrentHistory;
243  typedef RunInfoCurrentHistory<RunInfoPI::m_stop_current> RunInfoStopCurrentHistory;
244  typedef RunInfoCurrentHistory<RunInfoPI::m_avg_current> RunInfoAverageCurrentHistory;
245  typedef RunInfoCurrentHistory<RunInfoPI::m_max_current> RunInfoMaxCurrentHistory;
246  typedef RunInfoCurrentHistory<RunInfoPI::m_min_current> RunInfoMinCurrentHistory;
247  typedef RunInfoCurrentHistory<RunInfoPI::m_BField> RunInfoBFieldHistory;
248 
249 } // namespace
250 
252  PAYLOAD_INSPECTOR_CLASS(RunInfoTest);
253  PAYLOAD_INSPECTOR_CLASS(RunInfoParameters);
254  PAYLOAD_INSPECTOR_CLASS(RunInfoStopCurrentHistory);
255  PAYLOAD_INSPECTOR_CLASS(RunInfoAverageCurrentHistory);
256  PAYLOAD_INSPECTOR_CLASS(RunInfoMaxCurrentHistory);
257  PAYLOAD_INSPECTOR_CLASS(RunInfoMinCurrentHistory);
258  PAYLOAD_INSPECTOR_CLASS(RunInfoBFieldHistory);
259 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
RunInfoPI::m_min_current
Definition: RunInfoPayloadInspectoHelper.h:28
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
PayloadInspector.h
cond::payloadInspector::Histogram1D
Definition: PayloadInspector.h:682
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
RunInfoPayloadInspectoHelper.h
photonAnalyzer_cfi.yBin
yBin
Definition: photonAnalyzer_cfi.py:85
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
PayloadInspectorModule.h
RunInfoPI::m_stop_current
Definition: RunInfoPayloadInspectoHelper.h:25
RunInfoPI::m_start_current
Definition: RunInfoPayloadInspectoHelper.h:24
RunInfo
Definition: RunInfo.h:18
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
parameter
Definition: vlib.h:168
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
RunInfoPI::m_run
Definition: RunInfoPayloadInspectoHelper.h:21
jets_cff.payload
payload
Definition: jets_cff.py:34
RunInfoPI::m_run_intervall_micros
Definition: RunInfoPayloadInspectoHelper.h:29
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
cond::payloadInspector::Plot2D< PayloadType, float, float, IOV_M, 1 >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:460
cond::payloadInspector::HistoryPlot
Definition: PayloadInspector.h:500
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RunInfoPI::END_OF_TYPES
Definition: RunInfoPayloadInspectoHelper.h:32
edm::LogWarning
Definition: MessageLogger.h:141
cond
Definition: plugin.cc:23
RunInfoPI::m_BField
Definition: RunInfoPayloadInspectoHelper.h:31
Time.h
cond::payloadInspector::Histogram1D::fill
bool fill() override
Definition: PayloadInspector.h:724
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
RunInfoPI::theBField
float theBField(const float current)
Definition: RunInfoPayloadInspectoHelper.h:36
RunInfoPI::reportSummaryMapPalette
void reportSummaryMapPalette(TH2 *obj)
Definition: RunInfoPayloadInspectoHelper.h:79
RunInfoPI::parameters
parameters
Definition: RunInfoPayloadInspectoHelper.h:20
cond::payloadInspector::HistoryPlot::getFromPayload
virtual Y getFromPayload(PayloadType &payload)=0
RunInfo.h
RunInfoPI::m_max_current
Definition: RunInfoPayloadInspectoHelper.h:27
RunInfoPI::m_avg_current
Definition: RunInfoPayloadInspectoHelper.h:26
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
RunInfoPI::m_fedIN
Definition: RunInfoPayloadInspectoHelper.h:30
RunInfoPI::m_start_time_ll
Definition: RunInfoPayloadInspectoHelper.h:22
RunInfoPI::m_stop_time_ll
Definition: RunInfoPayloadInspectoHelper.h:23
RunInfoPI::getStringFromTypeEnum
std::string getStringFromTypeEnum(const parameters &parameter)
Definition: RunInfoPayloadInspectoHelper.h:49