ATLAS Offline Software
Loading...
Searching...
No Matches
TileDQstatus.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
11
12
17#include "GaudiKernel/MsgStream.h"
18#include <iostream>
19
20
21const int TileDQstatus::s_ch2dmuLB[48] = { 0, 0, 0, 0, 0, 0,
22 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
24 0, 0, 0, 0 };
25
26const int TileDQstatus::s_ch2dmuEB[48] = { 0, 0, 0, 0, 0, 0,
27 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 2,
28 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 2, 2,
29 2, 2, 2, 2 };
30
31const int TileDQstatus::s_ch2dmuEBspecial[48] = { 2, 2, 2, 1,
32 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
34 2, 2, 2, 2, 2, 2 };
35
36// Constructor
38 : m_isBiGain(false),
39 m_checkDigi(false),
40 m_BCID(0),
42 m_calibMode(0xFFFFFFFF),
43 m_cispar{0},
44 m_trigType(0)
45{
46 setAllGood();
47}
48
50 // Intitalize all arrays to no errors
51 m_isFilled = false;
52 //m_isBiGain = false; //BAD!
53 m_counter = 0;
54 memset(m_EmptyEventArray, 0, sizeof(m_EmptyEventArray));
55 memset(m_GlobalCRCErrArray, 0, sizeof(m_GlobalCRCErrArray));
56 memset(m_FE_DMUmaskArray, -1, sizeof(m_FE_DMUmaskArray));
57 memset(m_ROD_DMUmaskArray, -1, sizeof(m_ROD_DMUmaskArray));
58 memset(m_BCIDErrArray, 0, sizeof(m_BCIDErrArray));
67}
68
69
70// Function to fill error arrays from DQ fragment stores in DSP RawChannelContainer
71// If monogain run, both gains contain the same results
73 const TileDigitsContainer* digitsCnt,
74 int gain, unsigned short fragBCID)
75{
76 if (digitsCnt) {
77 m_checkDigi = true;
78 }
79
80 int frag = coll->identify();
81 int partition = (frag >> 8); // 0=AUX,1=LBA,2=LBC,3=EBA,4=EBC
82 int drawer = (frag & 0x3F); // 0-63
83 bool eb = (frag > 0x2ff); // true if ext.barrel
84 bool ebsp = (frag == 0x30e || frag == 0x411);// EBA15 or EBC18
85
86 m_isBiGain |= (coll->size() > 48);
87 // attention! it's assignment below, i.e. only single "=", not "=="
88 // LF: ... which is something very dangerous. Does it provide any speed advantage?
89 if ((m_GlobalCRCErrArray[partition][drawer][gain] = coll->getFragGlobalCRC())) ++m_counter;
90 if ((m_BCIDErrArray[partition][drawer][gain] = fragBCID)) ++m_counter;
91 if ((m_MemoryParityErrArray[partition][drawer][gain] = coll->getFragMemoryPar())) ++m_counter;
92 if ((m_SingleStrobeErrArray[partition][drawer][gain] = coll->getFragSstrobe())) ++m_counter;
93 if ((m_DoubleStrobeErrArray[partition][drawer][gain] = coll->getFragDstrobe())) ++m_counter;
94 if ((m_HeaderFormatErrArray[partition][drawer][gain] = coll->getFragHeaderBit())) ++m_counter;
95 if ((m_HeaderParityErrArray[partition][drawer][gain] = coll->getFragHeaderPar())) ++m_counter;
96 if ((m_SampleFormatErrArray[partition][drawer][gain] = coll->getFragSampleBit())) ++m_counter;
97 if ((m_SampleParityErrArray[partition][drawer][gain] = coll->getFragSamplePar())) ++m_counter;
98 if ((m_ROD_DMUmaskArray[partition][drawer][gain] = coll->getFragRODChipMask())) ++m_counter;
99// special treatment of FE DMU mask - take into account that some DMUs in Ext.barrel do not exist
100 if(uint32_t FE_DMUmask = coll->getFragFEChipMask()) {
101 if (eb) { // EBA or EBC
102 if (ebsp) FE_DMUmask <<= 1; // shift by one DMU in EBA15 EBC18
103 FE_DMUmask = (FE_DMUmask & 0xFF) | ((FE_DMUmask & 0xF00) << 2); // shift upper half by two DMUs
104 }
105 m_FE_DMUmaskArray[partition][drawer][gain] = FE_DMUmask;
106 ++m_counter;
107 }
108
109 unsigned short BCIDerr = fragBCID;
110
111 if (BCIDerr & 0x2) { // DMU1 (second DMU) is bad - can not trust others
112 m_BCIDErrArray[partition][drawer][gain] = -1;
113 } else {
114 // additional check if DQ frag BCID is the same as event BCID
115 uint32_t DSPBCID = coll->getFragDSPBCID();
116 if (DSPBCID != 0xDEAD && DSPBCID != m_BCID) { // DSP BCID doesn't match! all wrong
117 m_BCIDErrArray[partition][drawer][gain] = -1; // I preferred 0xFFFF; but variable is decleared as signed!
118 ++m_counter;
119 } else {
120 int n_badMB = 0;
121 if (eb) { // do not count non-existing DMUs in EB
122 if (ebsp) {
123 BCIDerr &= 0x3cfe;
124 } else {
125 BCIDerr &= 0x3cff;
126 }
127 }
128 while (BCIDerr) {
129 if (BCIDerr & 0xF)
130 ++n_badMB;
131 BCIDerr >>= 4;
132 }
133 if (n_badMB == 4) { // BCID errors in all 4 motherboards - assume that all DMUs are bad
134 m_BCIDErrArray[partition][drawer][gain] = -1;
135#ifdef TILECELL_DEBUG
136 std::cout << "masking whole drawer " << drawer << " in partition " << partition << " because all 4 MB have BCID errors"
137 << std::endl;
138#endif
139 }
140 }
141 }
142
143 if ((m_BCIDErrArray[partition][drawer][gain] & 0x2) && digitsCnt) {
144 fillBCIDErrDetail(digitsCnt, frag, gain);
145 } else {
146 m_BCIDErrArrayDetail[partition][drawer][gain] = fragBCID;
147 }
148
149 if (m_HeaderFormatErrArray[partition][drawer][gain]
150 || m_HeaderParityErrArray[partition][drawer][gain]
151 || m_SampleFormatErrArray[partition][drawer][gain]
152 || m_SampleParityErrArray[partition][drawer][gain]) {
153 // can not trust FE mask, assume that FE is good
154 m_FE_DMUmaskArray[partition][drawer][gain] = -1;
155 }
156
157#ifdef TILECELL_DEBUG
158 std::cout << std::hex
159 << " " << coll->getFragGlobalCRC()
160 << " " << coll->getFragFEChipMask()
161 << " " << coll->getFragRODChipMask()
162 << " " << coll->getFragDSPBCID()
163 << " " << coll->getFragBCID()
164 << " " << coll->getFragMemoryPar()
165 << " " << coll->getFragSstrobe()
166 << " " << coll->getFragDstrobe()
167 << " " << coll->getFragHeaderBit()
168 << " " << coll->getFragHeaderPar()
169 << " " << coll->getFragSampleBit()
170 << " " << coll->getFragSamplePar()
171 << " counter is " << std::dec << m_counter << std::endl;
172#endif
173
174}
175
176
177// Returns AND of all error check reults
178bool TileDQstatus::isAdcDQgood(int partition, int drawer, int ch, int gain) const {
179
180 int dmu = ch/3;
181
182#ifdef TILECELL_DEBUG
183
184 int errorArray[11];
185 errorArray[0] = checkGlobalCRCErr (partition,drawer,gain);
186 errorArray[1] = checkROD_CRCErr (partition,drawer,dmu,gain);
187 errorArray[2] = (m_isBiGain) ? 0 : checkFE_CRCErr(partition,drawer,dmu,gain); // Skip FE CRC for bigain runs
188 errorArray[3] = checkBCIDErr (partition,drawer,dmu,gain);
189 errorArray[4] = checkHeaderFormatErr (partition,drawer,dmu,gain);
190 errorArray[5] = checkHeaderParityErr (partition,drawer,dmu,gain);
191 errorArray[6] = checkSampleFormatErr (partition,drawer,dmu,gain);
192 errorArray[7] = checkSampleParityErr (partition,drawer,dmu,gain);
193 errorArray[8] = checkMemoryParityErr (partition,drawer,dmu,gain);
194 errorArray[9] = checkSingleStrobeErr (partition,drawer,dmu,gain);
195 errorArray[10]= checkDoubleStrobeErr (partition,drawer,dmu,gain);
196
197 int nError=0;
198 for(int i=0;i<9;++i){ // exclude Strobe errors from decision
199 nError += errorArray[i];
200 }
201 std::cout << std::dec <<"Part: " << partition << " Drawer: " << drawer+1 << " DMU: " << dmu << " ch: " << ch << std::endl;
202 std::cout << "IsBigain " << m_isBiGain << std::endl;
203 std::cout << "EmptyEvent (LG) " << m_EmptyEventArray[partition][drawer][dmu][0] << std::endl;
204 std::cout << "EmptyEvent (HG) " << m_EmptyEventArray[partition][drawer][dmu][1] << std::endl;
205 std::cout << "GlobalCRCErr " << errorArray[0] << std::endl;
206 std::cout << "ROD_CRCmask (LG) " << std::hex << m_ROD_DMUmaskArray[partition][drawer][0] << std::endl;
207 std::cout << "ROD_CRCmask (HG) " << std::hex << m_ROD_DMUmaskArray[partition][drawer][1] << std::endl;
208 std::cout << "ROD_CRCErr " << std::dec << errorArray[1] << std::endl;
209 std::cout << "FE_CRCmask (LG) " << std::hex << m_FE_DMUmaskArray[partition][drawer][0] << std::endl;
210 std::cout << "FE_CRCmask (HG) " << std::hex << m_FE_DMUmaskArray[partition][drawer][1] << std::endl;
211 std::cout << "FE_CRCErr " << std::dec << errorArray[2] << std::endl;
212 std::cout << "BCIDErr " << std::dec << errorArray[3] << std::endl;
213 std::cout << "HeaderFormatErr " << std::dec << errorArray[4] << std::endl;
214 std::cout << "HeaderParityErr " << std::dec << errorArray[5] << std::endl;
215 std::cout << "SampleFormatErr " << std::dec << errorArray[6] << std::endl;
216 std::cout << "SampleParityErr " << std::dec << errorArray[7] << std::endl;
217 std::cout << "MemoryParityErr " << std::dec << errorArray[8] << std::endl;
218 std::cout << "SingleStrobeErr " << std::dec << errorArray[9] << std::endl;
219 std::cout << "DoubleStrobeErr " << std::dec << errorArray[10] << std::endl;
220 std::cout << "Total number of errors: " << std::dec << nError << std::endl;
221
222#endif
223
224 if (checkGlobalCRCErr(partition, drawer, gain)
225 || checkROD_CRCErr(partition, drawer, dmu, gain)
226 || ((m_isBiGain) ? 0 : checkFE_CRCErr(partition, drawer, dmu, gain)) // Skip FE CRC for bigain runs
227 || checkBCIDErr(partition, drawer, dmu, gain)
228 || checkHeaderFormatErr(partition, drawer, dmu, gain)
229 || checkHeaderParityErr(partition, drawer, dmu, gain)
230 || checkSampleFormatErr(partition, drawer, dmu, gain)
231 || checkSampleParityErr(partition, drawer, dmu, gain)
232 || checkMemoryParityErr(partition, drawer, dmu, gain)) {
233 return false;
234 }
235
236 return true;
237}
238
239// Returns AND of error checks for both adc's for a single channel
240bool TileDQstatus::isChanDQgood(int partition, int drawer, int ch) const {
241 bool isGood = isAdcDQgood(partition, drawer, ch, 0);
242
243 if (m_isBiGain)
244 isGood &= isAdcDQgood(partition, drawer, ch, 1);
245
246 return isGood;
247}
248
250 int frag, int gain)
251{
252 int partition = (frag >> 8);
253 int drawer = (frag & 0x3F);
254 m_BCIDErrArrayDetail[partition][drawer][gain] =
255 m_BCIDErrArray[partition][drawer][gain]; //initialize
256 if (digitsCnt == NULL)
257 // by default a conservative return value of 1 (channel Mask)
258 m_BCIDErrArrayDetail[partition][drawer][gain] = short(-1);
259 else {
260 TileDigitsContainer::const_iterator collItr = digitsCnt->begin();
261 TileDigitsContainer::const_iterator lastColl = digitsCnt->end();
262
263 for (; collItr != lastColl; ++collItr) { // Loop over TileModules
264 if ((*collItr)->identify() != frag)
265 continue;
266
267 std::vector < uint32_t > data;
268 if ( isBiGain() && gain ) //high Gain in bigain run
269 data = (*collItr)->getFragChipHeaderWordsHigh();
270 else
271 data = (*collItr)->getFragChipHeaderWords();
272
273 unsigned int dataSize = std::min(16u, (unsigned int) data.size());
274 short bcidCheck = 0x0;
275 uint32_t rodbcid = (*collItr)->getRODBCID();
276 for (unsigned int dmu = 0; dmu < dataSize; ++dmu) {
277 bcidCheck |= ((data[dmu] & 0xFFF) != rodbcid) << dmu;
278#ifdef TILECELL_DEBUG
279 std::cout << "Part: " << partition << " Drawer: " << drawer << " DMU: " << dmu << (gain?"HG":"LG")
280 << " DMU BCID: " << (data[dmu] & 0xFFF) << " ROD BCID: " << rodbcid << std::endl;
281#endif
282 }
283 if (dataSize > 0)
284 m_BCIDErrArrayDetail[partition][drawer][gain] = bcidCheck;
285 break; // break after the digit is found
286 }
287 }
288}
289
290
291void TileDQstatus::fillTrips(unsigned int partition,
292 const std::vector<float>& trips,
293 double* rndmVec,
294 MsgStream& msg)
295{
296 for (unsigned int drawer = 0; drawer < TileCalibUtils::MAX_DRAWER; ++drawer) {
297 if (trips[drawer] > rndmVec[drawer]) {
298 msg << MSG::DEBUG
299 << "The drawer has been tripped (simulation): "
300 << TileCalibUtils::getDrawerString(partition, drawer) << endmsg;
301 m_GlobalCRCErrArray[partition][drawer][0] = -1;
302 m_GlobalCRCErrArray[partition][drawer][1] = -1;
303 m_counter += 2;
304 }
305 }
306}
307
308
310{
311 m_incompleteDigits = incomplete;
312}
313
314
319
320
322{
323 return m_cispar;
324}
325
326
#define endmsg
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Information produced by TileDQstatusAlg (used to be done by TileBeamInfoProvider).
size_type size() const noexcept
Returns the number of elements in the collection.
const_iterator end() const
return const_iterator for end of container
const_iterator begin() const
return const_iterator for first entry
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
short m_BCIDErrArrayDetail[5][64][2]
Array of bit masks storing BCID errors for all DMUs (from comparison with Digits)
short m_EmptyEventArray[5][64][16][2]
Array storing whether event is empty.
void fillArrays(const TileRawChannelCollection *coll, const TileDigitsContainer *digitsCnt, int gain, unsigned short fragBCID)
parses DQ fragments and fill error arrays for event
bool isAdcDQgood(int partition, int drawer, int ch, int gain) const
returns status of single ADC returns False if there are any errors
bool m_incompleteDigits
True if not all digits are available.
uint32_t m_cispar[110]
CIS parameters.
short m_BCIDErrArray[5][64][2]
Array of bit masks storing BCID errors for all DMUs (from comparison with DMU1)
short m_SampleFormatErrArray[5][64][2]
Array of bit masks storing Sample Format errors for all DMUs.
int checkHeaderFormatErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has header word format error
void setCalibMode(uint32_t calibMode)
bool isChanDQgood(int partition, int drawer, int ch) const
returns status of single channel (if bigain, returns AND of ADCs' status
uint32_t m_BCID
Event bunch crossing identification.
short m_HeaderParityErrArray[5][64][2]
Array of bit masks storing Header Parity errors for all DMUs.
int checkBCIDErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has BCID mismatch between DMU and ROD Since BCID errors in the DQ fragment are det...
int checkDoubleStrobeErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has double strobe error
short m_MemoryParityErrArray[5][64][2]
Array of bit masks storing Memory Parity errors for all DMUs.
short m_HeaderFormatErrArray[5][64][2]
Array of bit masks storing Header Format errors for all DMUs.
short m_FE_DMUmaskArray[5][64][2]
Array of bit masks storing CRC errors for all DMUs.
bool m_isBiGain
Boolean storing gain mode of run.
int trigType() const
Trigger type.
void fillTrips(unsigned int partition, const std::vector< float > &trips, double *rndmVec, MsgStream &msg)
bool m_isFilled
Boolean storing if DQ fragment has been parsed already.
int checkGlobalCRCErr(int partition, int drawer, int gain) const
returns 1 if adc channel has global CRC error
short m_ROD_DMUmaskArray[5][64][2]
Array of bit masks storing CRC errors for all DMUs.
int checkSampleFormatErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has data word format error
static const int s_ch2dmuEB[48]
int checkSingleStrobeErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has single strobe error
TileDQstatus()
Default constructor.
bool m_checkDigi
Boolean flag to control TileDigitsContainer access.
int checkROD_CRCErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has CRC error originating in ROD
uint32_t calibMode() const
Calibration mode.
static const int s_ch2dmuLB[48]
int checkHeaderParityErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has header word parity error
short m_SingleStrobeErrArray[5][64][2]
Array of bit masks storing Single Strobe errors for all DMUs.
void setIncompleteDigits(bool incomplete)
int m_counter
Counter of non-zero elements in all error arrays.
short m_SampleParityErrArray[5][64][2]
Array of bit masks storing Sample Parity errors for all DMUs.
short m_GlobalCRCErrArray[5][64][2]
Array of bit masks storing CRC errors for all DMUs.
void setTrigType(int trigType)
uint32_t m_calibMode
Calibration mode.
int m_trigType
Trigger type.
short m_DoubleStrobeErrArray[5][64][2]
Array of bit masks storing Double Strobe errors for all DMUs.
const uint32_t * cispar() const
CIS parameters.
int checkFE_CRCErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has CRC error originating in FE electronics
int checkMemoryParityErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has memory parity error
void fillBCIDErrDetail(const TileDigitsContainer *digitsCnt, int frag, int gain)
bool isBiGain() const
returns gain mode of run
void setAllGood()
mark all channels/ADC's as DQ good
static const int s_ch2dmuEBspecial[48]
int checkSampleParityErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has data word parity error
uint32_t getFragGlobalCRC() const
Various get methods.
MsgStream & msg
Definition testRead.cxx:32