Project
Loading...
Searching...
No Matches
DCSProcessor.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#include <string_view>
17
18// O2 includes
22#include "Framework/Logger.h"
23
24#include "TPCdcs/DCSProcessor.h"
25
26using namespace o2::tpc;
27using namespace o2::dcs;
28
29void DCSProcessor::process(const gsl::span<const DPCOM> dps)
30{
31 if (dps.size() == 0) {
32 return;
33 }
34
35 mHasData = true;
36
37 using namespace std::literals;
38 constexpr auto TEMP_ID{"TPC_PT"sv};
39 constexpr auto HV_ID{"TPC_HV"sv};
40 constexpr auto GAS_ID1{"TPC_GC"sv};
41 constexpr auto GAS_ID2{"TPC_An"sv};
42 constexpr auto PRESS_ID1{"Cavern"sv};
43 constexpr auto PRESS_ID2{"Surfac"sv};
44
45 for (const auto& dp : dps) {
46 const std::string_view alias(dp.id.get_alias());
47 const auto id = alias.substr(0, 6);
48 if (id == TEMP_ID) {
49 LOGP(debug, "Temperature DP: {}", alias);
51 } else if (id == HV_ID) {
52 LOGP(debug, "HV DP: {}", alias);
53 fillHV(dp);
54 } else if (id == GAS_ID1 || id == GAS_ID2) {
55 LOGP(debug, "Gas DP: {}", alias);
56 fillGas(dp);
57 } else if (id == PRESS_ID1 || id == PRESS_ID2) {
58 LOGP(debug, "Pressure DP: {}", alias);
59 fillPressure(dp);
60 } else {
61 LOGP(warning, "Unknown data point: {} with id {}", alias, id);
62 }
63 }
64}
65
66float DCSProcessor::getValueF(const DPCOM& dp) const
67{
68 if (dp.id.get_type() == DeliveryType::DPVAL_FLOAT) {
69 return o2::dcs::getValue<float>(dp);
70 } else if (dp.id.get_type() == DeliveryType::DPVAL_DOUBLE) {
71 return static_cast<float>(o2::dcs::getValue<double>(dp));
72 } else {
73 LOGP(warning, "Unexpected delivery type for {}: {}", dp.id.get_alias(), (int)dp.id.get_type());
74 }
75
76 return 0.f;
77}
78
80{
81 const std::string_view alias(dp.id.get_alias());
82 const auto value = getValueF(dp);
83 const auto time = dp.data.get_epoch_time();
84 mTemperature.fill(alias, time, value);
85}
86
88{
89 const std::string_view alias(dp.id.get_alias());
90 const auto time = dp.data.get_epoch_time();
91
92 const auto type = dp.id.get_type();
93 if (alias.back() == 'S') { //
94 uint32_t value;
95 // TODO: Remove once type is clear
96 static bool statTypePrinted = false;
97 if (!statTypePrinted) {
98 LOGP(info, "Delivery type for STATUS ({}): {}", alias, (int)type);
99 statTypePrinted = true;
100 }
101 if (type == DeliveryType::DPVAL_UINT) {
102 value = o2::dcs::getValue<uint32_t>(dp);
103 } else if (type == DeliveryType::DPVAL_INT) {
104 value = uint32_t(o2::dcs::getValue<int32_t>(dp));
105 } else {
106 value = uint32_t(getValueF(dp));
107 }
108 mHighVoltage.fillStatus(alias, time, value);
109 } else {
110 // TODO: Remove once type is clear
111 static bool uiTypePrinted = false;
112 if (!uiTypePrinted) {
113 LOGP(info, "Delivery type for current, voltage ({}): {}", alias, (int)type);
114 uiTypePrinted = true;
115 }
116 const auto value = getValueF(dp);
117 mHighVoltage.fillUI(alias, time, value);
118 }
119}
120
122{
123 const std::string_view alias(dp.id.get_alias());
124 const auto value = getValueF(dp);
125 const auto time = dp.data.get_epoch_time();
126 mGas.fill(alias, time, value);
127}
128
130{
131 const std::string_view alias(dp.id.get_alias());
132 const auto value = getValueF(dp);
133 const auto time = dp.data.get_epoch_time();
134 mPressure.fill(alias, time, value);
135}
136
138{
141 finalizeGas();
143 mHasData = false;
144}
145
147{
148 mTemperature.sortAndClean();
149 mTemperature.fitTemperature(Side::A, mFitInterval, mRoundToInterval);
150 mTemperature.fitTemperature(Side::C, mFitInterval, mRoundToInterval);
151 mTimeTemperature = {getMinTime(mTemperature.raw, mRoundToInterval, mFitInterval), getMaxTime(mTemperature.raw)};
152}
153
155{
156 mHighVoltage.sortAndClean();
157
158 auto minTime = getMinTime(mHighVoltage.currents, mRoundToInterval, mFitInterval);
159 minTime = std::min(minTime, getMinTime(mHighVoltage.voltages, mRoundToInterval, mFitInterval));
160 minTime = std::min(minTime, getMinTime(mHighVoltage.states, mRoundToInterval, mFitInterval));
161
162 auto maxTime = getMaxTime(mHighVoltage.currents);
163 maxTime = std::max(maxTime, getMaxTime(mHighVoltage.voltages));
164 maxTime = std::max(maxTime, getMaxTime(mHighVoltage.states));
165
166 mTimeHighVoltage = {minTime, maxTime};
167}
168
170{
171 mGas.sortAndClean();
172 mTimeGas = {mGas.getMinTime(), mGas.getMaxTime()};
173}
174
176{
177 mPressure.sortAndClean();
178 mTimePressure = {mPressure.getMinTime(), mPressure.getMaxTime()};
179 // if there is data perform the processing
180 if (mTimePressure.last > 0) {
181 mPressure.makeRobustPressure(mPressureInterval, mPressureIntervalRef, mTimePressure.first, mTimePressure.last);
182 }
183}
184
186{
187 if (!mDebugStream) {
188 mDebugStream = std::make_unique<o2::utils::TreeStreamRedirector>(mDebugOutputName.data(), "recreate");
189 }
190
191 *mDebugStream << "dcs"
192 << "Temperature=" << mTemperature
193 << "HV=" << mHighVoltage
194 << "Gas=" << mGas
195 << "Pressure=" << mPressure
196 << "\n";
197}
198
200{
201 if (mDebugStream) {
202 mDebugStream->Close();
203 }
204}
int16_t time
Definition RawEventData.h:4
TPC DCS data point processor.
std::ostringstream debug
DeliveryType get_type() const noexcept
const char *const get_alias() const noexcept
void fillPressure(const DPCOM &dp)
void process(const gsl::span< const DPCOM > dps)
void fillHV(const DPCOM &dp)
void fillTemperature(const DPCOM &dp)
float getValueF(const DPCOM &dp) const
void writeDebug()
write the debug output tree
void fillGas(const DPCOM &dp)
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
Global TPC definitions and constants.
Definition SimTraits.h:167
@ A
Definition Defs.h:35
@ C
Definition Defs.h:36
uint64_t get_epoch_time() const noexcept
void fill(std::string_view sensor, const TimeStampType time, const DataType value)
Definition DCS.h:464
TimeStampType getMaxTime() const
Definition DCS.cxx:106
TimeStampType getMinTime() const
Definition DCS.cxx:89
void sortAndClean()
Definition DCS.h:507
void sortAndClean()
Definition DCS.h:423
std::vector< RawDPsF > voltages
voltages per GEM stack, counting is IROCs GEM1 top, bottom, GEM2 top, bottom, .. O1 ....
Definition DCS.h:370
std::vector< RawDPsState > states
HV state per sector.
Definition DCS.h:372
std::vector< RawDPsF > currents
currents per GEM stack, counting is IROCs GEM1 top, bottom, GEM2 top, bottom, .. O1 ....
Definition DCS.h:371
void fillStatus(std::string_view sensor, const TimeStampType time, const uint32_t value)
Fill stack status information.
Definition DCS.h:413
void fillUI(std::string_view sensor, const TimeStampType time, const DataType value)
Fill voltage and current information.
Definition DCS.h:391
void sortAndClean(float pMin=800, float pMax=1100)
Definition DCS.cxx:285
void fill(std::string_view sensor, const TimeStampType time, const DataType value)
fill pressure data
Definition DCS.cxx:272
void makeRobustPressure(TimeStampType timeInterval=100 *1000, TimeStampType timeIntervalRef=24 *60 *1000, TimeStampType tStart=1, TimeStampType tEnd=0, const int nthreads=1)
average pressure values for given time interval
Definition DCS.cxx:342
TimeStampType getMinTime() const
Definition DCS.cxx:123
TimeStampType getMaxTime() const
Definition DCS.cxx:135
void fitTemperature(Side side, dcs::TimeStampType fitInterval=5 *60 *1000, const bool roundToInterval=false)
make fit of the mean temperature and gradients in time intervals
Definition DCS.cxx:165
std::vector< RawDPsF > raw
raw temperature values from DCS for
Definition DCS.h:289
void fill(std::string_view sensor, const TimeStampType time, const DataType temperature)
Definition DCS.h:301