|
|
Go to the documentation of this file. 1 #ifndef CondCore_Utilities_PayloadInspector_h
2 #define CondCore_Utilities_PayloadInspector_h
12 #include <type_traits>
16 #include <boost/python/list.hpp>
17 #include <boost/python/dict.hpp>
18 #include <boost/python/tuple.hpp>
22 boost::python::list
ret;
23 ret.append(boost::python::make_tuple(
tagName, std::to_string(
start), std::to_string(
end)));
32 boost::python::list
ret;
33 ret.append(boost::python::make_tuple(tagName0, std::to_string(start0), std::to_string(end0)));
34 ret.append(boost::python::make_tuple(tagName1, std::to_string(start1), std::to_string(end1)));
41 namespace payloadInspector {
46 static constexpr
const char*
const TITLE_K =
"title";
48 static constexpr
const char*
const INFO_K =
"info";
49 static constexpr
const char*
const XAXIS_K =
"x_label";
50 static constexpr
const char*
const YAXIS_K =
"y_label";
51 static constexpr
const char*
const ZAXIS_K =
"z_label";
54 std::map<std::string, std::string>
m;
73 if constexpr (std::is_same_v<
V, std::pair<bool, float>>) {
75 ss <<
"\"" << entryLabel <<
"\":" <<
value.second;
78 ss <<
"\"" << entryLabel <<
"\":" <<
value;
86 ss <<
"\"" << entryLabel <<
"\":\"" <<
value <<
"\"";
94 ss << serializeValue(entryLabel, std::get<0>(
value));
101 template <
typename V>
103 std::stringstream
ss;
111 std::stringstream
ss;
113 ss <<
"\"annotations\": {";
115 for (
const auto&
a : annotations.
m) {
118 ss <<
"\"" <<
a.first <<
"\":\"" <<
a.second <<
"\"";
125 template <
typename X,
typename Y>
128 std::stringstream
ss;
134 for (
auto d :
data) {
142 if (!serializedY.empty()) {
146 ss <<
" { " << serializedX <<
", " << serializedY <<
" }";
155 template <
typename X,
typename Y,
typename Z>
158 std::stringstream
ss;
164 for (
auto d :
data) {
177 std::stringstream
ss;
181 ss <<
"\"file\": \"" << imageFileName <<
"\"";
187 static constexpr
const char*
const label =
"2.0";
192 const std::pair<cond::Time_t, cond::Time_t>&
b,
193 const std::vector<std::tuple<cond::Time_t, cond::Hash>>&
i)
197 const std::pair<cond::Time_t, cond::Time_t>&
boundary;
198 const std::vector<std::tuple<cond::Time_t, cond::Hash>>&
iovs;
216 unsigned int ntags()
const;
238 const std::vector<std::tuple<std::string, cond::Time_t, cond::Time_t>>& tagsWithTimeBoundaries);
253 template <
typename PayloadType>
263 if (sz == 0 ||
index >= sz) {
280 std::vector<std::vector<std::tuple<cond::Time_t, cond::Hash>>>
m_tagIovs;
299 template <IOVMultiplicity IOV_M,
int NTAGS>
314 virtual bool fill() = 0;
333 virtual bool fill() = 0;
353 virtual bool fill() = 0;
378 virtual bool fill() = 0;
404 std::vector<std::tuple<cond::Time_t, cond::Hash>> theIovs = PlotBase::getTag<0>().iovs;
406 auto tag2iovs = PlotBase::getTag<1>().iovs;
407 size_t oldSize = theIovs.size();
408 size_t newSize = oldSize + tag2iovs.size();
409 theIovs.resize(newSize);
410 for (
size_t i = 0;
i < tag2iovs.size();
i++) {
411 theIovs[
i + oldSize] = tag2iovs[
i];
414 return fill(theIovs);
417 virtual bool fill(
const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs) {
return false; }
421 m_singleIovSet =
true;
433 bool m_singleIovSet =
false;
452 std::vector<std::tuple<cond::Time_t, cond::Hash>> theIovs = PlotBase::getTag<0>().iovs;
454 auto tag2iovs = PlotBase::getTag<1>().iovs;
455 size_t oldSize = theIovs.size();
456 size_t newSize = oldSize + tag2iovs.size();
457 theIovs.resize(newSize);
458 for (
size_t i = 0;
i < tag2iovs.size();
i++) {
459 theIovs[
i + oldSize] = tag2iovs[
i];
462 return fill(theIovs);
465 virtual bool fill(
const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs) {
return false; }
471 template <
typename PayloadType,
typename X,
typename Y, IOVMultiplicity IOV_M = UNSPECIFIED_IOV,
int NTAGS = 0>
485 return PlotBase::fetchPayload<PayloadType>(payloadHash);
492 template <
typename PayloadType,
516 return PlotBase::fetchPayload<PayloadType>(payloadHash);
523 template <
typename PayloadType,
typename Y>
533 auto tag = PlotBase::getTag<0>();
534 for (
auto iov :
tag.iovs) {
546 template <
typename PayloadType,
typename Y>
552 :
Base(
"RunHistory",
title,
"iov_since", yLabel) {}
557 auto tag = PlotBase::getTag<0>();
559 std::map<cond::Time_t, unsigned int>
runs;
563 for (
auto iov :
tag.iovs) {
564 unsigned int run = std::get<0>(iov) >> 32;
566 if (it ==
runs.end())
567 it =
runs.insert(std::make_pair(
run, 0)).first;
571 unsigned int currentRun = 0;
573 unsigned int lumiSize = 0;
574 unsigned int rind = 0;
577 for (
auto iov :
tag.iovs) {
578 unsigned long long since = std::get<0>(iov);
583 if (
run != currentRun) {
587 if (it ==
runs.end()) {
591 lumiSize = it->second;
596 label = std::to_string(
run) +
" : " + std::to_string(
lumi);
603 label = boost::posix_time::to_simple_string(
t);
620 template <
typename PayloadType,
typename Y>
626 :
Base(
"TimeHistory",
title,
"iov_since", yLabel) {}
630 auto tag = PlotBase::getTag<0>();
643 for (
auto iov :
tag.iovs) {
645 boost::posix_time::ptime
time;
648 unsigned int nlumi =
since & 0xFFFFFFFF;
661 label += (
" : " + std::to_string(nlumi));
665 label = boost::posix_time::to_simple_string(
time);
679 template <
typename PayloadType,
typename X,
typename Y>
685 :
Base(
"Scatter",
title, xLabel, yLabel) {}
689 auto tag = PlotBase::getTag<0>();
690 for (
auto iov :
tag.iovs) {
704 template <
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV>
748 auto tag = PlotBase::getTag<0>();
749 for (
auto iov :
tag.iovs) {
770 template <
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV>
784 :
Base(
"Histo2D",
title, xLabel, yLabel,
"entries"),
797 if (xbinSize > 0 && ybinSize > 0) {
821 auto tag = PlotBase::getTag<0>();
822 for (
auto iov :
tag.iovs) {
836 return std::make_tuple(x, y);
851 template <
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV,
int NTAGS = 0>
856 std::string payloadTypeName = cond::demangledName(
typeid(PayloadType));
864 return PlotBase::fetchPayload<PayloadType>(payloadHash);
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash >> &iovs)
ret
prodAgent to be discontinued
Plot2D< PayloadType, float, float, IOV_M, 1 > Base
std::string processData() override
cudaStream_t T uint32_t const T *__restrict__ const uint32_t *__restrict__ uint32_t int cudaStream_t V
std::string m_imageFileName
~HistoryPlot() override=default
~Plot3D() override=default
PlotImpl(const std::string &type, const std::string &title)
boost::posix_time::ptime to_boost(Time_t iValue)
bool process(const std::string &connectionString, const boost::python::list &tagsWithTimeBoundaries)
void fillWithValue(float value, float weight=1)
virtual float getFromPayload(PayloadType &payload)
boost::python::list mk_input(const std::string &tagName, cond::Time_t start, cond::Time_t end)
std::string payloadType() const
Histogram2D(const std::string &title, const std::string &xLabel, size_t nxbins, float xmin, float xmax, const std::string &yLabel, size_t nybins, float ymin, float ymax)
void setSingleIov(bool flag)
~TimeHistoryPlot() override=default
cond::persistency::Session m_dbSession
std::vector< std::pair< cond::Time_t, cond::Time_t > > m_tagBoundaries
~Plot2D() override=default
static constexpr const char *const PLOT_TYPE_K
std::string get(const std::string &key) const
Plot2D< PayloadType, X, Y, MULTI_IOV, 1 > Base
static constexpr const char *const INFO_K
const std::map< std::string, std::string > & inputParamValues() const
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
~ScatterPlot() override=default
PlotImage(const std::string &title)
boost::python::list inputParams() const
PlotImpl< IOV_M, NTAGS > Base
RunHistoryPlot(const std::string &title, const std::string &yLabel)
static const char *const JSON_FORMAT_VERSION
std::string serializeValue(const std::string &entryLabel, const V &value)
std::string serialize(const PlotAnnotations &annotations, const std::vector< std::tuple< X, Y >> &data)
void setTwoTags(bool flag)
void setTwoTags(bool flag)
virtual Y getFromPayload(PayloadType &payload)=0
bool exec_process(const std::string &connectionString, const std::vector< std::tuple< std::string, cond::Time_t, cond::Time_t >> &tagsWithTimeBoundaries)
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
std::map< std::string, std::string > m
static constexpr const char *const ZAXIS_K
std::vector< std::tuple< X, Y > > m_plotData
virtual std::tuple< X, Y > getFromPayload(PayloadType &payload)=0
std::string serializeData() override
void setAnnotations(const std::string &type, const std::string &title, IOVMultiplicity IOV_M, int NTAGS, PlotAnnotations &target)
const unsigned int SECONDS_PER_LUMI(23)
PlotImpl(const std::string &type, const std::string &title)
void setTwoTags(bool flag)
unsigned int ntags() const
virtual std::string serializeData()=0
std::vector< std::string > m_tagNames
PlotImpl< IOV_M, NTAGS > Base
cond::persistency::Session dbSession()
std::map< std::string, std::string > m_inputParamValues
Plot2D< PayloadType, std::tuple< unsigned long long, std::string >, Y, MULTI_IOV, 1 > Base
cond::Tag_t getTagInfo(const std::string &tag)
Plot2D(const std::string &type, const std::string &title, const std::string xLabel, const std::string &yLabel)
RunInfoProxy getRunInfo(cond::Time_t start, cond::Time_t end)
static constexpr const char *const label
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
~PlotImpl() override=default
PlotImpl(const std::string &type, const std::string &title)
Plot3D< PayloadType, float, float, float, IOV_M, 1 > Base
std::string title() const
std::string processData() override
Plot2D< PayloadType, unsigned long long, Y, MULTI_IOV, 1 > Base
std::string processData() override
void setInputParamValues(const boost::python::dict &values)
virtual std::tuple< float, float > getFromPayload(PayloadType &payload)
ScatterPlot(const std::string &title, const std::string &xLabel, const std::string &yLabel)
void fillWithValue(float xvalue, float yvalue, float weight=1)
Time_t from_boost(boost::posix_time::ptime bt)
PlotImpl< IOV_M, NTAGS > Base
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
unsigned long long Time_t
static constexpr const char *const TITLE_K
~RunHistoryPlot() override=default
std::string createGlobalIdentifier(bool binary=false)
HistoryPlot(const std::string &title, const std::string &yLabel)
std::vector< std::tuple< X, Y, Z > > m_plotData
std::set< std::string > m_inputParams
static constexpr const char *const PAYLOAD_TYPE_K
virtual Y getFromPayload(PayloadType &payload)=0
std::string processData() override
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
std::vector< std::vector< std::tuple< cond::Time_t, cond::Hash > > > m_tagIovs
TagReference(const TagReference &rhs)
virtual Y getFromPayload(PayloadType &payload)=0
virtual std::string processData()
virtual ~PlotBase()=default
const std::vector< std::tuple< cond::Time_t, cond::Hash > > & iovs
TimeHistoryPlot(const std::string &title, const std::string &yLabel)
const std::pair< cond::Time_t, cond::Time_t > & boundary
std::string serializeData() override
TagReference(const std::string &n, const std::pair< cond::Time_t, cond::Time_t > &b, const std::vector< std::tuple< cond::Time_t, cond::Hash >> &i)
std::string processData() override
static constexpr const char *const XAXIS_K
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash >> &iovs)
char data[epos_bytes_allocation]
PlotImpl(const std::string &type, const std::string &title)
Plot2D< PayloadType, std::tuple< float, std::string >, Y, MULTI_IOV, 1 > Base
Plot3D(const std::string &type, const std::string &title, const std::string xLabel, const std::string &yLabel, const std::string &zLabel)
PlotImpl(const std::string &type, const std::string &title)
void addInputParam(const std::string ¶mName)
Histogram1D(const std::string &title, const std::string &xLabel, size_t nbins, float min, float max, const std::string &yLabel="entries")
void setSingleIov(bool flag)
PlotAnnotations m_plotAnnotations
static constexpr const char *const YAXIS_K
std::string serializeAnnotations(const PlotAnnotations &annotations)
std::string serializeData() override
void throwException(const std::string &message, const std::string &methodName)
void fillWithBinAndValue(size_t bin, float weight=1)