Project
Loading...
Searching...
No Matches
EMCDCSProcessor.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
30
31#include <map>
32#include <iterator>
33#include "EMCALCalib/CalibDB.h"
35
36using namespace o2::dcs;
37using namespace o2::emcal;
38
42
43void EMCDCSProcessor::init(const std::vector<DPID>& pids)
44{
45
46 for (const auto& it : pids) {
47 mPids[it] = false;
48 }
49
50 mFEECFG = std::make_unique<FeeDCS>();
51 mELMB = std::make_unique<EMCELMB>();
52 mELMBdata = std::make_unique<ElmbData>();
53
54 mELMB->init();
55
56 mTFprevELMB = 0;
57}
58
59int EMCDCSProcessor::process(const gsl::span<const DPCOM> dps)
60{
61 mUpdateFEEcfg = false;
62 mUpdateELMB = false;
63
64 if (mVerbose) {
65 LOG(info) << "\n\n\nProcessing new TF\n-----------------";
66 }
67
68 for (auto& it : dps) {
69 const auto& el = mPids.find(it.id);
70
71 if (el == mPids.end()) {
72 LOG(debug) << "DP " << it.id << " not found in the map of expected DPs- ignoring...";
73 continue;
74 } else {
75 LOG(debug) << "DP " << it.id << " found in map";
76 }
77
78 processDP(it);
79 }
80
81 return 0;
82}
83
85{
86
87 mUpdateELMB = true;
88 mELMB->process();
89 mELMBdata->setData(mELMB->getData());
90 mELMB->reset();
91}
92
94{
95
96 auto& dpid = dp.id;
97 const auto& type = dpid.get_type();
98 auto& val = dp.data;
99
100 if (mVerbose) {
101 if (type == DPVAL_DOUBLE) {
102 LOG(info) << "Processing DP = " << dp << ", with value = " << o2::dcs::getValue<double>(dp);
103 } else if (type == DPVAL_INT) {
104 LOG(info) << "Processing DP = " << dp << ", with value = " << o2::dcs::getValue<int32_t>(dp);
105 } else if (type == DPVAL_UINT) {
106 LOG(info) << "Processing DP = " << dp << ", with value = " << o2::dcs::getValue<uint32_t>(dp);
107 }
108 }
109
110 if ((type == DPVAL_INT) || (type == DPVAL_UINT)) // FEE config params and STU_TRU error counters
111 {
112 auto& dpval_prev = mapFEEcfg[dpid];
113 if (dpval_prev.size() == 0 || val.get_epoch_time() != dpval_prev.back().get_epoch_time()) // compare the time stamps
114 {
115 dpval_prev.push_back(val); // do we need to archive them all???
116 // mUpdateFEEcfg = true; FEE data will be updated based on SOR/EOR
117
118 FillFeeDP(dp);
119 setTF(val.get_epoch_time()); // fix: this must not be here!
120 }
121 } else if (type == DPVAL_DOUBLE) { // ELMB data
122 FillElmbDP(dp);
123 }
124 // printPDCOM(dp);
125
126 return 0;
127}
128
129void EMCDCSProcessor::FillElmbDP(const DPCOM& dpcom)
130{
131 auto& dpid = dpcom.id;
132 const auto type = dpid.get_type();
133 std::string type_str = show(type);
134
135 std::string alias(dpid.get_alias());
136
137 auto& dpval = dpcom.data;
138 auto val = o2::dcs::getValue<double>(dpcom); // dpval.payload_pt1;
139
140 std::size_t index;
141 int iPT = -1;
142
143 if ((index = alias.find("EMC_PT")) != std::string::npos) {
144 std::sscanf(alias.data(), "EMC_PT_%d.Temperature", &iPT);
145 if (mVerbose) {
146 LOG(debug) << "alias=" << alias.data() << ": iPT=" << iPT << ", val=" << val;
147 }
148
149 if (iPT < 0 || iPT > 159) {
150 LOG(error) << "Wrong Sensor Index iPT=" << iPT << " for DP " << alias.data();
151 return;
152 }
153 mELMB->addMeasurement(iPT, val);
154 } else {
155 LOG(info) << "EMC_PT pattern not found for DPype = DPVAL_DOUBLE: alias = " << alias.data();
156 }
157 return;
158}
159
160void EMCDCSProcessor::FillFeeDP(const DPCOM& dpcom)
161{
162 auto& dpid = dpcom.id;
163 const auto type = dpid.get_type();
164 std::string type_str = show(type);
165
166 std::string alias(dpid.get_alias());
167
168 auto& dpval = dpcom.data;
169 auto ts = dpval.get_epoch_time();
170 auto val = dpval.payload_pt1;
171
172 std::size_t index;
173 int iTRU = -1;
174 int iMask = -1;
175 int iSM = -1;
176
177 // if (mVerbose) {
178 // LOG(info) << "EMCDCSProcessor::FillFeeDP called";
179 // }
180 //
181
182 if ((index = alias.find("STU_ERROR_COUNT_TRU")) != std::string::npos) {
183 // processing of STU_TRU error counters not included yet
184 return;
185 }
186
187 else if (alias.find("EMC_RUNNUMBER") != std::string::npos) {
188 if (mFEECFG->getRunNumber() != val) {
189 mUpdateFEEcfg = true;
190 }
191 if (mRunNumberFromGRP == -2) { // no run number from GRP
192 mFEECFG->setRunNumber(val);
193 } else {
194 mFEECFG->setRunNumber(mRunNumberFromGRP);
195 if (mRunNumberFromGRP != val) {
196 LOG(error) << "RunNumber from GRP (=" << mRunNumberFromGRP << ") and from EMC DCS (=" << val << ") are not consistant";
197 }
198 }
199 } else if (alias.find("EMC_DDL_LIST0") != std::string::npos) {
200 mFEECFG->setDDLlist0(val);
201 } else if (alias.find("EMC_DDL_LIST1") != std::string::npos) {
202 mFEECFG->setDDLlist1(val);
203 } else if ((index = alias.find("SRU")) != std::string::npos) {
204 if ((index = alias.find("FMVER")) != std::string::npos) {
205 std::sscanf((std::string(alias.substr(index - 3, 2))).data(), "%02d", &iSM);
206 if (iSM < 0 || iSM >= 20) {
207 LOG(error) << "ERROR : iSM = " << iSM << " for" << alias.data();
208 return;
209 }
210 mFEECFG->setSRUFWversion(iSM, val);
211 } else if ((index = alias.find("CFG")) != std::string::npos) {
212 std::sscanf((std::string(alias.substr(index - 3, 2))).data(), "%02d", &iSM);
213 if (iSM < 0 || iSM >= 20) {
214 LOG(error) << "ERROR : iSM = " << iSM << " for" << alias.data();
215 return;
216 }
217 mFEECFG->setSRUconfig(iSM, val);
218 }
219 } else if ((index = alias.find("TRU")) != std::string::npos) {
220 std::sscanf((std::string(alias.substr(index + 3, 2))).data(), "%02d", &iTRU);
221
222 if (iTRU < 0 || iTRU >= kNTRU) {
223 LOG(error) << "ERROR : iTRU = " << iTRU << " for" << alias.data();
224 return;
225 }
226
227 mTRU = mFEECFG->getTRUDCS(iTRU);
228 if (alias.find("L0ALGSEL") != std::string::npos) {
229 mTRU.setL0SEL(val);
230 } else if (alias.find("PEAKFINDER") != std::string::npos) {
231 mTRU.setSELPF(val);
232 } else if (alias.find("GLOBALTHRESH") != std::string::npos) {
233 mTRU.setGTHRL0(val);
234 } else if (alias.find("COSMTHRESH") != std::string::npos) {
235 mTRU.setL0COSM(val);
236 } else if ((index = alias.find("MASK")) != std::string::npos) {
237 std::sscanf((std::string(alias.substr(index + 4, 1))).data(), "%02d", &iMask);
238 mTRU.setMaskReg(val, iMask);
239 if (iMask < 0 || iMask > 5) {
240 LOG(error) << "ERROR : iMask = " << iMask << " for" << alias.data();
241 return;
242 }
243 }
244
245 mFEECFG->setTRUDCS(iTRU, mTRU);
246 } else if ((index = alias.find("_STU_")) != std::string::npos) {
247 bool kEMC = (std::string(alias.substr(index - 3, 3))).compare(0, 3, "DMC", 0, 3);
248 mSTU = kEMC ? mFEECFG->getSTUDCSEMCal() : mFEECFG->getSTUDCSDCal();
249
250 if (alias.find("MEDIAN") != std::string::npos) {
251 mSTU.setMedianMode(val);
252 } else if (alias.find("GETRAW") != std::string::npos) {
253 mSTU.setRawData(val);
254 } else if (alias.find("REGION") != std::string::npos) {
255 mSTU.setRegion(val);
256 } else if (alias.find("FWVERS") != std::string::npos) {
257 mSTU.setFw(val);
258 } else if (alias.find("PATCHSIZE") != std::string::npos) {
259 mSTU.setPatchSize(val);
260 } else if ((index = alias.find("STU_G")) != std::string::npos) {
261 char par1;
262 int par2;
263 std::sscanf((std::string(alias.substr(index + 5, 2))).data(), "%c%d", &par1, &par2);
264 if (par2 == 0) {
265 mSTU.setGammaHigh((int)par1 - 65, val);
266 } else {
267 mSTU.setGammaLow((int)par1 - 65, val);
268 }
269 } else if ((index = alias.find("STU_J")) != std::string::npos) {
270 char par1;
271 int par2;
272 std::sscanf((std::string(alias.substr(index + 5, 2))).data(), "%c%d", &par1, &par2);
273 if (par2 == 0) {
274 mSTU.setJetHigh((int)par1 - 65, val);
275 } else {
276 mSTU.setJetLow((int)par1 - 65, val);
277 }
278 }
279
280 if (kEMC) {
281 mFEECFG->setSTUEMCal(mSTU);
282 } else {
283 mFEECFG->setSTUDCal(mSTU);
284 }
285 }
286}
287
289{
290 if (mVerbose) {
291 LOG(info) << "updating Temperture objects in CCDB";
292 // LOG(info) << "Temperture objects to be written in CCDB\n";
293 // << *mFEECFG.get();
294 }
295
296 std::map<std::string, std::string> metadata;
297 metadata["responsible"] = "Martin Poghosyan";
298 prepareCCDBobjectInfo(*mELMBdata.get(), mccdbELMBinfo, o2::emcal::CalibDB::getCDBPathTemperatureSensor(), mTF, metadata);
299}
300
302{
303 if (mVerbose) {
304 LOG(info) << "updating FEE DCS objects in CCDB";
305 // LOG(info) << "FEE DCS object to be written in CCDB\n"
306 // << *mFEECFG.get();
307 }
308 std::map<std::string, std::string> metadata;
309 metadata["responsible"] = "Martin Poghosyan";
310 prepareCCDBobjectInfo(*mFEECFG.get(), mccdbFEEcfginfo, o2::emcal::CalibDB::getCDBPathFeeDCS(), mTF, metadata);
311}
312
314{
315 auto& dpid = dpcom.id;
316 const auto type = dpid.get_type();
317 std::string type_str = show(type);
318
319 auto alias = dpid.get_alias();
320
321 auto& dpval = dpcom.data;
322 auto ts = dpval.get_epoch_time();
323 auto val = dpval.payload_pt1;
324
325 std::cout << "DPCOM Info:";
326
327 std::cout << " alias: " << alias;
328 std::cout << " | type : " << type_str;
329 std::cout << " | ts : " << ts;
330 std::cout << " | value: " << val << std::endl;
331}
std::ostringstream debug
DeliveryType get_type() const noexcept
static const char * getCDBPathTemperatureSensor()
Get CDB path for the Temperature Sensor data.
Definition CalibDB.h:362
static const char * getCDBPathFeeDCS()
Get CDB path for the FEE DCS settings.
Definition CalibDB.h:358
void printPDCOM(const DPCOM &dpcom)
void prepareCCDBobjectInfo(const T &obj, CcdbObjectInfo &info, const std::string &path, TFType tf, const std::map< std::string, std::string > &md)
int processDP(const DPCOM &dpcom)
int process(const gsl::span< const DPCOM > dps)
void setPatchSize(int size)
void setGammaHigh(int vzpar, int val)
void setJetHigh(int vzpar, int val)
void setMedianMode(int mode)
void setGammaLow(int vzpar, int val)
void setJetLow(int vzpar, int val)
void setL0SEL(uint64_t la)
void setL0COSM(uint64_t lc)
void setGTHRL0(uint64_t lg)
void setSELPF(uint64_t pf)
void setMaskReg(uint32_t msk, int pos)
GLuint index
Definition glcorearb.h:781
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLuint GLfloat * val
Definition glcorearb.h:1582
std::string show(const DeliveryType type)
const Int_t kNTRU
Definition FeeDCS.h:29
void compare(const PedestalProcessorData &testobject, const TProfile &refFECHG, const TProfile &refFECLG, const TProfile &refLEDMONHG, const TProfile &refLEDMONLG, bool testCount, bool verbose)
uint64_t get_epoch_time() const noexcept
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"