18 : info_(std::
move(iInfo)),
20 SiStripDetCabling_(nullptr),
22 useEmptyRunInfo_(
false) {}
27 std::vector<unsigned int> ovect, vect;
29 unsigned short Nstrips;
41 if (range.first != range.second) {
48 if (orange.second - orange.first != 1 || data_.
firstStrip != 0 || data_.
range < Nstrips) {
49 ovect.insert(ovect.end(), orange.first, orange.second);
50 vect.insert(vect.end(), range.first, range.second);
55 edm::LogError(
"SiStripQuality") <<
"[" << __PRETTY_FUNCTION__ <<
"] " << std::endl;
64 std::vector<unsigned int> vect;
69 std::vector<uint32_t> vdets;
71 std::vector<uint32_t>::const_iterator iter = vdets.begin();
72 std::vector<uint32_t>::const_iterator iterEnd = vdets.end();
74 for (; iter != iterEnd; ++iter) {
77 LogTrace(
"SiStripQuality") <<
"[add Voff] add detid " << *iter <<
" first strip " << firstStrip <<
" range "
78 << range << std::endl;
79 vect.push_back(
encode(firstStrip, range));
86 bool allFedsEmpty = runInfo->
m_fed_in.empty();
89 ss <<
"WARNING: the full list of feds in RunInfo is empty. ";
91 ss <<
" SiStripQuality will still use it and all tracker will be off." << std::endl;
93 ss <<
" SiStripQuality will not use it." << std::endl;
102 std::vector<uint16_t> activeFedsFromCabling(ids.begin(), ids.end());
104 std::vector<int> activeFedsFromRunInfo;
107 runInfo->
m_fed_in.begin(), runInfo->
m_fed_in.end(), std::back_inserter(activeFedsFromRunInfo), [&](
int x) {
116 std::sort(activeFedsFromCabling.begin(), activeFedsFromCabling.end());
117 std::sort(activeFedsFromRunInfo.begin(), activeFedsFromRunInfo.end());
118 std::vector<int> differentFeds;
121 activeFedsFromCabling.end(),
122 activeFedsFromRunInfo.begin(),
123 activeFedsFromRunInfo.end(),
124 std::back_inserter(differentFeds));
138 std::vector<int>
check;
140 activeFedsFromRunInfo.end(),
141 activeFedsFromCabling.begin(),
142 activeFedsFromCabling.end(),
143 std::back_inserter(check));
145 if (!check.empty()) {
147 edm::LogInfo(
"SiStripQuality") <<
"The cabling should always include the active feds in runInfo and "
148 "possibly have some more"
149 <<
"there are instead " << check.size() <<
" feds only active in runInfo";
166 auto iter = allData.begin();
167 auto iterEnd = allData.end();
168 std::vector<unsigned int> vect;
169 short firstStrip = 0;
171 for (; iter != iterEnd; ++iter)
174 range = iter->second.nApvs * 128;
175 LogTrace(
"SiStripQuality") <<
"[addNotConnectedConnectionFromCabling] add detid " << iter->first << std::endl;
176 vect.push_back(
encode(firstStrip, range));
183 std::vector<uint32_t> connected_detids;
185 std::vector<uint32_t>::const_iterator itdet = connected_detids.begin();
186 std::vector<uint32_t>::const_iterator itdetEnd = connected_detids.end();
187 for (; itdet != itdetEnd; ++itdet) {
191 std::vector<const FedChannelConnection *>::const_iterator itconns = fedconns.begin();
192 std::vector<const FedChannelConnection *>::const_iterator itconnsEnd = fedconns.end();
195 short ngoodConn = 0, goodConn = 0;
196 for (; itconns != itconnsEnd; ++itconns) {
204 goodConn = goodConn | (0x1 << (*itconns)->apvPairNumber());
207 if (ngoodConn != nApvPairs) {
208 std::vector<unsigned int> vect;
209 for (
size_t idx = 0; idx < nApvPairs; ++idx) {
210 if (!(goodConn & (0x1 << idx))) {
211 short firstStrip = idx * 256;
213 LogTrace(
"SiStripQuality") <<
"[addInvalidConnectionFromCabling] add detid " << *itdet <<
"firstStrip "
214 << firstStrip << std::endl;
215 vect.push_back(
encode(firstStrip, range));
233 uint32_t detid = basep->detid;
234 LogTrace(
"SiStripQuality") <<
"add detid " << detid << std::endl;
239 add(detid, baserange);
244 std::vector<unsigned int> vect,
tmp;
253 if (range.first == range.second) {
254 LogTrace(
"SiStripQuality") <<
"new detid" << std::endl;
256 tmp.insert(tmp.end(), baserange.first, baserange.second);
257 std::stable_sort(tmp.begin(), tmp.end());
258 LogTrace(
"SiStripQuality") <<
"ordered" << std::endl;
260 LogTrace(
"SiStripQuality") <<
"already exists" << std::endl;
265 if (range.second - range.first == 1 && data_.
firstStrip == 0 && data_.
range >= Nstrips) {
266 LogTrace(
"SiStripQuality") <<
"full det is bad.. " << range.second - range.first <<
" "
273 tmp.insert(tmp.end(), baserange.first, baserange.second);
274 tmp.insert(tmp.end(), range.first, range.second);
275 std::stable_sort(tmp.begin(), tmp.end());
276 LogTrace(
"SiStripQuality") <<
"ordered" << std::endl;
282 edm::LogError(
"SiStripQuality") <<
"[" << __PRETTY_FUNCTION__ <<
"] " << std::endl;
286 std::vector<unsigned int>
tmp = vect;
288 std::stable_sort(tmp.begin(), tmp.end());
297 size_t sd = input.second - input.first;
299 detregistry.
detid = DetId;
305 if (p !=
indexes.end() && p->detid == DetId) {
306 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::put_replace] Replacing "
307 "SiStripQuality for already stored DetID "
308 << DetId << std::endl;
312 indexes.insert(p, detregistry);
328 uint16_t BadStripPerApv[6], ipos;
329 std::vector<unsigned int> vect;
331 for (; rp != rend; ++rp) {
332 uint32_t detid = rp->detid;
334 BadStripPerApv[0] = 0;
335 BadStripPerApv[1] = 0;
336 BadStripPerApv[2] = 0;
337 BadStripPerApv[3] = 0;
338 BadStripPerApv[4] = 0;
339 BadStripPerApv[5] = 0;
345 for (
int it = 0; it < sqrange.second - sqrange.first; it++) {
346 data_ =
decode(*(sqrange.first + it));
347 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::ReduceGranularity] detid " << detid <<
" first strip "
352 BadStripPerApv[ipos] +=
354 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::ReduceGranularity] ipos " << ipos <<
" Counter "
355 << BadStripPerApv[ipos] <<
" min "
364 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::ReduceGranularity] Total for detid " << detid <<
" values "
365 << BadStripPerApv[0] <<
" " << BadStripPerApv[1] <<
" " << BadStripPerApv[2] <<
" "
366 << BadStripPerApv[3] <<
" " << BadStripPerApv[4] <<
" " << BadStripPerApv[5];
369 for (
size_t i = 0;
i < 6; ++
i) {
370 if (BadStripPerApv[
i] >= threshold * 128) {
371 vect.push_back(
encode(
i * 128, 128));
395 for (; it != tmp.end(); ++it) {
422 for (; it != itend; ++it) {
429 std::vector<unsigned int>
tmp;
434 for (; jt != jtend; ++jt) {
465 std::vector<unsigned int> v_badstrips_tmp =
v_badstrips;
466 std::vector<DetRegistry> indexes_tmp =
indexes;
468 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::cleanUp] before cleanUp v_badstrips.size()= " <<
v_badstrips.size()
469 <<
" indexes.size()=" <<
indexes.size() << std::endl;
478 if (basep->ibegin != basep->iend) {
481 edm::LogError(
"SiStripQuality") <<
"[" << __PRETTY_FUNCTION__ <<
"] " << std::endl;
485 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::cleanUp] after cleanUp v_badstrips.size()= " <<
v_badstrips.size()
486 <<
" indexes.size()=" <<
indexes.size() << std::endl;
497 unsigned short resultA = 0, resultF = 0;
505 if (basep->iend - basep->ibegin == 1 && fs.
firstStrip == 0 && fs.
range == Nstrips) {
506 result.
detid = basep->detid;
508 result.
BadFibers = (1 << (Nstrips / 256)) - 1;
509 result.
BadApvs = (1 << (Nstrips / 128)) - 1;
519 for (
short apvNb = 0; apvNb < 6; ++apvNb) {
521 resultA = resultA | (1 << apvNb);
525 for (
short fiberNb = 0; fiberNb < 3; ++fiberNb) {
527 resultF = resultF | (1 << fiberNb);
532 result.
detid = basep->detid;
570 return ((p->BadFibers >> fiberNb) & 0x1);
578 return ((p->BadApvs >> apvNb) & 0x1);
643 const uint32_t &detId,
644 const uint32_t &apvPairNumber,
645 std::stringstream &
ss) {
672 ss << detId <<
" and apv = " << apvPairNumber <<
" of subDet = " << subDetName <<
", layer = " << layer
673 <<
" stereo = " << stereo << std::endl;
677 const std::vector<int> &activeFedsFromRunInfo,
678 const std::vector<int> &differentFeds,
680 std::ostringstream
ss;
683 ss <<
"activeFedsFromCabling:" << std::endl;
684 std::copy(activeFedsFromCabling.begin(), activeFedsFromCabling.end(), std::ostream_iterator<uint16_t>(
ss,
" "));
686 ss <<
"activeFedsFromRunInfo:" << std::endl;
687 std::copy(activeFedsFromRunInfo.begin(), activeFedsFromRunInfo.end(), std::ostream_iterator<int>(
ss,
" "));
690 if (differentFeds.size() != 440) {
691 ss <<
"differentFeds : " << std::endl;
692 std::copy(differentFeds.begin(), differentFeds.end(), std::ostream_iterator<int>(
ss,
" "));
695 ss <<
"There are 440 feds (all) active for Cabling but off for RunInfo. "
696 "Tracker was probably not in this run"
699 edm::LogInfo(
"SiStripQuality") << ss.str() << std::endl;
703 std::stringstream
ss;
705 ss <<
"associated to detIds : " << std::endl;
708 std::vector<int>::const_iterator fedIdIt = fedsList.begin();
709 for (; fedIdIt != fedsList.end(); ++fedIdIt) {
710 std::vector<FedChannelConnection>::const_iterator fedChIt =
713 uint32_t detId = fedChIt->detId();
714 if (detId == 0 || detId == 0xFFFFFFFF)
716 uint16_t apvPairNumber = fedChIt->apvPairNumber();
724 std::vector<unsigned int> vect;
725 vect.push_back(
encode(apvPairNumber * 256, 256));
728 LogTrace(
"SiStripQuality") <<
"[addOffForRunInfo] adding apvPairNumber " << apvPairNumber <<
" for detId "
729 << detId <<
" off according to RunInfo" << std::endl;
734 edm::LogInfo(
"SiStripQuality") << ss.str() << std::endl;
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
bool IsFiberBad(const uint32_t &detid, const short &fiberNb) const
static constexpr auto TEC
bool cleanUp(bool force=false)
short getBadFibers(const uint32_t &detid) const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
void addInvalidConnectionFromCabling()
bool tobIsStereo(const DetId &id) const
void add(const uint32_t &, const SiStripBadStrip::Range &)
bool IsStripBad(const uint32_t &detid, const short &strip) const
std::vector< unsigned int >::const_iterator ContainerIterator
const TrackerTopology *const trackerTopology() const
void printDetInfo(const TrackerTopology *const tTopo, const uint32_t &detId, const uint32_t &apvPairNumber, std::stringstream &ss)
Prints debug output for a given detId.
bool IsConnected(const uint32_t &det_id) const
Registry::const_iterator RegistryIterator
SiStripQuality difference(const SiStripQuality &) const
std::vector< BadComponent > BadComponentVect
bool tidIsStereo(const DetId &id) const
constexpr std::array< uint8_t, layerIndexSize > layer
static std::string const input
const uint16_t range(const Frame &aFrame)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
void subtract(std::vector< unsigned int > &, const std::vector< unsigned int > &)
bool tecIsStereo(const DetId &id) const
RegistryIterator getRegistryVectorEnd() const
short getBadApvs(const uint32_t &detid) const
bool IsModuleUsable(const uint32_t &detid) const
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::vector< int > m_fed_in
FedsConstIterRange fedIds() const
void compact(unsigned int &, std::vector< unsigned int > &)
const SiStripDetCabling * SiStripDetCabling_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool IsModuleBad(const uint32_t &detid) const
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
static const std::string B
static constexpr auto TOB
void subtraction(std::vector< unsigned int > &, const unsigned int &)
bool put_replace(const uint32_t &DetId, Range input)
ContainerIterator getDataVectorBegin() const
const SiStripFedCabling * fedCabling() const
Log< level::Info, false > LogInfo
static constexpr auto TIB
unsigned short firstStrip
bool tibIsStereo(const DetId &id) const
static const uint16_t invalid_
ConnsConstIterRange fedConnections(uint16_t fed_id) const
int nBadStripsOnTheLeft(const Range &range, const short &strip) const
unsigned int layer(const DetId &id) const
RegistryIterator getRegistryVectorBegin() const
const uint16_t nApvPairs(uint32_t det_id) const
const Range getRange(const uint32_t detID) const
const std::map< uint32_t, DetInfo > & getAllData() const noexcept
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
std::pair< ContainerIterator, ContainerIterator > Range
void turnOffFeds(const std::vector< int > &fedsList, const bool turnOffStrips, const bool printDebug)
void printActiveFedsInfo(const std::vector< uint16_t > &activeFedsFromCabling, const std::vector< int > &activeFedsFromRunInfo, const std::vector< int > &differentFeds, const bool printDebug)
bool put(const uint32_t &detID, const InputVector &vect)
static constexpr auto TID
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void addNotConnectedConnectionFromCabling()
int nBadStripsOnTheRight(const Range &range, const short &strip) const
data decode(const unsigned int &value) const
void ReduceGranularity(double)