51 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh"
52 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
69 virtual void endJob()
override;
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);
130 : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"RawDataTag",edm::InputTag(
"source",
""))),
131 topFolderName_(iConfig.getUntrackedParameter<std::
string>(
"TopFolderName",
"SiStrip")),
132 fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>(
"FillAllDetailedHistograms",
false)),
133 fillWithEvtNum_(iConfig.getUntrackedParameter<bool>(
"FillWithEventNumber",
false)),
134 printDebug_(iConfig.getUntrackedParameter<unsigned int>(
"PrintDebugMessages",1)),
136 writeDQMStore_(iConfig.getUntrackedParameter<bool>(
"WriteDQMStore",
false)),
137 dqmStoreFileName_(iConfig.getUntrackedParameter<std::
string>(
"DQMStoreFileName",
"DQMStore.root")),
150 std::ostringstream debugStream;
152 debugStream <<
"[SiStripFEDMonitorPlugin]Configuration for SiStripFEDMonitorPlugin: " << std::endl
153 <<
"[SiStripFEDMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
154 <<
"[SiStripFEDMonitorPlugin]\tHistogramFolderName: " << folderName_ << std::endl
156 <<
"[SiStripFEDMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
157 <<
"[SiStripFEDMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl
158 <<
"[SiStripFEDMonitorPlugin]\tWriteDQMStore? " << (
writeDQMStore_ ?
"yes" :
"no") << std::endl;
163 std::ostringstream* pDebugStream = (
printDebug_>1 ? &debugStream :
NULL);
165 fedHists_.initialise(iConfig,pDebugStream);
174 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
223 fedErrors_.fillEventProperties(he->deltaBX());
227 std::map<unsigned int,std::pair<unsigned short,unsigned short> > badChannelFraction;
229 unsigned int lNFEDMonitoring = 0;
230 unsigned int lNFEDUnpacker = 0;
231 unsigned int lNChannelMonitoring = 0;
232 unsigned int lNChannelUnpacker = 0;
234 unsigned int lNTotBadFeds = 0;
235 unsigned int lNTotBadChannels = 0;
236 unsigned int lNTotBadActiveChannels = 0;
238 std::vector<std::vector<std::pair<unsigned int,unsigned int> > > lFeMajFrac;
239 const unsigned int nParts = 4;
241 lFeMajFrac.resize(nParts);
243 lFeMajFrac[0].reserve(912);
244 lFeMajFrac[1].reserve(1080);
245 lFeMajFrac[2].reserve(768);
246 lFeMajFrac[3].reserve(760);
259 bool lFullDebug =
false;
263 bool lDataExist =
fedErrors_.checkDataPresent(fedData);
285 bool lFailUnpackerFEDcheck =
fedErrors_.failUnpackerFEDCheck();
288 unsigned int lSize = fedData.
size();
296 bool lFailMonitoringFEDcheck =
fedErrors_.failMonitoringFEDCheck();
297 if (lFailMonitoringFEDcheck) lNTotBadFeds++;
303 if (lFailMonitoringFEDcheck != lFailUnpackerFEDcheck) {
305 std::ostringstream debugStream;
306 debugStream <<
" --- WARNING: FED " << fedId << std::endl
307 <<
" ------ Monitoring FED check " ;
308 if (lFailMonitoringFEDcheck) debugStream <<
"failed." << std::endl;
309 else debugStream <<
"passed." << std::endl ;
310 debugStream <<
" ------ Unpacker FED check " ;
311 if (lFailUnpackerFEDcheck) debugStream <<
"failed." << std::endl;
312 else debugStream <<
"passed." << std::endl ;
313 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
316 if (lFailMonitoringFEDcheck) lNFEDMonitoring++;
317 else if (lFailUnpackerFEDcheck) lNFEDUnpacker++;
326 <<
", TkHistoMap enabled but pointer is null." << std::endl;
333 lNTotBadActiveChannels);
338 for (
unsigned int iP(0); iP<nParts; ++iP){
341 if (lFeMajFrac[iP].
size()==0)
continue;
344 unsigned int lMajorityCounter = 0;
345 std::vector<unsigned int> lfedIds;
347 getMajority(lFeMajFrac[iP],lMajorityCounter,lfedIds);
349 fedHists_.fillMajorityHistograms(iP,static_cast<float>(lMajorityCounter)/lFeMajFrac[iP].
size(),lfedIds);
353 if ((lNTotBadFeds> 0 || lNTotBadChannels>0) &&
printDebug_>1) {
354 std::ostringstream debugStream;
355 debugStream <<
"[SiStripFEDMonitorPlugin] --- Total number of bad feds = "
356 << lNTotBadFeds << std::endl
357 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad channels = "
358 << lNTotBadChannels << std::endl
359 <<
"[SiStripFEDMonitorPlugin] --- Total number of bad active channels = "
360 << lNTotBadActiveChannels << std::endl;
361 edm::LogInfo(
"SiStripMonitorHardware") << debugStream.str();
364 if ((lNFEDMonitoring > 0 || lNFEDUnpacker > 0 || lNChannelMonitoring > 0 || lNChannelUnpacker > 0) &&
printDebug_) {
365 std::ostringstream debugStream;
367 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
368 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
369 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at FED level : " << std::endl
370 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNFEDMonitoring << std::endl
371 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNFEDUnpacker << std::endl
372 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
373 <<
"[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at Channel level : " << std::endl
374 <<
"[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNChannelMonitoring << std::endl
375 <<
"[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNChannelUnpacker << std::endl
376 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
377 <<
"[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl ;
378 edm::LogError(
"SiStripMonitorHardware") << debugStream.str();
384 fedErrors_.getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels;
385 fedErrors_.getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels;
398 const std::pair<unsigned int, unsigned int> & pair2){
399 return (pair1.second < pair2.second) ;
403 unsigned int & aMajorityCounter,
404 std::vector<unsigned int> & afedIds) {
407 unsigned int lMajAddress = 0;
408 std::vector<std::pair<unsigned int,unsigned int> >::const_iterator lIter = aFeMajVec.begin();
409 unsigned int lMajAddr = (*lIter).second;
410 unsigned int lCounter = 0;
415 for ( ; lIter != aFeMajVec.end(); ++lIter,++iele) {
417 if ((*lIter).second == lMajAddr) {
423 if (lCounter > aMajorityCounter) {
425 aMajorityCounter = lCounter;
427 lMajAddress = lMajAddr;
432 lMajAddr = (*lIter).second;
439 if (lCounter > aMajorityCounter) {
441 aMajorityCounter = lCounter;
442 lMajAddress = lMajAddr;
447 lIter = aFeMajVec.begin();
448 afedIds.reserve(135);
449 for ( ; lIter != aFeMajVec.end(); ++lIter ) {
450 if((*lIter).second != lMajAddress) {
451 afedIds.push_back((*lIter).first);
454 lIter += aMajorityCounter-1;
455 if(lIter >= aFeMajVec.end()) {
456 std::cout <<
"Here it is a bug: " << aMajorityCounter <<
" " << aFeMajVec.size() <<
" " << lIter - aFeMajVec.end() << std::endl;
461 if (afedIds.size()>0) {
462 std::sort(afedIds.begin(),afedIds.end());
463 std::vector<unsigned int>::iterator lIt = std::unique(afedIds.begin(),afedIds.end());
464 afedIds.erase(lIt,afedIds.end());
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
~SiStripFEDMonitorPlugin()
std::string dqmStoreFileName_
bool fillAllDetailedHistograms_
virtual void endJob() override
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const SiStripFedCabling * cabling_
#define DEFINE_FWK_MODULE(type)
virtual void analyze(const edm::Event &, const edm::EventSetup &) 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_
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
size_t size() const
Lenght of the data buffer in bytes.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
SiStripFEDMonitorPlugin(const edm::ParameterSet &)
T const * product() const
virtual void beginJob() override
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
edm::InputTag rawDataTag_
static bool pairComparison(const std::pair< unsigned int, unsigned int > &pair1, const std::pair< unsigned int, unsigned int > &pair2)
volatile std::atomic< bool > shutdown_flag false
edm::EDGetTokenT< EventWithHistory > heToken_
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
void updateCabling(const edm::EventSetup &eventSetup)