113 {
114
115 if (writeCdo==nullptr) {
116 ATH_MSG_FATAL(
"Pointer of derived conditions object is null");
117 return StatusCode::FAILURE;
118 }
119
120 unsigned int nDisabledChips{0};
121 unsigned int nDisabledChipsExclusive{0};
122 unsigned int nDisabledStripsExclusive{0};
126
127
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,
141 MASK3_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)};
148
149
152
153 if (
fillLinkStatus(writeCdo, writeHandle, ctx).isFailure())
return StatusCode::FAILURE;
154
155
157 const CondAttrListVec* readCdo{*readHandle};
158 if (readCdo==nullptr) {
160 return StatusCode::FAILURE;
161 }
163
165
166
167 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEle{
m_SCTDetEleCollKey, ctx};
168 const InDetDD::SiDetectorElementCollection* elements(sctDetEle.
retrieve());
169 if (elements==nullptr) {
171 return StatusCode::FAILURE;
172 }
173
175
176
179 constexpr unsigned int nChips{12};
180 for (; itr!=
end; itr+=nChips) {
181
182
183 const unsigned int truncatedSerialNumber{
run1 ? (itr->first-1) : (itr->
first)};
184 const IdentifierHash&
hash{
m_cablingTool->getHashFromSerialNumber(truncatedSerialNumber, ctx)};
185 if (not
hash.is_valid())
continue;
186 const Identifier waferId{m_pHelper->wafer_id(hash)};
187 const Identifier moduleId{m_pHelper->module_id(waferId)};
188
189 IdentifierHash oppWaferHash;
190 m_pHelper->get_other_side(hash, oppWaferHash);
191 const Identifier oppWaferId{m_pHelper->wafer_id(oppWaferHash)};
192 bool isBadModule{writeCdo->isBadModuleId(moduleId)};
193
194
195
196 std::pair<bool, bool> linkResults{writeCdo->areBadLinks(hash)};
197 bool link0ok{linkResults.first};
198 bool link1ok{linkResults.second};
199
200 std::vector<SCT_Chip> chipsInMod;
201 chipsInMod.reserve(nChips);
202 bool isBadSide0{true};
203 bool isBadSide1{true};
206 for (; channelItr!=channelEnd; ++channelItr) {
207
208
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;
218 }
221
222
223 if (
m_readoutTool->determineReadout(moduleId, chipsInMod, link0ok, link1ok).isFailure())
return StatusCode::FAILURE;
224
225
226 std::vector<int> badStripsVec;
227 unsigned int chipStatusWord{0};
228 for (const auto& thisChip:chipsInMod) {
229
230 if (thisChip.numberOfMaskedChannels()!=0) {
231
232 badStripsVec.clear();
233 thisChip.appendBadStripsToVector(badStripsVec);
234
235 for (const auto& thisBadStrip:badStripsVec) {
236 const Identifier stripId{
getStripId(truncatedSerialNumber, thisChip.id(), thisBadStrip, elements, ctx)};
237
239 thisChip.id()<6 ? hash : oppWaferHash,
241 }
242 }
243
244
246 chipStatusWord |= (1<<thisChip.id());
247 nDisabledChips++;
248 if (not isBadModule) nDisabledChipsExclusive++;
249 } else {
250 if (not isBadModule) nDisabledStripsExclusive += thisChip.numberOfMaskedChannels();
251 }
252 }
253
254
255 if (chipStatusWord!=0) {
257 }
258 }
259
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);
265
266 return StatusCode::SUCCESS;
267}
char data[hepevt_bytes_allocation_ATLAS]
AttrListVec::const_iterator const_iterator
const_iterator end() const
const_iterator begin() const
bool is_valid() const
Check if id is in a valid state.
static const std::string s_coolChannelFolderName
Identifier getStripId(const unsigned int truncatedSerialNumber, const unsigned int chipNumber, const unsigned int stripNumber, const InDetDD::SiDetectorElementCollection *elements, const EventContext &ctx) const
ToolHandle< ISCT_ReadoutTool > m_readoutTool
Handle on readout tool.
ToolHandle< ISCT_CablingTool > m_cablingTool
Handle on SCT cabling service.
const SCT_ID * m_pHelper
ID helper for SCT.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
SG::ReadCondHandleKey< CondAttrListVec > m_readKeyChannel
StatusCode fillLinkStatus(SCT_ConfigurationCondData *writeCdo, SG::WriteCondHandle< SCT_ConfigurationCondData > &writeHandle, const EventContext &ctx) const
static const std::string s_coolChannelFolderName2Slim
void setBadChips(const Identifier &moduleId, const unsigned int chipStatus)
Set bad chips for a module.
void clearBadStripIds()
Clear all bad strip identifiers.
void setBadWaferId(const Identifier &badWaferId)
Set a bad wafer identifier.
void setBadStripId(const Identifier &badStripId, const IdentifierHash &hash, const int strip)
Set a bad strip identifier.
const std::set< Identifier > * getBadStripIds() const
Get all bad strip identifiers.
void clearBadChips()
Clear all bad chips.
const_pointer_type retrieve()
void addDependency(const EventIDRange &range)