Project
Loading...
Searching...
No Matches
DCSConfigUtils.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 O2_MFT_DNSUTILS_H
13#define O2_MFT_DNSUTILS_H
14
17
18#include <TString.h>
19#include "Framework/Logger.h"
20#include <map>
21#include <iostream>
22#include <fstream>
23#include <sstream>
24
25namespace o2
26{
27namespace mft
28{
29
31{
32
33 public:
35 {
36 init();
37 }
38 void init()
39 {
40 initDictionary();
41 }
42
43 void clear()
44 {
45 }
46
47 int getAddress(std::string name, std::string type)
48 {
49 return (mNameDict[type])[name];
50 }
51
52 std::string getName(int add, std::string type)
53 {
54 return (mAddressDict[type])[add];
55 }
56
57 std::map<int, std::string> getAddressMap(std::string type)
58 {
59 return mAddressDict[type];
60 }
61
62 std::map<int, std::string> getAddressMap(int type)
63 {
64 return mAddressDict[getTypeName(type)];
65 }
66
67 std::map<std::string, int> getNameMap(std::string type)
68 {
69 return mNameDict[type];
70 }
71
72 std::map<std::string, int> getNameMap(int type)
73 {
74 return mNameDict[getTypeName(type)];
75 }
76
77 const std::string getTypeName(int type)
78 {
79 if (type == 0) {
80 return "RU";
81 } else if (type == 1) {
82 return "ALPIDE";
83 } else if (type == 2) {
84 return "UBB";
85 } else if (type == 3) {
86 return "DeadMap";
87 } else {
88 LOG(error) << "You can select 0 (RU), 1 (ALPIDE), 2 (UBB), 3 (DeadMap)";
89 return "Unknown";
90 }
91 }
92
93 const int getType(std::string type)
94 {
95 if (type == "RU") {
96 return 0;
97 } else if (type == "ALPIDE") {
98 return 1;
99 } else if (type == "UBB") {
100 return 2;
101 } else if (type == "DeadMap") {
102 return 3;
103 } else {
104 LOG(error) << "You can select RU (0), ALPIDE (1), UBB (2), DeadMap (3)";
105 return -999;
106 }
107 }
108
109 std::string& getVersion()
110 {
111 return mVersion;
112 }
113
115 {
116 return mVerNameLine;
117 }
119 {
120 return mRUConfAddLine;
121 }
123 {
124 return mRUConfValLine;
125 }
127 {
128 return mALPIDEConfAddLine;
129 }
131 {
132 return mALPIDEConfValLine;
133 }
135 {
136 return mUBBNameLine;
137 }
139 {
140 return mUBBValLine;
141 }
143 {
144 return mDeadMapLine;
145 }
146
147 private:
148 const int mVerNameLine = 0;
149 const int mALPIDEConfAddLine = 1;
150 const int mALPIDEConfValLine = 2;
151 const int mRUConfAddLine = 3;
152 const int mRUConfValLine = 4;
153 const int mUBBNameLine = 5;
154 const int mUBBValLine = 6;
155 const int mDeadMapLine = 7;
156
157 std::string mVersion;
158
159 std::map<std::string, std::map<std::string, int>> mNameDict;
160 std::map<std::string, int> mNameDictRU;
161 std::map<std::string, int> mNameDictALPIDE;
162 std::map<std::string, int> mNameDictUBB;
163
164 std::map<std::string, std::map<int, std::string>> mAddressDict;
165 std::map<int, std::string> mAddressDictRU;
166 std::map<int, std::string> mAddressDictALPIDE;
167 std::map<int, std::string> mAddressDictUBB;
168
169 void initDictionary()
170 {
171 mNameDict.clear();
172 mNameDictRU.clear();
173 mNameDictALPIDE.clear();
174 mNameDictUBB.clear();
175
176 mAddressDict.clear();
177 mAddressDictRU.clear();
178 mAddressDictALPIDE.clear();
179 mAddressDictUBB.clear();
180
181 std::vector<std::pair<std::string, uint>> pairRU;
182 pairRU.push_back(std::make_pair("MANCHESTER", 1046));
183 pairRU.push_back(std::make_pair("ENABLE", 4096));
184 pairRU.push_back(std::make_pair("TRIGGER_PERIOD", 4097));
185 pairRU.push_back(std::make_pair("PULSE_nTRIGGER", 4098));
186 pairRU.push_back(std::make_pair("TRIGGER_MIN_DISTANCE", 4099));
187 pairRU.push_back(std::make_pair("OPCODE_GATING", 4101));
188 pairRU.push_back(std::make_pair("TRIGGER_DELAY", 4102));
189 pairRU.push_back(std::make_pair("ENABLE_PACKER_0", 4103));
190 pairRU.push_back(std::make_pair("ENABLE_PACKER_1", 4104));
191 pairRU.push_back(std::make_pair("ENABLE_PACKER_2", 4105));
192 pairRU.push_back(std::make_pair("TRIG_SOURCE", 4106));
193 pairRU.push_back(std::make_pair("TIMEOUT_TO_START", 5376));
194 pairRU.push_back(std::make_pair("TIMEOUT_TO_STOP", 5377));
195 pairRU.push_back(std::make_pair("TIMEOUT_IN_IDLE", 5378));
196 pairRU.push_back(std::make_pair("GBT_LOAD_BALANCING", 5631));
197
198 std::vector<std::pair<std::string, uint>> pairALPIDE;
199 pairALPIDE.push_back(std::make_pair("Mode_Control_Register", 1));
200 pairALPIDE.push_back(std::make_pair("FROMU_Configration_Register_1", 4));
201 pairALPIDE.push_back(std::make_pair("FROMU_Configration_Register_2", 5));
202 pairALPIDE.push_back(std::make_pair("FROMU_Configration_Register_3", 6));
203 pairALPIDE.push_back(std::make_pair("FROMU_Pulsing_Register_1", 7));
204 pairALPIDE.push_back(std::make_pair("FROMU_Pulsing_Register_2", 8));
205 pairALPIDE.push_back(std::make_pair("CMUandDMU_Configration_Register", 16));
206 pairALPIDE.push_back(std::make_pair("DTU_Configration_Register", 20));
207 pairALPIDE.push_back(std::make_pair("DTU_DACs_Register", 21));
208 pairALPIDE.push_back(std::make_pair("DTU_Test_Register_1", 24));
209 pairALPIDE.push_back(std::make_pair("DTU_Test_Register_2", 25));
210 pairALPIDE.push_back(std::make_pair("DTU_Test_Register_3", 26));
211 pairALPIDE.push_back(std::make_pair("VCASP", 1539));
212 pairALPIDE.push_back(std::make_pair("VCLIP", 1544));
213 pairALPIDE.push_back(std::make_pair("IBIAS", 1549));
214 pairALPIDE.push_back(std::make_pair("VPULSEH", 1541));
215 pairALPIDE.push_back(std::make_pair("VPULSEL", 1542));
216 pairALPIDE.push_back(std::make_pair("VRESETD", 1538));
217 pairALPIDE.push_back(std::make_pair("IDB", 1548));
218 pairALPIDE.push_back(std::make_pair("AUTO_ROF__NOISE_MASK__MASK_LEV__MC_HIT__MC_ID", 65535));
219
220 std::vector<std::pair<std::string, uint>> pairUBB;
221 int idUBB = 0;
222 for (int iH = 0; iH <= 1; ++iH) {
223 for (int iD = 0; iD <= 4; ++iD) {
224 for (int iF = 0; iF <= 1; ++iF) {
225 for (int iZ = 0; iZ <= 3; ++iZ) {
226 pairUBB.push_back(std::make_pair(Form("U_BB_H%dD%dF%dZ%d", iH, iD, iF, iZ), idUBB));
227 ++idUBB;
228 }
229 }
230 }
231 }
232
233 for (int iRU = 0; iRU < pairRU.size(); ++iRU) {
234 std::pair<std::string, int> p = pairRU[iRU];
235 mAddressDictRU.emplace(p.second, p.first);
236 mNameDictRU.emplace(p.first, p.second);
237 }
238 for (int iALPIDE = 0; iALPIDE < pairALPIDE.size(); ++iALPIDE) {
239 std::pair<std::string, int> p = pairALPIDE[iALPIDE];
240 mAddressDictALPIDE.emplace(p.second, p.first);
241 mNameDictALPIDE.emplace(p.first, p.second);
242 }
243 for (int iUBB = 0; iUBB < pairUBB.size(); ++iUBB) {
244 std::pair<std::string, int> p = pairUBB[iUBB];
245 mAddressDictUBB.emplace(p.second, p.first);
246 mNameDictUBB.emplace(p.first, p.second);
247 }
248
249 mNameDict.emplace("RU", mNameDictRU);
250 mNameDict.emplace("ALPIDE", mNameDictALPIDE);
251 mNameDict.emplace("UBB", mNameDictUBB);
252
253 mAddressDict.emplace("RU", mAddressDictRU);
254 mAddressDict.emplace("ALPIDE", mAddressDictALPIDE);
255 mAddressDict.emplace("UBB", mAddressDictUBB);
256 }
257
258 ClassDefNV(DCSConfigUtils, 1);
259
260}; // end class
261} // namespace mft
262} // namespace o2
263
264#endif
const std::string getTypeName(int type)
std::map< int, std::string > getAddressMap(std::string type)
std::map< std::string, int > getNameMap(int type)
std::map< int, std::string > getAddressMap(int type)
int getAddress(std::string name, std::string type)
std::map< std::string, int > getNameMap(std::string type)
std::string & getVersion()
const int getType(std::string type)
std::string getName(int add, std::string type)
GLuint const GLchar * name
Definition glcorearb.h:781
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"