20#include <unordered_map>
21#include <TStopwatch.h>
40using Duration = std::chrono::duration<double, std::ratio<1, 1>>;
47const std::unordered_map<CDBType, o2::header::DataDescription>
CDBDescMap{
86 LOGP(info,
"endOfStream");
100 HighResClock::time_point mIntervalStartTime;
101 uint64_t mUpdateIntervalStart{0};
102 uint64_t mLastCreationTime{0};
103 int mCCDBupdateInterval;
105 bool mDebugWritten{
false};
106 bool mWriteDebug{
false};
107 bool mReportTiming{
false};
112 mWriteDebug = ic.
options().
get<
bool>(
"write-debug");
113 mCCDBupdateInterval = ic.
options().
get<
int>(
"update-interval");
114 mFitInterval = ic.
options().
get<
int>(
"fit-interval");
115 if (mCCDBupdateInterval < 0) {
116 mCCDBupdateInterval = 0;
118 if (mFitInterval >= mCCDBupdateInterval) {
119 LOGP(info,
"fit interval {} >= ccdb update interval {}, making them identical", mFitInterval, mCCDBupdateInterval);
120 mFitInterval = mCCDBupdateInterval;
127 mCDBStorage.
setResponsible(
"Jens Wiechula (jens.wiechula@cern.ch)");
129 mCDBStorage.
setReason(
"DCS workflow upload");
130 mReportTiming = ic.
options().
get<
bool>(
"report-timing") || mWriteDebug;
137 if (mUpdateIntervalStart == 0) {
138 mUpdateIntervalStart = mLastCreationTime;
140 if (mLastCreationTime - mUpdateIntervalStart >= uint64_t(mCCDBupdateInterval * 1000)) {
142 mUpdateIntervalStart = mLastCreationTime;
144 auto dps = pc.
inputs().
get<gsl::span<DPCOM>>(
"input");
155 LOGP(info,
"Prepare CCDB for {}",
CDBTypeMap.at(calibType));
157 std::map<std::string, std::string> md = mCDBStorage.
getMetaData();
162 LOGP(info,
"Sending object {} / {} of size {} bytes, valid for {} : {} ",
w.getPath(),
w.getFileName(),
image->size(),
w.getStartValidityTimestamp(),
w.getEndValidityTimestamp());
180 std::vector<OutputSpec> outputs;
192 Inputs{{
"input",
"DCS",
"TPCDATAPOINTS"}},
196 {
"write-debug", VariantType::Bool,
false, {
"write a debug output tree"}},
197 {
"report-timing", VariantType::Bool,
false, {
"Report timing for every slice"}},
198 {
"update-interval", VariantType::Int, 60 * 5, {
"update interval in seconds for which ccdb entries are written"}},
199 {
"fit-interval", VariantType::Int, 60, {
"interval in seconds for which to e.g. perform fits of the temperature sensors"}},
200 {
"round-to-interval", VariantType::Bool,
false, {
"round fit interval to fixed times e.g. to every 5min in the hour"}},
Simple interface to the CDB manager.
constexpr auto CDBWrapper
constexpr auto CDBPayload
constexpr auto CDBWrapper
constexpr auto CDBPayload
Utils and constants for calibration and related workflows.
std::chrono::duration< double, std::ratio< 1, 1 > > Duration
std::chrono::high_resolution_clock HighResClock
TPC DCS data point processor.
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
T get(const char *key) const
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void setReason(std::string_view reason)
void setIntervention(CDBIntervention const intervention)
void setResponsible(std::string_view responsible)
const auto & getMetaData() const
void sendObject(DataAllocator &output, T &obj, const CDBType calibType)
void init(o2::framework::InitContext &ic) final
void finalizeDCS(DataAllocator &output)
void updateCCDB(DataAllocator &output)
void run(o2::framework::ProcessingContext &pc) final
void stop() final
This is invoked on stop.
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
bool hasData() const
if data to process
void setFitInterval(dcs::TimeStampType interval)
set the fit interval
void process(const gsl::span< const DPCOM > dps)
void reset()
reset all data
void setRoundToInterval(const bool round=true)
round to fit interval
void writeDebug()
write the debug output tree
GLubyte GLubyte GLubyte GLubyte w
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
Global TPC definitions and constants.
const std::unordered_map< CDBType, const std::string > CDBTypeMap
Storage name in CCDB for each calibration and parameter type.
DataProcessorSpec getDCSSpec()
create DCS processor
const std::unordered_map< CDBType, o2::header::DataDescription > CDBDescMap
@ Automatic
Automatic upload.
CDBType
Calibration and parameter types for CCDB.
@ CalTemperature
DCS temperature measurements.
@ CalGas
DCS gas measurements.
@ CalHV
DCS HV measurements.
static void prepareCCDBobjectInfo(T &obj, o2::ccdb::CcdbObjectInfo &info, const std::string &path, const std::map< std::string, std::string > &md, long start, long end=-1)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload