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};
108 int mUpdateIntervalnTFs{-1};
113 mWriteDebug = ic.
options().
get<
bool>(
"write-debug");
114 mCCDBupdateInterval = ic.
options().
get<
int>(
"update-interval");
115 mFitInterval = ic.
options().
get<
int>(
"fit-interval");
116 const int pressureInterval = ic.
options().
get<
int>(
"pressure-interval");
117 const int pressureIntervalRef = ic.
options().
get<
int>(
"pressure-ref-interval");
118 if (mCCDBupdateInterval < 0) {
119 mCCDBupdateInterval = 0;
121 if (mFitInterval >= mCCDBupdateInterval) {
122 LOGP(info,
"fit interval {} >= ccdb update interval {}, making them identical", mFitInterval, mCCDBupdateInterval);
123 mFitInterval = mCCDBupdateInterval;
125 mUpdateIntervalnTFs = ic.
options().
get<
int>(
"update-interval-nTFs");
133 mCDBStorage.
setResponsible(
"Jens Wiechula (jens.wiechula@cern.ch)");
135 mCDBStorage.
setReason(
"DCS workflow upload");
136 mReportTiming = ic.
options().
get<
bool>(
"report-timing");
143 if (mUpdateIntervalStart == 0) {
144 mUpdateIntervalStart = mLastCreationTime;
150 if (mLastCreationTime - mUpdateIntervalStart >= uint64_t(mCCDBupdateInterval * 1000)) {
152 mUpdateIntervalStart = mLastCreationTime;
156 auto dps = pc.
inputs().
get<gsl::span<DPCOM>>(
"input");
167 LOGP(info,
"Prepare CCDB for {}",
CDBTypeMap.at(calibType));
169 std::map<std::string, std::string> md = mCDBStorage.
getMetaData();
175 LOGP(info,
"Sending object {} / {} of size {} bytes, valid for {} : {} ",
w.getPath(),
w.getFileName(),
image->size(),
w.getStartValidityTimestamp(),
w.getEndValidityTimestamp());
194 std::vector<OutputSpec> outputs;
209 Inputs{{
"input",
"DCS",
"TPCDATAPOINTS"}},
213 {
"write-debug", VariantType::Bool,
false, {
"write a debug output tree"}},
214 {
"report-timing", VariantType::Bool,
false, {
"Report timing for every slice"}},
215 {
"update-interval", VariantType::Int, 60 * 15, {
"update interval in seconds for which ccdb entries are written"}},
216 {
"fit-interval", VariantType::Int, 60 * 5, {
"interval in seconds for which to e.g. perform fits of the temperature sensors"}},
217 {
"round-to-interval", VariantType::Bool,
false, {
"round fit interval to fixed times e.g. to every 5min in the hour"}},
218 {
"pressure-interval", VariantType::Int, 100, {
"interval in seconds for which to average the pressure values"}},
219 {
"pressure-ref-interval", VariantType::Int, 24 * 60 * 60, {
"interval in seconds for which to calculate the reference pressure values"}},
220 {
"update-interval-nTFs", VariantType::Int, -1, {
"only used when larger than 0: update interval in nTFs for which ccdb entries are written "}}}
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 setRefPressureInterval(dcs::TimeStampType interval)
void setRoundToInterval(const bool round=true)
round to fit interval
void setPressureInterval(dcs::TimeStampType interval)
set the interval for averaging the pressure values
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.
@ CalPressure
DCS pressure measurements.
@ 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
uint32_t tfCounter
the orbit the TF begins