CMS 3D CMS Logo

RPCFEDIntegrity.cc

Go to the documentation of this file.
00001 /*  \author Anna Cimmino*/
00002 #include <DQM/RPCMonitorClient/interface/RPCFEDIntegrity.h>
00003 
00004 // Framework
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include <FWCore/Framework/interface/LuminosityBlock.h>
00007 #include <FWCore/Framework/interface/Event.h>
00008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00009 //DQM Services
00010 #include "DQMServices/Core/interface/DQMStore.h"
00011 #include "DQMServices/Core/interface/MonitorElement.h"
00012 
00013 //EventFilter
00014 #include "EventFilter/RPCRawToDigi/interface/RPCRawDataCounts.h"
00015 #include "EventFilter/RPCRawToDigi/interface/DataRecord.h"
00016 
00017 using namespace edm;
00018 using namespace std;
00019 RPCFEDIntegrity::RPCFEDIntegrity(const ParameterSet& ps ) {
00020   LogVerbatim ("rpceventsummary") << "[RPCFEDIntegrity]: Constructor";
00021 
00022   prefixDir_ = ps.getUntrackedParameter<string>("RPCPrefixDir", "RPC");
00023   merge_ = ps.getUntrackedParameter<bool>("MergeRuns", false);
00024   numOfFED_ =  ps.getUntrackedParameter<int>("NumberOfFED", 3);
00025   minFEDNum_ =  ps.getUntrackedParameter<int>("MinimumFEDID", 790);
00026   maxFEDNum_ =  ps.getUntrackedParameter<int>("MaximumFEDID", 792);
00027 
00028   histoName_.push_back("FEDEntries");
00029   histoName_.push_back("FEDFatal");
00030   histoName_.push_back("FEDNonFatal");
00031   
00032   FATAL_LIMIT = 5;
00033 
00034   init_ = false;
00035 }
00036 
00037 RPCFEDIntegrity::~RPCFEDIntegrity(){
00038   LogVerbatim ("rpceventsummary") << "[RPCFEDIntegrity]: Destructor ";
00039   //  dbe_=0;
00040 }
00041 
00042 void RPCFEDIntegrity::beginJob(const EventSetup& iSetup){
00043  LogVerbatim ("rpceventsummary") << "[RPCFEDIntegrity]: Begin job ";
00044  dbe_ = Service<DQMStore>().operator->();
00045 }
00046 
00047 void RPCFEDIntegrity::beginRun(const Run& r, const EventSetup& c){
00048  LogVerbatim ("rpceventsummary") << "[RPCFEDIntegrity]: Begin run ";
00049 
00050  if (!init_) this->bookFEDMe();
00051  else if (!merge_) this->reset();
00052 }
00053 
00054 void RPCFEDIntegrity::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context){} 
00055 
00056 void RPCFEDIntegrity::analyze(const Event& iEvent, const EventSetup& c) {
00057 
00058   //get hold of raw data counts
00059   Handle<RPCRawDataCounts> rawCounts;
00060   iEvent.getByType( rawCounts);
00061 
00062   const RPCRawDataCounts * aCounts = rawCounts.product();
00063   //  const RPCRawDataCounts * theCounts += *aCounts;
00064 
00065   vector<double> v1;
00066   map<int,double> fedOccupancy;
00067 
00068   MonitorElement * me;
00069 
00070   //loop  on all FEDS
00071   for (int fedId=minFEDNum_ ;fedId<maxFEDNum_+1;fedId++) {
00072     v1.clear();
00073     aCounts->recordTypeVector(fedId,v1); 
00074 
00075     if(fedOccupancy.find(fedId)== fedOccupancy.end() || fedOccupancy.size()==0) fedOccupancy[fedId]=0;
00076     
00077     //loop on errors
00078     for (unsigned int err = 1 ; err<v1.size(); err +=2){//get onlz even elements of the vector
00079        fedOccupancy[fedId] += v1[err];
00080 
00081       if(err-1!=0 && err-1 <= FATAL_LIMIT){
00082         me= dbe_->get(prefixDir_+"/FEDIntegrity/FEDFatal");
00083         me ->Fill(fedId,v1[err]);
00084       }
00085       else if (err-1!=0){
00086         me= dbe_->get(prefixDir_+"/FEDIntegrity/FEDNonFatal");
00087         me ->Fill(fedId,v1[err]);
00088       }
00089 
00090     }//end loop o errors
00091 
00092       me = dbe_->get(prefixDir_+"/FEDIntegrity/FEDEntries");
00093 
00094       if(me!=0) me->Fill(fedId, fedOccupancy[fedId] );
00095   }//end loop on all FEDs
00096 }
00097 
00098 void RPCFEDIntegrity::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& iSetup) {}
00099 
00100 void RPCFEDIntegrity::endRun(const Run& r, const EventSetup& c){}
00101 
00102 void RPCFEDIntegrity::endJob(){
00103   dbe_=0;
00104 }
00105 
00106 //Fill report summary
00107 void  RPCFEDIntegrity::bookFEDMe(void){
00108 
00109   if(dbe_){
00110     dbe_->setCurrentFolder(prefixDir_+"/FEDIntegrity/");
00111    
00112     for(unsigned int i = 0; i<histoName_.size(); i++){
00113      dbe_->book1D(histoName_[i].c_str(),histoName_[i].c_str(),numOfFED_, minFEDNum_, maxFEDNum_ +1);
00114     }
00115   }
00116 
00117   init_ = true;
00118 }
00119 
00120 void  RPCFEDIntegrity::reset(void){
00121 
00122   MonitorElement * me;  
00123 
00124   if(dbe_){
00125     for(unsigned int i = 0; i<histoName_.size(); i++){
00126       if( me = dbe_->get(prefixDir_ +"FEDIntegrity/"+ histoName_[i]) )  me->Reset();
00127     }
00128   }
00129 }

Generated on Tue Jun 9 17:33:17 2009 for CMSSW by  doxygen 1.5.4