Project
Loading...
Searching...
No Matches
DCSProcessor.h
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#ifndef O2_TPC_DCSProcessor_H_
17#define O2_TPC_DCSProcessor_H_
18
19#include <memory>
20#include <gsl/span>
21#include <algorithm>
22#include <limits>
23
24#include "Rtypes.h"
25
28#include "DataFormatsTPC/DCS.h"
29
31
32namespace o2::tpc
33{
35{
36 public:
37 struct TimeRange {
38 uint64_t first{};
39 uint64_t last{};
40 };
41
42 void process(const gsl::span<const DPCOM> dps);
43
44 float getValueF(const DPCOM& dp) const;
45
46 void fillTemperature(const DPCOM& dp);
47 void fillHV(const DPCOM& dp);
48 void fillGas(const DPCOM& dp);
49 void finalizeSlot();
50 void finalize();
51
54 void finalizeGas();
55
57
59 template <typename T>
61
63 template <typename T>
65
67 void setDebugOutputName(std::string_view name) { mDebugOutputName = name; }
68
70 void setWriteDebug(const bool debug = true) { mWriteDebug = debug; }
71
73 void writeDebug();
74
76 void setFitInterval(dcs::TimeStampType interval) { mFitInterval = interval; }
77
79 auto getFitInterval() const { return mFitInterval; }
80
82 void setRoundToInterval(const bool round = true) { mRoundToInterval = round; }
83
85 void reset()
86 {
87 mTemperature.clear();
88 mHighVoltage.clear();
89 mGas.clear();
90
91 mTimeTemperature = {};
92 mTimeHighVoltage = {};
93 mTimeGas = {};
94 }
95
97 bool hasData() const { return mHasData; }
98
99 const auto& getTimeTemperature() const { return mTimeTemperature; }
100 const auto& getTimeHighVoltage() const { return mTimeHighVoltage; }
101 const auto& getTimeGas() const { return mTimeGas; }
102
103 auto& getTemperature() { return mTemperature; }
104 auto& getHighVoltage() { return mHighVoltage; }
105 auto& getGas() { return mGas; }
106
107 private:
108 dcs::Temperature mTemperature;
109 dcs::HV mHighVoltage;
110 dcs::Gas mGas;
111
112 TimeRange mTimeTemperature;
113 TimeRange mTimeHighVoltage;
114 TimeRange mTimeGas;
115
116 dcs::TimeStampType mFitInterval{5 * 60 * 1000};
117 bool mWriteDebug{false};
118 bool mRoundToInterval{false};
119 bool mHasData{false};
120 std::string mDebugOutputName{"DCS_debug.root"};
121 std::unique_ptr<o2::utils::TreeStreamRedirector> mDebugStream;
122
123 ClassDefNV(DCSProcessor, 0);
124};
125
126template <typename T>
128{
129 constexpr auto max = std::numeric_limits<dcs::TimeStampType>::max();
130 dcs::TimeStampType firstTime = std::numeric_limits<dcs::TimeStampType>::max();
131 for (const auto& sensor : data) {
132 const auto time = sensor.data.size() ? sensor.data.front().time : max;
133 firstTime = std::min(firstTime, time);
134 }
135
136 // mFitInterval is is seconds. Round to full amount.
137 // if e.g. mFitInterval = 5min, then round 10:07:20.510 to 10:05:00.000
138 if (mRoundToInterval) {
139 firstTime -= (firstTime % mFitInterval);
140 }
141
142 return firstTime;
143}
144
145template <typename T>
147{
148 constexpr auto min = 0;
149 dcs::TimeStampType lastTime = 0;
150 for (const auto& sensor : data) {
151 const auto time = sensor.data.size() ? sensor.data.back().time : 0;
152 lastTime = std::max(lastTime, time);
153 }
154
155 // mFitInterval is is seconds. Round to full amount.
156 // if e.g. mFitInterval = 5min, then round 10:07:20.510 to 10:05:00.000
157 // TODO: fix this
158 // if (mRoundToInterval) {
159 // lastTime -= (lastTime % mFitInterval);
160 //}
161
162 return lastTime;
163}
164
165} // namespace o2::tpc
166#endif
DCS data point data formats.
int16_t time
Definition RawEventData.h:4
uint32_t side
Definition RawData.h:0
std::ostringstream debug
const auto & getTimeGas() const
bool hasData() const
if data to process
void setFitInterval(dcs::TimeStampType interval)
set the fit interval
dcs::TimeStampType getMinTime(const std::vector< dcs::DataPointVector< T > > &data)
get minimum time over all sensors. Assumes data is sorted in time
void setWriteDebug(const bool debug=true)
if to write debug information
void fitTemperature(Side side)
void fillHV(const DPCOM &dp)
const auto & getTimeTemperature() const
void reset()
reset all data
dcs::TimeStampType getMaxTime(const std::vector< dcs::DataPointVector< T > > &data)
get maximum time over all sensors. Assumes data is sorted in time
void setRoundToInterval(const bool round=true)
round to fit interval
void fillTemperature(const DPCOM &dp)
float getValueF(const DPCOM &dp) const
void setDebugOutputName(std::string_view name)
name of the debug output tree
void writeDebug()
write the debug output tree
const auto & getTimeHighVoltage() const
auto getFitInterval() const
get fit interval
void fillGas(const DPCOM &dp)
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean * data
Definition glcorearb.h:298
uint64_t TimeStampType
Definition DCS.h:41
Global TPC definitions and constants.
Definition SimTraits.h:167
Side
TPC readout sidE.
Definition Defs.h:35
void clear()
Definition DCS.h:455
void clear()
Definition DCS.h:366
constexpr size_t min
constexpr size_t max