31 const std::vector<Color_t>
PLOT_COLORS{kRed, kBlue, kBlack, kOrange, kMagenta};
40 void dumpCSV(
bool isHV, std::size_t nModules);
60 std::map<cond::Time_t, std::map<std::string, std::pair<int, int>>>
iovMap;
67 m_condDb(iConfig.getParameter<
std::
string>(
"conditionDatabase")),
69 m_interval(iConfig.getParameter<
int>(
"timeInterval")),
70 m_startTime(iConfig.getUntrackedParameter<
std::
string>(
"startTime",
"")),
71 m_endTime(iConfig.getUntrackedParameter<
std::
string>(
"endTime",
"")),
72 m_outputPlot(iConfig.getUntrackedParameter<
std::
string>(
"outputPlot",
"")),
73 m_outputRootFile(iConfig.getUntrackedParameter<
std::
string>(
"outputRootFile",
"")),
74 m_outputCSV(iConfig.getUntrackedParameter<
std::
string>(
"outputCSV",
"")),
93 boost::posix_time::ptime p_start, p_end;
96 p_end = boost::posix_time::second_clock::universal_time();
100 p_start = boost::posix_time::time_from_string(
m_startTime);
101 p_end = boost::posix_time::time_from_string(
m_endTime);
105 if (startIov > endIov)
108 <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 109 <<
"Set start IOV " << startIov <<
" (" << boost::posix_time::to_simple_string(p_start) <<
")" 110 <<
"\n ... Set end IOV " << endIov <<
" (" << boost::posix_time::to_simple_string(p_end) <<
")";
113 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 114 <<
"Query the condition database " <<
m_condDb;
119 std::vector<TGraph *> hvgraphs, lvgraphs;
120 TLegend *leg_hv =
new TLegend(0.6, 0.87, 0.99, 0.99);
121 TLegend *leg_lv =
new TLegend(0.6, 0.87, 0.99, 0.99);
122 for (
unsigned itag = 0; itag <
m_plotTags.size(); ++itag) {
126 std::vector<double> vTime;
127 std::vector<double> vHVOffPercent, vLVOffPercent;
130 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 131 <<
"Reading IOVs from tag " <<
tag;
134 auto iiov = iovs.
find(startIov);
135 auto eiov = iovs.find(endIov);
137 while (iiov != iovs.end() && (*iiov).since <= (*eiov).since) {
139 if ((*iiov).since < startIov)
144 vHVOffPercent.push_back(1.0 *
payload->getHVoffCounts() / num_modules);
145 vLVOffPercent.push_back(1.0 *
payload->getLVoffCounts() / num_modules);
150 <<
", # HV Off=" << std::setw(6) <<
payload->getHVoffCounts() <<
", # LV Off=" << std::setw(6)
151 <<
payload->getLVoffCounts() << std::endl;
156 <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 157 <<
"Read " << niov <<
" IOVs from tag " <<
tag <<
" in the specified interval.";
159 TGraph *hv =
new TGraph(vTime.size(), vTime.data(), vHVOffPercent.data());
160 prepGraph(hv, TString(
"HVOff_") +
tag,
";UTC;Fraction of HV off", color);
161 leg_hv->AddEntry(hv,
tag.data(),
"LP");
163 TGraph *lv =
new TGraph(vTime.size(), vTime.data(), vLVOffPercent.data());
164 prepGraph(lv, TString(
"LVOff_") +
tag,
";UTC;Fraction of LV off", color);
165 leg_lv->AddEntry(lv,
tag.data(),
"LP");
167 hvgraphs.push_back(hv);
168 lvgraphs.push_back(lv);
174 TCanvas
c(
"c",
"c", 1800, 1200);
175 c.SetTopMargin(0.12);
176 c.SetBottomMargin(0.08);
179 for (
const auto hv : hvgraphs) {
180 if (hv == hvgraphs.front())
192 c.Print((
"HVOff_" + plot_postfix).
data());
195 for (
const auto lv : lvgraphs) {
196 if (lv == lvgraphs.front())
206 c.Print((
"LVOff_" + plot_postfix).
data());
215 auto facet =
new boost::posix_time::time_facet(
format.c_str());
216 std::ostringstream
stream;
225 gr->SetLineColor(color);
227 gr->SetMarkerStyle(20);
228 gr->SetMarkerSize(1.5);
229 gr->SetMarkerColor(color);
230 gr->GetXaxis()->SetTimeDisplay(1);
231 gr->GetXaxis()->SetLabelOffset(0.02);
232 gr->GetXaxis()->SetTimeFormat(
"#splitline{%b %d}{%H:%M}");
233 gr->GetXaxis()->SetTimeOffset(0,
"gmt");
234 gr->GetXaxis()->SetLabelSize(0.025);
235 gr->GetXaxis()->SetTitleSize(0.025);
236 gr->GetXaxis()->SetTitleOffset(1.6);
237 gr->GetYaxis()->SetRangeUser(0, 1.05);
244 csv <<
"IOV,Timestamp(UTC),";
256 if (
v.second.find(
tag) !=
v.second.end()) {
257 int count = isHV ?
v.second.at(
tag).first :
v.second.at(
tag).second;
258 csv <<
count <<
" (" << 100. *
count / nModules <<
"%)";
~SiStripDetVOffTrendPlotter() override
T getParameter(std::string const &) const
void dumpCSV(bool isHV, std::size_t nModules)
void start(bool readOnly=true)
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::vector< std::string > m_plotTags
Transaction & transaction()
void prepGraph(TGraph *gr, TString name, TString title, Color_t color)
void setParameters(const edm::ParameterSet &connectionPset)
unsigned long long Time_t
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
std::string formatIOV(cond::Time_t iov, std::string format="%Y-%m-%d__%H_%M_%S")
std::vector< uint32_t > getSiStripDetIds(const GeometricDet &geomDet)
Session createSession(const std::string &connectionString, bool writeCapable=false)
#define DEFINE_FWK_MODULE(type)
Iterator find(cond::Time_t time) const
bool getData(T &iHolder) const
Time_t from_boost(boost::posix_time::ptime bt)
std::map< cond::Time_t, std::map< std::string, std::pair< int, int > > > iovMap
IOVProxy readIov(const std::string &tag)
cond::persistency::ConnectionPool m_connectionPool
Log< level::Info, false > LogInfo
const std::vector< Color_t > PLOT_COLORS
SiStripDetVOffTrendPlotter(const edm::ParameterSet &iConfig)
char data[epos_bytes_allocation]
std::string m_outputRootFile
boost::posix_time::ptime to_boost(Time_t iValue)
cond::UnpackedTime unpack(cond::Time_t iValue)