#include <DQM/SiStripMonitorHardware/plugins/SiStripFEDMonitor.cc>
Public Member Functions | |
SiStripFEDMonitorPlugin (const edm::ParameterSet &) | |
~SiStripFEDMonitorPlugin () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) |
virtual void | endJob () |
virtual void | endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) |
void | getMajority (const std::vector< std::pair< unsigned int, unsigned int > > &aFeMajVec, unsigned int &aMajorityCounter, std::vector< unsigned int > &afedIds) |
void | updateCabling (const edm::EventSetup &eventSetup) |
Static Private Member Functions | |
static bool | pairComparison (const std::pair< unsigned int, unsigned int > &pair1, const std::pair< unsigned int, unsigned int > &pair2) |
Private Attributes | |
const SiStripFedCabling * | cabling_ |
uint32_t | cablingCacheId_ |
bool | doFEMajorityCheck_ |
bool | doMedHists_ |
bool | doTkHistoMap_ |
DQMStore * | dqm_ |
std::string | dqmStoreFileName_ |
FEDErrors | fedErrors_ |
FEDHistograms | fedHists_ |
bool | fillAllDetailedHistograms_ |
bool | fillWithEvtNum_ |
std::string | folderName_ |
unsigned int | maxFedBufferSize_ |
unsigned int | nEvt_ |
unsigned int | printDebug_ |
edm::InputTag | rawDataTag_ |
bool | writeDQMStore_ |
Description: DQM source application to produce data integrety histograms for SiStrip data
Definition at line 57 of file SiStripFEDMonitor.cc.
SiStripFEDMonitorPlugin::SiStripFEDMonitorPlugin | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 121 of file SiStripFEDMonitor.cc.
References doFEMajorityCheck_, doMedHists_, doTkHistoMap_, dqmStoreFileName_, fedHists_, fillAllDetailedHistograms_, fillWithEvtNum_, folderName_, LogTrace, nEvt_, NULL, printDebug_, rawDataTag_, and writeDQMStore_.
: rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>("RawDataTag",edm::InputTag("source",""))), folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName","SiStrip/ReadoutView/FedSummary")), fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms",false)), fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber",false)), printDebug_(iConfig.getUntrackedParameter<unsigned int>("PrintDebugMessages",1)), //printDebug_(iConfig.getUntrackedParameter<bool>("PrintDebugMessages",false)), writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)), dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>("DQMStoreFileName","DQMStore.root")), dqm_(0), cablingCacheId_(0), maxFedBufferSize_(0) { //print config to debug log std::ostringstream debugStream; if (printDebug_>1) { debugStream << "[SiStripFEDMonitorPlugin]Configuration for SiStripFEDMonitorPlugin: " << std::endl << "[SiStripFEDMonitorPlugin]\tRawDataTag: " << rawDataTag_ << std::endl << "[SiStripFEDMonitorPlugin]\tHistogramFolderName: " << folderName_ << std::endl << "[SiStripFEDMonitorPlugin]\tFillAllDetailedHistograms? " << (fillAllDetailedHistograms_ ? "yes" : "no") << std::endl << "[SiStripFEDMonitorPlugin]\tFillWithEventNumber?" << (fillWithEvtNum_ ? "yes" : "no") << std::endl << "[SiStripFEDMonitorPlugin]\tPrintDebugMessages? " << (printDebug_ ? "yes" : "no") << std::endl << "[SiStripFEDMonitorPlugin]\tWriteDQMStore? " << (writeDQMStore_ ? "yes" : "no") << std::endl; if (writeDQMStore_) debugStream << "[SiStripFEDMonitorPlugin]\tDQMStoreFileName: " << dqmStoreFileName_ << std::endl; } //don;t generate debug mesages if debug is disabled std::ostringstream* pDebugStream = (printDebug_>1 ? &debugStream : NULL); fedHists_.initialise(iConfig,pDebugStream); doTkHistoMap_ = fedHists_.tkHistoMapEnabled(); doMedHists_ = fedHists_.cmHistosEnabled(); doFEMajorityCheck_ = fedHists_.feMajHistosEnabled(); if (printDebug_) { LogTrace("SiStripMonitorHardware") << debugStream.str(); //debugStream.str(""); //debugStream << " -- Quelle est la difference entre un canard ? " << std::endl // << " -- Reponse: c'est qu'il a les deux pattes de la meme longueur, surtout la gauche." << std::endl; //edm::LogError("SiStripMonitorHardware") << debugStream.str(); } nEvt_ = 0; }
SiStripFEDMonitorPlugin::~SiStripFEDMonitorPlugin | ( | ) |
Definition at line 173 of file SiStripFEDMonitor.cc.
{ }
void SiStripFEDMonitorPlugin::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 184 of file SiStripFEDMonitor.cc.
References begin, cabling_, doFEMajorityCheck_, doMedHists_, doTkHistoMap_, end, edm::EventID::event(), FEDRawDataCollection::FEDData(), fedErrors_, fedHists_, fillWithEvtNum_, edm::Event::getByLabel(), getMajority(), edm::EventBase::id(), maxFedBufferSize_, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, nEvt_, edm::EventBase::orbitNumber(), pairComparison(), printDebug_, rawDataTag_, findQualityFiles::size, FEDRawData::size(), python::multivaluedict::sort(), and updateCabling().
{ //update cabling updateCabling(iSetup); //get raw data edm::Handle<FEDRawDataCollection> rawDataCollectionHandle; iEvent.getByLabel(rawDataTag_,rawDataCollectionHandle); const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle; fedErrors_.initialiseEvent(); //initialise map of fedId/bad channel number std::map<unsigned int,std::pair<unsigned short,unsigned short> > badChannelFraction; unsigned int lNFEDMonitoring = 0; unsigned int lNFEDUnpacker = 0; unsigned int lNChannelMonitoring = 0; unsigned int lNChannelUnpacker = 0; unsigned int lNTotBadFeds = 0; unsigned int lNTotBadChannels = 0; unsigned int lNTotBadActiveChannels = 0; std::vector<std::vector<std::pair<unsigned int,unsigned int> > > lFeMajFrac; const unsigned int nParts = 4; if (doFEMajorityCheck_){ lFeMajFrac.resize(nParts); //max nFE per partition lFeMajFrac[0].reserve(912); lFeMajFrac[1].reserve(1080); lFeMajFrac[2].reserve(768); lFeMajFrac[3].reserve(760); } maxFedBufferSize_ = 0; //loop over siStrip FED IDs for (unsigned int fedId = FEDNumbering::MINSiStripFEDID; fedId <= FEDNumbering::MAXSiStripFEDID; fedId++) {//loop over FED IDs const FEDRawData& fedData = rawDataCollection.FEDData(fedId); //create an object to fill all errors fedErrors_.initialiseFED(fedId,cabling_); bool lFullDebug = false; //Do detailed check //first check if data exists bool lDataExist = fedErrors_.checkDataPresent(fedData); if (!lDataExist) { fedHists_.fillFEDHistograms(fedErrors_,0,lFullDebug); continue; } //check for problems and fill detailed histograms fedErrors_.fillFEDErrors(fedData, lFullDebug, printDebug_, lNChannelMonitoring, lNChannelUnpacker, doMedHists_, fedHists_.cmHistPointer(false), fedHists_.cmHistPointer(true), doFEMajorityCheck_, lFeMajFrac ); //check filled in previous method. bool lFailUnpackerFEDcheck = fedErrors_.failUnpackerFEDCheck(); fedErrors_.incrementFEDCounters(); unsigned int lSize = fedData.size(); if (lSize > maxFedBufferSize_){ maxFedBufferSize_ = lSize; } //std::cout << " -- " << fedId << " " << lSize << std::endl; fedHists_.fillFEDHistograms(fedErrors_,lSize,lFullDebug); bool lFailMonitoringFEDcheck = fedErrors_.failMonitoringFEDCheck(); if (lFailMonitoringFEDcheck) lNTotBadFeds++; //sanity check: if something changed in the unpacking code //but wasn't propagated here //print only the summary, and more info if printDebug>1 if (lFailMonitoringFEDcheck != lFailUnpackerFEDcheck) { if (printDebug_>1) { std::ostringstream debugStream; debugStream << " --- WARNING: FED " << fedId << std::endl << " ------ Monitoring FED check " ; if (lFailMonitoringFEDcheck) debugStream << "failed." << std::endl; else debugStream << "passed." << std::endl ; debugStream << " ------ Unpacker FED check " ; if (lFailUnpackerFEDcheck) debugStream << "failed." << std::endl; else debugStream << "passed." << std::endl ; edm::LogError("SiStripMonitorHardware") << debugStream.str(); } if (lFailMonitoringFEDcheck) lNFEDMonitoring++; else if (lFailUnpackerFEDcheck) lNFEDUnpacker++; } //Fill TkHistoMap: //add an entry for all channels (good = 0), //so that tkHistoMap knows which channels should be there. if (doTkHistoMap_ && !fedHists_.tkHistoMapPointer()) { edm::LogWarning("SiStripMonitorHardware") << " -- Fedid " << fedId << ", TkHistoMap enabled but pointer is null." << std::endl; } fedErrors_.fillBadChannelList(doTkHistoMap_, fedHists_.tkHistoMapPointer(), fedHists_.getFedvsAPVpointer(), lNTotBadChannels, lNTotBadActiveChannels); }//loop over FED IDs if (doFEMajorityCheck_){ for (unsigned int iP(0); iP<nParts; ++iP){ //std::cout << " -- Partition " << iP << std::endl; //std::cout << " --- Number of elements in vec = " << lFeMajFrac[iP].size() << std::endl; if (lFeMajFrac[iP].size()==0) continue; std::sort(lFeMajFrac[iP].begin(),lFeMajFrac[iP].end(),SiStripFEDMonitorPlugin::pairComparison); unsigned int lMajorityCounter = 0; std::vector<unsigned int> lfedIds; getMajority(lFeMajFrac[iP],lMajorityCounter,lfedIds); //std::cout << " -- Found " << lfedIds.size() << " unique elements not matching the majority." << std::endl; fedHists_.fillMajorityHistograms(iP,static_cast<float>(lMajorityCounter)/lFeMajFrac[iP].size(),lfedIds); } } if ((lNTotBadFeds> 0 || lNTotBadChannels>0) && printDebug_>1) { std::ostringstream debugStream; debugStream << "[SiStripFEDMonitorPlugin] --- Total number of bad feds = " << lNTotBadFeds << std::endl << "[SiStripFEDMonitorPlugin] --- Total number of bad channels = " << lNTotBadChannels << std::endl << "[SiStripFEDMonitorPlugin] --- Total number of bad active channels = " << lNTotBadActiveChannels << std::endl; edm::LogInfo("SiStripMonitorHardware") << debugStream.str(); } if ((lNFEDMonitoring > 0 || lNFEDUnpacker > 0 || lNChannelMonitoring > 0 || lNChannelUnpacker > 0) && printDebug_) { std::ostringstream debugStream; debugStream << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl << "[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at FED level : " << std::endl << "[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNFEDMonitoring << std::endl << "[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNFEDUnpacker << std::endl << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl << "[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at Channel level : " << std::endl << "[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNChannelMonitoring << std::endl << "[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNChannelUnpacker << std::endl << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl ; edm::LogError("SiStripMonitorHardware") << debugStream.str(); } FEDErrors::getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels; FEDErrors::getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels; //fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(), nEvt_); //time in seconds since beginning of the run or event number if (fillWithEvtNum_) fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(),FEDErrors::getChannelErrorsCounters(),maxFedBufferSize_,iEvent.id().event()); else fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(),FEDErrors::getChannelErrorsCounters(),maxFedBufferSize_,iEvent.orbitNumber()/11223.); nEvt_++; }//analyze method
void SiStripFEDMonitorPlugin::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 434 of file SiStripFEDMonitor.cc.
References dqm_, fedHists_, fillAllDetailedHistograms_, folderName_, nEvt_, and DQMStore::setCurrentFolder().
{ //get DQM store dqm_ = &(*edm::Service<DQMStore>()); dqm_->setCurrentFolder(folderName_); //this propagates dqm_ to the histoclass, must be called ! fedHists_.bookTopLevelHistograms(dqm_); if (fillAllDetailedHistograms_) fedHists_.bookAllFEDHistograms(); nEvt_ = 0; //const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID; //const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID; //mark all channels as inactive until they have been 'locked' at least once // activeChannels_.resize(siStripFedIdMax+1); // for (unsigned int fedId = siStripFedIdMin; // fedId <= siStripFedIdMax; // fedId++) { // activeChannels_[fedId].resize(sistrip::FEDCH_PER_FED,false); // } }
void SiStripFEDMonitorPlugin::beginLuminosityBlock | ( | const edm::LuminosityBlock & | lumiSeg, |
const edm::EventSetup & | context | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 473 of file SiStripFEDMonitor.cc.
References fedErrors_.
{ fedErrors_.initialiseLumiBlock(); }
void SiStripFEDMonitorPlugin::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 465 of file SiStripFEDMonitor.cc.
References dqm_, dqmStoreFileName_, DQMStore::save(), and writeDQMStore_.
{ if (writeDQMStore_) dqm_->save(dqmStoreFileName_); }
void SiStripFEDMonitorPlugin::endLuminosityBlock | ( | const edm::LuminosityBlock & | lumiSeg, |
const edm::EventSetup & | context | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 483 of file SiStripFEDMonitor.cc.
References fedErrors_, and fedHists_.
{ fedHists_.fillLumiHistograms(fedErrors_.getLumiErrors()); }
void SiStripFEDMonitorPlugin::getMajority | ( | const std::vector< std::pair< unsigned int, unsigned int > > & | aFeMajVec, |
unsigned int & | aMajorityCounter, | ||
std::vector< unsigned int > & | afedIds | ||
) | [private] |
Definition at line 371 of file SiStripFEDMonitor.cc.
References python::multivaluedict::sort().
Referenced by analyze().
{ unsigned int lMajAddress = 0; std::vector<std::pair<unsigned int,unsigned int> >::const_iterator lIter = aFeMajVec.begin(); unsigned int lMajAddr = (*lIter).second; unsigned int lCounter = 0; //std::cout << " --- First element: addr = " << lMajAddr << " counter = " << lCounter << std::endl; unsigned int iele=0; bool foundMaj = false; for ( ; lIter != aFeMajVec.end(); ++lIter,++iele) { //std::cout << " ---- Ele " << iele << " " << (*lIter).first << " " << (*lIter).second << " ref " << lMajAddr << std::endl; if ((*lIter).second == lMajAddr) { ++lCounter; //std::cout << " ----- =ref: Counter = " << lCounter << std::endl; } else { //std::cout << " ----- !=ref: Counter = " << lCounter << " Majority = " << aMajorityCounter << std::endl; if (lCounter > aMajorityCounter) { //std::cout << " ------ >Majority: " << std::endl; aMajorityCounter = lCounter; lMajAddress = (*lIter).second; foundMaj=true; } lCounter = 0; lMajAddr = (*lIter).second; --lIter; --iele; } } if (!foundMaj) { if (lCounter > aMajorityCounter) { //std::cout << " ------ >Majority: " << std::endl; aMajorityCounter = lCounter; lMajAddress = lMajAddr; } } //std::cout << " -- found majority value for " << aMajorityCounter << " elements out of " << aFeMajVec.size() << "." << std::endl; //get list of feds with address different from majority in partition: lIter = aFeMajVec.begin(); afedIds.reserve(135); for ( ; lIter != aFeMajVec.end(); ++lIter ) { if((*lIter).second != lMajAddress) { afedIds.push_back((*lIter).first); } else { lIter += aMajorityCounter-1; } } //std::cout << " -- Found " << lfedIds.size() << " elements not matching the majority." << std::endl; if (afedIds.size()>0) { std::sort(afedIds.begin(),afedIds.end()); std::vector<unsigned int>::iterator lIt = std::unique(afedIds.begin(),afedIds.end()); afedIds.erase(lIt,afedIds.end()); } }
bool SiStripFEDMonitorPlugin::pairComparison | ( | const std::pair< unsigned int, unsigned int > & | pair1, |
const std::pair< unsigned int, unsigned int > & | pair2 | ||
) | [static, private] |
Definition at line 366 of file SiStripFEDMonitor.cc.
Referenced by analyze().
{
return (pair1.second < pair2.second) ;
}
void SiStripFEDMonitorPlugin::updateCabling | ( | const edm::EventSetup & | eventSetup | ) | [private] |
Definition at line 492 of file SiStripFEDMonitor.cc.
References cabling_, cablingCacheId_, edm::EventSetup::get(), and edm::ESHandle< T >::product().
Referenced by analyze().
{ uint32_t currentCacheId = eventSetup.get<SiStripFedCablingRcd>().cacheIdentifier(); if (cablingCacheId_ != currentCacheId) { edm::ESHandle<SiStripFedCabling> cablingHandle; eventSetup.get<SiStripFedCablingRcd>().get(cablingHandle); cabling_ = cablingHandle.product(); cablingCacheId_ = currentCacheId; } }
const SiStripFedCabling* SiStripFEDMonitorPlugin::cabling_ [private] |
Definition at line 101 of file SiStripFEDMonitor.cc.
Referenced by analyze(), and updateCabling().
uint32_t SiStripFEDMonitorPlugin::cablingCacheId_ [private] |
Definition at line 100 of file SiStripFEDMonitor.cc.
Referenced by updateCabling().
bool SiStripFEDMonitorPlugin::doFEMajorityCheck_ [private] |
Definition at line 106 of file SiStripFEDMonitor.cc.
Referenced by analyze(), and SiStripFEDMonitorPlugin().
bool SiStripFEDMonitorPlugin::doMedHists_ [private] |
Definition at line 105 of file SiStripFEDMonitor.cc.
Referenced by analyze(), and SiStripFEDMonitorPlugin().
bool SiStripFEDMonitorPlugin::doTkHistoMap_ [private] |
Definition at line 104 of file SiStripFEDMonitor.cc.
Referenced by analyze(), and SiStripFEDMonitorPlugin().
DQMStore* SiStripFEDMonitorPlugin::dqm_ [private] |
Definition at line 98 of file SiStripFEDMonitor.cc.
Referenced by beginJob(), and endJob().
std::string SiStripFEDMonitorPlugin::dqmStoreFileName_ [private] |
Definition at line 96 of file SiStripFEDMonitor.cc.
Referenced by endJob(), and SiStripFEDMonitorPlugin().
FEDErrors SiStripFEDMonitorPlugin::fedErrors_ [private] |
Definition at line 112 of file SiStripFEDMonitor.cc.
Referenced by analyze(), beginLuminosityBlock(), and endLuminosityBlock().
FEDHistograms SiStripFEDMonitorPlugin::fedHists_ [private] |
Definition at line 84 of file SiStripFEDMonitor.cc.
Referenced by analyze(), beginJob(), endLuminosityBlock(), and SiStripFEDMonitorPlugin().
bool SiStripFEDMonitorPlugin::fillAllDetailedHistograms_ [private] |
Definition at line 88 of file SiStripFEDMonitor.cc.
Referenced by beginJob(), and SiStripFEDMonitorPlugin().
bool SiStripFEDMonitorPlugin::fillWithEvtNum_ [private] |
Definition at line 90 of file SiStripFEDMonitor.cc.
Referenced by analyze(), and SiStripFEDMonitorPlugin().
std::string SiStripFEDMonitorPlugin::folderName_ [private] |
Definition at line 86 of file SiStripFEDMonitor.cc.
Referenced by beginJob(), and SiStripFEDMonitorPlugin().
unsigned int SiStripFEDMonitorPlugin::maxFedBufferSize_ [private] |
Definition at line 113 of file SiStripFEDMonitor.cc.
Referenced by analyze().
unsigned int SiStripFEDMonitorPlugin::nEvt_ [private] |
Definition at line 108 of file SiStripFEDMonitor.cc.
Referenced by analyze(), beginJob(), and SiStripFEDMonitorPlugin().
unsigned int SiStripFEDMonitorPlugin::printDebug_ [private] |
Definition at line 92 of file SiStripFEDMonitor.cc.
Referenced by analyze(), and SiStripFEDMonitorPlugin().
Definition at line 82 of file SiStripFEDMonitor.cc.
Referenced by analyze(), and SiStripFEDMonitorPlugin().
bool SiStripFEDMonitorPlugin::writeDQMStore_ [private] |
Definition at line 95 of file SiStripFEDMonitor.cc.
Referenced by endJob(), and SiStripFEDMonitorPlugin().