16#ifndef TPC_DCSCalibData_H_
17#define TPC_DCSCalibData_H_
26#include <unordered_map>
79 std::unique(
data.begin(),
data.end(),
80 [](
const auto& dp1,
const auto& dp2) {
81 return dp1.time == dp2.time;
99 const auto i = std::upper_bound(
data.begin(),
data.end(),
DPType{timeStamp, {}});
100 return (
i ==
data.begin()) ? (*i).value : (*(
i - 1)).value;
112 const auto iFrom = std::upper_bound(
data.begin(),
data.end(),
DPType{from, {}});
113 const auto iUntil = (from == until) ? iFrom :
std::upper_bound(
data.
begin(),
data.
end(), DPType{until, {}});
114 const auto distFrom = std::distance(
data.begin(), iFrom);
115 const auto distUntil = std::distance(iUntil,
data.end());
116 const auto nFrom = std::min(distFrom,
range + 1);
117 const auto nUntil = std::min(distUntil,
range);
118 const auto nPoints = std::distance(iFrom - nFrom, iUntil + nUntil);
119 return {std::accumulate(iFrom - nFrom, iUntil + nUntil, DPType{(*(iFrom - nFrom)).time, T{}}).
value, nPoints};
124 const auto sumAndPoints = getSumAndPoints(from, until,
range);
125 return sumAndPoints.first /
static_cast<float>(sumAndPoints.second);
134 for (
auto&
data : dataVector) {
142 for (
auto&
data : dataVector) {
150 if (
a.size() !=
b.size()) {
151 LOGP(warning,
"Trying to append std::vector<dcs::DataPointVector<T>>s of different size: {} != {}",
a.size(),
b.size());
153 for (
size_t i = 0;
i <
a.size(); ++
i) {
164 for (
const auto& dps : dpVec) {
165 const auto sumAndPoints = dps.getSumAndPoints(from, until,
range);
166 ret += sumAndPoints.first;
167 nPoints += sumAndPoints.second;
169 return (nPoints > 0) ? ret /
static_cast<float>(nPoints) : T{};
186 static constexpr
int SensorsPerSide = 9;
188 static const
std::unordered_map<
std::
string,
int> SensorNameMap;
196 {-150.34f, -205.04f},
205 {-175.82f, -183.66f},
211 static constexpr auto&
getSensorPosition(
const size_t sensor) {
return SensorPosition[sensor]; }
241 raw[SensorNameMap.at(sensor.data())].fill(
time, temperature);
279 static constexpr
size_t SidePos = 7;
280 static constexpr
size_t SectorPos = 8;
281 static constexpr
size_t ROCPos = 11;
282 static constexpr
size_t GEMPos = 14;
283 static constexpr
size_t ElectrodePos = 15;
312 const auto sideOffset = (sensor[SidePos] ==
'A') ? 0 :
SECTORSPERSIDE;
313 const auto sector = std::atoi(sensor.substr(SectorPos, 2).data());
314 return sector + sideOffset;
319 if (sensor[ROCPos] ==
'I') {
320 return GEMstack::IROCgem;
322 const auto orocType =
int(sensor[ROCPos + 1] -
'0');
323 return static_cast<GEMstack>(orocType);
329 const int sector = getSector(sensor);
330 const auto stack = getStack(sensor);
331 const auto rocOffset =
int(
stack != GEMstack::IROCgem);
332 const auto gem =
int(sensor[GEMPos + rocOffset] -
'0');
333 const bool isTop = sensor[ElectrodePos + rocOffset] ==
'T';
335 const int electrode = 2 * (gem - 1) + !isTop;
339 const auto type = sensor.back();
343 }
else if (
type ==
'U') {
351 const int sector = getSector(sensor);
352 const auto stack = getStack(sensor);
387 static constexpr size_t SensorPos = 4;
388 static constexpr size_t TypePosGC = 7;
389 static constexpr size_t TypePosAn = 15;
402 if (sensor[SensorPos] ==
'G') {
403 switch (sensor[TypePosGC]) {
405 if (sensor[TypePosGC + 1] ==
'E') {
425 LOGP(warning,
"Unknown gas sensor {}", sensor);
429 switch (sensor[TypePosAn]) {
437 LOGP(warning,
"Unknown gas sensor {}", sensor);
448 argon.sortAndClean();
451 h2oSensor.sortAndClean();
452 o2Sensor.sortAndClean();
469 neon.append(
other.neon);
470 co2.append(
other.co2);
472 argon.append(
other.argon);
473 h2o.append(
other.h2o);
475 h2oSensor.append(
other.h2oSensor);
476 o2Sensor.append(
other.o2Sensor);
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLboolean GLboolean GLboolean GLboolean a
void doAppend(std::vector< dcs::DataPointVector< T > > &a, const std::vector< dcs::DataPointVector< T > > &b)
void doClear(std::vector< dcs::DataPointVector< T > > &dataVector)
const T getAverageValueForTime(const std::vector< dcs::DataPointVector< T > > &dpVec, const TimeStampType from, const TimeStampType until, const long range)
void doSortAndClean(std::vector< dcs::DataPointVector< T > > &dataVector)
Global TPC definitions and constants.
GEMstack
TPC GEM stack types.
constexpr unsigned char SECTORSPERSIDE
Enum< T >::Iterator begin(Enum< T >)
constexpr unsigned short GEMSPERSTACK
constexpr unsigned char SIDES
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
GEM stack identification.
std::vector< DPType > data
void fill(const TimeStampType time, const T &value)
void fill(const DPType &dataPoint)
const T getAverageValueForTime(const TimeStampType from, const TimeStampType until, const long range) const
void append(const DataPointVector< T > &other)
ClassDefNV(DataPointVector, 1)
const std::pair< T, long > getSumAndPoints(const TimeStampType from, const TimeStampType until, const long range) const
calculate average value between from and unil, extending the range by +- range elements
const T & getValueForTime(const TimeStampType timeStamp) const
const T getAverageValueForTime(const TimeStampType timeStamp, const long range) const
calculate average value for timeStamp, extending the range by +- range elements
bool equalTime(const DataPoint &other) const
bool operator<(const TimeStampType timeStamp) const
DataPoint operator/(const DataType denom) const
DataPoint operator+(const DataPoint &other) const
bool operator<(const DataPoint &other) const
void fill(std::string_view sensor, const TimeStampType time, const DataType value)
void append(const Gas &other)
std::vector< RawDPsF > voltages
voltages per GEM stack, counting is IROCs GEM1 top, bottom, GEM2 top, bottom, .. O1 ....
static const std::unordered_map< StackState, std::string > StackStateNameMap
map state to string
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 ....
static GEMstack getStack(std::string_view sensor)
static int getSector(std::string_view sensor)
void fillStatus(std::string_view sensor, const TimeStampType time, const uint32_t value)
Fill stack status information.
void append(const HV &other)
void fillUI(std::string_view sensor, const TimeStampType time, const DataType value)
Fill voltage and current information.
Stats operator+(const Stats &other) const
Stats operator/(const DataType val) const
DataType getMeanTempRaw()
StatsDPs statsA
statistics fit values per integration time A-Side
ClassDefNV(Temperature, 1)
void append(const Temperature &other)
StatsDPs statsC
statistics fit values per integration time C-Side
static constexpr auto & getSensorPosition(const size_t sensor)
std::vector< RawDPsF > raw
raw temperature values from DCS for
void fill(std::string_view sensor, const TimeStampType time, const DataType temperature)
const Stats & getStats(const Side s, const TimeStampType timeStamp) const
VectorOfTObjectPtrs other