115 if (writeCdo==
nullptr) {
116 ATH_MSG_FATAL(
"Pointer of derived conditions object is null");
117 return StatusCode::FAILURE;
120 unsigned int nDisabledChips{0};
121 unsigned int nDisabledChipsExclusive{0};
122 unsigned int nDisabledStripsExclusive{0};
128 enum RUN1_MODULE_INDICES{PK, FOREIGN_KEY, CRATE_1, ROD_1, CHANNEL_1,OUTPUTCURRENT_1,
129 OUTPUTDELAY_1, OUTPUT_TOF_DELTA_1, OUTPUTMARKSPACE_1, STREAM0THRESHOLD_1,
130 STREAM0DELAY_1, STREAM0ERRMASK_1, STREAM1THRESHOLD_1, STREAM1DELAY_1, STREAM1ERRMASK_1};
131 enum RUN2_MODULE_INDICES{CRATE_2, ROD_2, CHANNEL_2,OUTPUTCURRENT_2,
132 OUTPUTDELAY_2, OUTPUTMARKSPACE_2, STREAM0THRESHOLD_2,
133 STREAM0DELAY_2, STREAM0ERRMASK_2, STREAM1THRESHOLD_2, STREAM1DELAY_2, STREAM1ERRMASK_2};
134 enum RUN1_CHIP_INDICES{CHIP_PK, CHIP_FOREIGN_KEY,CHIP_1, ACTIVE_1,ADDRESS_1, CONFIG_1,
135 MASK0_1,MASK1_1,MASK2_1,MASK3_1, VTHR_1, VCAL_1, DELAY_1, PREAMP_1, SHAPER_1,
136 RC_FUNCTION_1, RC_ARGS_1, C_FACTOR_1, TARGET_1, TRIM_1};
137 enum RUN2_CHIP_INDICES{CHIP_2, ACTIVE_2, ADDRESS_2, CONFIG_2, MASK0_2,MASK1_2,MASK2_2,
138 MASK3_2, VTHR_2, VCAL_2, DELAY_2, PREAMP_2, SHAPER_2, RC_FUNCTION_2, RC_ARGS_2,
139 C_FACTOR_2, TARGET_2, TRIM_2};
140 enum RUN2_CHIPSLIM_INDICES{CHIP_2_SLIM, CONFIG_2_SLIM, MASK0_2_SLIM, MASK1_2_SLIM, MASK2_2_SLIM,
142 const unsigned int chipIndex{ run1 ?
static_cast<unsigned int>(CHIP_1) : slim ?
static_cast<unsigned int>(CHIP_2_SLIM) :
static_cast<unsigned int>(CHIP_2)};
143 const unsigned int configIndex{run1 ?
static_cast<unsigned int>(CONFIG_1) : slim ?
static_cast<unsigned int>(CONFIG_2_SLIM) :
static_cast<unsigned int>(CONFIG_2)};
144 const unsigned int mask0Index{ run1 ?
static_cast<unsigned int>(MASK0_1) : slim ?
static_cast<unsigned int>(MASK0_2_SLIM) :
static_cast<unsigned int>(MASK0_2)};
145 const unsigned int mask1Index{ run1 ?
static_cast<unsigned int>(MASK1_1) : slim ?
static_cast<unsigned int>(MASK1_2_SLIM) :
static_cast<unsigned int>(MASK1_2)};
146 const unsigned int mask2Index{ run1 ?
static_cast<unsigned int>(MASK2_1) : slim ?
static_cast<unsigned int>(MASK2_2_SLIM) :
static_cast<unsigned int>(MASK2_2)};
147 const unsigned int mask3Index{ run1 ?
static_cast<unsigned int>(MASK3_1) : slim ?
static_cast<unsigned int>(MASK3_2_SLIM) :
static_cast<unsigned int>(MASK3_2)};
153 if (
fillLinkStatus(writeCdo, writeHandle, ctx).isFailure())
return StatusCode::FAILURE;
158 if (readCdo==
nullptr) {
160 return StatusCode::FAILURE;
169 if (elements==
nullptr) {
171 return StatusCode::FAILURE;
179 constexpr unsigned int nChips{12};
180 for (; itr!=end; itr+=nChips) {
183 const unsigned int truncatedSerialNumber{run1 ? (itr->first-1) : (itr->first)};
185 if (not hash.is_valid())
continue;
190 m_pHelper->get_other_side(hash, oppWaferHash);
196 std::pair<bool, bool> linkResults{writeCdo->
areBadLinks(hash)};
197 bool link0ok{linkResults.first};
198 bool link1ok{linkResults.second};
200 std::vector<SCT_Chip> chipsInMod;
201 chipsInMod.reserve(nChips);
202 bool isBadSide0{
true};
203 bool isBadSide1{
true};
206 for (; channelItr!=channelEnd; ++channelItr) {
209 const short id{ run1 ? (channelItr->second[chipIndex].data<
short>()) :
static_cast<short>(channelItr->second[chipIndex].data<
unsigned char>())};
210 const short config{run1 ? (channelItr->second[configIndex].data<
short>()) :
static_cast<short>(channelItr->second[configIndex].data<
unsigned short>())};
211 const int mask0{ run1 ? (channelItr->second[mask0Index].data<
int>()) :
static_cast<int>(channelItr->second[mask0Index].data<
unsigned int>())};
212 const int mask1{ run1 ? (channelItr->second[mask1Index].data<
int>()) :
static_cast<int>(channelItr->second[mask1Index].data<
unsigned int>())};
213 const int mask2{ run1 ? (channelItr->second[mask2Index].data<
int>()) :
static_cast<int>(channelItr->second[mask2Index].data<
unsigned int>())};
214 const int mask3{ run1 ? (channelItr->second[mask3Index].data<
int>()) :
static_cast<int>(channelItr->second[mask3Index].data<
unsigned int>())};
215 chipsInMod.emplace_back(
id,
config, mask0, mask1, mask2,
mask3);
216 if (
id>=0 and
id< 6 and (mask0!=0 or mask1!=0 or mask2!=0 or
mask3!=0)) isBadSide0 =
false;
217 if (
id>=6 and
id<12 and (mask0!=0 or mask1!=0 or mask2!=0 or
mask3!=0)) isBadSide1 =
false;
223 if (
m_readoutTool->determineReadout(moduleId, chipsInMod, link0ok, link1ok).isFailure())
return StatusCode::FAILURE;
226 std::vector<int> badStripsVec;
227 unsigned int chipStatusWord{0};
228 for (
const auto& thisChip:chipsInMod) {
230 if (thisChip.numberOfMaskedChannels()!=0) {
232 badStripsVec.clear();
233 thisChip.appendBadStripsToVector(badStripsVec);
235 for (
const auto& thisBadStrip:badStripsVec) {
236 const Identifier stripId{
getStripId(truncatedSerialNumber, thisChip.id(), thisBadStrip, elements, ctx)};
239 thisChip.id()<6 ? hash : oppWaferHash,
246 chipStatusWord |= (1<<thisChip.id());
248 if (not isBadModule) nDisabledChipsExclusive++;
250 if (not isBadModule) nDisabledStripsExclusive += thisChip.numberOfMaskedChannels();
255 if (chipStatusWord!=0) {
260 const long unsigned int totalBad{writeCdo->
getBadStripIds()->size()};
261 ATH_MSG_INFO(
"Total number of bad chips is " << nDisabledChips);
262 ATH_MSG_INFO(
"Total number of bad chips not in bad modules is " << nDisabledChipsExclusive);
263 ATH_MSG_INFO(
"Total number of bad strip identifiers is " << totalBad);
264 ATH_MSG_INFO(
"Total number of bad strip identifiers not in bad modules nor bad chips is " << nDisabledStripsExclusive);
266 return StatusCode::SUCCESS;