|
9 | 9 | #include "FWCore/MessageLogger/interface/MessageLogger.h"
|
10 | 10 |
|
11 | 11 | // system includes
|
| 12 | +#include <ctime> |
12 | 13 | #include <fmt/printf.h>
|
13 | 14 | #include <memory>
|
14 | 15 | #include <sstream>
|
@@ -60,6 +61,26 @@ namespace beamSpotPI {
|
60 | 61 | END_OF_TYPES = 25,
|
61 | 62 | };
|
62 | 63 |
|
| 64 | + /************************************************/ |
| 65 | + // Function to convert cond::Time_t (in microseconds) to human-readable date string |
| 66 | + std::string convertTimeToDateString(cond::Time_t timeValue, bool hasMicros = false, bool toUTC = true) { |
| 67 | + // Convert microseconds to seconds |
| 68 | + std::time_t unixTime = static_cast<std::time_t>(hasMicros ? timeValue / 1000000 : timeValue); |
| 69 | + |
| 70 | + // Convert std::time_t to struct tm (to UTC, or not) |
| 71 | + std::tm* timeInfo = toUTC ? std::gmtime(&unixTime) : std::localtime(&unixTime); |
| 72 | + |
| 73 | + // Convert struct tm to human-readable string format |
| 74 | + char buffer[80]; |
| 75 | + std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeInfo); |
| 76 | + |
| 77 | + // Append microseconds to the string |
| 78 | + std::string dateString(buffer); |
| 79 | + //dateString += "." + std::to_string(timeValue % 1000000); |
| 80 | + |
| 81 | + return dateString; |
| 82 | + } |
| 83 | + |
63 | 84 | /************************************************/
|
64 | 85 | inline std::string getStringFromParamEnum(const parameters& parameter,
|
65 | 86 | const bool addUnits = false /*not used by default*/) {
|
@@ -432,6 +453,29 @@ namespace beamSpotPI {
|
432 | 453 | (tagname + " IOV: #color[4]{" + std::to_string(runLS.first) + "," + std::to_string(runLS.second) + "}")
|
433 | 454 | .c_str());
|
434 | 455 |
|
| 456 | + if constexpr (std::is_same_v<PayloadType, BeamSpotOnlineObjects>) { |
| 457 | + canvas.cd(2); |
| 458 | + ltx.SetTextSize(0.025); |
| 459 | + ltx.DrawLatexNDC( |
| 460 | + gPad->GetLeftMargin() + 0.01, |
| 461 | + gPad->GetBottomMargin() + 0.15, |
| 462 | + ("#color[2]{(" + beamSpotPI::convertTimeToDateString(m_payload->creationTime(), /*has us*/ true) + ")}") |
| 463 | + .c_str()); |
| 464 | + |
| 465 | + ltx.DrawLatexNDC( |
| 466 | + gPad->GetLeftMargin() + 0.01, |
| 467 | + gPad->GetBottomMargin() + 0.085, |
| 468 | + ("#color[2]{(" + beamSpotPI::convertTimeToDateString(m_payload->startTimeStamp()) + ")}").c_str()); |
| 469 | + |
| 470 | + ltx.DrawLatexNDC( |
| 471 | + gPad->GetLeftMargin() + 0.01, |
| 472 | + gPad->GetBottomMargin() + 0.025, |
| 473 | + ("#color[2]{(" + beamSpotPI::convertTimeToDateString(m_payload->endTimeStamp()) + ")}").c_str()); |
| 474 | + |
| 475 | + ltx.DrawLatexNDC( |
| 476 | + gPad->GetLeftMargin(), gPad->GetBottomMargin() - 0.05, "#color[4]{N.B.} TimeStamps are in UTC"); |
| 477 | + } |
| 478 | + |
435 | 479 | std::string fileName(this->m_imageFileName);
|
436 | 480 | canvas.SaveAs(fileName.c_str());
|
437 | 481 |
|
|
0 commit comments