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;
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();
174 const uint64_t endTime = endTimeOverride > 0 ? endTimeOverride : mLastCreationTime + 2 * mCCDBupdateInterval * 1000;
178 LOGP(info,
"Sending object {} / {} of size {} bytes, valid for {} : {} ",
w.getPath(),
w.getFileName(),
image->size(),
w.getStartValidityTimestamp(),
w.getEndValidityTimestamp());
198 const auto& pressureTime = mDCS.
getPressure().robustPressure.time;
201 const uint64_t pressureEnd = pressureTime.empty() ? 0 :
static_cast<uint64_t>(pressureTime.back()) + std::max(genericMargin, tailMargin);
212 std::vector<OutputSpec> outputs;
227 Inputs{{
"input",
"DCS",
"TPCDATAPOINTS"}},
231 {
"write-debug", VariantType::Bool,
false, {
"write a debug output tree"}},
232 {
"report-timing", VariantType::Bool,
false, {
"Report timing for every slice"}},
233 {
"update-interval", VariantType::Int, 60 * 15, {
"update interval in seconds for which ccdb entries are written"}},
234 {
"fit-interval", VariantType::Int, 60 * 5, {
"interval in seconds for which to e.g. perform fits of the temperature sensors"}},
235 {
"round-to-interval", VariantType::Bool,
false, {
"round fit interval to fixed times e.g. to every 5min in the hour"}},
236 {
"pressure-interval", VariantType::Int, 100, {
"interval in seconds for which to average the pressure values"}},
237 {
"pressure-ref-interval", VariantType::Int, 24 * 60 * 60, {
"interval in seconds for which to calculate the reference pressure values"}},
238 {
"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
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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 init(o2::framework::InitContext &ic) final
void sendObject(DataAllocator &output, T &obj, const CDBType calibType, uint64_t startTime, uint64_t endTimeOverride=0)
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.
auto getPressureCCDBStartTime() const
const auto & getTimeGas() const
const auto & getTimePressure() const
bool hasData() const
if data to process
void setFitInterval(dcs::TimeStampType interval)
set the fit interval
void process(const gsl::span< const DPCOM > dps)
const auto & getTimeTemperature() const
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
auto getPressureInterval() const
get fit interval
const auto & getTimeHighVoltage() const
GLubyte GLubyte GLubyte GLubyte w
Defining ITS Vertex explicitly as messageable.
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