Go to the documentation of this file.00001 #include "DQM/RPCMonitorClient/interface/RPCMonitorRaw.h"
00002
00003
00004 #include "DQMServices/Core/interface/DQMStore.h"
00005 #include "DQMServices/Core/interface/MonitorElement.h"
00006 #include "FWCore/ServiceRegistry/interface/Service.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012
00013 #include "CondFormats/RPCObjects/interface/LinkBoardElectronicIndex.h"
00014 #include "DataFormats/RPCDigi/interface/RPCRawDataCounts.h"
00015 #include "DataFormats/RPCDigi/interface/ReadoutError.h"
00016 #include "DQM/RPCMonitorClient/interface/RPCRawDataCountsHistoMaker.h"
00017
00018 #include "TH1F.h"
00019 #include "TH2F.h"
00020 #include "TFile.h"
00021
00022 #include <fstream>
00023 #include <iostream>
00024 #include <iomanip>
00025 #include <bitset>
00026
00027 typedef std::map< std::pair<int,int>, int>::const_iterator IT;
00028
00029 RPCMonitorRaw::RPCMonitorRaw(const edm::ParameterSet& cfg)
00030 : theConfig(cfg),
00031 rpcRawDataCountsTag_(cfg.getParameter<edm::InputTag>("rpcRawDataCountsTag"))
00032 {
00033 for (unsigned int i=0; i<10;i++) theWatchedErrorHistoPos[i]=0;
00034 std::vector<int> algos = cfg.getUntrackedParameter<std::vector<int> >("watchedErrors");
00035 for (std::vector<int>::const_iterator it=algos.begin();it!= algos.end(); ++it) {
00036 unsigned int ialgo = *it;
00037 if (ialgo < 10) theWatchedErrorHistoPos[ialgo]=1;
00038 }
00039 }
00040
00041 RPCMonitorRaw::~RPCMonitorRaw() { LogTrace("") << "RPCMonitorRaw destructor"; }
00042
00043 void RPCMonitorRaw::beginJob()
00044 {
00045
00046
00047 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00048
00049 theDMBE->setCurrentFolder("RPC/LinkMonitor");
00050
00051 me_t[0]=theDMBE->book1D("recordType_790",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(790));
00052 me_t[1]=theDMBE->book1D("recordType_791",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(791));
00053 me_t[2]=theDMBE->book1D("recordType_792",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(792));
00054 for (int i=0;i<3;++i)me_t[i]->getTH1F()->SetStats(0);
00055
00056 me_e[0]=theDMBE->book1D("readoutErrors_790",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(790));
00057 me_e[1]=theDMBE->book1D("readoutErrors_791",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(791));
00058 me_e[2]=theDMBE->book1D("readoutErrors_792",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(792));
00059 for (int i=0;i<3;++i)me_e[i]->getTH1F()->SetStats(0);
00060
00061 me_mapGoodEvents=theDMBE->book2D("mapGoodRecords","mapGoodRecords",36,-0.5,35.5, 3, 789.5,792.5);
00062 me_mapGoodEvents->getTH2F()->SetNdivisions(3,"y");
00063 me_mapGoodEvents->getTH2F()->SetXTitle("rmb");
00064 me_mapGoodEvents->getTH2F()->SetYTitle("fed");
00065 me_mapGoodEvents->getTH2F()->SetStats(0);
00066 me_mapBadEvents =theDMBE->book2D("mapErrorRecords", "mapErrorRecords", 36,-0.5,35.5, 3, 789.5,792.5);
00067 me_mapBadEvents->getTH2F()->SetXTitle("fed");
00068 me_mapBadEvents->getTH2F()->SetYTitle("rmb");
00069 me_mapBadEvents->getTH2F()->SetNdivisions(3,"y");
00070 me_mapBadEvents->getTH2F()->SetStats(0);
00071
00072 for (unsigned int i=0; i<=9; ++i) {
00073 if (theWatchedErrorHistoPos[i]) {
00074 for (unsigned int fed=790; fed <=792; ++fed) {
00075 TH2F * histo = RPCRawDataCountsHistoMaker::emptyReadoutErrorMapHisto(fed,i);
00076 MonitorElement* watched = theDMBE->book2D(histo->GetName(),histo);
00077 theWatchedErrorHistos[fed-790].push_back(watched);
00078 theWatchedErrorHistoPos[i] = theWatchedErrorHistos[fed-790].size();
00079 }
00080 }
00081 }
00082
00083 }
00084 void RPCMonitorRaw::endJob()
00085 {
00086 bool writeHistos = theConfig.getUntrackedParameter<bool>("writeHistograms", false);
00087 if (writeHistos) {
00088 std::string histoFile = theConfig.getUntrackedParameter<std::string>("histoFileName");
00089 TFile f(histoFile.c_str(),"RECREATE");
00090 for (int i=0; i<3; ++i) {
00091 me_t[i]->getTH1F()->Write();
00092 me_e[i]->getTH1F()->Write();
00093 std::vector<MonitorElement* > & wh = theWatchedErrorHistos[i];
00094 for (std::vector<MonitorElement* >::const_iterator it=wh.begin(); it != wh.end(); ++it)(*it)->getTH2F()->Write();
00095 }
00096 me_mapGoodEvents->getTH2F()->Write();
00097 me_mapBadEvents->getTH2F()->Write();
00098 edm::LogInfo(" END JOB, histos saved!");
00099 f.Close();
00100 }
00101 }
00102
00103
00104 void RPCMonitorRaw::analyze(const edm::Event& ev, const edm::EventSetup& es)
00105 {
00106
00107 edm::Handle<RPCRawDataCounts> rawCounts;
00108 ev.getByLabel(rpcRawDataCountsTag_, rawCounts);
00109 const RPCRawDataCounts & counts = *rawCounts.product();
00110
00111
00112
00113
00114 for (IT it=counts.theRecordTypes.begin(); it != counts.theRecordTypes.end(); ++it)
00115 me_t[it->first.first-790]->Fill(it->first.second,it->second);
00116
00117
00118
00119
00120 for (IT it = counts.theGoodEvents.begin(); it != counts.theGoodEvents.end(); ++it)
00121 me_mapGoodEvents->Fill(it->first.second, it->first.first, it->second);
00122
00123
00124
00125
00126 for (IT it = counts.theBadEvents.begin(); it != counts.theBadEvents.end(); ++it)
00127 me_mapBadEvents->Fill(it->first.second, it->first.first, it->second);
00128
00129
00130
00131
00132
00133 for (IT it=counts.theReadoutErrors.begin(); it != counts.theReadoutErrors.end(); ++it) {
00134 rpcrawtodigi::ReadoutError error(it->first.second);
00135 LinkBoardElectronicIndex ele = error.where();
00136 rpcrawtodigi::ReadoutError::ReadoutErrorType type = error.type();
00137
00138 int fed = it->first.first;
00139 me_e[fed-790]->Fill(type, it->second);
00140
00141
00142
00143
00144 int idx = theWatchedErrorHistoPos[type]-1;
00145 if ( idx >= 0) {
00146 std::vector<MonitorElement* > & wh = theWatchedErrorHistos[fed-790];
00147 MonitorElement* me = wh[idx];
00148 me->Fill(ele.dccInputChannelNum, ele.tbLinkInputNum, it->second);
00149 }
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 }