CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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       rpcRawSynchroProdItemTag_(cfg.getParameter<edm::InputTag>("rpcRawSynchroProdItemTag"))
00034 { 
00035 }
00036 
00037 RPCMonitorLinkSynchro::~RPCMonitorLinkSynchro()
00038 { 
00039 }
00040 
00041 void RPCMonitorLinkSynchro::beginRun(const edm::Run&, const edm::EventSetup& es)
00042 {
00043   if (theCablingWatcher.check(es)) {
00044     edm::ESTransientHandle<RPCEMap> readoutMapping;
00045     es.get<RPCEMapRcd>().get(readoutMapping);
00046     RPCReadOutMapping * cabling = readoutMapping->convert();
00047     edm::LogInfo("RPCMonitorLinkSynchro") << "RPCMonitorLinkSynchro - record has CHANGED!!, read map, VERSION: " << cabling->version();
00048     theSynchroStat.init(cabling, theConfig.getUntrackedParameter<bool>("dumpDelays"));
00049     delete cabling;
00050   }
00051 }
00052 
00053 void RPCMonitorLinkSynchro::endLuminosityBlock(const edm::LuminosityBlock& ls, const edm::EventSetup& es)
00054 {
00055 
00056   RPCLinkSynchroHistoMaker hm(theSynchroStat);
00057   hm.fill(me_delaySummary->getTH1F(), me_delaySpread->getTH2F(), me_topOccup->getTH2F(), me_topSpread->getTH2F());
00058 }
00059 
00060 void RPCMonitorLinkSynchro::beginJob()
00061 {
00062   DQMStore* dmbe = edm::Service<DQMStore>().operator->();
00063   dmbe->setCurrentFolder("RPC/LinkMonitor/");
00064 
00065   me_delaySummary = dmbe->book1D("delaySummary","LinkDelaySummary",8,-3.5, 4.5);
00066   me_delaySummary->getTH1F()->SetStats(111);
00067 
00068   me_delaySpread = dmbe->book2D("delaySpread","LinkDelaySpread",71,-3.05, 4.05, 31,-0.05,3.05);
00069   me_delaySpread->getTH2F()->SetStats(0);
00070 
00071   me_notComplete[0] = dmbe->book2D("notComplete790","FED790: not All Paths hit",36,-0.5,35.5,18,-0.5,17.5);
00072   me_notComplete[1] = dmbe->book2D("notComplete791","FED791: not All Paths hit",36,-0.5,35.5,18,-0.5,17.5);
00073   me_notComplete[2] = dmbe->book2D("notComplete792","FED792: not All Paths hit",36,-0.5,35.5,18,-0.5,17.5);
00074   for (unsigned int i=0;i<3;++i) {
00075     me_notComplete[i]->getTH2F()->GetXaxis()->SetNdivisions(512);
00076     me_notComplete[i]->getTH2F()->GetYaxis()->SetNdivisions(505);
00077     me_notComplete[i]->getTH2F()->SetXTitle("rmb");
00078     me_notComplete[i]->getTH2F()->SetYTitle("link");
00079     me_notComplete[i]->getTH2F()->SetStats(0);
00080   }
00081   me_topOccup  = dmbe->book2D("topOccup","Top10 LinkBoard occupancy",8,-0.5,7.5, 10,0.,10.);
00082   me_topSpread = dmbe->book2D("topSpread","Top10 LinkBoard delay spread",8,-0.5,7.5, 10,0.,10.);
00083   me_topOccup->getTH2F()->GetXaxis()->SetNdivisions(110);
00084   me_topSpread->getTH2F()->GetXaxis()->SetNdivisions(110);
00085   me_topOccup->getTH2F()->SetStats(0);
00086   me_topSpread->getTH2F()->SetStats(0);
00087 
00088 }
00089 
00090 TObjArray RPCMonitorLinkSynchro::histos() const
00091 {
00092   TObjArray result;
00093   result.Add(me_delaySummary->getTH1F());
00094   result.Add(me_delaySpread->getTH2F());
00095   result.Add(me_topOccup->getTH2F());
00096   result.Add(me_topSpread->getTH2F());
00097   for (unsigned int i=0;i<=2;i++) result.Add(me_notComplete[i]->getTH2F());
00098   return result;
00099 }
00100 
00101 
00102 void RPCMonitorLinkSynchro::endJob()
00103 {
00104   if (theConfig.getUntrackedParameter<bool>("dumpDelays")) edm::LogInfo("RPCMonitorLinkSynchro DumpDelays") <<  theSynchroStat.dumpDelays();
00105 }
00106 
00107 void RPCMonitorLinkSynchro::analyze(const edm::Event& ev, const edm::EventSetup& es)
00108 {
00109   edm::Handle<RPCRawSynchro::ProdItem> synchroCounts;
00110   ev.getByLabel(rpcRawSynchroProdItemTag_, synchroCounts);
00111   std::vector<LinkBoardElectronicIndex> problems;
00112   const RPCRawSynchro::ProdItem &vItem = select(*synchroCounts.product(), ev,es);
00113   theSynchroStat.add(vItem, problems);
00114 
00115   for (std::vector<LinkBoardElectronicIndex>::const_iterator it=problems.begin(); it != problems.end(); ++it) {
00116     me_notComplete[it->dccId-790]->Fill(it->dccInputChannelNum,it->tbLinkInputNum);    
00117   }
00118 }