48 return StatusCode::FAILURE;
52 return StatusCode::FAILURE;
56 return StatusCode::FAILURE;
70 return StatusCode::SUCCESS;
79 if (writeHandle.isValid()) {
80 ATH_MSG_DEBUG(
"CondHandle " << writeHandle.fullKey() <<
" is already valid."
81 <<
". In theory this should not be called, but may happen"
82 <<
" if multiple concurrent events are being processed out of order.");
83 return StatusCode::SUCCESS;
87 std::unique_ptr<SCT_ConfigurationCondData> writeCdo{std::make_unique<SCT_ConfigurationCondData>()};
92 if (
fillModuleData(writeCdo.get(), writeHandle, ctx).isFailure()) {
93 return StatusCode::FAILURE;
98 return StatusCode::FAILURE;
101 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
102 ATH_MSG_FATAL(
"Could not record SCT_ConfigurationCondData " << writeHandle.key()
103 <<
" with EventRange " << writeHandle.getRange()
104 <<
" into Conditions Store");
105 return StatusCode::FAILURE;
107 ATH_MSG_INFO(
"recorded new CDO " << writeHandle.key() <<
" with range " << writeHandle.getRange() <<
" into Conditions Store");
109 return StatusCode::SUCCESS;
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;
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;
272 if (writeCdo==
nullptr) {
273 ATH_MSG_FATAL(
"Pointer of derived conditions object is null");
274 return StatusCode::FAILURE;
279 unsigned int totalNumberOfModules{0};
280 unsigned int totalNumberOfValidModules{0};
289 if (readCdo==
nullptr) {
291 return StatusCode::FAILURE;
299 enum RUN1_INDICES{PK, FOREIGN_KEY, ID_1, GROUP_1, ACTIVE_1, SELECT_1};
300 enum RUN2_INDICES{ID_2, SLAVEGROUP_2, ACTIVE_2, CLOCKSELECT_2, CHIPSTATUS_2};
301 const unsigned int groupIndex{
run1 ?
static_cast<unsigned int>(GROUP_1) :
static_cast<unsigned int>(SLAVEGROUP_2)};
306 for (; itr!=
end; ++itr) {
309 const unsigned int truncatedSerialNumber{
run1 ? (itr->first-1) : (itr->first)};
311 ++totalNumberOfModules;
312 if (not
hash.is_valid())
continue;
315 ++totalNumberOfValidModules;
322 const short group{itr->second[groupIndex].data<
short>()};
332 ATH_MSG_INFO(
"Total number of module identifiers is " << totalNumberOfModules);
333 ATH_MSG_INFO(
"Total number of modules also found in the cabling is " << totalNumberOfValidModules);
334 ATH_MSG_INFO(
"Total number of bad module identifiers is " << totalBad);
336 return StatusCode::SUCCESS;
342 if (writeCdo==
nullptr) {
343 ATH_MSG_FATAL(
"Pointer of derived conditions object is null");
344 return StatusCode::FAILURE;
356 if (readCdo==
nullptr) {
358 return StatusCode::FAILURE;
366 enum RUN1_INDICES{PK, FOREIGN_KEY, MUR_1, MODULE_1, MODULEID_1, RMODULEID_1, RX0FIBRE_1, RX1FIBRE_1, TXFIBRE_1};
367 enum RUN2_INDICES{MUR_2, MODULE_2, MODULEID_2, RMODULEID_2, RX0FIBRE_2, RX1FIBRE_2, TXFIBRE_2};
368 const unsigned int snIndex{
run1 ?
static_cast<unsigned int>(MODULEID_1) :
static_cast<unsigned int>(MODULEID_2)};
369 const unsigned int link0Index{
run1 ?
static_cast<unsigned int>(RX0FIBRE_1) :
static_cast<unsigned int>(RX0FIBRE_2)};
370 const unsigned int link1Index{
run1 ?
static_cast<unsigned int>(RX1FIBRE_1) :
static_cast<unsigned int>(RX1FIBRE_2)};
375 for (; itr!=
end; ++itr) {
377 if (itr->second[snIndex].isNull())
continue;
379 const long long ullSerialNumber{itr->second[snIndex].data<
long long>()};
381 if (not serialNumber.is_valid())
continue;
384 if (not
hash.is_valid())
continue;
386 int link0{
run1 ? (itr->second[link0Index].data<
int>()) :
static_cast<int>(itr->second[link0Index].data<
unsigned char>())};
387 int link1{
run1 ? (itr->second[link1Index].data<
int>()) :
static_cast<int>(itr->second[link1Index].data<
unsigned char>())};
395 return StatusCode::SUCCESS;
404 unsigned int strip{0};
408 return invalidIdentifier;
414 waferHash =
m_cablingTool->getHashFromSerialNumber(truncatedSerialNumber, ctx);
423 if (not waferId.
is_valid())
return invalidIdentifier;
426 if (pElement==
nullptr) {
427 ATH_MSG_FATAL(
"Element pointer is nullptr in 'getStripId' method");
428 return invalidIdentifier;
436 return StatusCode::SUCCESS;