CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/DQM/RPCMonitorClient/src/RPCMonitorLinkSynchro.cc

Go to the documentation of this file.
00001 #include "DQM/RPCMonitorClient/interface/RPCMonitorLinkSynchro.h"
00002 #include "FWCore/Utilities/interface/InputTag.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 #include "DQMServices/Core/interface/DQMStore.h"
00007 
00008 #include "DataFormats/Common/interface/Handle.h"
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/Framework/interface/ESTransientHandle.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/Framework/interface/ESWatcher.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "CondFormats/RPCObjects/interface/RPCEMap.h"
00016 #include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
00017 #include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
00018 
00019 #include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
00020 
00021 #include "DQM/RPCMonitorClient/interface/RPCLinkSynchroHistoMaker.h"
00022 #include "TH1F.h"
00023 #include "TH2F.h"
00024 #include "TFile.h"
00025 
00026 //#include "UserCode/konec/test/R2DTimerObserver.h"
00027 
00028 
00029 
00030 RPCMonitorLinkSynchro::RPCMonitorLinkSynchro( const edm::ParameterSet& cfg) 
00031     : theConfig(cfg),
00032       theSynchroStat(RPCLinkSynchroStat(theConfig.getUntrackedParameter<bool>("useFirstHitOnly", false))) 
00033 { 
00034 }
00035 
00036 RPCMonitorLinkSynchro::~RPCMonitorLinkSynchro()
00037 { 
00038 }
00039 
00040 void RPCMonitorLinkSynchro::beginRun(const edm::Run&, const edm::EventSetup& es)
00041 {
00042   if (theCablingWatcher.check(es)) {
00043     edm::ESTransientHandle<RPCEMap> readoutMapping;
00044     es.get<RPCEMapRcd>().get(readoutMapping);
00045     RPCReadOutMapping * cabling = readoutMapping->convert();
00046     edm::LogInfo("RPCMonitorLinkSynchro") << "RPCMonitorLinkSynchro - record has CHANGED!!, read map, VERSION: " << cabling->version();
00047     theSynchroStat.init(cabling, theConfig.getUntrackedParameter<bool>("dumpDelays"));
00048     delete cabling;
00049   }
00050 }
00051 
00052 void RPCMonitorLinkSynchro::endLuminosityBlock(const edm::LuminosityBlock& ls, const edm::EventSetup& es)
00053 {
00054 
00055   RPCLinkSynchroHistoMaker hm(theSynchroStat);
00056   hm.fill(me_delaySummary->getTH1F(), me_delaySpread->getTH2F(), me_topOccup->getTH2F(), me_topSpread->getTH2F());
00057 }
00058 
00059 void RPCMonitorLinkSynchro::beginJob()
00060 {
00061   DQMStore* dmbe = edm::Service<DQMStore>().operator->();
00062   dmbe->setCurrentFolder("RPC/LinkMonitor/");
00063 
00064   me_delaySummary = dmbe->book1D("delaySummary","LinkDelaySummary",8,-3.5, 4.5);
00065   me_delaySummary->getTH1F()->SetStats(111);
00066 
00067   me_delaySpread = dmbe->book2D("delaySpread","LinkDelaySpread",71,-3.05, 4.05, 31,-0.05,3.05);
00068   me_delaySpread->getTH2F()->SetStats(0);
00069 
00070   me_notComplete[0] = dmbe->book2D("notComplete790","FED790: not All Paths hit",36,-0.5,35.5,18,-0.5,17.5);
00071   me_notComplete[1] = dmbe->book2D("notComplete791","FED791: not All Paths hit",36,-0.5,35.5,18,-0.5,17.5);
00072   me_notComplete[2] = dmbe->book2D("notComplete792","FED792: not All Paths hit",36,-0.5,35.5,18,-0.5,17.5);
00073   for (unsigned int i=0;i<3;++i) {
00074     me_notComplete[i]->getTH2F()->GetXaxis()->SetNdivisions(512);
00075     me_notComplete[i]->getTH2F()->GetYaxis()->SetNdivisions(505);
00076     me_notComplete[i]->getTH2F()->SetXTitle("rmb");
00077     me_notComplete[i]->getTH2F()->SetYTitle("link");
00078     me_notComplete[i]->getTH2F()->SetStats(0);
00079   }
00080   me_topOccup  = dmbe->book2D("topOccup","Top10 LinkBoard occupancy",8,-0.5,7.5, 10,0.,10.);
00081   me_topSpread = dmbe->book2D("topSpread","Top10 LinkBoard delay spread",8,-0.5,7.5, 10,0.,10.);
00082   me_topOccup->getTH2F()->GetXaxis()->SetNdivisions(110);
00083   me_topSpread->getTH2F()->GetXaxis()->SetNdivisions(110);
00084   me_topOccup->getTH2F()->SetStats(0);
00085   me_topSpread->getTH2F()->SetStats(0);
00086 
00087 }
00088 
00089 TObjArray RPCMonitorLinkSynchro::histos() const
00090 {
00091   TObjArray result;
00092   result.Add(me_delaySummary->getTH1F());
00093   result.Add(me_delaySpread->getTH2F());
00094   result.Add(me_topOccup->getTH2F());
00095   result.Add(me_topSpread->getTH2F());
00096   for (unsigned int i=0;i<=2;i++) result.Add(me_notComplete[i]->getTH2F());
00097   return result;
00098 }
00099 
00100 
00101 void RPCMonitorLinkSynchro::endJob()
00102 {
00103   if (theConfig.getUntrackedParameter<bool>("dumpDelays")) edm::LogInfo("RPCMonitorLinkSynchro DumpDelays") <<  theSynchroStat.dumpDelays();
00104 }
00105 
00106 void RPCMonitorLinkSynchro::analyze(const edm::Event& ev, const edm::EventSetup& es)
00107 {
00108   edm::Handle<RPCRawSynchro::ProdItem> synchroCounts;
00109   ev.getByType(synchroCounts);
00110   std::vector<LinkBoardElectronicIndex> problems;
00111   const RPCRawSynchro::ProdItem &vItem = select(*synchroCounts.product(), ev,es);
00112   theSynchroStat.add(vItem, problems);
00113 
00114   for (std::vector<LinkBoardElectronicIndex>::const_iterator it=problems.begin(); it != problems.end(); ++it) {
00115     me_notComplete[it->dccId-790]->Fill(it->dccInputChannelNum,it->tbLinkInputNum);    
00116   }
00117 }