CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/DQM/RPCMonitorClient/src/RPCDcsInfoClient.cc

Go to the documentation of this file.
00001 #include "DQM/RPCMonitorClient/interface/RPCDcsInfoClient.h"
00002 #include "FWCore/Framework/interface/LuminosityBlock.h"
00003 
00004 RPCDcsInfoClient::RPCDcsInfoClient( const edm::ParameterSet& ps ) {
00005 
00006   dbe_ = edm::Service<DQMStore>().operator->();
00007 
00008   dcsinfofolder_ = ps.getUntrackedParameter<std::string>("dcsInfoFolder", "RPC/DCSInfo") ;
00009 }
00010 
00011 
00012 RPCDcsInfoClient::~RPCDcsInfoClient() {}
00013 
00014 void RPCDcsInfoClient::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00015   DCS.clear();
00016   DCS.resize(10);  // start with 10 LS, resize later
00017 }
00018 
00019 void RPCDcsInfoClient::analyze(const edm::Event& e, const edm::EventSetup& c){}
00020 
00021 void RPCDcsInfoClient::endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c){
00022   if (!dbe_) return;
00023 
00024   unsigned int nlumi = l.id().luminosityBlock() ;
00025 
00026   if (nlumi+1 > DCS.size())   DCS.resize(nlumi+1);
00027 
00028 
00029   MonitorElement* DCSbyLS_ = dbe_->get(dcsinfofolder_ + "/DCSbyLS" ); 
00030 
00031   if ( !DCSbyLS_ ) return;
00032   
00033   if ( TH1F * h1 = DCSbyLS_->getTH1F()) {
00034     int hvStatus = 0;
00035    
00036     if ( h1->GetBinContent(1) != 0 ) {
00037       hvStatus = 0; // set to 0 because HV was off (!)
00038     } else  {
00039       hvStatus = 1;    // set to 1 because HV was on (!)
00040     }
00041 
00042     DCS[nlumi] = hvStatus;
00043   }
00044   
00045   return; 
00046 }
00047 
00048 void RPCDcsInfoClient::endRun(const edm::Run& r, const edm::EventSetup& c) {
00049 
00050   // book 
00051   dbe_->cd();  
00052   dbe_->setCurrentFolder(dcsinfofolder_ );
00053 
00054   unsigned int nlsmax = DCS.size();
00055   if (nlsmax > 900 ) nlsmax = 900;
00056    
00057   std::string meName = dcsinfofolder_ + "/rpcHVStatus";
00058   MonitorElement* rpcHVStatus = dbe_->get(meName);
00059   if (rpcHVStatus) dbe_->removeElement(rpcHVStatus->getName());
00060 
00061   rpcHVStatus = dbe_->book2D("rpcHVStatus","RPC HV Status", nlsmax, 1., nlsmax+1, 1, 0.5, 1.5);
00062   rpcHVStatus->setAxisTitle("Luminosity Section", 1);
00063   rpcHVStatus->setBinLabel(1,"",2);   
00064 
00065   int lsCounter = 0;
00066   // fill
00067   for (unsigned int i = 0 ; i < nlsmax ; i++ )  {
00068     rpcHVStatus->setBinContent(i+1,1,DCS[i]);
00069     lsCounter +=DCS[i];
00070   }
00071 
00072   meName = dcsinfofolder_ + "/rpcHV";
00073   MonitorElement* rpcHV = dbe_->get(meName);
00074   if (rpcHV) dbe_->removeElement(rpcHVStatus->getName());
00075   rpcHV = dbe_->bookInt("rpcHV");
00076 
00077   rpcHV ->Fill(lsCounter);
00078   
00079   return;
00080 }