19#include "TLinearFitter.h"
35 if (dps.size() == 0) {
41 using namespace std::literals;
42 constexpr auto TEMP_ID{
"TPC_PT"sv};
43 constexpr auto HV_ID{
"TPC_HV"sv};
44 constexpr auto GAS_ID1{
"TPC_GC"sv};
45 constexpr auto GAS_ID2{
"TPC_An"sv};
47 for (
const auto& dp : dps) {
48 const std::string_view alias(dp.id.get_alias());
49 const auto id = alias.substr(0, 6);
51 LOGP(
debug,
"Temperature DP: {}", alias);
53 }
else if (
id == HV_ID) {
54 LOGP(
debug,
"HV DP: {}", alias);
56 }
else if (
id == GAS_ID1 ||
id == GAS_ID2) {
57 LOGP(
debug,
"Gas DP: {}", alias);
60 LOGP(warning,
"Unknown data point: {}", alias);
67 if (dp.
id.
get_type() == DeliveryType::DPVAL_FLOAT) {
68 return o2::dcs::getValue<float>(dp);
69 }
else if (dp.
id.
get_type() == DeliveryType::DPVAL_DOUBLE) {
70 return static_cast<float>(o2::dcs::getValue<double>(dp));
92 if (alias.back() ==
'S') {
95 static bool statTypePrinted =
false;
96 if (!statTypePrinted) {
97 LOGP(info,
"Delivery type for STATUS ({}): {}", alias, (
int)
type);
98 statTypePrinted =
true;
100 if (
type == DeliveryType::DPVAL_UINT) {
101 value = o2::dcs::getValue<uint32_t>(dp);
102 }
else if (
type == DeliveryType::DPVAL_INT) {
103 value = uint32_t(o2::dcs::getValue<int32_t>(dp));
110 static bool uiTypePrinted =
false;
111 if (!uiTypePrinted) {
112 LOGP(info,
"Delivery type for current, voltage ({}): {}", alias, (
int)
type);
113 uiTypePrinted =
true;
139 TLinearFitter fitter(3,
"x0 ++ x1 ++ x2");
140 bool nextInterval =
true;
141 std::array<size_t, dcs::Temperature::SensorsPerSide> startPos{};
145 while (nextInterval) {
149 nextInterval =
false;
151 const auto& sensor = mTemperature.
raw[iSensor + sensorOffset];
153 LOGP(
debug,
"sensor {}, start {}, size {}", sensor.sensorNumber, startPos[iSensor], sensor.data.size());
154 while (startPos[iSensor] < sensor.data.size()) {
155 const auto& dataPoint = sensor.data[startPos[iSensor]];
156 if ((dataPoint.time - refTime) >= mFitInterval) {
157 LOGP(
debug,
"sensor {}, {} - {} >= {}", sensor.sensorNumber, dataPoint.time, refTime, mFitInterval);
161 firstTime = std::min(firstTime, dataPoint.time);
162 const auto temperature = dataPoint.value;
164 if (temperature < 15 || temperature > 25) {
169 double x[] = {1., double(
pos.x), double(
pos.y)};
170 fitter.AddPoint(
x, temperature, 1);
174 if (firstTime < std::numeric_limits<dcs::TimeStampType>::max()) {
176 LOGP(info,
"Side {}, fit interval {} - {} with {} points",
int(
side), refTime, refTime + mFitInterval - 1, fitter.GetNpoints());
179 auto& stat = stats.data.emplace_back();
180 stat.time = firstTime;
181 stat.value.mean = fitter.GetParameter(0);
182 stat.value.gradX = fitter.GetParameter(1);
183 stat.value.gradY = fitter.GetParameter(2);
185 fitter.ClearPoints();
186 refTime += mFitInterval;
211 mTimeHighVoltage = {minTime, maxTime};
223 mDebugStream = std::make_unique<o2::utils::TreeStreamRedirector>(mDebugOutputName.data(),
"recreate");
226 *mDebugStream <<
"dcs"
227 <<
"Temperature=" << mTemperature
228 <<
"HV=" << mHighVoltage
236 mDebugStream->Close();
TPC DCS data point processor.
DeliveryType get_type() const noexcept
const char *const get_alias() const noexcept
void finalizeHighVoltage()
dcs::TimeStampType getMinTime(const std::vector< dcs::DataPointVector< T > > &data)
get minimum time over all sensors. Assumes data is sorted in time
void process(const gsl::span< const DPCOM > dps)
void fitTemperature(Side side)
void fillHV(const DPCOM &dp)
dcs::TimeStampType getMaxTime(const std::vector< dcs::DataPointVector< T > > &data)
get maximum time over all sensors. Assumes data is sorted in time
void fillTemperature(const DPCOM &dp)
float getValueF(const DPCOM &dp) const
void writeDebug()
write the debug output tree
void finalizeTemperature()
void fillGas(const DPCOM &dp)
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
Global TPC definitions and constants.
const DataPointIdentifier id
uint64_t get_epoch_time() const noexcept
void fill(std::string_view sensor, const TimeStampType time, const DataType value)
TimeStampType getMaxTime() const
TimeStampType getMinTime() const
std::vector< RawDPsF > voltages
voltages per GEM stack, counting is IROCs GEM1 top, bottom, GEM2 top, bottom, .. O1 ....
std::vector< RawDPsState > states
HV state per sector.
std::vector< RawDPsF > currents
currents per GEM stack, counting is IROCs GEM1 top, bottom, GEM2 top, bottom, .. O1 ....
void fillStatus(std::string_view sensor, const TimeStampType time, const uint32_t value)
Fill stack status information.
void fillUI(std::string_view sensor, const TimeStampType time, const DataType value)
Fill voltage and current information.
static constexpr std::array< Position, SensorsPerSide *SIDES > SensorPosition
StatsDPs statsA
statistics fit values per integration time A-Side
StatsDPs statsC
statistics fit values per integration time C-Side
static constexpr int SensorsPerSide
number of temperature sensors in the active volume per side
std::vector< RawDPsF > raw
raw temperature values from DCS for
void fill(std::string_view sensor, const TimeStampType time, const DataType temperature)