-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathDCSProcessor.h
More file actions
134 lines (104 loc) · 4.46 KB
/
DCSProcessor.h
File metadata and controls
134 lines (104 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// @file DCSProcessor.h
/// @brief TPC DCS data point processor
/// @author Jens Wiechula
#ifndef O2_TPC_DCSProcessor_H_
#define O2_TPC_DCSProcessor_H_
#include <memory>
#include <gsl/span>
#include <algorithm>
#include <limits>
#include "Rtypes.h"
#include "DetectorsDCS/DataPointCompositeObject.h"
#include "CommonUtils/TreeStreamRedirector.h"
#include "DataFormatsTPC/DCS.h"
using DPCOM = o2::dcs::DataPointCompositeObject;
namespace o2::tpc
{
class DCSProcessor
{
public:
struct TimeRange {
uint64_t first{};
uint64_t last{};
};
void process(const gsl::span<const DPCOM> dps);
float getValueF(const DPCOM& dp) const;
void fillTemperature(const DPCOM& dp);
void fillHV(const DPCOM& dp);
void fillGas(const DPCOM& dp);
void fillPressure(const DPCOM& dp);
void finalizeSlot();
void finalize();
void finalizeTemperature();
void finalizeHighVoltage();
void finalizeGas();
void finalizePressure();
/// name of the debug output tree
void setDebugOutputName(std::string_view name) { mDebugOutputName = name; }
/// if to write debug information
void setWriteDebug(const bool debug = true) { mWriteDebug = debug; }
/// write the debug output tree
void writeDebug();
/// set the fit interval
void setFitInterval(dcs::TimeStampType interval) { mFitInterval = interval; }
/// set the interval for averaging the pressure values
void setPressureInterval(dcs::TimeStampType interval) { mPressureInterval = interval; }
void setRefPressureInterval(dcs::TimeStampType interval) { mPressureIntervalRef = interval; }
/// get fit interval
auto getFitInterval() const { return mFitInterval; }
/// get fit interval
auto getPressureInterval() const { return mPressureInterval; }
/// round to fit interval
void setRoundToInterval(const bool round = true) { mRoundToInterval = round; }
/// reset all data
void reset()
{
mTemperature.clear();
mHighVoltage.clear();
mGas.clear();
mPressure.clear();
mTimeTemperature = {};
mTimeHighVoltage = {};
mTimeGas = {};
}
/// if data to process
bool hasData() const { return mHasData; }
const auto& getTimeTemperature() const { return mTimeTemperature; }
const auto& getTimeHighVoltage() const { return mTimeHighVoltage; }
const auto& getTimeGas() const { return mTimeGas; }
const auto& getTimePressure() const { return mTimePressure; }
auto& getTemperature() { return mTemperature; }
auto& getHighVoltage() { return mHighVoltage; }
auto& getGas() { return mGas; }
auto& getPressure() { return mPressure; }
private:
dcs::Temperature mTemperature; ///< temperature value store
dcs::HV mHighVoltage; ///< HV value store
dcs::Gas mGas; ///< Gas value store
dcs::Pressure mPressure; ///< Pressure value
TimeRange mTimeTemperature; ///< Time range for temperature values
TimeRange mTimeHighVoltage; ///< Time range for high voltage values
TimeRange mTimeGas; ///< Time range for gas values
TimeRange mTimePressure; ///< Time range for pressure values
dcs::TimeStampType mFitInterval{5 * 60 * 1000}; ///< fit interval (ms) e.g. for temparature data
dcs::TimeStampType mPressureInterval{200 * 1000}; ///< interval (ms) for averaging pressure values
dcs::TimeStampType mPressureIntervalRef{60 * 60 * 1000}; ///< interval (ms) for averaging pressure values for longer reference time interval
bool mWriteDebug{false}; ///< switch to dump debug tree
bool mRoundToInterval{false}; ///< round to full fit interval e.g. full minute
bool mHasData{false}; ///< if there are data to process
std::string mDebugOutputName{"DCS_debug.root"}; ///< name of the debug output tree
std::unique_ptr<o2::utils::TreeStreamRedirector> mDebugStream; //!< debug output streamer
ClassDefNV(DCSProcessor, 0);
};
} // namespace o2::tpc
#endif