Project
Loading...
Searching...
No Matches
FITDCSDataReader.cxx
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
16
18
23
24#include <cstdint>
25#include <gsl/gsl>
26#include <string>
27#include <unordered_map>
28#include <vector>
29
30using namespace o2::fit;
31using namespace o2::dcs;
32
35
36void FITDCSDataReader::init(const std::vector<DPID>& pids)
37{
38 // Fill the array of sub-detector specific DPIDs that will be processed
39 for (const auto& it : pids) {
40 mPids[it] = false;
41 mDpData[it].makeEmpty();
42 }
43}
44
45int FITDCSDataReader::process(const gsl::span<const DPCOM> dps)
46{
47 // first we check which DPs are missing - if some are, it means that
48 // the delta map was sent
49
50 if (getVerboseMode()) {
51 LOG(info) << "\n\nProcessing new DCS DP map\n-------------------------";
52 }
53
54 if (false) {
55 std::unordered_map<DPID, DPVAL> mapin;
56 for (auto& it : dps) {
57 mapin[it.id] = it.data;
58 }
59 for (auto& it : mPids) {
60 const auto& el = mapin.find(it.first);
61 if (el == mapin.end()) {
62 LOG(debug) << "DP " << it.first << " not found in DPs from DCS";
63 } else {
64 LOG(debug) << "DP " << it.first << " found in DPs from DCS";
65 }
66 }
67 }
68
69 // now we process all DPs, one by one
70 for (const auto& it : dps) {
71 // we process only the DPs defined in the configuration
72 const auto& el = mPids.find(it.id);
73 if (el == mPids.end()) {
74 LOG(info) << "DP " << it.id << " not found in FITDCSProcessor, we will not process it";
75 continue;
76 }
77 processDP(it);
78 mPids[it.id] = true;
79 }
80
81 return 0;
82}
83
85{
86 // Processing a single DP
87 const auto& dpid = dpcom.id;
88 const auto& type = dpid.get_type();
89 const auto& val = dpcom.data;
90
91 if (getVerboseMode()) {
92 if (type == DPVAL_DOUBLE) {
93 LOG(info) << "Processing DP = " << dpcom << " (epoch " << val.get_epoch_time() << "), with value = " << o2::dcs::getValue<double>(dpcom);
94 } else if (type == DPVAL_UINT) {
95 LOG(info) << "Processing DP = " << dpcom << " (epoch " << val.get_epoch_time() << "), with value = " << o2::dcs::getValue<uint>(dpcom);
96 }
97 }
98
99 auto flags = val.get_flags();
100 if (processFlags(flags, dpid.get_alias()) == 0) {
101 // Store all DP values
102 if (mDpData[dpid].values.empty() || val.get_epoch_time() > mDpData[dpid].values.back().first) {
103 dpValueConverter.raw_data = val.payload_pt1;
104 if (type == DPVAL_DOUBLE) {
105 mDpData[dpid].add(val.get_epoch_time(), llround(dpValueConverter.double_value * 1000)); // store as nA
106 } else if (type == DPVAL_UINT) {
107 mDpData[dpid].add(val.get_epoch_time(), dpValueConverter.uint_value);
108 }
109 }
110 }
111
112 return 0;
113}
114
115uint64_t FITDCSDataReader::processFlags(const uint64_t flags, const char* pid)
116{
117 // function to process the flag. the return code zero means that all is fine.
118 // anything else means that there was an issue
119
120 // for now, I don't know how to use the flags, so I do nothing
121
123 LOG(debug) << "KEEP_ALIVE_FLAG active for DP " << pid;
124 }
126 LOG(debug) << "FBI_FLAG active for DP " << pid;
127 }
129 LOG(debug) << "NEW_FLAG active for DP " << pid;
130 }
132 LOG(debug) << "DIRTY_FLAG active for DP " << pid;
133 }
135 LOG(debug) << "TURN_FLAG active for DP " << pid;
136 }
138 LOG(debug) << "WRITE_FLAG active for DP " << pid;
139 }
141 LOG(debug) << "READ_FLAG active for DP " << pid;
142 }
144 LOG(debug) << "OVERWRITE_FLAG active for DP " << pid;
145 }
147 LOG(debug) << "VICTIM_FLAG active for DP " << pid;
148 }
150 LOG(debug) << "DIM_ERROR_FLAG active for DP " << pid;
151 }
153 LOG(debug) << "BAD_DPID_FLAG active for DP " << pid;
154 }
156 LOG(debug) << "BAD_FLAGS_FLAG active for DP " << pid;
157 }
159 LOG(debug) << "BAD_TIMESTAMP_FLAG active for DP " << pid;
160 }
162 LOG(debug) << "BAD_PAYLOAD_FLAG active for DP " << pid;
163 }
165 LOG(debug) << "BAD_FBI_FLAG active for DP " << pid;
166 }
167
168 return 0;
169}
170
172{
173 // Prepare the object to be sent to CCDB
174 if (getVerboseMode()) {
175 for (auto& dp : mDpData) {
176 // if (dp.second.values.empty()) {
177 // continue;
178 // }
179 LOG(info) << "PID = " << dp.first.get_alias();
180 dp.second.print();
181 }
182 }
183
184 std::map<std::string, std::string> metadata;
186
187 return;
188}
189
190const std::unordered_map<DPID, DCSDPValues>& FITDCSDataReader::getDpData() const { return mDpData; }
191
193{
194 mDpsMap.clear();
195 mDpData.clear();
196}
197
198const std::string& FITDCSDataReader::getCcdbPath() const { return mCcdbPath; }
199void FITDCSDataReader::setCcdbPath(const std::string& ccdbPath) { mCcdbPath = ccdbPath; }
200long FITDCSDataReader::getStartValidity() const { return mStartValidity; }
201void FITDCSDataReader::setStartValidity(const long startValidity) { mStartValidity = startValidity; }
204long FITDCSDataReader::getEndValidity() const { return mStartValidity + 3 * o2::ccdb::CcdbObjectInfo::DAY; }
205const o2::ccdb::CcdbObjectInfo& FITDCSDataReader::getccdbDPsInfo() const { return mCcdbDpInfo; }
207
208bool FITDCSDataReader::getVerboseMode() const { return mVerbose; }
209void FITDCSDataReader::setVerboseMode(bool verboseMode) { mVerbose = verboseMode; }
Utils and constants for calibration and related workflows.
std::ostringstream debug
DCS data point reader for FIT.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
std::string ccdbPath(const std::string badChannelType)
uint16_t pid
Definition RawData.h:2
static constexpr long DAY
static constexpr long INFINITE_TIMESTAMP
DeliveryType get_type() const noexcept
const std::string & getCcdbPath() const
uint64_t processFlags(uint64_t flag, const char *pid)
void setVerboseMode(bool verboseMode=true)
const CcdbObjectInfo & getccdbDPsInfo() const
void setStartValidity(long startValidity)
void init(const std::vector< DPID > &pids)
int processDP(const DPCOM &dpcom)
const std::unordered_map< DPID, DCSDPValues > & getDpData() const
int process(const gsl::span< const DPCOM > dps)
void setCcdbPath(const std::string &ccdbPath)
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLenum GLsizei GLsizei GLint * values
Definition glcorearb.h:1576
GLuint GLfloat * val
Definition glcorearb.h:1582
static void prepareCCDBobjectInfo(T &obj, o2::ccdb::CcdbObjectInfo &info, const std::string &path, const std::map< std::string, std::string > &md, long start, long end=-1)
Definition Utils.h:91
static constexpr uint16_t BAD_TIMESTAMP_FLAG
static constexpr uint16_t WRITE_FLAG
static constexpr uint16_t DIRTY_FLAG
static constexpr uint64_t TURN_FLAG
static constexpr uint16_t END_FLAG
static constexpr uint16_t BAD_PAYLOAD_FLAG
static constexpr uint16_t BAD_DPID_FLAG
static constexpr uint16_t KEEP_ALIVE_FLAG
static constexpr uint16_t DIM_ERROR_FLAG
static constexpr uint16_t OVERWRITE_FLAG
static constexpr uint16_t BAD_FBI_FLAG
static constexpr uint16_t VICTIM_FLAG
static constexpr uint16_t BAD_FLAGS_FLAG
static constexpr uint16_t READ_FLAG
static constexpr uint16_t NEW_FLAG
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"