|
|
Go to the documentation of this file. 1 #ifndef CondCore_Utilities_PayloadInspector_h
2 #define CondCore_Utilities_PayloadInspector_h
12 #include <type_traits>
17 #include <boost/python/list.hpp>
18 #include <boost/python/dict.hpp>
19 #include <boost/python/tuple.hpp>
23 boost::python::list
ret;
24 ret.append(boost::python::make_tuple(
tagName, std::to_string(
start), std::to_string(
end)));
33 boost::python::list
ret;
34 ret.append(boost::python::make_tuple(tagName0, std::to_string(start0), std::to_string(end0)));
35 ret.append(boost::python::make_tuple(tagName1, std::to_string(start1), std::to_string(end1)));
42 namespace payloadInspector {
47 static constexpr
const char*
const TITLE_K =
"title";
49 static constexpr
const char*
const INFO_K =
"info";
50 static constexpr
const char*
const XAXIS_K =
"x_label";
51 static constexpr
const char*
const YAXIS_K =
"y_label";
52 static constexpr
const char*
const ZAXIS_K =
"z_label";
55 std::map<std::string, std::string>
m;
74 if constexpr (std::is_same_v<
V, std::pair<bool, float>>) {
76 ss <<
"\"" << entryLabel <<
"\":" <<
value.second;
78 }
else if constexpr (std::is_same_v<V, double>) {
84 ss <<
"\"" << entryLabel <<
"\":" <<
value;
92 ss <<
"\"" << entryLabel <<
"\":\"" <<
value <<
"\"";
100 ss << serializeValue(entryLabel, std::get<0>(
value));
107 template <
typename V>
109 std::stringstream
ss;
117 std::stringstream
ss;
119 ss <<
"\"annotations\": {";
121 for (
const auto&
a : annotations.
m) {
124 ss <<
"\"" <<
a.first <<
"\":\"" <<
a.second <<
"\"";
131 template <
typename X,
typename Y>
134 std::stringstream
ss;
140 for (
auto d :
data) {
148 if (!serializedY.empty()) {
152 ss <<
" { " << serializedX <<
", " << serializedY <<
" }";
161 template <
typename X,
typename Y,
typename Z>
164 std::stringstream
ss;
170 for (
auto d :
data) {
183 std::stringstream
ss;
187 ss <<
"\"file\": \"" << imageFileName <<
"\"";
193 static constexpr
const char*
const label =
"2.0";
198 const std::pair<cond::Time_t, cond::Time_t>&
b,
199 const std::vector<std::tuple<cond::Time_t, cond::Hash>>&
i)
203 const std::pair<cond::Time_t, cond::Time_t>&
boundary;
204 const std::vector<std::tuple<cond::Time_t, cond::Hash>>&
iovs;
222 unsigned int ntags()
const;
244 const std::vector<std::tuple<std::string, cond::Time_t, cond::Time_t>>& tagsWithTimeBoundaries);
259 template <
typename PayloadType>
269 if (sz == 0 ||
index >= sz) {
286 std::vector<std::vector<std::tuple<cond::Time_t, cond::Hash>>>
m_tagIovs;
305 template <IOVMultiplicity IOV_M,
int NTAGS>
320 virtual bool fill() = 0;
339 virtual bool fill() = 0;
359 virtual bool fill() = 0;
384 virtual bool fill() = 0;
410 std::vector<std::tuple<cond::Time_t, cond::Hash>> theIovs = PlotBase::getTag<0>().iovs;
412 auto tag2iovs = PlotBase::getTag<1>().iovs;
413 size_t oldSize = theIovs.size();
414 size_t newSize = oldSize + tag2iovs.size();
415 theIovs.resize(newSize);
416 for (
size_t i = 0;
i < tag2iovs.size();
i++) {
417 theIovs[
i + oldSize] = tag2iovs[
i];
420 return fill(theIovs);
423 virtual bool fill(
const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs) {
return false; }
427 m_singleIovSet =
true;
439 bool m_singleIovSet =
false;
458 std::vector<std::tuple<cond::Time_t, cond::Hash>> theIovs = PlotBase::getTag<0>().iovs;
460 auto tag2iovs = PlotBase::getTag<1>().iovs;
461 size_t oldSize = theIovs.size();
462 size_t newSize = oldSize + tag2iovs.size();
463 theIovs.resize(newSize);
464 for (
size_t i = 0;
i < tag2iovs.size();
i++) {
465 theIovs[
i + oldSize] = tag2iovs[
i];
468 return fill(theIovs);
471 virtual bool fill(
const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs) {
return false; }
477 template <
typename PayloadType,
typename X,
typename Y, IOVMultiplicity IOV_M = UNSPECIFIED_IOV,
int NTAGS = 0>
491 return PlotBase::fetchPayload<PayloadType>(payloadHash);
498 template <
typename PayloadType,
522 return PlotBase::fetchPayload<PayloadType>(payloadHash);
529 template <
typename PayloadType,
typename Y>
539 auto tag = PlotBase::getTag<0>();
540 for (
auto iov :
tag.iovs) {
552 template <
typename PayloadType,
typename Y>
558 :
Base(
"RunHistory",
title,
"iov_since", yLabel) {}
563 auto tag = PlotBase::getTag<0>();
565 std::map<cond::Time_t, unsigned int>
runs;
569 for (
auto iov :
tag.iovs) {
570 unsigned int run = std::get<0>(iov) >> 32;
572 if (it ==
runs.end())
573 it =
runs.insert(std::make_pair(
run, 0)).first;
577 unsigned int currentRun = 0;
579 unsigned int lumiSize = 0;
580 unsigned int rind = 0;
583 for (
auto iov :
tag.iovs) {
584 unsigned long long since = std::get<0>(iov);
589 if (
run != currentRun) {
593 if (it ==
runs.end()) {
597 lumiSize = it->second;
602 label = std::to_string(
run) +
" : " + std::to_string(
lumi);
609 label = boost::posix_time::to_simple_string(
t);
626 template <
typename PayloadType,
typename Y>
632 :
Base(
"TimeHistory",
title,
"iov_since", yLabel) {}
636 auto tag = PlotBase::getTag<0>();
649 for (
auto iov :
tag.iovs) {
651 boost::posix_time::ptime
time;
654 unsigned int nlumi =
since & 0xFFFFFFFF;
667 label += (
" : " + std::to_string(nlumi));
671 label = boost::posix_time::to_simple_string(
time);
685 template <
typename PayloadType,
typename X,
typename Y>
691 :
Base(
"Scatter",
title, xLabel, yLabel) {}
695 auto tag = PlotBase::getTag<0>();
696 for (
auto iov :
tag.iovs) {
710 template <
typename AxisType,
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV>
727 <<
" trying to book an histogram with less then 1 bin!" << std::endl;
732 <<
" trying to book an histogram with minimum " <<
m_min <<
"> maximum" <<
m_max <<
" !" << std::endl;
764 auto tag = PlotBase::getTag<0>();
765 for (
auto iov :
tag.iovs) {
789 template <
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV>
792 template <
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV>
796 template <
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV>
810 :
Base(
"Histo2D",
title, xLabel, yLabel,
"entries"),
823 <<
" trying to book an histogram with less then 1 bin!" << std::endl;
827 edm::LogError(
"payloadInspector::Histogram2D()") <<
" trying to book an histogram with x-minimum " <<
m_xmin
828 <<
"> x-maximum" <<
m_xmax <<
" !" << std::endl;
832 edm::LogError(
"payloadInspector::Histogram2D()") <<
" trying to book an histogram with y-minimum " <<
m_ymin
833 <<
"> y-maximum" <<
m_ymax <<
" !" << std::endl;
839 if (xbinSize > 0 && ybinSize > 0) {
863 auto tag = PlotBase::getTag<0>();
864 for (
auto iov :
tag.iovs) {
878 return std::make_tuple(x, y);
893 template <
typename PayloadType, IOVMultiplicity IOV_M = UNSPECIFIED_IOV,
int NTAGS = 0>
898 std::string payloadTypeName = cond::demangledName(
typeid(PayloadType));
906 return PlotBase::fetchPayload<PayloadType>(payloadHash);
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash >> &iovs)
ret
prodAgent to be discontinued
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)
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
virtual AxisType getFromPayload(PayloadType &payload)
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
Plot2D< PayloadType, AxisType, AxisType, IOV_M, 1 > Base
Histogram1(const std::string &title, const std::string &xLabel, size_t nbins, float min, float max, const std::string &yLabel="entries")
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
Log< level::Error, false > LogError
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)
void fillWithValue(AxisType value, AxisType weight=1)
PlotImpl(const std::string &type, const std::string &title)
void addInputParam(const std::string ¶mName)
void fillWithBinAndValue(size_t bin, AxisType weight=1)
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)