29 const std::vector<Color_t>
PLOT_COLORS {kRed, kBlue, kBlack, kOrange, kMagenta};
60 std::map<cond::Time_t, std::map<std::string, std::pair<int, int>>>
iovMap;
89 boost::posix_time::ptime p_start, p_end;
92 p_end = boost::posix_time::second_clock::universal_time();
93 p_start = p_end - boost::posix_time::hours(
m_interval);
96 p_start = boost::posix_time::time_from_string(
m_startTime);
97 p_end = boost::posix_time::time_from_string(
m_endTime);
101 if (startIov > endIov)
103 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 104 <<
"Set start IOV " << startIov <<
" (" << boost::posix_time::to_simple_string(p_start) <<
")" 105 <<
"\n ... Set end IOV " << endIov <<
" (" << boost::posix_time::to_simple_string(p_end) <<
")" ;
108 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 109 <<
"Query the condition database " <<
m_condDb;
114 std::vector<TGraph*> hvgraphs, lvgraphs;
115 TLegend *leg_hv =
new TLegend(0.6, 0.87, 0.99, 0.99);
116 TLegend *leg_lv =
new TLegend(0.6, 0.87, 0.99, 0.99);
117 for (
unsigned itag=0; itag<
m_plotTags.size(); ++itag){
121 std::vector<double> vTime;
122 std::vector<double> vHVOffPercent, vLVOffPercent;
125 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 126 <<
"Reading IOVs from tag " <<
tag;
128 auto iiov = iovProxy.
find(startIov);
129 auto eiov = iovProxy.
find(endIov);
131 while (iiov != iovProxy.
end() && (*iiov).since <= (*eiov).since){
133 if ((*iiov).since<startIov)
138 vHVOffPercent.push_back( 1.0*
payload->getHVoffCounts()/num_modules );
139 vLVOffPercent.push_back( 1.0*
payload->getLVoffCounts()/num_modules );
143 <<
" (" << (*iiov).since <<
")" 144 <<
", # HV Off=" << std::setw(6) <<
payload->getHVoffCounts()
145 <<
", # LV Off=" << std::setw(6) <<
payload->getLVoffCounts() << std::endl;
149 edm::LogInfo(
"SiStripDetVOffTrendPlotter") <<
"[SiStripDetVOffTrendPlotter::" << __func__ <<
"] " 150 <<
"Read " << niov <<
" IOVs from tag " << tag <<
" in the specified interval.";
152 TGraph *
hv =
new TGraph(vTime.size(), vTime.data(), vHVOffPercent.data());
153 prepGraph(hv, TString(
"HVOff_")+tag,
";UTC;Fraction of HV off",
color);
154 leg_hv->AddEntry(hv, tag.data(),
"LP");
156 TGraph *lv =
new TGraph(vTime.size(), vTime.data(), vLVOffPercent.data());
157 prepGraph(lv, TString(
"LVOff_")+tag,
";UTC;Fraction of LV off",
color);
158 leg_lv->AddEntry(lv, tag.data(),
"LP");
160 hvgraphs.push_back(hv);
161 lvgraphs.push_back(lv);
167 TCanvas
c(
"c",
"c", 1800, 1200);
168 c.SetTopMargin(0.12);
169 c.SetBottomMargin(0.08);
172 for (
const auto hv : hvgraphs){
173 if (
hv==hvgraphs.front())
184 c.Print( (
"HVOff_" + plot_postfix).
data() );
187 for (
const auto lv : lvgraphs){
188 if (lv==lvgraphs.front())
198 c.Print( (
"LVOff_" + plot_postfix).
data() );
211 auto facet =
new boost::posix_time::time_facet(format.c_str());
212 std::ostringstream stream;
213 stream.imbue(std::locale(stream.getloc(), facet));
221 gr->SetLineColor(color);
223 gr->SetMarkerStyle(20);
224 gr->SetMarkerSize(1.5);
225 gr->SetMarkerColor(color);
226 gr->GetXaxis()->SetTimeDisplay(1);
227 gr->GetXaxis()->SetLabelOffset(0.02);
228 gr->GetXaxis()->SetTimeFormat(
"#splitline{%b %d}{%H:%M}");
229 gr->GetXaxis()->SetTimeOffset(0,
"gmt");
230 gr->GetXaxis()->SetLabelSize(0.025);
231 gr->GetXaxis()->SetTitleSize(0.025);
232 gr->GetXaxis()->SetTitleOffset(1.6);
233 gr->GetYaxis()->SetRangeUser(0, 1.05);
244 csv <<
"IOV,Timestamp(UTC),";
254 for (
const auto &tag : m_plotTags){
255 if (
v.second.find(tag)!=
v.second.end()){
256 int count = isHV ?
v.second.at(tag).first :
v.second.at(tag).second;
257 csv << count <<
" (" << 100.*count/num_modules <<
"%)";
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
void start(bool readOnly=true)
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)
edm::Service< SiStripDetInfoFileReader > detidReader
payload
payload postfix for testing
IOVProxy readIov(const std::string &tag, bool full=false)
unsigned long long Time_t
const std::vector< uint32_t > & getAllDetIds() const
virtual void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup)
std::string formatIOV(cond::Time_t iov, std::string format="%Y-%m-%d__%H_%M_%S")
Iterator find(cond::Time_t time)
Session createSession(const std::string &connectionString, bool writeCapable=false)
Time_t from_boost(boost::posix_time::ptime bt)
std::map< cond::Time_t, std::map< std::string, std::pair< int, int > > > iovMap
cond::persistency::ConnectionPool m_connectionPool
const std::vector< Color_t > PLOT_COLORS
SiStripDetVOffTrendPlotter(const edm::ParameterSet &iConfig)
virtual ~SiStripDetVOffTrendPlotter()
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)
std::shared_ptr< T > fetchPayload(const cond::Hash &payloadHash)