32 bool doesNotHaveNumbers(
const std::string& numberString) {
33 return (numberString.empty() or numberString.find_first_of(
"0123456789") == std::string::npos);
42 base_class(
type, name, parent)
50 if (detStore()->retrieve(
m_pHelper,
"SCT_ID").isFailure()) {
52 return StatusCode::FAILURE;
58 return StatusCode::SUCCESS;
65 return StatusCode::SUCCESS;
110 const EventContext& ctx{Gaudi::Hive::currentContext()};
112 return isGood(elementId, ctx,
h);
127 const EventContext& ctx{Gaudi::Hive::currentContext()};
129 return isGood(hashId, ctx);
136 if (not condDataHandle.
isValid()) {
146 if (status.empty()) {
147 status.resize(
m_pHelper->wafer_hash_max(),
true);
149 for (
unsigned int hash=0; hash<status.size(); ++hash) {
154 if (chip_status.empty()) {
157 chip_status.resize(
m_pHelper->wafer_hash_max(),all_chips_set);
160 std::vector<std::vector<unsigned short> > &bad_strips = element_status.
getBadCells();
161 if (bad_strips.empty()) {
162 bad_strips.resize(status.size());
165 std::vector<std::pair<unsigned int, unsigned int> > tmp_bad_strips;
166 for (
unsigned int module_hash=0; module_hash<status.size(); ++module_hash) {
169 std::vector<unsigned short> &bad_module_strips_out = bad_strips.at(module_hash);
170 std::array<unsigned int, SCT::N_CHIPS_PER_SIDE> bad_strip_counts{};
172 const std::array<std::bitset<SCT_ConditionsData::STRIPS_PER_CHIP>,
176 unsigned int strip_i=0;
177 tmp_bad_strips.clear();
180 for (
const auto& chip_i : bad_module_strips_in) {
183 for (
unsigned int strip_per_chip_i=0; strip_per_chip_i<chip_i.size(); ++strip_per_chip_i) {
184 if (chip_i.test(strip_per_chip_i)) {
185 tmp_bad_strips.emplace_back(geoemtrical_chip_id,strip_i);
186 ++bad_strip_counts.at(geoemtrical_chip_id);
192 InDet::ChipFlags_t bad_chips=0;
193 for (
unsigned int the_chip=0; the_chip< bad_strip_counts.size(); ++the_chip) {
194 bad_chips |=
static_cast<InDet::ChipFlags_t
>((bad_strip_counts[the_chip]>=
m_nhits_noisychip) << the_chip);
196 chip_status[module_hash] &= ~bad_chips;
198 for (
const std::pair<unsigned int, unsigned int> &chip_and_strip : tmp_bad_strips) {
199 unsigned int strip_i=chip_and_strip.second;
200 std::vector<unsigned short>::const_iterator iter = std::lower_bound(bad_module_strips_out.begin(),bad_module_strips_out.end(),strip_i);
201 if (iter == bad_module_strips_out.end() || *iter != strip_i) {
202 bad_module_strips_out.insert( iter, strip_i);
216 for (; waferItr != waferEnd; ++waferItr) {
217 if (
m_pHelper->side(*waferItr) != 0)
continue;
225 const EventContext& ctx{Gaudi::Hive::currentContext()};
235 std::string defectStr{
getList(moduleId, ctx)};
236 if (doesNotHaveNumbers(defectStr))
return;
239 std::set<int> defectList;
243 std::set<int>::const_iterator defectItr{defectList.begin()}, defectEnd{defectList.end()};
244 for (; defectItr!=defectEnd; ++defectItr) {
254 ATH_MSG_DEBUG(
"Bad Strip: Strip number in DB = " << *defectItr<<
", side/offline strip number = " << side <<
"/" << stripNum<<
", Identifier = " << stripId);
256 strips.insert(stripId);
262 const EventContext& ctx{Gaudi::Hive::currentContext()};
275 const EventContext& ctx{Gaudi::Hive::currentContext()};
285 string currentDefectList{
""};
289 condData->
find(moduleHash, currentDefectList);
293 return currentDefectList;
302 std::string::size_type sepPos{rangeStr.find(
s_separator)};
304 if (sepPos != std::string::npos) {
306 std::string::size_type len1{sepPos++}, len2{rangeStr.size()-sepPos};
307 int min{std::stoi(rangeStr.substr(0,len1))};
308 int max{std::stoi(rangeStr.substr(sepPos,len2))};
310 while (
min != (
max+1)) rangeList.insert(
min++);
313 rangeList.insert(std::stoi(rangeStr));
324 if (doesNotHaveNumbers(defectStr))
return;
326 std::istringstream is{defectStr};
327 std::istream_iterator<std::string> defectItr{is};
328 std::istream_iterator<std::string> defectEnd;
331 for (; defectItr != defectEnd; ++defectItr)
expandRange(*defectItr, defectList);
#define ATH_CHECK
Evaluate an expression and check for errors.
header file containing the number of elements and enumerated type of parameters which may be retrieve...
This is an Identifier helper class for the SCT subdetector.
Header file for AthHistogramAlgorithm.
This is a "hash" representation of an Identifier.
const std::vector< bool > & getElementStatus() const
const std::vector< ChipFlags_t > & getElementChipStatus() const
const std::vector< std::vector< unsigned short > > & getBadCells() const
std::vector< Identifier >::const_iterator const_id_iterator
Class for data object used in SCT_MonitorCondAlg and SCT_MonitorConditionsTool.
std::size_t nBadStripsForModule(const IdentifierHash &moduleHash) const
Get the number of bad strips for a module.
bool find(const IdentifierHash &hash, std::string &defectList) const
Check if a module has a defect (a list of bad strips). If it does not have defect return false.
bool isBadStrip(const IdentifierHash &waferHash, const int strip) const
Check if a strip is bad.
const std::array< std::bitset< SCT_ConditionsData::STRIPS_PER_CHIP >, SCT_ConditionsData::CHIPS_PER_SIDE > & badStripsForModule(const IdentifierHash &waferHash) const
std::size_t nBadStripsForChip(const IdentifierHash &waferHash, const int strip) const
Get the number of bad strips for the chip, where a strip locates.
std::size_t nBadStripsForWafer(const IdentifierHash &waferHash) const
Get the number of bad strips for a wafer.
const_pointer_type retrieve()
const_pointer_type cptr()
void addDependency(const EventIDRange &range)
constexpr unsigned int N_CHIPS_PER_SIDE
constexpr unsigned int getGeometricalChipID(unsigned int strip)
Get the geometrical chip ID for the given strip.
constexpr unsigned int N_SIDES