30 const unsigned short aAPVNumber,
31 const unsigned short aFlag,
32 unsigned int& aCounter);
35 const unsigned int aDetId,
36 const unsigned short aApvNum,
37 const unsigned short aFlag,
38 unsigned int& aCounter);
63 fp_(iConfig.getUntrackedParameter<
edm::FileInPath>(
64 "file",
edm::FileInPath(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
65 threshold_(iConfig.getUntrackedParameter<double>(
"Threshold", 0)),
66 debug_(iConfig.getUntrackedParameter<unsigned
int>(
"Debug", 0)),
68 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::SiStripFEDErrorsDQM()]";
72 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::~SiStripFEDErrorsDQM]";
86 std::ostringstream lPath;
87 lPath <<
"Run " <<
getRunNumber() <<
"/SiStrip/Run summary/ReadoutView/";
91 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Now in " << lBaseDir << std::endl;
93 std::vector<std::pair<std::string, unsigned int> > lFedsFolder;
96 lFedsFolder.push_back(std::pair<std::string, unsigned int>(
"FedMonitoringSummary", 0));
104 std::ostringstream lFedDir;
105 lFedDir <<
"FrontEndDriver" << ifed;
110 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] - Errors detected for FED " << ifed
112 lFedsFolder.push_back(std::pair<std::string, unsigned int>(lFedDir.str(), ifed));
117 unsigned int nAPVsTotal = 0;
120 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] cabling not filled, return false "
125 for (
unsigned int iFed(0); iFed < lFedVec.size(); iFed++) {
128 <<
"[SiStripFEDErrorsDQM::readBadAPVs] Invalid fedid : " << *(lFedVec.begin() + iFed) << std::endl;
132 for (
unsigned int iConn(0); iConn < lConnVec.size(); iConn++) {
136 unsigned int lDetid = lConnection.
detId();
144 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total number of APVs found : "
145 << nAPVsTotal << std::endl;
147 unsigned int nAPVsWithErrorTotal = 0;
148 unsigned int nFolders = 0;
150 for (
const auto& iFolder : lFedsFolder) {
151 const std::string lDirName = lBaseDir +
"/" + iFolder.first;
152 const unsigned int lFedId = iFolder.second;
157 std::vector<MonitorElement*> lMeVec = getter.
getContents(lDirName);
160 for (
auto iMe : lMeVec) {
162 if (lMeName.find(
"nFEDErrors") != lMeName.npos) {
163 lNorm = iMe->getEntries();
169 <<
"[SiStripFEDErrorsDQM::readBadAPVs] nFEDErrors not found, norm is " << lNorm << std::endl;
174 unsigned int nAPVsWithError = 0;
175 for (
auto iMe : lMeVec) {
176 if (iMe->getEntries() == 0)
180 bool lookForErrors =
false;
183 lookForErrors = lMeName.find(
"DataMissing") != lMeName.npos || lMeName.find(
"AnyFEDErrors") != lMeName.npos ||
184 (lMeName.find(
"CorruptBuffer") != lMeName.npos && lMeName.find(
"nFED") == lMeName.npos);
187 lookForErrors = lMeName.find(
"APVAddressError") != lMeName.npos || lMeName.find(
"APVError") != lMeName.npos ||
188 lMeName.find(
"BadMajorityAddresses") != lMeName.npos ||
189 lMeName.find(
"FEMissing") != lMeName.npos || lMeName.find(
"OOSBits") != lMeName.npos ||
190 lMeName.find(
"UnlockedBits") != lMeName.npos;
198 nAPVsWithErrorTotal += nAPVsWithError;
203 <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total APVs with error found above threshold = " << nAPVsWithErrorTotal
214 unsigned int& aCounter,
216 const unsigned int aFedId) {
217 unsigned short lFlag = 0;
219 if (lMeName.find(
"DataMissing") != lMeName.npos) {
221 }
else if (lMeName.find(
"AnyFEDErrors") != lMeName.npos) {
223 }
else if (lMeName.find(
"CorruptBuffer") != lMeName.npos && lMeName.find(
"nFED") == lMeName.npos) {
225 }
else if (lMeName.find(
"FEMissing") != lMeName.npos) {
227 }
else if (lMeName.find(
"BadMajorityAddresses") != lMeName.npos) {
229 }
else if (lMeName.find(
"UnlockedBits") != lMeName.npos) {
231 }
else if (lMeName.find(
"OOSBits") != lMeName.npos) {
233 }
else if (lMeName.find(
"APVAddressError") != lMeName.npos) {
235 }
else if (lMeName.find(
"APVError") != lMeName.npos) {
238 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Shouldn't be here ..."
244 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Reading histo : " << lMeName
245 <<
", flag = " << lFlag << std::endl;
250 bool lIsFedHist =
false;
251 bool lIsAPVHist =
false;
252 bool lIsFeHist =
false;
253 bool lIsChHist =
false;
262 else if (lNBins < 10)
269 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFedHist: " << lIsFedHist
271 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsAPVHist: " << lIsAPVHist
273 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFeHist : " << lIsFeHist
275 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsChHist : " << lIsChHist
279 for (
unsigned int ibin(1); ibin < lNBins + 1; ibin++) {
285 <<
"[SiStripFEDErrorsDQM::readHistogramError] ---- Below threshold : " << lStat << std::endl;
289 unsigned int lFedId = ibin + lBinShift;
295 addBadAPV(lConnection, 0, lFlag, aCounter);
299 unsigned int iFeId = ibin + lBinShift;
306 addBadAPV(lConnection, 0, lFlag, aCounter);
309 unsigned int iChId = ibin + lBinShift;
311 unsigned int iAPVid = iChId % 2 + 1;
312 iChId = static_cast<unsigned int>(iChId / 2.);
314 addBadAPV(lConnection, iAPVid, lFlag, aCounter);
319 addBadAPV(lConnection, 0, lFlag, aCounter);
328 const unsigned short aAPVNumber,
329 const unsigned short aFlag,
330 unsigned int& aCounter) {
332 edm::LogWarning(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, incompatible cabling ! "
333 "Channel is not connected, but entry found in histo ... "
337 unsigned int lDetid = aConnection.
detId();
340 <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, DetId is invalid: " << lDetid << std::endl;
344 unsigned short lApvNum = 0;
345 if (aAPVNumber < 2) {
347 addBadStrips(aConnection, lDetid, lApvNum, aFlag, aCounter);
349 if (aAPVNumber == 0 || aAPVNumber == 2) {
351 addBadStrips(aConnection, lDetid, lApvNum, aFlag, aCounter);
356 const unsigned int aDetId,
357 const unsigned short aApvNum,
358 const unsigned short aFlag,
359 unsigned int& aCounter) {
361 const unsigned short lFirstBadStrip = aApvNum * 128;
362 const unsigned short lConsecutiveBadStrips = 128;
364 unsigned int lBadStripRange =
obj_.
encode(lFirstBadStrip, lConsecutiveBadStrips, aFlag);
366 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadStrips] ---- Adding : detid " << aDetId <<
" (FED "
367 << aConnection.
fedId() <<
", Ch " << aConnection.
fedCh() <<
")"
368 <<
", APV " << aApvNum <<
", flag " << aFlag << std::endl;
383 inline void setFlagBit(
unsigned short& aFlag,
const unsigned short aBit) { aFlag = aFlag | (0x1 << aBit); }
388 const std::vector<uint32_t>& lList = it.second;
392 std::map<unsigned short, unsigned short> lAPVMap;
393 for (
auto cCont : lList) {
395 unsigned short lFlag = 0;
396 setFlagBit(lFlag, lData.
flag);
400 auto lInsert = lAPVMap.emplace(lData.
firstStrip, lFlag);
401 if (!lInsert.second) {
403 setFlagBit(lInsert.first->second, lData.
flag);
409 std::vector<unsigned int> lStripVector;
410 const unsigned short lConsecutiveBadStrips = 128;
411 lStripVector.reserve(lAPVMap.size());
412 for (
const auto& lIter : lAPVMap) {
413 lStripVector.push_back(
obj_.
encode(lIter.first, lConsecutiveBadStrips, lIter.second));
417 if (!
obj_.
put(it.first, lRange)) {
418 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadStrips] detid already exists." << std::endl;