51 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh"
52 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
78 static bool pairComparison(
const std::pair<unsigned int, unsigned int> & pair1,
79 const std::pair<unsigned int, unsigned int> & pair2);
81 void getMajority(
const std::vector<std::pair<unsigned int,unsigned int> > & aFeMajVec,
82 unsigned int & aMajorityCounter,
83 std::vector<unsigned int> & afedIds);
126 : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"RawDataTag",edm::InputTag(
"source",
""))),
127 folderName_(iConfig.getUntrackedParameter<std::
string>(
"HistogramFolderName",
"SiStrip/ReadoutView/FedSummary")),
128 fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>(
"FillAllDetailedHistograms",
false)),
129 fillWithEvtNum_(iConfig.getUntrackedParameter<bool>(
"FillWithEventNumber",
false)),
130 printDebug_(iConfig.getUntrackedParameter<unsigned int>(
"PrintDebugMessages",1)),
132 writeDQMStore_(iConfig.getUntrackedParameter<bool>(
"WriteDQMStore",
false)),
133 dqmStoreFileName_(iConfig.getUntrackedParameter<std::
string>(
"DQMStoreFileName",
"DQMStore.root")),
139 std::ostringstream debugStream;
141 debugStream <<
"[SiStripFEDMonitorPlugin]Configuration for SiStripFEDMonitorPlugin: " << std::endl
142 <<
"[SiStripFEDMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
143 <<
"[SiStripFEDMonitorPlugin]\tHistogramFolderName: " <<
folderName_ << std::endl
145 <<
"[SiStripFEDMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
146 <<
"[SiStripFEDMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl
147 <<
"[SiStripFEDMonitorPlugin]\tWriteDQMStore? " << (
writeDQMStore_ ?
"yes" :
"no") << std::endl;
152 std::ostringstream* pDebugStream = (
printDebug_>1 ? &debugStream :
NULL);
154 fedHists_.initialise(iConfig,pDebugStream);
163 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
212 fedErrors_.fillEventProperties(he->deltaBX());
216 std::map<unsigned int,std::pair<unsigned short,unsigned short> > badChannelFraction;
218 unsigned int lNFEDMonitoring = 0;
219 unsigned int lNFEDUnpacker = 0;
220 unsigned int lNChannelMonitoring = 0;
221 unsigned int lNChannelUnpacker = 0;
223 unsigned int lNTotBadFeds = 0;
224 unsigned int lNTotBadChannels = 0;
225 unsigned int lNTotBadActiveChannels = 0;
227 std::vector<std::vector<std::pair<unsigned int,unsigned int> > > lFeMajFrac;
228 const unsigned int nParts = 4;
230 lFeMajFrac.resize(nParts);
232 lFeMajFrac[0].reserve(912);
233 lFeMajFrac[1].reserve(1080);
234 lFeMajFrac[2].reserve(768);
235 lFeMajFrac[3].reserve(760);
248 bool lFullDebug =
false;
252 bool lDataExist =
fedErrors_.checkDataPresent(fedData);
274 bool lFailUnpackerFEDcheck =
fedErrors_.failUnpackerFEDCheck();
277 unsigned int lSize = fedData.
size();
285 bool lFailMonitoringFEDcheck =
fedErrors_.failMonitoringFEDCheck();
286 if (lFailMonitoringFEDcheck) lNTotBadFeds++;
292 if (lFailMonitoringFEDcheck != lFailUnpackerFEDcheck) {
294 std::ostringstream debugStream;
295 debugStream <<
" --- WARNING: FED " << fedId << std::endl
296 <<
" ------ Monitoring FED check " ;
297 if (lFailMonitoringFEDcheck) debugStream <<
"failed." << std::endl;
298 else debugStream <<
"passed." << std::endl ;
299 debugStream <<
" ------ Unpacker FED check " ;
300 if (lFailUnpackerFEDcheck) debugStream <<
"failed." << std::endl;
301 else debugStream <<
"passed." << std::endl ;
302 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
305 if (lFailMonitoringFEDcheck) lNFEDMonitoring++;
306 else if (lFailUnpackerFEDcheck) lNFEDUnpacker++;
315 <<
", TkHistoMap enabled but pointer is null." << std::endl;
322 lNTotBadActiveChannels);
327 for (
unsigned int iP(0); iP<nParts; ++iP){
330 if (lFeMajFrac[iP].
size()==0)
continue;
333 unsigned int lMajorityCounter = 0;
334 std::vector<unsigned int> lfedIds;
336 getMajority(lFeMajFrac[iP],lMajorityCounter,lfedIds);
338 fedHists_.fillMajorityHistograms(iP,static_cast<float>(lMajorityCounter)/lFeMajFrac[iP].
size(),lfedIds);
342 if ((lNTotBadFeds> 0 || lNTotBadChannels>0) &&
printDebug_>1) {
343 std::ostringstream debugStream;
344 debugStream <<
"[SiStripFEDMonitorPlugin] --- Total number of bad feds = "
345 << lNTotBadFeds << std::endl
346 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad channels = "
347 << lNTotBadChannels << std::endl
348 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad active channels = "
349 << lNTotBadActiveChannels << std::endl;
350 edm::LogInfo(
"SiStripMonitorHardware") << debugStream.str();
353 if ((lNFEDMonitoring > 0 || lNFEDUnpacker > 0 || lNChannelMonitoring > 0 || lNChannelUnpacker > 0) &&
printDebug_) {
354 std::ostringstream debugStream;
356 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
357 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
358 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at FED level : " << std::endl
359 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNFEDMonitoring << std::endl
360 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNFEDUnpacker << std::endl
361 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
362 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at Channel level : " << std::endl
363 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNChannelMonitoring << std::endl
364 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNChannelUnpacker << std::endl
365 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
366 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl ;
367 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
371 FEDErrors::getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels;
372 FEDErrors::getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels;
385 const std::pair<unsigned int, unsigned int> & pair2){
386 return (pair1.second < pair2.second) ;
390 unsigned int & aMajorityCounter,
391 std::vector<unsigned int> & afedIds) {
394 unsigned int lMajAddress = 0;
395 std::vector<std::pair<unsigned int,unsigned int> >::const_iterator lIter = aFeMajVec.begin();
396 unsigned int lMajAddr = (*lIter).second;
397 unsigned int lCounter = 0;
402 for ( ; lIter != aFeMajVec.end(); ++lIter,++iele) {
404 if ((*lIter).second == lMajAddr) {
410 if (lCounter > aMajorityCounter) {
412 aMajorityCounter = lCounter;
414 lMajAddress = lMajAddr;
419 lMajAddr = (*lIter).second;
426 if (lCounter > aMajorityCounter) {
428 aMajorityCounter = lCounter;
429 lMajAddress = lMajAddr;
434 lIter = aFeMajVec.begin();
435 afedIds.reserve(135);
436 for ( ; lIter != aFeMajVec.end(); ++lIter ) {
437 if((*lIter).second != lMajAddress) {
438 afedIds.push_back((*lIter).first);
441 lIter += aMajorityCounter-1;
442 if(lIter >= aFeMajVec.end()) {
443 std::cout <<
"Here it is a bug: " << aMajorityCounter <<
" " << aFeMajVec.size() <<
" " << lIter - aFeMajVec.end() << std::endl;
448 if (afedIds.size()>0) {
449 std::sort(afedIds.begin(),afedIds.end());
450 std::vector<unsigned int>::iterator lIt = std::unique(afedIds.begin(),afedIds.end());
451 afedIds.erase(lIt,afedIds.end());
EventNumber_t event() const
~SiStripFEDMonitorPlugin()
std::string dqmStoreFileName_
bool fillAllDetailedHistograms_
const SiStripFedCabling * cabling_
#define DEFINE_FWK_MODULE(type)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
void getMajority(const std::vector< std::pair< unsigned int, unsigned int > > &aFeMajVec, unsigned int &aMajorityCounter, std::vector< unsigned int > &afedIds)
unsigned int maxFedBufferSize_
size_t size() const
Lenght of the data buffer in bytes.
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
SiStripFEDMonitorPlugin(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
T const * product() const
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)
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
void updateCabling(const edm::EventSetup &eventSetup)