Project
Loading...
Searching...
No Matches
DCSConfigReader.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
14#include "Framework/Logger.h"
15#include "TSystem.h"
16#include <fstream>
17
18using namespace o2::mft;
19
20//_______________________________________________________________
22{
23 mVerbose = ver;
24 clear();
25 mDCSUtils = new DCSConfigUtils();
26 mDCSUtils->init();
27}
28
29//_______________________________________________________________
30void DCSConfigReader::loadConfig(gsl::span<const char> configBuf)
31{
32 const char* params = configBuf.data();
33 mParams = std::string(params);
34 parseConfig();
35}
36
38{
39 mDCSConfig.clear();
40}
41
43{
44 for (int iChip = 0; iChip < 936; ++iChip) {
45 mNoiseMap.resetChip(iChip);
46 }
47}
48
49//_______________________________________________________________
50
51void DCSConfigReader::parseConfig()
52{
54
55 char delimiter_newline = '\n';
56 char delimiter = ',';
57
58 std::stringstream stream(mParams);
59 std::string row;
60
61 int nrow = 0;
62 int nru = 0;
63 int nalpide = 0;
64 int nubb = 0;
65 int ndeadmap = 0;
66
67 std::string verName = "";
68 std::vector<int> arrRUAdd;
69 std::vector<int> arrRUVal;
70 std::vector<int> arrALPIDEAdd;
71 std::vector<int> arrALPIDEVal;
72 std::vector<std::string> arrUBBName;
73 std::vector<double> arrUBBVal;
74 std::vector<int> arrDeadChip;
75
76 while (std::getline(stream, row, delimiter_newline)) {
77
78 std::stringstream srow(row);
79 std::string col;
80
81 while (std::getline(srow, col, delimiter)) {
82
83 col.erase(std::remove(col.begin(), col.end(), ' '), col.end());
84 int val = atoi(col.c_str());
85
86 if (nrow == mDCSUtils->getVersionNameLineInCsv()) {
87 verName = col.c_str();
88 } else if (nrow == mDCSUtils->getRUConfigAddressLineInCsv()) {
89 arrRUAdd.emplace_back(atoi(col.c_str()));
90 ++nru;
91 } else if (nrow == mDCSUtils->getRUConfigValueLineInCsv()) {
92 arrRUVal.emplace_back(atoi(col.c_str()));
93 } else if (nrow == mDCSUtils->getALPIDEConfigAddressLineInCsv()) {
94 arrALPIDEAdd.emplace_back(atoi(col.c_str()));
95 ++nalpide;
96 } else if (nrow == mDCSUtils->getALPIDEConfigValueLineInCsv()) {
97 arrALPIDEVal.emplace_back(atoi(col.c_str()));
98 } else if (nrow == mDCSUtils->getUBBConfigNameLineInCsv()) {
99 col = col.substr(0, 13);
100 arrUBBName.emplace_back(col.c_str());
101 ++nubb;
102 } else if (nrow == mDCSUtils->getUBBConfigValueLineInCsv()) {
103 arrUBBVal.emplace_back(atof(col.c_str()));
104 } else if (nrow == mDCSUtils->getDeadMapLineInCsv()) {
105 arrDeadChip.emplace_back(atoi(col.c_str()));
106 ++ndeadmap;
107 } else {
108 LOG(warning) << "Not expected parameters are sent from DCS!!!!";
109 }
110 }
111 ++nrow;
112 }
113 if (mVerbose) {
114 LOG(info) << "Configuration version / type: " << verName;
115 LOG(info) << "Found " << nru << " RU parameters";
116 }
117 for (int iRUconf = 0; iRUconf < nru; ++iRUconf) {
118 if (mVerbose) {
119 LOG(info) << "(" << arrRUAdd[iRUconf] << ") "
120 << mDCSUtils->getName(arrRUAdd[iRUconf], "RU")
121 << " : " << arrRUVal[iRUconf];
122 }
124 conf.clear();
125 conf.setData(arrRUVal[iRUconf]);
126 conf.setAdd(arrRUAdd[iRUconf]);
127 conf.setType(0); // RU = 0
128 conf.setVersion(verName);
129 mDCSConfig.emplace_back(conf);
130 if (arrRUAdd[iRUconf] == 4097) {
131 const std::string& key = "MFTAlpideParam.roFrameLengthInBC";
132 const std::string& keyval = Form("%d", arrRUVal[iRUconf]);
133 mAlpideInfo.setValue(key, keyval);
134 }
135 }
136
137 if (mVerbose) {
138 LOG(info) << "Found " << nalpide << " ALPIDE parameters";
139 }
140 for (int iALPIDEconf = 0; iALPIDEconf < nalpide; ++iALPIDEconf) {
141 if (mVerbose) {
142 LOG(info) << "(" << arrALPIDEAdd[iALPIDEconf] << ") "
143 << mDCSUtils->getName(arrALPIDEAdd[iALPIDEconf], "ALPIDE")
144 << " : " << arrALPIDEVal[iALPIDEconf];
145 }
147 conf.clear();
148 conf.setData(arrALPIDEVal[iALPIDEconf]);
149 conf.setAdd(arrALPIDEAdd[iALPIDEconf]);
150 conf.setType(1); // ALPIDE = 1
151 conf.setVersion(verName);
152 mDCSConfig.emplace_back(conf);
153 }
154
155 if (mVerbose) {
156 LOG(info) << "Found " << nubb << " UBB parameters";
157 }
158 for (int iUBBconf = 0; iUBBconf < nubb; ++iUBBconf) {
159 if (mVerbose) {
160 LOG(info) << "(" << mDCSUtils->getAddress(arrUBBName[iUBBconf], "UBB") << ") "
161 << arrUBBName[iUBBconf]
162 << " : " << arrUBBVal[iUBBconf];
163 }
165 conf.clear();
166 conf.setData(arrUBBVal[iUBBconf]);
167 conf.setAdd(mDCSUtils->getAddress(arrUBBName[iUBBconf], "UBB"));
168 conf.setType(2); // UBB = 2
169 conf.setVersion(verName);
170 mDCSConfig.emplace_back(conf);
171 }
172
173 if (mVerbose) {
174 LOG(info) << "Found " << ndeadmap << " Dead chips";
175 }
176 for (int iDeadMap = 0; iDeadMap < ndeadmap; ++iDeadMap) {
177 if (mVerbose) {
178 LOG(info) << "Chip" << arrDeadChip[iDeadMap] << " is dead.";
179 }
181 conf.clear();
182 conf.setData(1);
183 conf.setAdd(arrDeadChip[iDeadMap]);
184 conf.setType(3); // DeadMap = 3
185 conf.setVersion(verName);
186 mDCSConfig.emplace_back(conf);
187
188 mNoiseMap.maskFullChip(arrDeadChip[iDeadMap], true);
189 }
190}
MFT Processor for DCS Config.
uint32_t col
Definition RawData.h:4
StringRef key
void maskFullChip(int chip, bool cleanNoisyPixels=false)
Definition NoiseMap.h:178
void resetChip(int chip)
Definition NoiseMap.h:191
void setVersion(std::string str)
void loadConfig(gsl::span< const char > configBuf)
int getAddress(std::string name, std::string type)
std::string getName(int add, std::string type)
GLenum const GLfloat * params
Definition glcorearb.h:272
GLuint GLfloat * val
Definition glcorearb.h:1582
GLuint GLuint stream
Definition glcorearb.h:1806
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row