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);
61 threshold_(iConfig.getUntrackedParameter<double>(
"Threshold", 0)),
62 debug_(iConfig.getUntrackedParameter<unsigned
int>(
"Debug", 0)),
64 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::SiStripFEDErrorsDQM()]";
68 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::~SiStripFEDErrorsDQM]";
80 std::ostringstream lPath;
81 lPath <<
"Run " <<
getRunNumber() <<
"/SiStrip/Run summary/ReadoutView/";
85 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Now in " << lBaseDir << std::endl;
87 std::vector<std::pair<std::string, unsigned int> > lFedsFolder;
90 lFedsFolder.push_back(std::pair<std::string, unsigned int>(
"FedMonitoringSummary", 0));
98 std::ostringstream lFedDir;
99 lFedDir <<
"FrontEndDriver" << ifed;
104 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] - Errors detected for FED " << ifed
106 lFedsFolder.push_back(std::pair<std::string, unsigned int>(lFedDir.str(), ifed));
111 unsigned int nAPVsTotal = 0;
114 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] cabling not filled, return false " 119 for (
unsigned int iFed(0); iFed < lFedVec.size(); iFed++) {
122 <<
"[SiStripFEDErrorsDQM::readBadAPVs] Invalid fedid : " << *(lFedVec.begin() + iFed) << std::endl;
126 for (
unsigned int iConn(0); iConn < lConnVec.size(); iConn++) {
130 unsigned int lDetid = lConnection.
detId();
138 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total number of APVs found : " 139 << nAPVsTotal << std::endl;
141 unsigned int nAPVsWithErrorTotal = 0;
142 unsigned int nFolders = 0;
144 for (
const auto& iFolder : lFedsFolder) {
145 const std::string lDirName = lBaseDir +
"/" + iFolder.first;
146 const unsigned int lFedId = iFolder.second;
151 std::vector<MonitorElement*> lMeVec = getter.
getContents(lDirName);
154 for (
auto iMe : lMeVec) {
156 if (lMeName.find(
"nFEDErrors") != lMeName.npos) {
157 lNorm = iMe->getEntries();
163 <<
"[SiStripFEDErrorsDQM::readBadAPVs] nFEDErrors not found, norm is " << lNorm << std::endl;
168 unsigned int nAPVsWithError = 0;
169 for (
auto iMe : lMeVec) {
170 if (iMe->getEntries() == 0)
174 bool lookForErrors =
false;
177 lookForErrors = lMeName.find(
"DataMissing") != lMeName.npos || lMeName.find(
"AnyFEDErrors") != lMeName.npos ||
178 (lMeName.find(
"CorruptBuffer") != lMeName.npos && lMeName.find(
"nFED") == lMeName.npos);
181 lookForErrors = lMeName.find(
"APVAddressError") != lMeName.npos || lMeName.find(
"APVError") != lMeName.npos ||
182 lMeName.find(
"BadMajorityAddresses") != lMeName.npos ||
183 lMeName.find(
"FEMissing") != lMeName.npos || lMeName.find(
"OOSBits") != lMeName.npos ||
184 lMeName.find(
"UnlockedBits") != lMeName.npos;
192 nAPVsWithErrorTotal += nAPVsWithError;
197 <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total APVs with error found above threshold = " << nAPVsWithErrorTotal
208 unsigned int& aCounter,
210 const unsigned int aFedId) {
211 unsigned short lFlag = 0;
213 if (lMeName.find(
"DataMissing") != lMeName.npos) {
215 }
else if (lMeName.find(
"AnyFEDErrors") != lMeName.npos) {
217 }
else if (lMeName.find(
"CorruptBuffer") != lMeName.npos && lMeName.find(
"nFED") == lMeName.npos) {
219 }
else if (lMeName.find(
"FEMissing") != lMeName.npos) {
221 }
else if (lMeName.find(
"BadMajorityAddresses") != lMeName.npos) {
223 }
else if (lMeName.find(
"UnlockedBits") != lMeName.npos) {
225 }
else if (lMeName.find(
"OOSBits") != lMeName.npos) {
227 }
else if (lMeName.find(
"APVAddressError") != lMeName.npos) {
229 }
else if (lMeName.find(
"APVError") != lMeName.npos) {
232 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Shouldn't be here ..." 238 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Reading histo : " << lMeName
239 <<
", flag = " << lFlag << std::endl;
244 bool lIsFedHist =
false;
245 bool lIsAPVHist =
false;
246 bool lIsFeHist =
false;
247 bool lIsChHist =
false;
256 else if (lNBins < 10)
263 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFedHist: " << lIsFedHist
265 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsAPVHist: " << lIsAPVHist
267 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFeHist : " << lIsFeHist
269 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsChHist : " << lIsChHist
273 for (
unsigned int ibin(1); ibin < lNBins + 1; ibin++) {
279 <<
"[SiStripFEDErrorsDQM::readHistogramError] ---- Below threshold : " << lStat << std::endl;
283 unsigned int lFedId = ibin + lBinShift;
289 addBadAPV(lConnection, 0, lFlag, aCounter);
293 unsigned int iFeId = ibin + lBinShift;
300 addBadAPV(lConnection, 0, lFlag, aCounter);
303 unsigned int iChId = ibin + lBinShift;
305 unsigned int iAPVid = iChId % 2 + 1;
306 iChId =
static_cast<unsigned int>(iChId / 2.);
308 addBadAPV(lConnection, iAPVid, lFlag, aCounter);
313 addBadAPV(lConnection, 0, lFlag, aCounter);
322 const unsigned short aAPVNumber,
323 const unsigned short aFlag,
324 unsigned int& aCounter) {
326 edm::LogWarning(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, incompatible cabling ! " 327 "Channel is not connected, but entry found in histo ... " 331 unsigned int lDetid = aConnection.
detId();
334 <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, DetId is invalid: " << lDetid << std::endl;
338 unsigned short lApvNum = 0;
339 if (aAPVNumber < 2) {
341 addBadStrips(aConnection, lDetid, lApvNum, aFlag, aCounter);
343 if (aAPVNumber == 0 || aAPVNumber == 2) {
345 addBadStrips(aConnection, lDetid, lApvNum, aFlag, aCounter);
350 const unsigned int aDetId,
351 const unsigned short aApvNum,
352 const unsigned short aFlag,
353 unsigned int& aCounter) {
355 const unsigned short lFirstBadStrip = aApvNum * 128;
356 const unsigned short lConsecutiveBadStrips = 128;
358 unsigned int lBadStripRange =
obj_.
encode(lFirstBadStrip, lConsecutiveBadStrips, aFlag);
360 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadStrips] ---- Adding : detid " << aDetId <<
" (FED " 361 << aConnection.
fedId() <<
", Ch " << aConnection.
fedCh() <<
")" 362 <<
", APV " << aApvNum <<
", flag " << aFlag << std::endl;
377 inline void setFlagBit(
unsigned short& aFlag,
const unsigned short aBit) { aFlag = aFlag | (0x1 << aBit); }
382 const std::vector<uint32_t>& lList = it.second;
386 std::map<unsigned short, unsigned short> lAPVMap;
387 for (
auto cCont : lList) {
389 unsigned short lFlag = 0;
390 setFlagBit(lFlag, lData.
flag);
394 auto lInsert = lAPVMap.emplace(lData.
firstStrip, lFlag);
395 if (!lInsert.second) {
397 setFlagBit(lInsert.first->second, lData.
flag);
403 std::vector<unsigned int> lStripVector;
404 const unsigned short lConsecutiveBadStrips = 128;
405 lStripVector.reserve(lAPVMap.size());
406 for (
const auto& lIter : lAPVMap) {
407 lStripVector.push_back(
obj_.
encode(lIter.first, lConsecutiveBadStrips, lIter.second));
411 if (!
obj_.
put(it.first, lRange)) {
412 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadStrips] detid already exists." << std::endl;
void addBadStrips(const FedChannelConnection &aConnection, const unsigned int aDetId, const unsigned short aApvNum, const unsigned short aFlag, unsigned int &aCounter)
static const uint16_t FED_ID_MIN
virtual void setCurrentFolder(std::string const &fullpath)
static const uint32_t invalid32_
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
virtual bool dirExists(std::string const &path) const
Log< level::Error, false > LogError
void initES(const edm::EventSetup &iSetup) override
std::map< uint32_t, std::vector< unsigned int > > detIdErrors_
Class containning control, module, detector and connection information, at the level of a FED channel...
const uint16_t & fedId() const
SiStripPopConFEDErrorsHandlerFromDQM(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
#define DEFINE_FWK_MODULE(type)
bool getData(T &iHolder) const
void addErrors()
Writes the errors to the db.
const uint32_t & detId() const
~SiStripPopConFEDErrorsHandlerFromDQM() override
void addBadAPV(const FedChannelConnection &aConnection, const unsigned short aAPVNumber, const unsigned short aFlag, unsigned int &aCounter)
Log< level::Info, false > LogInfo
unsigned short firstStrip
static const uint16_t FEDCH_PER_FEUNIT
const SiStripFedCabling * cabling_
SiStripBadStrip * getObj() const override
void readHistogram(MonitorElement *aMe, unsigned int &aCounter, const float aNorm, const unsigned int aFedId)
uint16_t apvPairNumber() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
bool check(const edm::EventSetup &iSetup)
const std::string & getName() const
get name of ME
static const uint16_t FEDCH_PER_FED
std::pair< ContainerIterator, ContainerIterator > Range
uint32_t getRunNumber() const
data decode(const unsigned int &value) const
virtual int getNbinsX() const
get # of bins in X-axis
static const uint16_t FED_ID_MAX
Log< level::Warning, false > LogWarning
const uint16_t & fedCh() const
bool put(const uint32_t &detID, const InputVector &vect)
FedsConstIterRange fedIds() const
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
ConnsConstIterRange fedConnections(uint16_t fed_id) const
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
dqm::legacy::MonitorElement MonitorElement
virtual double getBinContent(int binx) const
get content of bin (1-D)
dqm::legacy::DQMStore DQMStore