Project
Loading...
Searching...
No Matches
TOFDCSProcessor.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
12#ifndef DETECTOR_TOFDCSPROCESSOR_H_
13#define DETECTOR_TOFDCSPROCESSOR_H_
14
15#include <memory>
16#include <Rtypes.h>
17#include <unordered_map>
18#include <deque>
19#include <numeric>
20#include "Framework/Logger.h"
21#include "Framework/O2LongInt.h"
26#include "CCDB/CcdbObjectInfo.h"
28#include "CCDB/CcdbApi.h"
29#include <gsl/gsl>
30#include "TOFBase/Geo.h"
31
33
34namespace o2
35{
36namespace tof
37{
38
42
43struct TOFDCSinfo {
44 std::pair<O2LongUInt, double> firstValue; // first value seen by the TOF DCS processor
45 std::pair<O2LongUInt, double> lastValue; // last value seen by the TOF DCS processor
46 std::pair<O2LongUInt, double> midValue; // mid value seen by the TOF DCS processor
47 std::pair<std::array<O2LongUInt, 2>, double> maxChange; // maximum variation seen by the TOF DCS processor (previous - subsequent value)
48 std::pair<O2LongUInt, double> minValue; // smallest measurement seen by the TOF DCS processor
49 std::pair<O2LongUInt, double> maxValue; // largest measurement seen by the TOF DCS processor
50 bool updated = false;
52 {
53 firstValue = std::make_pair(0, -999999999);
54 lastValue = std::make_pair(0, -999999999);
55 midValue = std::make_pair(0, -999999999);
56 std::array<O2LongUInt, 2> atmp = {0, 0};
57 maxChange = std::make_pair(atmp, 0);
58 minValue = std::make_pair(0, 99999999999);
59 maxValue = std::make_pair(0, -99999999999);
60 }
61 void makeEmpty()
62 {
63 firstValue.first = lastValue.first = midValue.first = maxChange.first[0] = maxChange.first[1] = minValue.first = maxValue.first = maxChange.second = 0;
64 firstValue.second = lastValue.second = midValue.second = -999999999;
65 minValue.second = 99999999999;
66 maxValue.second = -99999999999;
67 }
68 void print() const;
69
71};
72
74 std::array<int32_t, 6> stripInSM = {-1, -1, -1, -1, -1, -1};
75 int32_t firstPadX = -1;
76 int32_t lastPadX = -1;
77};
78
80{
81
82 public:
84 using DQDoubles = std::deque<double>;
85
86 static constexpr int NFEACS = 8;
87 static constexpr int NDDLS = Geo::kNDDL * Geo::NSECTORS;
88
89 TOFDCSProcessor() = default;
90 ~TOFDCSProcessor() = default;
91
92 void init(const std::vector<DPID>& pids);
93
94 //int process(const std::vector<DPCOM>& dps);
95 int process(const gsl::span<const DPCOM> dps);
96 int processDP(const DPCOM& dpcom);
97 uint64_t processFlags(uint64_t flag, const char* pid);
98
99 void updateDPsCCDB();
100 void getStripsConnectedToFEAC(int nDDL, int nFEAC, TOFFEACinfo& info) const;
101 void updateFEACCCDB();
102 void updateHVCCDB();
103
104 const CcdbObjectInfo& getccdbDPsInfo() const { return mccdbDPsInfo; }
105 CcdbObjectInfo& getccdbDPsInfo() { return mccdbDPsInfo; }
106 const std::unordered_map<DPID, TOFDCSinfo>& getTOFDPsInfo() const { return mTOFDCS; }
107
108 const CcdbObjectInfo& getccdbLVInfo() const { return mccdbLVInfo; }
109 CcdbObjectInfo& getccdbLVInfo() { return mccdbLVInfo; }
110 const std::bitset<Geo::NCHANNELS>& getLVStatus() const { return mFeac; }
111 bool isLVUpdated() const { return mUpdateFeacStatus; }
112
113 const CcdbObjectInfo& getccdbHVInfo() const { return mccdbHVInfo; }
114 CcdbObjectInfo& getccdbHVInfo() { return mccdbHVInfo; }
115 const std::bitset<Geo::NCHANNELS>& getHVStatus() const { return mHV; }
116 bool isHVUpdated() const { return mUpdateHVStatus; }
117
118 void setStartValidityDPs(long t) { mStartValidityDPs = t; }
119 void setStartValidityLV(long t) { mStartValidityLV = t; }
120 void setStartValidityHV(long t) { mStartValidityHV = t; }
121 long getStartValidityDPs() const { return mStartValidityDPs; }
122 long getStartValidityLV() const { return mStartValidityLV; }
123 long getStartValidityHV() const { return mStartValidityHV; }
127 void useVerboseModeDP() { mVerboseDP = true; }
128 void useVerboseModeHVLV() { mVerboseHVLV = true; }
129
131 {
132 mDpsdoublesmap.clear();
133 // mTOFDCS.clear();
134 }
135
137 {
138 for (auto& it : mPids) {
139 if (!it.second) {
140 return false;
141 }
142 }
143 return true;
144 }
145
146 private:
147 std::unordered_map<DPID, TOFDCSinfo> mTOFDCS; // this is the object that will go to the CCDB
148 std::unordered_map<DPID, bool> mPids; // contains all PIDs for the processor, the bool
149 // will be true if the DP was processed at least once
150 std::unordered_map<DPID, std::vector<DPVAL>> mDpsdoublesmap; // this is the map that will hold the DPs for the
151 // double type (voltages and currents)
152
153 std::array<std::array<TOFFEACinfo, NFEACS>, NDDLS> mFeacInfo; // contains the strip/pad info per FEAC
154 std::array<std::bitset<8>, NDDLS> mPrevFEACstatus; // previous FEAC status
155 std::bitset<Geo::NCHANNELS> mFeac; // bitset with feac status per channel
156 bool mUpdateFeacStatus = false; // whether to update the FEAC status in CCDB or not
157 std::bitset<Geo::NCHANNELS> mHV; // bitset with HV status per channel
158 std::array<std::array<std::bitset<19>, Geo::NSECTORS>, Geo::NPLATES> mPrevHVstatus; // previous HV status
159 bool mUpdateHVStatus = false; // whether to update the HV status in CCDB or not
160 CcdbObjectInfo mccdbDPsInfo;
161 CcdbObjectInfo mccdbLVInfo;
162 CcdbObjectInfo mccdbHVInfo;
163 long mStartValidityDPs = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; // TF index for processing, used to store CCDB object for DPs
164 long mStartValidityLV = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; // TF index for processing, used to store CCDB object for LV
165 long mStartValidityHV = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; // TF index for processing, used to store CCDB object for HV
166
167 bool mVerboseDP = false;
168 bool mVerboseHVLV = false;
169
170 ClassDefNV(TOFDCSProcessor, 0);
171};
172} // namespace tof
173} // namespace o2
174
175#endif
static constexpr long INFINITE_TIMESTAMP
static constexpr Int_t NSECTORS
Definition Geo.h:120
@ kNDDL
Definition Geo.h:91
static constexpr Int_t NPLATES
Definition Geo.h:122
const CcdbObjectInfo & getccdbDPsInfo() const
CcdbObjectInfo & getccdbLVInfo()
void init(const std::vector< DPID > &pids)
std::deque< double > DQDoubles
static constexpr int NDDLS
CcdbObjectInfo & getccdbDPsInfo()
CcdbObjectInfo & getccdbHVInfo()
const std::bitset< Geo::NCHANNELS > & getLVStatus() const
void getStripsConnectedToFEAC(int nDDL, int nFEAC, TOFFEACinfo &info) const
const std::bitset< Geo::NCHANNELS > & getHVStatus() const
const CcdbObjectInfo & getccdbHVInfo() const
int processDP(const DPCOM &dpcom)
const CcdbObjectInfo & getccdbLVInfo() const
const std::unordered_map< DPID, TOFDCSinfo > & getTOFDPsInfo() const
uint64_t processFlags(uint64_t flag, const char *pid)
static constexpr int NFEACS
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
ClassDefNV(TOFDCSinfo, 2)
std::pair< O2LongUInt, double > minValue
std::pair< O2LongUInt, double > midValue
std::pair< O2LongUInt, double > firstValue
std::pair< std::array< O2LongUInt, 2 >, double > maxChange
std::pair< O2LongUInt, double > lastValue
std::pair< O2LongUInt, double > maxValue
std::array< int32_t, 6 > stripInSM