20 SiStripDetCabling_(nullptr),
22 useEmptyRunInfo_(
false) {}
27 std::vector<unsigned int> ovect, vect;
29 unsigned short Nstrips;
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;
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;
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 & (0
x1 <<
idx))) {
211 short firstStrip =
idx * 256;
213 LogTrace(
"SiStripQuality") <<
"[addInvalidConnectionFromCabling] add detid " << *itdet <<
"firstStrip " 214 << firstStrip << std::endl;
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;
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;
266 LogTrace(
"SiStripQuality") <<
"full det is bad.. " <<
range.second -
range.first <<
" " 273 tmp.insert(
tmp.end(), baserange.first, baserange.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());
306 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::put_replace] Replacing " 307 "SiStripQuality for already stored DetID " 308 <<
DetId << std::endl;
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;
344 for (
int it = 0; it < sqrange.second - sqrange.first; it++) {
345 data_ =
decode(*(sqrange.first + it));
346 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::ReduceGranularity] detid " << detid <<
" first strip " 351 BadStripPerApv[ipos] +=
353 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::ReduceGranularity] ipos " << ipos <<
" Counter " 354 << BadStripPerApv[ipos] <<
" min " 363 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::ReduceGranularity] Total for detid " << detid <<
" values " 364 << BadStripPerApv[0] <<
" " << BadStripPerApv[1] <<
" " << BadStripPerApv[2] <<
" " 365 << BadStripPerApv[3] <<
" " << BadStripPerApv[4] <<
" " << BadStripPerApv[5];
368 for (
size_t i = 0;
i < 6; ++
i) {
370 vect.push_back(
encode(
i * 128, 128));
394 for (; it !=
tmp.end(); ++it) {
421 for (; it != itend; ++it) {
428 std::vector<unsigned int>
tmp;
433 for (; jt != jtend; ++jt) {
464 std::vector<unsigned int> v_badstrips_tmp =
v_badstrips;
465 std::vector<DetRegistry> indexes_tmp =
indexes;
467 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::cleanUp] before cleanUp v_badstrips.size()= " <<
v_badstrips.size()
468 <<
" indexes.size()=" <<
indexes.size() << std::endl;
477 if (basep->ibegin != basep->iend) {
480 edm::LogError(
"SiStripQuality") <<
"[" << __PRETTY_FUNCTION__ <<
"] " << std::endl;
484 LogTrace(
"SiStripQuality") <<
"[SiStripQuality::cleanUp] after cleanUp v_badstrips.size()= " <<
v_badstrips.size()
485 <<
" indexes.size()=" <<
indexes.size() << std::endl;
496 unsigned short resultA = 0, resultF = 0;
504 if (basep->iend - basep->ibegin == 1 &&
fs.firstStrip == 0 &&
fs.range == Nstrips) {
505 result.detid = basep->detid;
507 result.BadFibers = (1 << (Nstrips / 256)) - 1;
508 result.BadApvs = (1 << (Nstrips / 128)) - 1;
518 for (
short apvNb = 0; apvNb < 6; ++apvNb) {
519 if (
fs.firstStrip <= apvNb * 128 && (apvNb + 1) * 128 <=
fs.firstStrip +
fs.range) {
520 resultA = resultA | (1 << apvNb);
524 for (
short fiberNb = 0; fiberNb < 3; ++fiberNb) {
525 if (
fs.firstStrip <= fiberNb * 256 && (fiberNb + 1) * 256 <=
fs.firstStrip +
fs.range) {
526 resultF = resultF | (1 << fiberNb);
531 result.detid = basep->detid;
533 result.BadFibers = resultF;
569 return ((
p->BadFibers >> fiberNb) & 0x1);
577 return ((
p->BadApvs >> apvNb) & 0x1);
643 uint32_t apvPairNumber,
644 std::stringstream &
ss) {
671 ss <<
detId <<
" and apv = " << apvPairNumber <<
" of subDet = " << subDetName <<
", layer = " <<
layer 672 <<
" stereo = " << stereo << std::endl;
676 const std::vector<int> &activeFedsFromRunInfo,
677 const std::vector<int> &differentFeds,
679 std::ostringstream
ss;
682 ss <<
"activeFedsFromCabling:" << std::endl;
683 std::copy(activeFedsFromCabling.begin(), activeFedsFromCabling.end(), std::ostream_iterator<uint16_t>(
ss,
" "));
685 ss <<
"activeFedsFromRunInfo:" << std::endl;
686 std::copy(activeFedsFromRunInfo.begin(), activeFedsFromRunInfo.end(), std::ostream_iterator<int>(
ss,
" "));
689 if (differentFeds.size() != 440) {
690 ss <<
"differentFeds : " << std::endl;
691 std::copy(differentFeds.begin(), differentFeds.end(), std::ostream_iterator<int>(
ss,
" "));
694 ss <<
"There are 440 feds (all) active for Cabling but off for RunInfo. " 695 "Tracker was probably not in this run" 702 std::stringstream
ss;
704 ss <<
"associated to detIds : " << std::endl;
707 std::vector<int>::const_iterator fedIdIt = fedsList.begin();
708 for (; fedIdIt != fedsList.end(); ++fedIdIt) {
709 std::vector<FedChannelConnection>::const_iterator fedChIt =
712 uint32_t
detId = fedChIt->detId();
715 uint16_t apvPairNumber = fedChIt->apvPairNumber();
723 std::vector<unsigned int> vect;
724 vect.push_back(
encode(apvPairNumber * 256, 256));
727 LogTrace(
"SiStripQuality") <<
"[addOffForRunInfo] adding apvPairNumber " << apvPairNumber <<
" for detId " 728 <<
detId <<
" off according to RunInfo" << std::endl;
void getDetIds(std::vector< uint32_t > &DetIds_) const
static constexpr auto TEC
ContainerIterator getDataVectorBegin() const
bool cleanUp(bool force=false)
bool IsApvBad(uint32_t detid, short apvNb) const
void addInvalidConnectionFromCabling()
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
short getBadFibers(uint32_t detid) const
std::vector< unsigned int >::const_iterator ContainerIterator
bool IsModuleBad(uint32_t detid) const
Registry::const_iterator RegistryIterator
bool IsConnected(const uint32_t &det_id) const
const Range getRange(const uint32_t detID) const
void add(uint32_t, const SiStripBadStrip::Range &)
bool tibIsStereo(const DetId &id) const
std::vector< BadComponent > BadComponentVect
unsigned int layer(const DetId &id) const
static std::string const input
bool tobIsStereo(const DetId &id) const
void subtract(std::vector< unsigned int > &, const std::vector< unsigned int > &)
const SiStripFedCabling * fedCabling() const
const SiStripDetCabling * SiStripDetCabling_
void compact(uint32_t detid, std::vector< unsigned int > &)
RegistryIterator getRegistryVectorEnd() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
static constexpr auto TOB
int nBadStripsOnTheLeft(const Range &range, short strip) const
void subtraction(std::vector< unsigned int > &, const unsigned int &)
Log< level::Info, false > LogInfo
static constexpr auto TIB
unsigned short firstStrip
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
int nBadStripsOnTheRight(const Range &range, short strip) const
bool IsStripBad(uint32_t detid, short strip) const
void printDetInfo(const TrackerTopology *const tTopo, uint32_t detId, uint32_t apvPairNumber, std::stringstream &ss)
Prints debug output for a given detId.
static const uint16_t invalid_
bool tecIsStereo(const DetId &id) const
SiStripQuality difference(const SiStripQuality &) const
bool put_replace(uint32_t detId, Range input)
bool tidIsStereo(const DetId &id) const
const std::map< uint32_t, DetInfo > & getAllData() const noexcept
std::pair< ContainerIterator, ContainerIterator > Range
void turnOffFeds(const std::vector< int > &fedsList, const bool turnOffStrips, const bool printDebug)
data decode(const unsigned int &value) const
const TrackerTopology *const trackerTopology() const
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)
bool IsModuleUsable(uint32_t detid) const
FedsConstIterRange fedIds() const
static constexpr auto TID
bool IsFiberBad(uint32_t detid, short fiberNb) const
RegistryIterator getRegistryVectorBegin() const
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void addNotConnectedConnectionFromCabling()
const uint16_t nApvPairs(uint32_t det_id) const
ConnsConstIterRange fedConnections(uint16_t fed_id) const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
void ReduceGranularity(double)
short getBadApvs(uint32_t detid) const