22 float coerceToFloatRange(
const double value) {
25 return static_cast<float>(std::clamp(
value,minfloat,maxfloat));
71 if (writeKeyData==
nullptr)
continue;
104 ATH_MSG_FATAL(
"IgnoreDefect != IgnoreDefectsParameters, check job options!");
105 return StatusCode::FAILURE;
108 return StatusCode::SUCCESS;
115 bool validWriteCondHandle{
true};
120 ATH_MSG_DEBUG(
"CondHandle " << writeHandleData[
i].fullKey() <<
" is already valid."
121 <<
". In theory this should not be called, but may happen"
122 <<
" if multiple concurrent events are being processed out of order.");
124 validWriteCondHandle =
false;
128 if (writeHandleInfo.isValid()) {
129 ATH_MSG_DEBUG(
"CondHandle " << writeHandleInfo.fullKey() <<
" is already valid."
130 <<
". In theory this should not be called, but may happen"
131 <<
" if multiple concurrent events are being processed out of order.");
133 validWriteCondHandle =
false;
135 if (validWriteCondHandle)
return StatusCode::SUCCESS;
141 if (readCdo[
i]==
nullptr) {
142 ATH_MSG_FATAL(
"Null pointer to the read conditions object " << readHandle[
i].
key());
143 return StatusCode::FAILURE;
146 writeHandleData[
i].addDependency(readHandle[
i]);
147 writeHandleInfo.addDependency(readHandle[
i]);
148 ATH_MSG_INFO(
"Size of CondAttrListCollection " << readHandle[
i].fullKey() <<
" readCdo->size()= " << readCdo[
i]->
size());
155 if (elements==
nullptr) {
157 return StatusCode::FAILURE;
160 writeHandleData[
i].addDependency(sctDetEle);
162 writeHandleInfo.addDependency(sctDetEle);
165 std::unique_ptr<SCT_CalibDefectData> writeCdoData[
NFEATURES]{
nullptr,
nullptr};
167 writeCdoData[
i] = std::make_unique<SCT_CalibDefectData>();
169 std::unique_ptr<SCT_AllGoodStripInfo> writeCdoInfo{std::make_unique<SCT_AllGoodStripInfo>()};
173 (*writeCdoInfo)[
w][
s]=
true;
185 for (; itLoop!=itLoop_end; ++itLoop) {
192 IdentifierHash hashId1;
198 p_element = (elements->getDetectorElement(hashId1));
199 bool phiSwap1Present{p_element->swapPhiReadoutDirection()};
208 const std::string &gaindefectb{(anAttrList[
"defectBeginChannel"]).data<std::string>()};
209 const std::string &gaindefecte{(anAttrList[
"defectEndChannel"]).data<std::string>()};
210 const std::string &defectType{(anAttrList[
"defectType"]).data<std::string>()};
211 const std::string &parValue{(anAttrList[
"defectParameter"]).data<std::string>()};
214 std::vector<unsigned int> gaindefectbvec;
215 fillEmptyVectorFromString(gaindefectb, gaindefectbvec);
216 std::vector<unsigned int> gaindefectevec;
217 fillEmptyVectorFromString(gaindefecte, gaindefectevec);
218 std::vector<unsigned int> defectTypevec;
219 fillEmptyVectorFromString(defectType, defectTypevec);
220 std::vector<double> parValuevec;
221 fillEmptyVectorFromString(parValue, parValuevec);
224 long unsigned int gainvec_size{gaindefectbvec.size()};
225 for (
long unsigned int i{0};
i<gainvec_size; ++
i) {
228 ATH_MSG_DEBUG(
"Defect type " << defectTypevec[
i] <<
" is not defined! This defect is ignored.");
231 theseDefects.
begDefects.push_back(gaindefectbvec[
i]);
232 theseDefects.
endDefects.push_back(gaindefectevec[
i]);
233 theseDefects.
parValue.push_back(coerceToFloatRange(parValuevec[
i]));
238 for (
unsigned int i{0};
i<theseDefects.
begDefects.size(); ++
i) {
240 bool ignoreDefect{
false};
256 if (not ignoreDefect) {
261 const unsigned int waferId0{hashId0};
264 thisWaferIsGoodData0[side0StripNumber] =
false;
266 const unsigned int waferId1{hashId1};
269 thisWaferIsGoodData1[side1StripNumber] =
false;
282 if (not (writeCdoData[
i]->addModule(moduleId, theseDefects))) {
283 ATH_MSG_ERROR(
"Unable to add module " << moduleId <<
" to NPtGain defect map");
284 return StatusCode::RECOVERABLE;
286 ATH_MSG_DEBUG(
"Defects for module " << moduleId <<
" added to NPG defect map");
290 ATH_MSG_DEBUG(
"No NoiseOccupancy defects for module " << moduleId);
293 if (not (writeCdoData[
i]->addModule(moduleId, theseDefects))) {
294 ATH_MSG_ERROR(
"Unable to add module " << moduleId <<
" to NoiseOccupancy defect map");
295 return StatusCode::RECOVERABLE;
297 ATH_MSG_DEBUG(
"Defects for module " << moduleId <<
" added to NoiseOccupancy defect map");
304 ATH_MSG_DEBUG(
"There are " << writeCdoInfo->size() <<
" elements in " << writeHandleInfo.key());
305 if (writeHandleInfo.record(std::move(writeCdoInfo)).isFailure()) {
306 ATH_MSG_FATAL(
"Could not record SCT_AllGoodStripInfo " << writeHandleInfo.key()
307 <<
" with EventRange " << writeHandleInfo.getRange() <<
" into Conditions Store");
308 return StatusCode::FAILURE;
310 ATH_MSG_INFO(
"recorded new CDO " << writeHandleInfo.key() <<
" with range " << writeHandleInfo.getRange() <<
" into Conditions Store");
313 if (writeHandleData[
i].record(std::move(writeCdoData[
i])).isFailure()) {
314 ATH_MSG_FATAL(
"Could not record SCT_CalibDefectData " << writeHandleData[
i].
key()
315 <<
" with EventRange " << writeHandleData[
i].
getRange() <<
" into Conditions Store");
316 return StatusCode::FAILURE;
318 ATH_MSG_INFO(
"recorded new CDO " << writeHandleData[
i].
key() <<
" with range " << writeHandleData[
i].
getRange() <<
" into Conditions Store");
321 return StatusCode::SUCCESS;
326 return StatusCode::SUCCESS;