Project
Loading...
Searching...
No Matches
FEEConfig.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
15
16#include <numeric>
17#include <string_view>
18#include <bitset>
19#include "fmt/format.h"
20#include "Framework/Logger.h"
22#include "TPCBase/FEEConfig.h"
23#include "TPCBase/CRU.h"
24#include "TPCBase/Mapper.h"
26
27using namespace o2::utils;
28using namespace o2::tpc;
29
30bool CRUConfig::setValues(std::string_view cruData)
31{
32 const auto cruDataV = Str::tokenize(cruData.data(), ',');
33 if (cruDataV.size() != CRUConfig::NConfigValues) {
34 LOGP(warning, "Wrong number of CRU config values {}/{} in line {}", cruDataV.size(), NConfigValues, cruData);
35 return false;
36 }
37
38 linkOn = static_cast<decltype(linkOn)>(std::stol(cruDataV[0]));
39 cmcEnabled = static_cast<decltype(cmcEnabled)>(std::stol(cruDataV[1]));
40 zsOffset = static_cast<decltype(zsOffset)>(std::stol(cruDataV[4]));
41 itCorr0 = std::stof(cruDataV[5]);
42 itfEnabled = static_cast<decltype(itfEnabled)>(std::stol(cruDataV[2]));
43 zsEnabled = static_cast<decltype(zsEnabled)>(std::stol(cruDataV[3]));
44 resyncEnabled = static_cast<decltype(resyncEnabled)>(std::stol(cruDataV[6]));
45
46 return true;
47}
48
49const std::unordered_map<FEEConfig::Tags, const std::string> FEEConfig::TagNames{
50 {Tags::Unspecified, "Unspecified"},
51 {Tags::TestWithZS, "TestWithZS"},
52 {Tags::Pedestals, "Pedestals"},
53 {Tags::Pulser, "Pulser"},
54 {Tags::Laser, "Laser"},
55 {Tags::Cosmics, "Cosmics"},
56 {Tags::Physics35sigma, "Physics35sigma"},
57 {Tags::Physics30sigma, "Physics30sigma"},
58 {Tags::Physics25sigma, "Physics25sigma"},
59 {Tags::Laser10ADCoff, "Laser10ADCoff"},
60 {Tags::TestNoFilters, "TestNoFilter"},
61 {Tags::Physics2025sigma, "Physics2025sigma"},
62 {Tags::Physics30sigmaPbPb, "Physics30sigmaPbPb"},
63};
64
65const std::unordered_map<FEEConfig::PadConfig, const std::string> FEEConfig::PadConfigNames{
66 {PadConfig::ITfraction, "ITfraction"},
67 {PadConfig::ITexpLambda, "ITexpLambda"},
68 {PadConfig::CMkValues, "CMkValues"},
69 {PadConfig::ThresholdMap, "ThresholdMap"},
70 {PadConfig::Pedestals, "Pedestals"},
71};
72
74{
75 return std::accumulate(cruConfig.begin(), cruConfig.end(), size_t(0),
76 [](size_t sum, const auto& c) {
77 return sum + std::bitset<32>(c.linkOn).count();
78 });
79}
80
82{
83 const auto nEnabled = std::accumulate(cruConfig.begin(), cruConfig.end(), size_t(0), [](size_t b, const auto& c) { return b + (c.cmcEnabled > 0); });
84 if ((nEnabled > 0) && (nEnabled != cruConfig.size())) {
85 LOGP(warning, "CMC not enabled for all CRUs: {} < {}", nEnabled, cruConfig.size());
86 }
87
88 return nEnabled > (cruConfig.size() / 2);
89}
90
92{
93 const auto nEnabled = std::accumulate(cruConfig.begin(), cruConfig.end(), size_t(0), [](size_t b, const auto& c) { return b + (c.itfEnabled); });
94 if ((nEnabled > 0) && (nEnabled != cruConfig.size())) {
95 LOGP(warning, "ITF not enabled for all CRUs: {} < {}", nEnabled, cruConfig.size());
96 }
97
98 return nEnabled > (cruConfig.size() / 2);
99}
100
102{
103 const auto nEnabled = std::accumulate(cruConfig.begin(), cruConfig.end(), size_t(0), [](size_t b, const auto& c) { return b + (c.zsEnabled); });
104 if ((nEnabled > 0) && (nEnabled != cruConfig.size())) {
105 LOGP(warning, "ZS not enabled for all CRUs: {} < {}", nEnabled, cruConfig.size());
106 }
107
108 return nEnabled > (cruConfig.size() / 2);
109}
110
112{
113 const auto nEnabled = std::accumulate(cruConfig.begin(), cruConfig.end(), size_t(0), [](size_t b, const auto& c) { return b + (c.resyncEnabled); });
114 if ((nEnabled > 0) && (nEnabled != cruConfig.size())) {
115 LOGP(warning, "Resync not enabled for all CRUs: {} < {}", nEnabled, cruConfig.size());
116 }
117
118 return nEnabled > (cruConfig.size() / 2);
119}
120
122{
123 const auto& mapper = Mapper::instance();
124
125 // ===| Check active link map |===
126 for (int iCRU = 0; iCRU < cruConfig.size(); ++iCRU) {
127 const CRU cru(iCRU);
128 const PartitionInfo& partInfo = mapper.getMapPartitionInfo()[cru.partition()];
129 const int nFECs = partInfo.getNumberOfFECs();
130 const int fecOffset = (nFECs + 1) / 2;
131 cruConfig.at(iCRU).linkOn = 0;
132 for (int iFEC = 0; iFEC < nFECs; ++iFEC) {
133 const int fecTest = (iFEC < fecOffset) ? iFEC : 10 + (iFEC - fecOffset);
134 const int fecBIT = 1 << fecTest;
135 cruConfig.at(iCRU).linkOn |= fecBIT;
136 }
137 }
138}
139
141{
142 fmt::print("\n");
143 const auto& mapper = Mapper::instance();
144
145 auto message = fmt::format("Printing tag {} ({})", int(tag), TagNames.at(tag));
146 const size_t boxWidth = 80;
147 fmt::print(
148 "┌{0:─^{2}}┐\n"
149 "│{1: ^{2}}│\n"
150 "└{0:─^{2}}┘\n",
151 "", message, boxWidth);
152 fmt::print("\n");
153
154 // ===| CRU summary |=========================================================
155 message = "| CRU summary |";
156 fmt::print("{0:=^{1}}\n", message, boxWidth);
157
158 if (cruConfig.size() != CRU::MaxCRU) {
159 LOGP(error, "Unexpected size of cru config:{} != {}", cruConfig.size(), (int)CRU::MaxCRU);
160 } else {
161 for (int iCRU = 0; iCRU < cruConfig.size(); ++iCRU) {
162 const auto& c = cruConfig.at(iCRU);
163 const CRU cru(iCRU);
164 const PartitionInfo& partInfo = mapper.getMapPartitionInfo()[cru.partition()];
165 const int nLinks = partInfo.getNumberOfFECs();
166 const auto nLinkOn = std::bitset<32>(c.linkOn).count();
167
168 fmt::print("CRU {:3d}: linkOn = {:5x} ({:2}/{:2}), cmcEn = {:5x}, zsOffset = {:5x}, itCorr0 = {:4.2f}, itfEn = {:b}, zsEn = {:b}, resyncEn = {:b}\n",
169 iCRU, c.linkOn, nLinkOn, nLinks, c.cmcEnabled, c.zsOffset, c.itCorr0, c.itfEnabled, c.zsEnabled, c.resyncEnabled);
170 }
171 }
172
173 fmt::print("\n");
174 // ===| CRU summary |=========================================================
175 message = "| Pad maps summary |";
176 fmt::print("{0:=^{1}}\n", message, boxWidth);
177
178 for ([[maybe_unused]] auto& [key, val] : padMaps) {
179 fmt::print("{}\n", key);
180 }
181}
182
184{
185 LOGP(info, "FEEConfig: tag: {}, #active links: {}, CMC enabled: {}, ITF enabled: {}, ZS enabled: {}, resync enabled: {}",
187}
188
190{
191 const auto& mapper = Mapper::instance();
192 CalDet<bool> deadMap("DeadChannelMap");
193
194 // ===| Check active link map |===
195 for (int iCRU = 0; iCRU < cruConfig.size(); ++iCRU) {
196 const CRU cru(iCRU);
197 const PartitionInfo& partInfo = mapper.getMapPartitionInfo()[cru.partition()];
198 const int nFECs = partInfo.getNumberOfFECs();
199 const int fecOffset = (nFECs + 1) / 2;
200 for (int iFEC = 0; iFEC < nFECs; ++iFEC) {
201 // const int fecInPartition = (iFEC < fecOffset) ? iFEC : 12 + (iFEC % 10);
202 const int fecTest = (iFEC < fecOffset) ? iFEC : 10 + (iFEC - fecOffset);
203 const int fecBIT = 1 << fecTest;
204 if (cruConfig.at(iCRU).linkOn & fecBIT) {
205 continue; // FEC is active
206 }
207
208 // all channels of the FEC are masked
209 for (int iChannel = 0; iChannel < 80; ++iChannel) {
210 const auto& [sampaOnFEC, channelOnSAMPA] = cru_calib_helpers::getSampaInfo(iChannel, cru);
211 const PadROCPos padROCPos = mapper.padROCPos(cru, iFEC, sampaOnFEC, channelOnSAMPA);
212 deadMap.getCalArray(padROCPos.getROC()).setValue(padROCPos.getRow(), padROCPos.getPad(), true);
213 }
214 }
215 }
216
217 // ===| Check pedestal values |===============================================
218 const auto& pedestals = padMaps.at(PadConfigNames.at(PadConfig::Pedestals));
219
220 for (int iROC = 0; iROC < pedestals.getData().size(); ++iROC) {
221 const auto& rocPed = pedestals.getCalArray(iROC);
222 auto& rocDead = deadMap.getCalArray(iROC);
223
224 for (int iPad = 0; iPad < rocPed.getData().size(); ++iPad) {
225 if (rocPed.getValue(iPad) > 1022) {
226 rocDead.setValue(iPad, true);
227 }
228 }
229 }
230
231 return deadMap;
232}
Frontend electronics configuration values.
uint32_t c
Definition RawData.h:2
StringRef key
@ MaxCRU
Definition CRU.h:31
unsigned char partition() const
Definition CRU.h:63
void setValue(const size_t channel, const T &value)
Definition CalArray.h:95
const CalType & getCalArray(size_t position) const
Definition CalDet.h:63
static Mapper & instance(const std::string mappingDir="")
Definition Mapper.h:44
Pad and row inside a ROC.
Definition PadROCPos.h:37
const ROC & getROC() const
Definition PadROCPos.h:55
int getPad() const
Definition PadROCPos.h:79
int getRow() const
Definition PadROCPos.h:75
unsigned char getNumberOfFECs() const
GLsizeiptr size
Definition glcorearb.h:659
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLuint GLfloat * val
Definition glcorearb.h:1582
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
std::tuple< int, int > getSampaInfo(int hwChannel, int cruID)
convert HW mapping to sampa and channel number
Global TPC definitions and constants.
Definition SimTraits.h:167
DataT sum(const Vector< DataT, N > &a)
Definition Vector.h:107
bool resyncEnabled
if resync feature is enabled
Definition FEEConfig.h:41
bool setValues(std::string_view cruData)
Definition FEEConfig.cxx:30
bool itfEnabled
if ion tail filter correction is enabled
Definition FEEConfig.h:39
bool zsEnabled
if zero suppression is enabled
Definition FEEConfig.h:40
uint32_t zsOffset
zero suppression offset value used in ITF
Definition FEEConfig.h:37
float itCorr0
ion tail scaling parameter
Definition FEEConfig.h:38
uint32_t linkOn
bitmask of active links
Definition FEEConfig.h:35
static constexpr int NConfigValues
number of configuration values
Definition FEEConfig.h:33
uint32_t cmcEnabled
if common mode correction is enabled
Definition FEEConfig.h:36
CalPadMapType padMaps
pad-wise configuration data
Definition FEEConfig.h:86
std::vector< CRUConfig > cruConfig
CRU configuration values.
Definition FEEConfig.h:87
bool isITFEnabled() const
Definition FEEConfig.cxx:91
void printShort() const
static const std::unordered_map< Tags, const std::string > TagNames
Definition FEEConfig.h:75
CalDet< bool > getDeadChannelMap() const
Dead channel map including deactivated links and single channels.
size_t getNumberActiveLinks() const
Definition FEEConfig.cxx:73
bool isResyncEnabled() const
static const std::unordered_map< PadConfig, const std::string > PadConfigNames
Definition FEEConfig.h:76
bool isZSEnabled() const
Tags tag
tag number
Definition FEEConfig.h:88
void print() const
bool isCMCEnabled() const
Definition FEEConfig.cxx:81
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)