31 const std::vector<Color_t>
PLOT_COLORS{kRed, kBlue, kBlack, kOrange, kMagenta};
41 void dumpCSV(
bool isHV, std::size_t nModules);
61 std::map<cond::Time_t, std::map<std::string, std::pair<int, int>>>
iovMap;
68 m_condDb(iConfig.getParameter<
std::
string>(
"conditionDatabase")),
70 m_interval(iConfig.getParameter<
int>(
"timeInterval")),
71 m_startTime(iConfig.getUntrackedParameter<
std::
string>(
"startTime",
"")),
72 m_endTime(iConfig.getUntrackedParameter<
std::
string>(
"endTime",
"")),
73 m_outputPlot(iConfig.getUntrackedParameter<
std::
string>(
"outputPlot",
"")),
74 m_outputRootFile(iConfig.getUntrackedParameter<
std::
string>(
"outputRootFile",
"")),
75 m_outputCSV(iConfig.getUntrackedParameter<
std::
string>(
"outputCSV",
"")),
94 boost::posix_time::ptime p_start, p_end;
97 p_end = boost::posix_time::second_clock::universal_time();
101 p_start = boost::posix_time::time_from_string(
m_startTime);
102 p_end = boost::posix_time::time_from_string(
m_endTime);
106 if (startIov > endIov)
109 <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] "
110 <<
"Set start IOV " << startIov <<
" (" << boost::posix_time::to_simple_string(p_start) <<
")"
111 <<
"\n ... Set end IOV " << endIov <<
" (" << boost::posix_time::to_simple_string(p_end) <<
")";
114 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] "
115 <<
"Query the condition database " <<
m_condDb;
120 std::vector<TGraph *> hvgraphs, lvgraphs;
121 TLegend *leg_hv =
new TLegend(0.6, 0.87, 0.99, 0.99);
122 TLegend *leg_lv =
new TLegend(0.6, 0.87, 0.99, 0.99);
123 for (
unsigned itag = 0; itag <
m_plotTags.size(); ++itag) {
127 std::vector<double> vTime;
128 std::vector<double> vHVOffPercent, vLVOffPercent;
131 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] "
132 <<
"Reading IOVs from tag " <<
tag;
135 auto iiov = iovs.
find(startIov);
136 auto eiov = iovs.find(endIov);
138 while (iiov != iovs.end() && (*iiov).since <= (*eiov).since) {
140 if ((*iiov).since < startIov)
145 vHVOffPercent.push_back(1.0 *
payload->getHVoffCounts() / num_modules);
146 vLVOffPercent.push_back(1.0 *
payload->getLVoffCounts() / num_modules);
151 <<
", # HV Off=" << std::setw(6) <<
payload->getHVoffCounts() <<
", # LV Off=" << std::setw(6)
152 <<
payload->getLVoffCounts() << std::endl;
157 <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] "
158 <<
"Read " << niov <<
" IOVs from tag " <<
tag <<
" in the specified interval.";
160 TGraph *hv =
new TGraph(vTime.size(), vTime.data(), vHVOffPercent.data());
161 prepGraph(hv, TString(
"HVOff_") +
tag,
";UTC;Fraction of HV off", color);
162 leg_hv->AddEntry(hv,
tag.data(),
"LP");
164 TGraph *lv =
new TGraph(vTime.size(), vTime.data(), vLVOffPercent.data());
165 prepGraph(lv, TString(
"LVOff_") +
tag,
";UTC;Fraction of LV off", color);
166 leg_lv->AddEntry(lv,
tag.data(),
"LP");
168 hvgraphs.push_back(hv);
169 lvgraphs.push_back(lv);
175 TCanvas
c(
"c",
"c", 1800, 1200);
176 c.SetTopMargin(0.12);
177 c.SetBottomMargin(0.08);
180 for (
const auto hv : hvgraphs) {
181 if (hv == hvgraphs.front())
193 c.Print((
"HVOff_" + plot_postfix).
data());
196 for (
const auto lv : lvgraphs) {
197 if (lv == lvgraphs.front())
207 c.Print((
"LVOff_" + plot_postfix).
data());
218 auto facet =
new boost::posix_time::time_facet(
format.c_str());
219 std::ostringstream
stream;
228 gr->SetLineColor(color);
230 gr->SetMarkerStyle(20);
231 gr->SetMarkerSize(1.5);
232 gr->SetMarkerColor(color);
233 gr->GetXaxis()->SetTimeDisplay(1);
234 gr->GetXaxis()->SetLabelOffset(0.02);
235 gr->GetXaxis()->SetTimeFormat(
"#splitline{%b %d}{%H:%M}");
236 gr->GetXaxis()->SetTimeOffset(0,
"gmt");
237 gr->GetXaxis()->SetLabelSize(0.025);
238 gr->GetXaxis()->SetTitleSize(0.025);
239 gr->GetXaxis()->SetTitleOffset(1.6);
240 gr->GetYaxis()->SetRangeUser(0, 1.05);
247 csv <<
"IOV,Timestamp(UTC),";
259 if (
v.second.find(
tag) !=
v.second.end()) {
260 int count = isHV ?
v.second.at(
tag).first :
v.second.at(
tag).second;
261 csv <<
count <<
" (" << 100. *
count / nModules <<
"%)";