CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DQM/RPCMonitorClient/src/RPCFEDIntegrity.cc

Go to the documentation of this file.
00001 /*  \author Anna Cimmino*/
00002 #include <algorithm>
00003 #include <DQM/RPCMonitorClient/interface/RPCFEDIntegrity.h>
00004 #include <DQM/RPCMonitorClient/interface/RPCRawDataCountsHistoMaker.h>
00005 // Framework
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include <FWCore/Framework/interface/LuminosityBlock.h>
00008 #include <FWCore/Framework/interface/Event.h>
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 //DQM Services
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include "DQMServices/Core/interface/MonitorElement.h"
00013 
00014 //EventFilter
00015 #include "EventFilter/RPCRawToDigi/interface/RPCRawDataCounts.h"
00016 #include "EventFilter/RPCRawToDigi/interface/DataRecord.h"
00017 #include "EventFilter/RPCRawToDigi/interface/ReadoutError.h"
00018 
00019 typedef std::map<std::pair<int, int>, int >::const_iterator IT;
00020 
00021 RPCFEDIntegrity::RPCFEDIntegrity(const edm::ParameterSet& ps ) {
00022   edm::LogVerbatim ("rpcfedintegrity") << "[RPCFEDIntegrity]: Constructor";
00023 
00024   rawCountsLabel_ = ps.getUntrackedParameter<edm::InputTag>("RPCRawCountsInputTag");
00025   prefixDir_ = ps.getUntrackedParameter<std::string>("RPCPrefixDir", "RPC/FEDIntegrity");
00026   merge_ = ps.getUntrackedParameter<bool>("MergeRuns", false);
00027   minFEDNum_ =  ps.getUntrackedParameter<int>("MinimumFEDID", 790);
00028   maxFEDNum_ =  ps.getUntrackedParameter<int>("MaximumFEDID", 792);
00029 
00030   init_ = false;
00031   numOfFED_=   maxFEDNum_ -  minFEDNum_ + 1;
00032   FATAL_LIMIT = 5;
00033 }
00034 
00035 RPCFEDIntegrity::~RPCFEDIntegrity(){
00036   edm::LogVerbatim ("rpcfedintegrity") << "[RPCFEDIntegrity]: Destructor ";
00037   //  dbe_=0;
00038 }
00039 
00040 void RPCFEDIntegrity::beginJob(){
00041   edm::LogVerbatim ("rpcfedintegrity") << "[RPCFEDIntegrity]: Begin job ";
00042   dbe_ = edm::Service<DQMStore>().operator->();
00043 }
00044 
00045 void RPCFEDIntegrity::beginRun(const edm::Run& r, const edm::EventSetup& c){
00046   edm::LogVerbatim ("rpcfedintegrity") << "[RPCFEDIntegrity]: Begin run ";
00047 
00048  if (!init_) this->bookFEDMe();
00049  else if (!merge_) this->reset();
00050 
00051 }
00052 
00053 void RPCFEDIntegrity::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context){} 
00054 
00055 void RPCFEDIntegrity::analyze(const edm::Event& iEvent, const edm::EventSetup& c) {
00056   
00057   //get hold of raw data counts
00058   edm::Handle<RPCRawDataCounts> rawCounts;
00059   iEvent.getByLabel (rawCountsLabel_, rawCounts);
00060   if(!rawCounts.isValid()) return;
00061 
00062 
00063   const RPCRawDataCounts  & counts = *rawCounts.product();
00064  
00065   for (int fed=minFEDNum_; fed <=maxFEDNum_; ++fed) {
00066     if (counts.fedBxRecords(fed) ) fedMe_[Entries]->Fill(fed);
00067     if (counts.fedFormatErrors(fed)) fedMe_[Fatal]->Fill(fed);
00068     if (counts.fedErrorRecords(fed)) fedMe_[NonFatal]->Fill(fed);
00069   }
00070 }
00071 
00072 void RPCFEDIntegrity::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {}
00073 
00074 void RPCFEDIntegrity::endRun(const edm::Run& r, const edm::EventSetup& c){}
00075 
00076 void RPCFEDIntegrity::endJob(){
00077   dbe_=0;
00078 }
00079 
00080 //Fill report summary
00081 void  RPCFEDIntegrity::bookFEDMe(void){
00082 
00083   if(dbe_){
00084     dbe_->setCurrentFolder(prefixDir_);
00085 
00086     fedMe_[Entries] =  dbe_->book1D("FEDEntries","FED Entries",numOfFED_, minFEDNum_, maxFEDNum_ +1);
00087     this->labelBins(fedMe_[Entries]);
00088     fedMe_[Fatal] =  dbe_->book1D("FEDFatal","FED Fatal Errors",numOfFED_, minFEDNum_, maxFEDNum_ +1);
00089     this->labelBins(fedMe_[Fatal]);
00090     fedMe_[NonFatal] =  dbe_->book1D("FEDNonFatal","FED NON Fatal Errors",numOfFED_, minFEDNum_, maxFEDNum_ +1);
00091    this->labelBins(fedMe_[NonFatal]);
00092   }
00093 
00094   init_ = true;
00095 }
00096 
00097 void RPCFEDIntegrity::labelBins( MonitorElement * myMe){
00098 
00099   int xbins = myMe->getNbinsX();
00100   
00101   if (xbins!= numOfFED_ ) return;
00102   std::stringstream xLabel;
00103 
00104   for (int i = 0; i<xbins; i++){
00105     xLabel.str("");
00106     int fedNum =  minFEDNum_ + i;
00107     xLabel<<fedNum;
00108     myMe->setBinLabel(i+1, xLabel.str(),1);    
00109   }
00110 }
00111 
00112 
00113 void  RPCFEDIntegrity::reset(void){
00114 
00115   MonitorElement * me;  
00116 
00117   if(dbe_){
00118     for(unsigned int i = 0; i<histoName_.size(); i++){
00119       me = 0;
00120       me = dbe_->get(prefixDir_ + histoName_[i]);
00121       if(0!=me ) me->Reset();
00122     }
00123   }
00124 }