24 unsigned int & aCounter,
26 const unsigned int aFedId);
29 const unsigned short aAPVNumber,
30 const unsigned short aFlag,
31 unsigned int & aCounter);
34 const unsigned int aDetId,
35 const unsigned short aApvNum,
36 const unsigned short aFlag,
37 unsigned int & aCounter);
62 ,
fp_(iConfig.getUntrackedParameter<
edm::FileInPath>(
"file",
edm::FileInPath(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat")))
63 ,
threshold_(iConfig.getUntrackedParameter<double>(
"Threshold", 0))
64 ,
debug_(iConfig.getUntrackedParameter<unsigned
int>(
"Debug",0))
67 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::SiStripFEDErrorsDQM()]";
71 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::~SiStripFEDErrorsDQM]";
91 std::ostringstream lPath;
92 lPath <<
"Run " <<
getRunNumber() <<
"/SiStrip/Run summary/ReadoutView/";
96 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Now in " << lBaseDir << std::endl;
98 std::vector<std::pair<std::string,unsigned int> > lFedsFolder;
101 lFedsFolder.push_back(std::pair<std::string,unsigned int>(
"FedMonitoringSummary",0));
110 std::ostringstream lFedDir;
111 lFedDir <<
"FrontEndDriver" << ifed;
112 if ( ! getter.
dirExists(lFedDir.str()) )
continue;
114 if (
debug_)
LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] - Errors detected for FED " << ifed << std::endl;
115 lFedsFolder.push_back(std::pair<std::string,unsigned int>(lFedDir.str(),ifed));
120 unsigned int nAPVsTotal = 0;
123 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] cabling not filled, return false " << std::endl;
127 for (
unsigned int iFed(0);iFed<lFedVec.size();iFed++){
129 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Invalid fedid : " << *(lFedVec.begin() + iFed) << std::endl;
133 for (
unsigned int iConn(0); iConn<lConnVec.size();iConn++){
136 unsigned int lDetid = lConnection.
detId();
143 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total number of APVs found : " << nAPVsTotal << std::endl;
145 unsigned int nAPVsWithErrorTotal = 0;
146 unsigned int nFolders = 0;
148 for (
const auto& iFolder : lFedsFolder ) {
149 const std::string lDirName = lBaseDir +
"/" + iFolder.first;
150 const unsigned int lFedId = iFolder.second;
152 if ( ! getter.
dirExists(lDirName) )
continue;
154 std::vector<MonitorElement*> lMeVec = getter.
getContents(lDirName);
157 for (
auto iMe : lMeVec ) {
159 if (lMeName.find(
"nFEDErrors") != lMeName.npos){
160 lNorm = iMe->getEntries();
165 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] nFEDErrors not found, norm is " << lNorm << std::endl;
170 unsigned int nAPVsWithError = 0;
171 for (
auto iMe : lMeVec ) {
172 if ( iMe->getEntries() == 0 )
continue;
175 bool lookForErrors =
false;
179 lMeName.find(
"DataMissing") != lMeName.npos ||
180 lMeName.find(
"AnyFEDErrors") != lMeName.npos ||
181 (lMeName.find(
"CorruptBuffer") != lMeName.npos &&
182 lMeName.find(
"nFED") == lMeName.npos);
187 lMeName.find(
"APVAddressError") != lMeName.npos ||
188 lMeName.find(
"APVError") != lMeName.npos ||
189 lMeName.find(
"BadMajorityAddresses") != lMeName.npos ||
190 lMeName.find(
"FEMissing") != lMeName.npos ||
191 lMeName.find(
"OOSBits") != lMeName.npos ||
192 lMeName.find(
"UnlockedBits") != lMeName.npos;
195 if (lookForErrors)
readHistogram(iMe,nAPVsWithError,lNorm,lFedId);
199 nAPVsWithErrorTotal += nAPVsWithError;
203 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total APVs with error found above threshold = " << nAPVsWithErrorTotal << std::endl;
216 unsigned int & aCounter,
218 const unsigned int aFedId)
220 unsigned short lFlag = 0;
222 if (lMeName.find(
"DataMissing") != lMeName.npos) {
225 else if (lMeName.find(
"AnyFEDErrors") != lMeName.npos) {
228 else if (lMeName.find(
"CorruptBuffer") != lMeName.npos &&
229 lMeName.find(
"nFED") == lMeName.npos) {
232 else if (lMeName.find(
"FEMissing") != lMeName.npos) {
235 else if (lMeName.find(
"BadMajorityAddresses") != lMeName.npos) {
238 else if (lMeName.find(
"UnlockedBits") != lMeName.npos) {
241 else if (lMeName.find(
"OOSBits") != lMeName.npos) {
244 else if (lMeName.find(
"APVAddressError") != lMeName.npos) {
247 else if (lMeName.find(
"APVError") != lMeName.npos) {
251 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Shouldn't be here ..." << std::endl;
256 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Reading histo : " << lMeName <<
", flag = " << lFlag << std::endl;
261 bool lIsFedHist =
false;
262 bool lIsAPVHist =
false;
263 bool lIsFeHist =
false;
264 bool lIsChHist =
false;
272 if (lNBins > 100) lIsAPVHist =
true;
273 else if (lNBins < 10) lIsFeHist =
true;
274 else lIsChHist =
true;
278 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFedHist: " << lIsFedHist << std::endl
279 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsAPVHist: " << lIsAPVHist << std::endl
280 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFeHist : " << lIsFeHist << std::endl
281 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsChHist : " << lIsChHist << std::endl;
284 for (
unsigned int ibin(1); ibin<lNBins+1; ibin++){
288 if (
debug_)
LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] ---- Below threshold : " << lStat << std::endl;
292 unsigned int lFedId = ibin+lBinShift;
294 for (
unsigned int iChId = 0;
304 unsigned int iFeId = ibin+lBinShift;
306 for (
unsigned int iFeCh = 0;
309 unsigned int iChId = sistrip::FEDCH_PER_FEUNIT*iFeId+iFeCh;
316 unsigned int iChId = ibin+lBinShift;
318 unsigned int iAPVid = iChId%2+1;
319 iChId =
static_cast<unsigned int>(iChId/2.);
321 addBadAPV(lConnection,iAPVid,lFlag,aCounter);
335 const unsigned short aAPVNumber,
336 const unsigned short aFlag,
337 unsigned int & aCounter)
340 edm::LogWarning(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, incompatible cabling ! Channel is not connected, but entry found in histo ... " << std::endl;
343 unsigned int lDetid = aConnection.
detId();
345 edm::LogWarning(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, DetId is invalid: " << lDetid << std::endl;
349 unsigned short lApvNum = 0;
350 if (aAPVNumber < 2) {
352 addBadStrips(aConnection,lDetid,lApvNum,aFlag,aCounter);
354 if (aAPVNumber == 0 || aAPVNumber == 2) {
356 addBadStrips(aConnection,lDetid,lApvNum,aFlag,aCounter);
362 const unsigned int aDetId,
363 const unsigned short aApvNum,
364 const unsigned short aFlag,
365 unsigned int & aCounter)
368 const unsigned short lFirstBadStrip = aApvNum*128;
369 const unsigned short lConsecutiveBadStrips = 128;
371 unsigned int lBadStripRange =
obj_.
encode(lFirstBadStrip, lConsecutiveBadStrips, aFlag);
373 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadStrips] ---- Adding : detid " << aDetId
374 <<
" (FED " << aConnection.
fedId()
375 <<
", Ch " << aConnection.
fedCh () <<
")" 376 <<
", APV " << aApvNum
377 <<
", flag " << aFlag
393 inline void setFlagBit(
unsigned short & aFlag,
const unsigned short aBit)
395 aFlag = aFlag | (0x1 << aBit);
402 const std::vector<uint32_t>& lList = it.second;
406 std::map<unsigned short,unsigned short> lAPVMap;
407 for (
auto cCont : lList ) {
409 unsigned short lFlag = 0;
410 setFlagBit(lFlag, lData.
flag);
414 auto lInsert = lAPVMap.emplace(lData.
firstStrip, lFlag);
415 if ( ! lInsert.second ) {
417 setFlagBit(lInsert.first->second, lData.
flag);
423 std::vector<unsigned int> lStripVector;
424 const unsigned short lConsecutiveBadStrips=128;
425 for (
const auto& lIter : lAPVMap ) {
426 lStripVector.push_back(
obj_.
encode(lIter.first, lConsecutiveBadStrips, lIter.second));
430 if ( !
obj_.
put(it.first,lRange) ) {
431 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
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
const uint16_t & fedCh() const
static const uint32_t invalid32_
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
uint16_t apvPairNumber() const
void setCurrentFolder(std::string const &fullpath)
const std::string & getName() const
get name of ME
const uint16_t & fedId() const
void initES(const edm::EventSetup &iSetup) override
SiStripBadStrip * getObj() const override
#define DEFINE_FWK_MODULE(type)
std::map< uint32_t, std::vector< unsigned int > > detIdErrors_
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
void addErrors()
Writes the errors to the db.
std::vector< MonitorElement * > getContents(Args &&...args)
~SiStripPopConFEDErrorsHandlerFromDQM() override
uint32_t getRunNumber() const
void addBadAPV(const FedChannelConnection &aConnection, const unsigned short aAPVNumber, const unsigned short aFlag, unsigned int &aCounter)
unsigned short firstStrip
static const uint16_t FEDCH_PER_FEUNIT
const SiStripFedCabling * cabling_
void readHistogram(MonitorElement *aMe, unsigned int &aCounter, const float aNorm, const unsigned int aFedId)
bool dirExists(std::string const &path)
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
double getBinContent(int binx) const
get content of bin (1-D)
static const uint16_t FEDCH_PER_FED
std::pair< ContainerIterator, ContainerIterator > Range
std::string fullPath() const
static const uint16_t FED_ID_MAX
SiStripPopConFEDErrorsHandlerFromDQM(const edm::ParameterSet &iConfig)
int getNbinsX() const
get # of bins in X-axis
bool put(const uint32_t &detID, const InputVector &vect)
T const * product() const
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
data decode(const unsigned int &value) const