11 fp_(iConfig.getUntrackedParameter<edm::
FileInPath>(
"file",edm::
FileInPath(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
13 threshold_(iConfig.getUntrackedParameter<double>(
"Threshold",0)),
14 debug_(iConfig.getUntrackedParameter<unsigned int>(
"Debug",0))
17 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::SiStripFEDErrorsDQM()]";
21 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::~SiStripFEDErrorsDQM]";
41 edm::LogError(
"SiStripFEDErrorsDQM")<<
"Service is unavailable"<<std::endl;
81 std::ostringstream lPath;
82 lPath <<
"Run " <<
getRunNumber() <<
"/SiStrip/Run summary/ReadoutView/";
85 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Now in " <<
dqmStore_->pwd() << std::endl;
89 std::vector<std::pair<std::string,unsigned int> > lFedsFolder;
92 lFedsFolder.push_back(std::pair<std::string,unsigned int>(
"FedMonitoringSummary",0));
101 std::ostringstream lFedDir;
102 lFedDir <<
"FrontEndDriver" << ifed;
103 if (!
goToDir(lFedDir.str()))
continue;
106 if (
debug_)
LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] - Errors detected for FED " << ifed << std::endl;
107 lFedsFolder.push_back(std::pair<std::string,unsigned int>(lFedDir.str(),ifed));
112 unsigned int nAPVsTotal = 0;
115 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] cabling not filled, return false " << std::endl;
119 for (
unsigned int iFed(0);iFed<lFedVec.size();iFed++){
121 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Invalid fedid : " << *(lFedVec.begin() + iFed) << std::endl;
125 for (
unsigned int iConn(0); iConn<lConnVec.size();iConn++){
128 unsigned int lDetid = lConnection.
detId();
135 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total number of APVs found : " << nAPVsTotal << std::endl;
137 unsigned int nAPVsWithErrorTotal = 0;
138 unsigned int nFolders = 0;
142 for( std::vector<std::pair<std::string,unsigned int> >::const_iterator iFolder = lFedsFolder.begin();
143 iFolder != lFedsFolder.end();
145 std::string lDirName = lBaseDir +
"/" + (*iFolder).first;
146 unsigned int lFedId = (*iFolder).second;
148 if (!
goToDir((*iFolder).first))
continue;
150 std::vector<MonitorElement *> lMeVec =
dqmStore_->getContents(lDirName);
154 for( std::vector<MonitorElement *>::const_iterator iMe = lMeVec.begin();
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;
172 for( std::vector<MonitorElement *>::const_iterator iMe = lMeVec.begin();
176 if ((*iMe)->getEntries() == 0)
continue;
179 bool lookForErrors =
false;
183 lMeName.find(
"DataMissing") != lMeName.npos ||
184 lMeName.find(
"AnyFEDErrors") != lMeName.npos ||
185 (lMeName.find(
"CorruptBuffer") != lMeName.npos &&
186 lMeName.find(
"nFED") == lMeName.npos);
191 lMeName.find(
"APVAddressError") != lMeName.npos ||
192 lMeName.find(
"APVError") != lMeName.npos ||
193 lMeName.find(
"BadMajorityAddresses") != lMeName.npos ||
194 lMeName.find(
"FEMissing") != lMeName.npos ||
195 lMeName.find(
"OOSBits") != lMeName.npos ||
196 lMeName.find(
"UnlockedBits") != lMeName.npos;
199 if (lookForErrors)
readHistogram(*iMe,nAPVsWithError,lNorm,lFedId);
203 nAPVsWithErrorTotal += nAPVsWithError;
210 edm::LogInfo(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readBadAPVs] Total APVs with error found above threshold = " << nAPVsWithErrorTotal << std::endl;
220 unsigned int & aCounter,
222 const unsigned int aFedId)
224 unsigned short lFlag = 0;
226 if (lMeName.find(
"DataMissing") != lMeName.npos) {
229 else if (lMeName.find(
"AnyFEDErrors") != lMeName.npos) {
232 else if (lMeName.find(
"CorruptBuffer") != lMeName.npos &&
233 lMeName.find(
"nFED") == lMeName.npos) {
236 else if (lMeName.find(
"FEMissing") != lMeName.npos) {
239 else if (lMeName.find(
"BadMajorityAddresses") != lMeName.npos) {
242 else if (lMeName.find(
"UnlockedBits") != lMeName.npos) {
245 else if (lMeName.find(
"OOSBits") != lMeName.npos) {
248 else if (lMeName.find(
"APVAddressError") != lMeName.npos) {
251 else if (lMeName.find(
"APVError") != lMeName.npos) {
255 edm::LogError(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Shouldn't be here ..." << std::endl;
260 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] Reading histo : " << lMeName <<
", flag = " << lFlag << std::endl;
265 bool lIsFedHist =
false;
266 bool lIsAPVHist =
false;
267 bool lIsFeHist =
false;
268 bool lIsChHist =
false;
276 if (lNBins > 100) lIsAPVHist =
true;
277 else if (lNBins < 10) lIsFeHist =
true;
278 else lIsChHist =
true;
282 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFedHist: " << lIsFedHist << std::endl
283 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsAPVHist: " << lIsAPVHist << std::endl
284 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsFeHist : " << lIsFeHist << std::endl
285 <<
"[SiStripFEDErrorsDQM::readHistogramError] lIsChHist : " << lIsChHist << std::endl;
288 for (
unsigned int ibin(1); ibin<lNBins+1; ibin++){
292 if (
debug_)
LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::readHistogramError] ---- Below threshold : " << lStat << std::endl;
296 unsigned int lFedId = ibin+lBinShift;
298 for (
unsigned int iChId = 0;
308 unsigned int iFeId = ibin+lBinShift;
310 for (
unsigned int iFeCh = 0;
313 unsigned int iChId = sistrip::FEDCH_PER_FEUNIT*iFeId+iFeCh;
320 unsigned int iChId = ibin+lBinShift;
322 unsigned int iAPVid = iChId%2+1;
323 iChId =
static_cast<unsigned int>(iChId/2.);
325 addBadAPV(lConnection,iAPVid,lFlag,aCounter);
339 const unsigned short aAPVNumber,
340 const unsigned short aFlag,
341 unsigned int & aCounter)
344 edm::LogWarning(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, incompatible cabling ! Channel is not connected, but entry found in histo ... " << std::endl;
347 unsigned int lDetid = aConnection.
detId();
349 edm::LogWarning(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadAPV] Warning, DetId is invalid: " << lDetid << std::endl;
353 unsigned short lApvNum = 0;
354 if (aAPVNumber < 2) {
356 addBadStrips(aConnection,lDetid,lApvNum,aFlag,aCounter);
358 if (aAPVNumber == 0 || aAPVNumber == 2) {
360 addBadStrips(aConnection,lDetid,lApvNum,aFlag,aCounter);
366 const unsigned int aDetId,
367 const unsigned short aApvNum,
368 const unsigned short aFlag,
369 unsigned int & aCounter)
372 unsigned int lBadStripRange;
373 unsigned short lFirstBadStrip=aApvNum*128;
374 unsigned short lConsecutiveBadStrips=128;
376 lBadStripRange =
obj_->
encode(lFirstBadStrip,lConsecutiveBadStrips,aFlag);
378 LogTrace(
"SiStripFEDErrorsDQM") <<
"[SiStripFEDErrorsDQM::addBadStrips] ---- Adding : detid " << aDetId
379 <<
" (FED " << aConnection.
fedId()
380 <<
", Ch " << aConnection.
fedCh () <<
")"
381 <<
", APV " << aApvNum
382 <<
", flag " << aFlag
401 std::vector<uint32_t> lList = it->second;
405 std::map<unsigned short,unsigned short> lAPVMap;
408 for (uint32_t iCh(0); iCh<lList.size(); iCh++) {
410 unsigned short lFlag = 0;
415 std::pair<std::map<unsigned short,unsigned short>::iterator,
bool> lInsert = lAPVMap.insert(std::pair<unsigned short,unsigned short>(lData.
firstStrip,lFlag));
416 if (!lInsert.second) {
424 std::vector<unsigned int> lStripVector;
425 unsigned short lConsecutiveBadStrips=128;
427 for (std::map<unsigned short,unsigned short>::iterator lIter = lAPVMap.begin();
428 lIter != lAPVMap.end();
431 lStripVector.push_back(
obj_->
encode(lIter->first,lConsecutiveBadStrips,lIter->second));
435 if ( !
obj_->
put(it->first,lRange) ) {
436 edm::LogError(
"SiStripFEDErrorsDQM")<<
"[SiStripFEDErrorsDQM::addBadStrips] detid already exists." << std::endl;
444 aFlag = aFlag | (0x1 << aBit) ;
const std::string & getName(void) const
get name of ME
std::map< uint32_t, std::vector< unsigned int > > detIdErrors_
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_
uint16_t apvPairNumber() const
void addErrors()
Writes the errors to the db.
bool goToDir(const std::string &name)
Uses DQM utilities to access the requested dir.
uint32_t getRunNumber() const
Returns the run number from the cfg.
const uint16_t & fedId() const
void addBadAPV(const FedChannelConnection &aConnection, const unsigned short aAPVNumber, const unsigned short aFlag, unsigned int &aCounter)
SiStripFEDErrorsDQM(const edm::ParameterSet &iConfig)
void setFlagBit(unsigned short &aFlag, const unsigned short aBit)
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
cond::Time_t beginOfTime() const
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
unsigned short firstStrip
static const uint16_t FEDCH_PER_FEUNIT
T const * product() const
cond::Time_t endOfTime() const
ConnsConstIterRange fedConnections(uint16_t fed_id) const
double getBinContent(int binx) const
get content of bin (1-D)
static const uint16_t FEDCH_PER_FED
cond::Time_t currentTime() const
std::pair< ContainerIterator, ContainerIterator > Range
int getNbinsX(void) const
get # of bins in X-axis
const SiStripFedCabling * cabling_
static const uint16_t FED_ID_MAX
std::string fullPath() const
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void updateCabling(const edm::EventSetup &eventSetup)
void readHistogram(MonitorElement *aMe, unsigned int &aCounter, const float aNorm, const unsigned int aFedId)
void openRequestedFile()
Uses DQMStore to access the DQM file.
data decode(const unsigned int &value) const
void addBadStrips(const FedChannelConnection &aConnection, const unsigned int aDetId, const unsigned short aApvNum, const unsigned short aFlag, unsigned int &aCounter)