50 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh" 51 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh" 75 static bool pairComparison(
const std::pair<unsigned int, unsigned int>& pair1,
76 const std::pair<unsigned int, unsigned int>& pair2);
78 void getMajority(
const std::vector<std::pair<unsigned int, unsigned int> >& aFeMajVec,
79 unsigned int& aMajorityCounter,
80 std::vector<unsigned int>& afedIds);
126 printDebug_(iConfig.getUntrackedParameter<unsigned
int>(
"PrintDebugMessages", 1)),
137 std::ostringstream debugStream;
139 debugStream <<
"[SiStripFEDMonitorPlugin]Configuration for SiStripFEDMonitorPlugin: " << std::endl
140 <<
"[SiStripFEDMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
141 <<
"[SiStripFEDMonitorPlugin]\tHistogramFolderName: " << folderName_ << std::endl
142 <<
"[SiStripFEDMonitorPlugin]\tFillAllDetailedHistograms? " 144 <<
"[SiStripFEDMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
145 <<
"[SiStripFEDMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl;
149 std::ostringstream* pDebugStream = (
printDebug_ > 1 ? &debugStream :
nullptr);
151 fedHists_.initialise(iConfig, pDebugStream);
160 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
199 std::map<unsigned int, std::pair<unsigned short, unsigned short> > badChannelFraction;
201 unsigned int lNFEDMonitoring = 0;
202 unsigned int lNFEDUnpacker = 0;
203 unsigned int lNChannelMonitoring = 0;
204 unsigned int lNChannelUnpacker = 0;
206 unsigned int lNTotBadFeds = 0;
207 unsigned int lNTotBadChannels = 0;
208 unsigned int lNTotBadActiveChannels = 0;
210 std::vector<std::vector<std::pair<unsigned int, unsigned int> > > lFeMajFrac;
211 const unsigned int nParts = 4;
213 lFeMajFrac.resize(nParts);
215 lFeMajFrac[0].reserve(912);
216 lFeMajFrac[1].reserve(1080);
217 lFeMajFrac[2].reserve(768);
218 lFeMajFrac[3].reserve(760);
226 unsigned int lNBadChannels_perFEDID = 0;
232 double aLumiSection = iEvent.
orbitNumber() / 262144.0;
236 bool lDataExist =
fedErrors_.checkDataPresent(fedData);
255 bool lFailUnpackerFEDcheck =
fedErrors_.failUnpackerFEDCheck();
258 unsigned int lSize = fedData.
size();
266 bool lFailMonitoringFEDcheck =
fedErrors_.failMonitoringFEDCheck();
267 if (lFailMonitoringFEDcheck)
273 if (lFailMonitoringFEDcheck != lFailUnpackerFEDcheck) {
275 std::ostringstream debugStream;
276 debugStream <<
" --- WARNING: FED " <<
fedId << std::endl <<
" ------ Monitoring FED check ";
277 if (lFailMonitoringFEDcheck)
278 debugStream <<
"failed." << std::endl;
280 debugStream <<
"passed." << std::endl;
281 debugStream <<
" ------ Unpacker FED check ";
282 if (lFailUnpackerFEDcheck)
283 debugStream <<
"failed." << std::endl;
285 debugStream <<
"passed." << std::endl;
286 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
289 if (lFailMonitoringFEDcheck)
291 else if (lFailUnpackerFEDcheck)
300 <<
" -- Fedid " <<
fedId <<
", TkHistoMap enabled but pointer is null." << std::endl;
307 lNTotBadActiveChannels,
308 lNBadChannels_perFEDID);
313 for (
unsigned int iP(0); iP < nParts; ++iP) {
316 if (lFeMajFrac[iP].
empty())
320 unsigned int lMajorityCounter = 0;
321 std::vector<unsigned int> lfedIds;
323 getMajority(lFeMajFrac[iP], lMajorityCounter, lfedIds);
325 fedHists_.fillMajorityHistograms(iP, static_cast<float>(lMajorityCounter) / lFeMajFrac[iP].
size(), lfedIds);
329 if ((lNTotBadFeds > 0 || lNTotBadChannels > 0) &&
printDebug_ > 1) {
330 std::ostringstream debugStream;
331 debugStream <<
"[SiStripFEDMonitorPlugin] --- Total number of bad feds = " << lNTotBadFeds << std::endl
332 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad channels = " << lNTotBadChannels << std::endl
333 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad active channels = " << lNTotBadActiveChannels
335 edm::LogInfo(
"SiStripMonitorHardware") << debugStream.str();
338 if ((lNFEDMonitoring > 0 || lNFEDUnpacker > 0 || lNChannelMonitoring > 0 || lNChannelUnpacker > 0) &&
printDebug_) {
339 std::ostringstream debugStream;
341 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" 343 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" 345 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at FED level : " 347 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNFEDMonitoring
349 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNFEDUnpacker
351 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" 353 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at Channel level : " 355 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNChannelMonitoring
357 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNChannelUnpacker
359 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" 361 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" 363 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
366 fedErrors_.getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels;
367 fedErrors_.getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels;
372 double eventNumber =
static_cast<double>(iEvent.
id().
event());
386 const std::pair<unsigned int, unsigned int>& pair2) {
387 return (pair1.second < pair2.second);
391 unsigned int& aMajorityCounter,
392 std::vector<unsigned int>& afedIds) {
393 unsigned int lMajAddress = 0;
394 std::vector<std::pair<unsigned int, unsigned int> >::const_iterator lIter = aFeMajVec.begin();
395 unsigned int lMajAddr = (*lIter).second;
396 unsigned int lCounter = 0;
399 unsigned int iele = 0;
401 for (; lIter != aFeMajVec.end(); ++lIter, ++iele) {
403 if ((*lIter).second == lMajAddr) {
408 if (lCounter > aMajorityCounter) {
410 aMajorityCounter = lCounter;
412 lMajAddress = lMajAddr;
417 lMajAddr = (*lIter).second;
424 if (lCounter > aMajorityCounter) {
426 aMajorityCounter = lCounter;
427 lMajAddress = lMajAddr;
432 lIter = aFeMajVec.begin();
433 afedIds.reserve(135);
434 for (; lIter != aFeMajVec.end(); ++lIter) {
435 if ((*lIter).second != lMajAddress) {
436 afedIds.push_back((*lIter).first);
438 lIter += aMajorityCounter - 1;
439 if (lIter >= aFeMajVec.end()) {
440 std::cout <<
"Here it is a bug: " << aMajorityCounter <<
" " << aFeMajVec.size() <<
" " 441 << lIter - aFeMajVec.end() << std::endl;
446 if (!afedIds.empty()) {
447 std::sort(afedIds.begin(), afedIds.end());
448 std::vector<unsigned int>::iterator lIt =
std::unique(afedIds.begin(), afedIds.end());
449 afedIds.erase(lIt, afedIds.end());
462 fedHists_.bookTopLevelHistograms(ibooker, tkDetMap);
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
bool fillAllDetailedHistograms_
long long deltaBX(const unsigned int ev2, const unsigned int ev1) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const SiStripFedCabling * cabling_
void setCurrentFolder(std::string const &fullpath)
void analyze(const edm::Event &, const edm::EventSetup &) override
void dqmEndLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
void getMajority(const std::vector< std::pair< unsigned int, unsigned int > > &aFeMajVec, unsigned int &aMajorityCounter, std::vector< unsigned int > &afedIds)
std::string topFolderName_
unsigned int maxFedBufferSize_
size_t size() const
Lenght of the data buffer in bytes.
#define DEFINE_FWK_MODULE(type)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
SiStripFEDMonitorPlugin(const edm::ParameterSet &)
def unique(seq, keepstr=True)
void dqmBeginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
edm::InputTag rawDataTag_
static bool pairComparison(const std::pair< unsigned int, unsigned int > &pair1, const std::pair< unsigned int, unsigned int > &pair2)
edm::EDGetTokenT< EventWithHistory > heToken_
~SiStripFEDMonitorPlugin() override
T const * product() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void updateCabling(const edm::EventSetup &eventSetup)