Project
Loading...
Searching...
No Matches
ZDCDCSProcessor.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#include <memory>
13#include <Rtypes.h>
14#include <unordered_map>
15#include <deque>
16#include <numeric>
17#include "Framework/Logger.h"
18#include "Framework/O2LongInt.h"
23#include "CCDB/CcdbObjectInfo.h"
25#include "CCDB/CcdbApi.h"
26#include <gsl/gsl>
28#ifndef DETECTOR_ZDCDCSPROCESSOR_H_
29#define DETECTOR_ZDCDCSPROCESSOR_H_
30
32
33namespace o2
34{
35namespace zdc
36{
37
41
42struct ZDCDCSinfo {
43 std::pair<O2LongUInt, double> firstValue; // first value seen by the ZDC DCS processor
44 std::pair<O2LongUInt, double> lastValue; // last value seen by the ZDC DCS processor
45 std::pair<O2LongUInt, double> midValue; // mid value seen by the ZDC DCS processor
46 std::pair<O2LongUInt, double> maxChange; // maximum variation seen by the ZDC DCS processor
47
49 {
50 firstValue = std::make_pair(0, -999999999);
51 lastValue = std::make_pair(0, -999999999);
52 midValue = std::make_pair(0, -999999999);
53 maxChange = std::make_pair(0, -999999999);
54 }
55 void makeEmpty()
56 {
57 firstValue.first = lastValue.first = midValue.first = maxChange.first = 0;
58 firstValue.second = lastValue.second = midValue.second = maxChange.second = -999999999;
59 }
60 void print() const;
61
63};
64
66 std::array<int, 4> moduleID = {-1, -1, -1, -1};
67 std::array<bool, 4> readChannel = {false, false, false, false};
68 std::array<bool, 4> triggerChannel = {false, false, false, false};
69 std::array<int, 4> channelValue = {-1, -1, -1, -1};
70};
71
72/*struct TriggerChannelConfig {
73 int id = -1;
74 int first = 0;
75 int last = 0;
76 uint8_t shift = 0;
77 int16_t threshold = 0;
78};*/
79
81{
82
83 public:
84 using TFType = uint64_t;
86
87 static constexpr int NDDLS = 16;
88 static constexpr int NMODULES = 8;
89 static constexpr int NCHANNELS = 4;
90 static constexpr int NHVCHANNELS = 22 + 12; // no. of HV+additional HV channels
91
92 ZDCDCSProcessor() = default;
93 ~ZDCDCSProcessor() = default;
94
95 void init(const std::vector<DPID>& pids);
96
97 int process(const gsl::span<const DPCOM> dps);
98 int processDP(const DPCOM& dpcom);
99 virtual uint64_t processFlags(uint64_t flag, const char* pid);
100
101 void getZDCActiveChannels(int nDDL, int nModule, ZDCModuleMap& info) const;
102 void updateDPsCCDB();
103 void updateMappingCCDB();
104 void updateHVCCDB();
105 void updatePositionCCDB();
106
107 const CcdbObjectInfo& getccdbDPsInfo() const { return mccdbDPsInfo; }
108 CcdbObjectInfo& getccdbDPsInfo() { return mccdbDPsInfo; }
109 const std::unordered_map<DPID, ZDCDCSinfo>& getZDCDPsInfo() const { return mZDCDCS; }
110
111 const std::bitset<NCHANNELS>& getMappingStatus() const { return mMapping; }
112 bool isMappingUpdated() const { return mUpdateMapping; }
113
114 const CcdbObjectInfo& getccdbHVInfo() const { return mccdbHVInfo; }
115 CcdbObjectInfo& getccdbHVInfo() { return mccdbHVInfo; }
116 const std::bitset<NHVCHANNELS>& getHVStatus() const { return mHV; }
117 bool isHVUpdated() const { return mUpdateHVStatus; }
118
119 const CcdbObjectInfo& getccdbPositionInfo() const { return mccdbPositionInfo; }
120 CcdbObjectInfo& getccdbPositionInfo() { return mccdbPositionInfo; }
121 const std::bitset<NCHANNELS>& getVerticalPosition() const { return mVerticalPosition; }
122 bool isPositionUpdated() const { return mUpdateVerticalPosition; }
123
124 template <typename T>
125 void prepareCCDBobjectInfo(T& obj, CcdbObjectInfo& info, const std::string& path, TFType tf,
126 const std::map<std::string, std::string>& md);
127
128 void setTF(TFType tf) { mTF = tf; }
129 void setStartValidity(long t) { mStartValidity = t; }
130 void useVerboseMode() { mVerbose = true; }
131
133 {
134 mDpsdoublesmap.clear();
135 mZDCDCS.clear();
136 }
137
138 private:
139 std::unordered_map<DPID, ZDCDCSinfo> mZDCDCS; // object that will go to the CCDB
140 std::unordered_map<DPID, bool> mPids; // contains all PIDs for the processor
141 // bool is true if the DP was processed at least once
142 std::unordered_map<DPID, std::vector<DPVAL>> mDpsdoublesmap; // map that will hold the double value DPs
143
144 std::array<std::array<ZDCModuleMap, NMODULES>, NDDLS> mZDCMapInfo; // contains the strip/pad info per module
145 std::array<std::bitset<NCHANNELS>, NDDLS> mPreviousMapping; // previous mapping
146 std::bitset<NCHANNELS> mMapping; // bitset with status per channel
147 bool mUpdateMapping = false; // whether to update mapping in CCDB
148
149 std::bitset<NHVCHANNELS> mHV; // bitset with HV status per channel
150 std::bitset<NHVCHANNELS> mPrevHVstatus; // previous HV status
151 bool mUpdateHVStatus = false; // whether to update the HV status in CCDB
152
153 std::bitset<NCHANNELS> mVerticalPosition; // bitset with hadronic calorimeter position
154 std::bitset<NCHANNELS> mPrevPositionstatus; // previous position values
155 bool mUpdateVerticalPosition = false; // whether to update the hadronic calorimeter position
156
157 CcdbObjectInfo mccdbDPsInfo;
158 CcdbObjectInfo mccdbMappingInfo;
159 CcdbObjectInfo mccdbHVInfo;
160 CcdbObjectInfo mccdbPositionInfo;
161 TFType mStartTF; // TF index for processing of first processed TF, used to store CCDB object
162 TFType mTF = 0; // TF index for processing, used to store CCDB object
163 bool mStartTFset = false;
164 long mStartValidity = 0; // TF index for processing, used to store CCDB object
165 bool mVerbose = false;
166
167 ClassDefNV(ZDCDCSProcessor, 0);
168};
169
170template <typename T>
172 const std::map<std::string, std::string>& md)
173{
174
175 // prepare all info to be sent to CCDB for object obj
177 auto flName = o2::ccdb::CcdbApi::generateFileName(clName);
178 info.setPath(path);
179 info.setObjectType(clName);
180 info.setFileName(flName);
182 info.setEndValidityTimestamp(99999999999999);
183 info.setMetaData(md);
184}
185
186} // namespace zdc
187} // namespace o2
188
189#endif
uint64_t TFType
static std::string generateFileName(const std::string &inp)
Definition CcdbApi.cxx:798
void setStartValidityTimestamp(long start)
void setFileName(const std::string &nm)
void setPath(const std::string &path)
void setEndValidityTimestamp(long end)
void setObjectType(const std::string &tp)
void setMetaData(const std::map< std::string, std::string > &md)
const std::bitset< NCHANNELS > & getVerticalPosition() const
void init(const std::vector< DPID > &pids)
const std::bitset< NCHANNELS > & getMappingStatus() const
const CcdbObjectInfo & getccdbHVInfo() const
const std::bitset< NHVCHANNELS > & getHVStatus() const
static constexpr int NCHANNELS
static constexpr int NHVCHANNELS
void getZDCActiveChannels(int nDDL, int nModule, ZDCModuleMap &info) const
static constexpr int NMODULES
CcdbObjectInfo & getccdbPositionInfo()
CcdbObjectInfo & getccdbDPsInfo()
const CcdbObjectInfo & getccdbPositionInfo() const
int processDP(const DPCOM &dpcom)
virtual uint64_t processFlags(uint64_t flag, const char *pid)
static constexpr int NDDLS
CcdbObjectInfo & getccdbHVInfo()
void prepareCCDBobjectInfo(T &obj, CcdbObjectInfo &info, const std::string &path, TFType tf, const std::map< std::string, std::string > &md)
const CcdbObjectInfo & getccdbDPsInfo() const
const std::unordered_map< DPID, ZDCDCSinfo > & getZDCDPsInfo() const
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::unique_ptr< GPUReconstructionTimeframe > tf
static std::string getClassName(const T &obj)
get the class name of the object
std::pair< O2LongUInt, double > maxChange
std::pair< O2LongUInt, double > midValue
std::pair< O2LongUInt, double > firstValue
std::pair< O2LongUInt, double > lastValue
ClassDefNV(ZDCDCSinfo, 1)
std::array< bool, 4 > triggerChannel
std::array< int, 4 > moduleID
std::array< bool, 4 > readChannel
std::array< int, 4 > channelValue