#include <DQM/SiStripMonitorHardware/plugins/SiStripCMMonitor.cc>
Classes | |
struct | Statistics |
Public Member Functions | |
SiStripCMMonitorPlugin (const edm::ParameterSet &) | |
~SiStripCMMonitorPlugin () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
void | fillMaps (uint32_t aDetId, unsigned short aChInModule, std::pair< uint16_t, uint16_t > aMedians) |
void | updateCabling (const edm::EventSetup &eventSetup) |
Private Attributes | |
const SiStripFedCabling * | cabling_ |
uint32_t | cablingCacheId_ |
CMHistograms | cmHists_ |
std::map< unsigned int, Statistics > | CommonModes_ |
std::map< unsigned int, Statistics > | CommonModesAPV0minusAPV1_ |
bool | doTkHistoMap_ |
DQMStore * | dqm_ |
std::string | dqmStoreFileName_ |
unsigned int | evt_ |
std::vector< unsigned int > | fedIdVec_ |
bool | fillAllDetailedHistograms_ |
bool | fillWithEvtNum_ |
bool | fillWithLocalEvtNum_ |
std::string | folderName_ |
std::pair< uint16_t, uint16_t > | prevMedians_ [FEDNumbering::MAXSiStripFEDID+1][sistrip::FEDCH_PER_FED] |
unsigned int | printDebug_ |
edm::InputTag | rawDataTag_ |
bool | writeDQMStore_ |
Description: DQM source application to monitor common mode for SiStrip data
Definition at line 63 of file SiStripCMMonitor.cc.
SiStripCMMonitorPlugin::SiStripCMMonitorPlugin | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 128 of file SiStripCMMonitor.cc.
References cmHists_, CommonModes_, CommonModesAPV0minusAPV1_, doTkHistoMap_, dqmStoreFileName_, evt_, sistrip::FEDCH_PER_FED, fillAllDetailedHistograms_, fillWithEvtNum_, folderName_, LogTrace, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, NULL, prevMedians_, printDebug_, rawDataTag_, and writeDQMStore_.
: rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>("RawDataTag",edm::InputTag("source",""))), folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName","SiStrip/ReadoutView/CMMonitoring")), fedIdVec_(iConfig.getUntrackedParameter<std::vector<unsigned int> >("FedIdVec")), fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms",false)), fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber",false)), fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithLocalEventNumber",false)), printDebug_(iConfig.getUntrackedParameter<unsigned int>("PrintDebugMessages",1)), writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)), dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>("DQMStoreFileName","DQMStore.root")), dqm_(0), cablingCacheId_(0) { //print config to debug log std::ostringstream debugStream; if (printDebug_>1) { debugStream << "[SiStripCMMonitorPlugin]Configuration for SiStripCMMonitorPlugin: " << std::endl << "[SiStripCMMonitorPlugin]\tRawDataTag: " << rawDataTag_ << std::endl << "[SiStripCMMonitorPlugin]\tHistogramFolderName: " << folderName_ << std::endl << "[SiStripCMMonitorPlugin]\tFillAllDetailedHistograms? " << (fillAllDetailedHistograms_ ? "yes" : "no") << std::endl << "[SiStripCMMonitorPlugin]\tFillWithEventNumber?" << (fillWithEvtNum_ ? "yes" : "no") << std::endl << "[SiStripCMMonitorPlugin]\tPrintDebugMessages? " << (printDebug_ ? "yes" : "no") << std::endl << "[SiStripCMMonitorPlugin]\tWriteDQMStore? " << (writeDQMStore_ ? "yes" : "no") << std::endl; if (writeDQMStore_) debugStream << "[SiStripCMMonitorPlugin]\tDQMStoreFileName: " << dqmStoreFileName_ << std::endl; } std::ostringstream* pDebugStream = (printDebug_>1 ? &debugStream : NULL); cmHists_.initialise(iConfig,pDebugStream); doTkHistoMap_ = cmHists_.tkHistoMapEnabled(); CommonModes_.clear(); CommonModesAPV0minusAPV1_.clear(); for (unsigned int fedId(FEDNumbering::MINSiStripFEDID); fedId <= FEDNumbering::MAXSiStripFEDID; fedId++){ for (unsigned int iCh(0); iCh<sistrip::FEDCH_PER_FED; iCh++){ prevMedians_[fedId][iCh] = std::pair<uint16_t,uint16_t>(0,0); } } if (printDebug_) { LogTrace("SiStripMonitorHardware") << debugStream.str(); } evt_ = 0; }
SiStripCMMonitorPlugin::~SiStripCMMonitorPlugin | ( | ) |
Definition at line 179 of file SiStripCMMonitor.cc.
{ }
void SiStripCMMonitorPlugin::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 190 of file SiStripCMMonitor.cc.
References cabling_, cmHists_, sistrip::FEDChannel::cmMedian(), SiStripFedCabling::connection(), gather_cfg::cout, FEDRawData::data(), FedChannelConnection::detId(), edm::EventID::event(), evt_, sistrip::FEDCH_PER_FED, FEDRawDataCollection::FEDData(), fillMaps(), fillWithEvtNum_, fillWithLocalEvtNum_, edm::Event::getByLabel(), edm::EventBase::id(), sistrip::invalid32_, FedChannelConnection::isConnected(), sistrip::FEDChannel::length(), FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, FedChannelConnection::nApvPairs(), edm::EventBase::orbitNumber(), prevMedians_, printDebug_, rawDataTag_, FEDRawData::size(), updateCabling(), and makeHLTPrescaleTable::values.
{ //static bool firstEvent = true; //static bool isBeingFilled = false; //update cabling updateCabling(iSetup); //get raw data edm::Handle<FEDRawDataCollection> rawDataCollectionHandle; iEvent.getByLabel(rawDataTag_,rawDataCollectionHandle); const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle; //FED errors FEDErrors lFedErrors; //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 lFedErrors.initialiseFED(fedId,cabling_); //Do detailed check //first check if data exists bool lDataExist = lFedErrors.checkDataPresent(fedData); if (!lDataExist) { continue; } std::auto_ptr<const sistrip::FEDBuffer> buffer; if (!lFedErrors.fillFatalFEDErrors(fedData,0)) { continue; } else { //need to construct full object to go any further buffer.reset(new sistrip::FEDBuffer(fedData.data(),fedData.size(),true)); bool channelLengthsOK = buffer->checkChannelLengthsMatchBufferLength(); bool channelPacketCodesOK = buffer->checkChannelPacketCodes(); bool feLengthsOK = buffer->checkFEUnitLengths(); if ( !channelLengthsOK || !channelPacketCodesOK || !feLengthsOK ) { continue; } } std::ostringstream infoStream; if (printDebug_ > 1) { infoStream << " --- Processing FED #" << fedId << std::endl; } std::vector<CMHistograms::CMvalues> values; for (unsigned int iCh = 0; iCh < sistrip::FEDCH_PER_FED; iCh++) {//loop on channels const FedChannelConnection & lConnection = cabling_->connection(fedId,iCh); bool connected = lConnection.isConnected(); //std::cout << "FedID " << fedId << ", ch " << iCh << ", nAPVPairs " << lConnection.nApvPairs() << " apvPairNumber " << lConnection.apvPairNumber() << std::endl; if (!connected) { continue; } uint32_t lDetId = lConnection.detId(); unsigned short nChInModule = lConnection.nApvPairs(); if (!lDetId || lDetId == sistrip::invalid32_) continue; bool lFailUnpackerChannelCheck = !buffer->channelGood(iCh) && connected; if (lFailUnpackerChannelCheck) { continue; } //short lAPVPair = lConnection.apvPairNumber(); //short lSubDet = DetId(lDetId).subdetId(); // if (firstEvent){ // infoStream << "Subdet " << lSubDet << ", " ; // if (lSubDet == 3) { // TIBDetId lId(lDetId); // infoStream << "TIB layer " << lId.layer() << ", fedID " << fedId << ", channel " << iCh << std::endl; // } // else if (lSubDet == 4) { // TIDDetId lId(lDetId); // infoStream << "TID side " << lId.side() << " wheel " << lId.wheel() << ", ring " << lId.ring() << ", fedID " << fedId << ", channel " << iCh << std::endl; // } // else if (lSubDet == 5) { // TOBDetId lId(lDetId); // infoStream << "TOB side " << lId.rod()[0] << " layer " << lId.layer() << ", rod " << lId.rodNumber() << ", fedID " << fedId << ", channel " << iCh << std::endl; // } // else if (lSubDet == 6) { // TECDetId lId(lDetId); // infoStream << "TEC side " << lId.side() << " wheel " << lId.wheel() << ", petal " << lId.petalNumber() << ", ring " << lId.ring() << ", fedID " << fedId << ", channel " << iCh << std::endl; // } // isBeingFilled=true; // } std::ostringstream lMode; lMode << buffer->readoutMode(); if (printDebug_ > 1) { static bool lFirst = true; if (lFirst) { std::cout << "Readout mode: " << lMode.str() << std::endl; lFirst = false; } } const sistrip::FEDChannel & lChannel = buffer->channel(iCh); std::pair<uint16_t,uint16_t> medians = std::pair<uint16_t,uint16_t>(0,0); if (lMode.str().find("Zero suppressed") != lMode.str().npos && lMode.str().find("lite") == lMode.str().npos) medians = std::pair<uint16_t,uint16_t>(lChannel.cmMedian(0),lChannel.cmMedian(1)); CMHistograms::CMvalues lVal; lVal.ChannelID = iCh; lVal.Medians = std::pair<uint16_t,uint16_t>(medians.first,medians.second); lVal.PreviousMedians = prevMedians_[fedId][iCh]; // if (medians.second-medians.first > 26){ // std::ostringstream info; // if (medians.second-medians.first > 44) info << " --- Second bump: event " << iEvent.id().event() << ", FED/Channel " << fedId << "/" << iCh << ", delta=" << medians.second-medians.first << std::endl; // else info << " --- First bump: event " << iEvent.id().event() << ", FED/Channel " << fedId << "/" << iCh << ", delta=" << medians.second-medians.first << std::endl; // edm::LogVerbatim("SiStripMonitorHardware") << info.str(); // } if (printDebug_ > 1) { if (lChannel.length() > 7) { infoStream << "Medians for channel #" << iCh << " (length " << lChannel.length() << "): " << medians.first << ", " << medians.second << std::endl; } } values.push_back(lVal); //if (iEvent.id().event() > 1000) fillMaps(lDetId,nChInModule,medians); prevMedians_[fedId][iCh] = std::pair<uint16_t,uint16_t>(medians.first,medians.second); }//loop on channels float lTime = 0; if (fillWithEvtNum_) lTime = iEvent.id().event(); else if (fillWithLocalEvtNum_) lTime = evt_;//iEvent.id().event(); else lTime = iEvent.orbitNumber()/11223.; cmHists_.fillHistograms(values,lTime,fedId); //if (printDebug_ > 0 && isBeingFilled && firstEvent) edm::LogVerbatim("SiStripMonitorHardware") << infoStream.str(); }//loop on FEDs //if (isBeingFilled) //firstEvent = false; evt_++; }//analyze method
void SiStripCMMonitorPlugin::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 366 of file SiStripCMMonitor.cc.
References cmHists_, dqm_, fillAllDetailedHistograms_, folderName_, and DQMStore::setCurrentFolder().
{ //get DQM store dqm_ = &(*edm::Service<DQMStore>()); dqm_->setCurrentFolder(folderName_); cmHists_.bookTopLevelHistograms(dqm_); if (fillAllDetailedHistograms_) cmHists_.bookAllFEDHistograms(); }
void SiStripCMMonitorPlugin::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 380 of file SiStripCMMonitor.cc.
References cmHists_, CommonModes_, CommonModesAPV0minusAPV1_, SiStripCMMonitorPlugin::Statistics::Counter, cond::rpcobgas::detid, doTkHistoMap_, dqm_, dqmStoreFileName_, SiStripCMMonitorPlugin::Statistics::Mean, timingPdfMaker::mean, python::rootplot::argparse::message, printDebug_, plotscripts::rms(), SiStripCMMonitorPlugin::Statistics::Rms, DQMStore::save(), mathSSE::sqrt(), and writeDQMStore_.
{ if (doTkHistoMap_) {//if TkHistoMap is enabled std::map<unsigned int,Statistics>::iterator fracIter; //int ele = 0; //int nBadChannels = 0; for (fracIter = CommonModes_.begin(); fracIter!=CommonModes_.end(); fracIter++){ uint32_t detid = fracIter->first; //if ((fracIter->second).second != 0) { //std::cout << "------ ele #" << ele << ", Frac for detid #" << detid << " = " <<(fracIter->second).second << "/" << (fracIter->second).first << std::endl; //nBadChannels++; //} float mean = 0; float rms = 0; Statistics lStat = fracIter->second; if (lStat.Counter > 0) mean = lStat.Mean/lStat.Counter; if (lStat.Counter > 1) rms = sqrt(lStat.Rms/(lStat.Counter-1)-(mean*mean)); cmHists_.fillTkHistoMap(cmHists_.tkHistoMapPointer(0),detid,mean); cmHists_.fillTkHistoMap(cmHists_.tkHistoMapPointer(1),detid,rms); if (printDebug_ > 1) { std::ostringstream message; message << "TkHistoMap CM: Detid " << detid << ", mean = " << mean << ", rms = " << rms << ", counter = " << lStat.Counter << std::endl; edm::LogVerbatim("SiStripMonitorHardware") << message.str(); } //ele++; } for (fracIter = CommonModesAPV0minusAPV1_.begin(); fracIter!=CommonModesAPV0minusAPV1_.end(); fracIter++){ uint32_t detid = fracIter->first; //if ((fracIter->second).second != 0) { //std::cout << "------ ele #" << ele << ", Frac for detid #" << detid << " = " <<(fracIter->second).second << "/" << (fracIter->second).first << std::endl; //nBadChannels++; //} float mean = 0; float rms = 0; Statistics lStat = fracIter->second; if (lStat.Counter > 0) mean = lStat.Mean/lStat.Counter; if (lStat.Counter > 1) rms = sqrt(lStat.Rms/(lStat.Counter-1)-(mean*mean)); cmHists_.fillTkHistoMap(cmHists_.tkHistoMapPointer(2),detid,mean); cmHists_.fillTkHistoMap(cmHists_.tkHistoMapPointer(3),detid,rms); if (printDebug_ > 1) { std::ostringstream message; message << "TkHistoMap APV0minusAPV1: Detid " << detid << ", mean = " << mean << ", rms = " << rms << ", counter = " << lStat.Counter << std::endl; edm::LogVerbatim("SiStripMonitorHardware") << message.str(); } //ele++; } }//if TkHistoMap is enabled if (writeDQMStore_) dqm_->save(dqmStoreFileName_); }
void SiStripCMMonitorPlugin::fillMaps | ( | uint32_t | aDetId, |
unsigned short | aChInModule, | ||
std::pair< uint16_t, uint16_t > | aMedians | ||
) | [private] |
Definition at line 451 of file SiStripCMMonitor.cc.
References CommonModes_, CommonModesAPV0minusAPV1_, SiStripCMMonitorPlugin::Statistics::Counter, doTkHistoMap_, SiStripCMMonitorPlugin::Statistics::Mean, SiStripCMMonitorPlugin::Statistics::Rms, and edm::second().
Referenced by analyze().
{ if (doTkHistoMap_){//if TkHistMap is enabled std::pair<std::map<unsigned int,Statistics>::iterator,bool> alreadyThere[2]; Statistics lStat; lStat.Mean = (aMedians.first+aMedians.second)*1./(2*aChInModule); lStat.Rms = (aMedians.first+aMedians.second)*(aMedians.first+aMedians.second)*1./(4*aChInModule); lStat.Counter = 1./aChInModule; alreadyThere[0] = CommonModes_.insert(std::pair<unsigned int,Statistics>(aDetId,lStat)); if (!alreadyThere[0].second) { ((alreadyThere[0].first)->second).Mean += (aMedians.first+aMedians.second)*1./(2*aChInModule); ((alreadyThere[0].first)->second).Rms += (aMedians.first+aMedians.second)*(aMedians.first+aMedians.second)*1./(4*aChInModule); ((alreadyThere[0].first)->second).Counter += 1./aChInModule; } lStat.Mean = (aMedians.first-aMedians.second)*1./aChInModule; lStat.Rms = (aMedians.first-aMedians.second)*(aMedians.first-aMedians.second)*1./aChInModule; lStat.Counter = 1./aChInModule; alreadyThere[1] = CommonModesAPV0minusAPV1_.insert(std::pair<unsigned int,Statistics>(aDetId,lStat)); if (!alreadyThere[1].second) { ((alreadyThere[1].first)->second).Mean += (aMedians.first-aMedians.second)*1./aChInModule; ((alreadyThere[1].first)->second).Rms += (aMedians.first-aMedians.second)*(aMedians.first-aMedians.second)*1./aChInModule; ((alreadyThere[1].first)->second).Counter += 1./aChInModule; } } }
void SiStripCMMonitorPlugin::updateCabling | ( | const edm::EventSetup & | eventSetup | ) | [private] |
Definition at line 439 of file SiStripCMMonitor.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* SiStripCMMonitorPlugin::cabling_ [private] |
Definition at line 107 of file SiStripCMMonitor.cc.
Referenced by analyze(), and updateCabling().
uint32_t SiStripCMMonitorPlugin::cablingCacheId_ [private] |
Definition at line 106 of file SiStripCMMonitor.cc.
Referenced by updateCabling().
CMHistograms SiStripCMMonitorPlugin::cmHists_ [private] |
Definition at line 112 of file SiStripCMMonitor.cc.
Referenced by analyze(), beginJob(), endJob(), and SiStripCMMonitorPlugin().
std::map<unsigned int,Statistics> SiStripCMMonitorPlugin::CommonModes_ [private] |
Definition at line 114 of file SiStripCMMonitor.cc.
Referenced by endJob(), fillMaps(), and SiStripCMMonitorPlugin().
std::map<unsigned int,Statistics> SiStripCMMonitorPlugin::CommonModesAPV0minusAPV1_ [private] |
Definition at line 115 of file SiStripCMMonitor.cc.
Referenced by endJob(), fillMaps(), and SiStripCMMonitorPlugin().
bool SiStripCMMonitorPlugin::doTkHistoMap_ [private] |
Definition at line 110 of file SiStripCMMonitor.cc.
Referenced by endJob(), fillMaps(), and SiStripCMMonitorPlugin().
DQMStore* SiStripCMMonitorPlugin::dqm_ [private] |
Definition at line 104 of file SiStripCMMonitor.cc.
Referenced by beginJob(), and endJob().
std::string SiStripCMMonitorPlugin::dqmStoreFileName_ [private] |
Definition at line 102 of file SiStripCMMonitor.cc.
Referenced by endJob(), and SiStripCMMonitorPlugin().
unsigned int SiStripCMMonitorPlugin::evt_ [private] |
Definition at line 119 of file SiStripCMMonitor.cc.
Referenced by analyze(), and SiStripCMMonitorPlugin().
std::vector<unsigned int> SiStripCMMonitorPlugin::fedIdVec_ [private] |
Definition at line 92 of file SiStripCMMonitor.cc.
bool SiStripCMMonitorPlugin::fillAllDetailedHistograms_ [private] |
Definition at line 94 of file SiStripCMMonitor.cc.
Referenced by beginJob(), and SiStripCMMonitorPlugin().
bool SiStripCMMonitorPlugin::fillWithEvtNum_ [private] |
Definition at line 96 of file SiStripCMMonitor.cc.
Referenced by analyze(), and SiStripCMMonitorPlugin().
bool SiStripCMMonitorPlugin::fillWithLocalEvtNum_ [private] |
Definition at line 97 of file SiStripCMMonitor.cc.
Referenced by analyze().
std::string SiStripCMMonitorPlugin::folderName_ [private] |
Definition at line 90 of file SiStripCMMonitor.cc.
Referenced by beginJob(), and SiStripCMMonitorPlugin().
std::pair<uint16_t,uint16_t> SiStripCMMonitorPlugin::prevMedians_[FEDNumbering::MAXSiStripFEDID+1][sistrip::FEDCH_PER_FED] [private] |
Definition at line 117 of file SiStripCMMonitor.cc.
Referenced by analyze(), and SiStripCMMonitorPlugin().
unsigned int SiStripCMMonitorPlugin::printDebug_ [private] |
Definition at line 99 of file SiStripCMMonitor.cc.
Referenced by analyze(), endJob(), and SiStripCMMonitorPlugin().
Definition at line 88 of file SiStripCMMonitor.cc.
Referenced by analyze(), and SiStripCMMonitorPlugin().
bool SiStripCMMonitorPlugin::writeDQMStore_ [private] |
Definition at line 101 of file SiStripCMMonitor.cc.
Referenced by endJob(), and SiStripCMMonitorPlugin().