49 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh"
50 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
76 static bool pairComparison(
const std::pair<unsigned int, unsigned int> & pair1,
77 const std::pair<unsigned int, unsigned int> & pair2);
79 void getMajority(
const std::vector<std::pair<unsigned int,unsigned int> > & aFeMajVec,
80 unsigned int & aMajorityCounter,
81 std::vector<unsigned int> & afedIds);
124 : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"RawDataTag",edm::InputTag(
"source",
""))),
125 folderName_(iConfig.getUntrackedParameter<std::string>(
"HistogramFolderName",
"SiStrip/ReadoutView/FedSummary")),
126 fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>(
"FillAllDetailedHistograms",
false)),
127 fillWithEvtNum_(iConfig.getUntrackedParameter<bool>(
"FillWithEventNumber",
false)),
128 printDebug_(iConfig.getUntrackedParameter<unsigned int>(
"PrintDebugMessages",1)),
130 writeDQMStore_(iConfig.getUntrackedParameter<bool>(
"WriteDQMStore",
false)),
131 dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>(
"DQMStoreFileName",
"DQMStore.root")),
137 std::ostringstream debugStream;
139 debugStream <<
"[SiStripFEDMonitorPlugin]Configuration for SiStripFEDMonitorPlugin: " << std::endl
140 <<
"[SiStripFEDMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
141 <<
"[SiStripFEDMonitorPlugin]\tHistogramFolderName: " <<
folderName_ << std::endl
143 <<
"[SiStripFEDMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
144 <<
"[SiStripFEDMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl
145 <<
"[SiStripFEDMonitorPlugin]\tWriteDQMStore? " << (
writeDQMStore_ ?
"yes" :
"no") << std::endl;
150 std::ostringstream* pDebugStream = (
printDebug_>1 ? &debugStream :
NULL);
152 fedHists_.initialise(iConfig,pDebugStream);
161 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
205 fedErrors_.fillEventProperties(he->deltaBX());
209 std::map<unsigned int,std::pair<unsigned short,unsigned short> > badChannelFraction;
211 unsigned int lNFEDMonitoring = 0;
212 unsigned int lNFEDUnpacker = 0;
213 unsigned int lNChannelMonitoring = 0;
214 unsigned int lNChannelUnpacker = 0;
216 unsigned int lNTotBadFeds = 0;
217 unsigned int lNTotBadChannels = 0;
218 unsigned int lNTotBadActiveChannels = 0;
220 std::vector<std::vector<std::pair<unsigned int,unsigned int> > > lFeMajFrac;
221 const unsigned int nParts = 4;
223 lFeMajFrac.resize(nParts);
225 lFeMajFrac[0].reserve(912);
226 lFeMajFrac[1].reserve(1080);
227 lFeMajFrac[2].reserve(768);
228 lFeMajFrac[3].reserve(760);
241 bool lFullDebug =
false;
245 bool lDataExist =
fedErrors_.checkDataPresent(fedData);
267 bool lFailUnpackerFEDcheck =
fedErrors_.failUnpackerFEDCheck();
270 unsigned int lSize = fedData.
size();
278 bool lFailMonitoringFEDcheck =
fedErrors_.failMonitoringFEDCheck();
279 if (lFailMonitoringFEDcheck) lNTotBadFeds++;
285 if (lFailMonitoringFEDcheck != lFailUnpackerFEDcheck) {
287 std::ostringstream debugStream;
288 debugStream <<
" --- WARNING: FED " << fedId << std::endl
289 <<
" ------ Monitoring FED check " ;
290 if (lFailMonitoringFEDcheck) debugStream <<
"failed." << std::endl;
291 else debugStream <<
"passed." << std::endl ;
292 debugStream <<
" ------ Unpacker FED check " ;
293 if (lFailUnpackerFEDcheck) debugStream <<
"failed." << std::endl;
294 else debugStream <<
"passed." << std::endl ;
295 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
298 if (lFailMonitoringFEDcheck) lNFEDMonitoring++;
299 else if (lFailUnpackerFEDcheck) lNFEDUnpacker++;
308 <<
", TkHistoMap enabled but pointer is null." << std::endl;
315 lNTotBadActiveChannels);
320 for (
unsigned int iP(0); iP<nParts; ++iP){
323 if (lFeMajFrac[iP].
size()==0)
continue;
326 unsigned int lMajorityCounter = 0;
327 std::vector<unsigned int> lfedIds;
329 getMajority(lFeMajFrac[iP],lMajorityCounter,lfedIds);
331 fedHists_.fillMajorityHistograms(iP,static_cast<float>(lMajorityCounter)/lFeMajFrac[iP].
size(),lfedIds);
335 if ((lNTotBadFeds> 0 || lNTotBadChannels>0) &&
printDebug_>1) {
336 std::ostringstream debugStream;
337 debugStream <<
"[SiStripFEDMonitorPlugin] --- Total number of bad feds = "
338 << lNTotBadFeds << std::endl
339 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad channels = "
340 << lNTotBadChannels << std::endl
341 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad active channels = "
342 << lNTotBadActiveChannels << std::endl;
343 edm::LogInfo(
"SiStripMonitorHardware") << debugStream.str();
346 if ((lNFEDMonitoring > 0 || lNFEDUnpacker > 0 || lNChannelMonitoring > 0 || lNChannelUnpacker > 0) &&
printDebug_) {
347 std::ostringstream debugStream;
349 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
350 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
351 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at FED level : " << std::endl
352 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNFEDMonitoring << std::endl
353 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNFEDUnpacker << std::endl
354 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
355 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at Channel level : " << std::endl
356 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNChannelMonitoring << std::endl
357 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNChannelUnpacker << std::endl
358 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
359 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl ;
360 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
364 FEDErrors::getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels;
365 FEDErrors::getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels;
378 const std::pair<unsigned int, unsigned int> & pair2){
379 return (pair1.second < pair2.second) ;
383 unsigned int & aMajorityCounter,
384 std::vector<unsigned int> & afedIds) {
387 unsigned int lMajAddress = 0;
388 std::vector<std::pair<unsigned int,unsigned int> >::const_iterator lIter = aFeMajVec.begin();
389 unsigned int lMajAddr = (*lIter).second;
390 unsigned int lCounter = 0;
395 for ( ; lIter != aFeMajVec.end(); ++lIter,++iele) {
397 if ((*lIter).second == lMajAddr) {
403 if (lCounter > aMajorityCounter) {
405 aMajorityCounter = lCounter;
407 lMajAddress = lMajAddr;
412 lMajAddr = (*lIter).second;
419 if (lCounter > aMajorityCounter) {
421 aMajorityCounter = lCounter;
422 lMajAddress = lMajAddr;
427 lIter = aFeMajVec.begin();
428 afedIds.reserve(135);
429 for ( ; lIter != aFeMajVec.end(); ++lIter ) {
430 if((*lIter).second != lMajAddress) {
431 afedIds.push_back((*lIter).first);
434 lIter += aMajorityCounter-1;
435 if(lIter >= aFeMajVec.end()) {
436 std::cout <<
"Here it is a bug: " << aMajorityCounter <<
" " << aFeMajVec.size() <<
" " << lIter - aFeMajVec.end() << std::endl;
441 if (afedIds.size()>0) {
442 std::sort(afedIds.begin(),afedIds.end());
443 std::vector<unsigned int>::iterator lIt = std::unique(afedIds.begin(),afedIds.end());
444 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)