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 {
00032 for (unsigned int i=0; i<10;i++) theWatchedErrorHistoPos[i]=0;
00033 std::vector<int> algos = cfg.getUntrackedParameter<std::vector<int> >("watchedErrors");
00034 for (std::vector<int>::const_iterator it=algos.begin();it!= algos.end(); ++it) {
00035 unsigned int ialgo = *it;
00036 if (ialgo < 10) theWatchedErrorHistoPos[ialgo]=1;
00037 }
00038 }
00039
00040 RPCMonitorRaw::~RPCMonitorRaw() { LogTrace("") << "RPCMonitorRaw destructor"; }
00041
00042 void RPCMonitorRaw::beginJob()
00043 {
00044
00045
00046 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00047
00048 theDMBE->setCurrentFolder("RPC/LinkMonitor");
00049
00050 me_t[0]=theDMBE->book1D("recordType_790",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(790));
00051 me_t[1]=theDMBE->book1D("recordType_791",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(791));
00052 me_t[2]=theDMBE->book1D("recordType_792",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(792));
00053 for (int i=0;i<3;++i)me_t[i]->getTH1F()->SetStats(0);
00054
00055 me_e[0]=theDMBE->book1D("readoutErrors_790",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(790));
00056 me_e[1]=theDMBE->book1D("readoutErrors_791",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(791));
00057 me_e[2]=theDMBE->book1D("readoutErrors_792",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(792));
00058 for (int i=0;i<3;++i)me_e[i]->getTH1F()->SetStats(0);
00059
00060 me_mapGoodEvents=theDMBE->book2D("mapGoodRecords","mapGoodRecords",36,-0.5,35.5, 3, 789.5,792.5);
00061 me_mapGoodEvents->getTH2F()->SetNdivisions(3,"y");
00062 me_mapGoodEvents->getTH2F()->SetXTitle("rmb");
00063 me_mapGoodEvents->getTH2F()->SetYTitle("fed");
00064 me_mapGoodEvents->getTH2F()->SetStats(0);
00065 me_mapBadEvents =theDMBE->book2D("mapErrorRecords", "mapErrorRecords", 36,-0.5,35.5, 3, 789.5,792.5);
00066 me_mapBadEvents->getTH2F()->SetXTitle("fed");
00067 me_mapBadEvents->getTH2F()->SetYTitle("rmb");
00068 me_mapBadEvents->getTH2F()->SetNdivisions(3,"y");
00069 me_mapBadEvents->getTH2F()->SetStats(0);
00070
00071 for (unsigned int i=0; i<=9; ++i) {
00072 if (theWatchedErrorHistoPos[i]) {
00073 for (unsigned int fed=790; fed <=792; ++fed) {
00074 TH2F * histo = RPCRawDataCountsHistoMaker::emptyReadoutErrorMapHisto(fed,i);
00075 MonitorElement* watched = theDMBE->book2D(histo->GetName(),histo);
00076 theWatchedErrorHistos[fed-790].push_back(watched);
00077 theWatchedErrorHistoPos[i] = theWatchedErrorHistos[fed-790].size();
00078 }
00079 }
00080 }
00081
00082 }
00083 void RPCMonitorRaw::endJob()
00084 {
00085 bool writeHistos = theConfig.getUntrackedParameter<bool>("writeHistograms", false);
00086 if (writeHistos) {
00087 std::string histoFile = theConfig.getUntrackedParameter<std::string>("histoFileName");
00088 TFile f(histoFile.c_str(),"RECREATE");
00089 for (int i=0; i<3; ++i) {
00090 me_t[i]->getTH1F()->Write();
00091 me_e[i]->getTH1F()->Write();
00092 std::vector<MonitorElement* > & wh = theWatchedErrorHistos[i];
00093 for (std::vector<MonitorElement* >::const_iterator it=wh.begin(); it != wh.end(); ++it)(*it)->getTH2F()->Write();
00094 }
00095 me_mapGoodEvents->getTH2F()->Write();
00096 me_mapBadEvents->getTH2F()->Write();
00097 edm::LogInfo(" END JOB, histos saved!");
00098 f.Close();
00099 }
00100 }
00101
00102
00103 void RPCMonitorRaw::analyze(const edm::Event& ev, const edm::EventSetup& es)
00104 {
00105
00106 edm::Handle<RPCRawDataCounts> rawCounts;
00107 ev.getByType( rawCounts);
00108 const RPCRawDataCounts & counts = *rawCounts.product();
00109
00110
00111
00112
00113 for (IT it=counts.theRecordTypes.begin(); it != counts.theRecordTypes.end(); ++it)
00114 me_t[it->first.first-790]->Fill(it->first.second,it->second);
00115
00116
00117
00118
00119 for (IT it = counts.theGoodEvents.begin(); it != counts.theGoodEvents.end(); ++it)
00120 me_mapGoodEvents->Fill(it->first.second, it->first.first, it->second);
00121
00122
00123
00124
00125 for (IT it = counts.theBadEvents.begin(); it != counts.theBadEvents.end(); ++it)
00126 me_mapBadEvents->Fill(it->first.second, it->first.first, it->second);
00127
00128
00129
00130
00131
00132 for (IT it=counts.theReadoutErrors.begin(); it != counts.theReadoutErrors.end(); ++it) {
00133 rpcrawtodigi::ReadoutError error(it->first.second);
00134 LinkBoardElectronicIndex ele = error.where();
00135 rpcrawtodigi::ReadoutError::ReadoutErrorType type = error.type();
00136
00137 int fed = it->first.first;
00138 me_e[fed-790]->Fill(type, it->second);
00139
00140
00141
00142
00143 int idx = theWatchedErrorHistoPos[type]-1;
00144 if ( idx >= 0) {
00145 std::vector<MonitorElement* > & wh = theWatchedErrorHistos[fed-790];
00146 MonitorElement* me = wh[idx];
00147 me->Fill(ele.dccInputChannelNum, ele.tbLinkInputNum, it->second);
00148 }
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 }