00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <DQM/DTMonitorClient/src/DTNoiseAnalysisTest.h>
00013
00014
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include <FWCore/Framework/interface/EventSetup.h>
00017 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00018
00019
00020
00021 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00022 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00023 #include "Geometry/DTGeometry/interface/DTLayer.h"
00024 #include "Geometry/DTGeometry/interface/DTTopology.h"
00025 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
00026
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028 #include "DQMServices/Core/interface/MonitorElement.h"
00029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00030
00031 #include <iostream>
00032 #include <sstream>
00033
00034
00035
00036 using namespace edm;
00037 using namespace std;
00038
00039
00040 DTNoiseAnalysisTest::DTNoiseAnalysisTest(const edm::ParameterSet& ps){
00041 LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "[DTNoiseAnalysisTest]: Constructor";
00042
00043 dbe = edm::Service<DQMStore>().operator->();
00044
00045
00046 noisyCellDef = ps.getUntrackedParameter<int>("noisyCellDef",500);
00047
00048
00049 doSynchNoise = ps.getUntrackedParameter<bool>("doSynchNoise", false);
00050 maxSynchNoiseRate = ps.getUntrackedParameter<double>("maxSynchNoiseRate", 0.001);
00051
00052 }
00053
00054
00055 DTNoiseAnalysisTest::~DTNoiseAnalysisTest(){
00056 LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "DTNoiseAnalysisTest: analyzed " << nevents << " events";
00057 }
00058
00059
00060 void DTNoiseAnalysisTest::beginJob(){
00061 LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: BeginJob";
00062
00063 nevents = 0;
00064
00065
00066 bookHistos();
00067
00068 }
00069
00070 void DTNoiseAnalysisTest::beginRun(Run const& run, EventSetup const& context) {
00071
00072
00073 context.get<MuonGeometryRecord>().get(muonGeom);
00074
00075 }
00076
00077
00078 void DTNoiseAnalysisTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00079
00080 LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: Begin of LS transition";
00081 }
00082
00083
00084 void DTNoiseAnalysisTest::analyze(const edm::Event& e, const edm::EventSetup& context){
00085
00086 nevents++;
00087 if(nevents%1000 == 0) LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00088 << "[DTNoiseAnalysisTest]: "<<nevents<<" events";
00089
00090 }
00091
00092 void DTNoiseAnalysisTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00093 LogVerbatim ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00094 <<"[DTNoiseAnalysisTest]: End of LS transition, performing the DQM client operation";
00095
00096
00097 for(map<int, MonitorElement* >::iterator plot = noiseHistos.begin();
00098 plot != noiseHistos.end(); ++plot) {
00099 (*plot).second->Reset();
00100 }
00101
00102 for(map<int, MonitorElement* >::iterator plot = noisyCellHistos.begin();
00103 plot != noisyCellHistos.end(); ++plot) {
00104 (*plot).second->Reset();
00105 }
00106
00107 summaryNoiseHisto->Reset();
00108
00109
00110
00111 vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
00112 vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
00113
00114 LogTrace ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00115 <<"[DTNoiseAnalysisTest]: Fill the summary histos";
00116
00117 for (; ch_it != ch_end; ++ch_it) {
00118 DTChamberId chID = (*ch_it)->id();
00119
00120 MonitorElement * histo = dbe->get(getMEName(chID));
00121
00122 if(histo) {
00123
00124 TH2F * histo_root = histo->getTH2F();
00125
00126 for(int sl = 1; sl != 4; ++sl) {
00127
00128 if(chID.station() == 4 && sl == 2) continue;
00129
00130 int binYlow = ((sl-1)*4)+1;
00131
00132 for(int layer = 1; layer <= 4; ++layer) {
00133
00134
00135 DTLayerId layID(chID,sl,layer);
00136
00137 int nWires = muonGeom->layer(layID)->specificTopology().channels();
00138 int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
00139
00140 int binY = binYlow+(layer-1);
00141
00142 for(int wire = firstWire; wire != (nWires+firstWire); wire++){
00143
00144 double noise = histo_root->GetBinContent(wire, binY);
00145
00146 noiseHistos[chID.wheel()]->Fill(noise);
00147 noiseHistos[3]->Fill(noise);
00148 int sector = chID.sector();
00149 if(noise>noisyCellDef) {
00150 if(sector == 13) {
00151 sector = 4;
00152 } else if(sector == 14) {
00153 sector = 10;
00154 }
00155 noisyCellHistos[chID.wheel()]->Fill(sector,chID.station());
00156 summaryNoiseHisto->Fill(sector,chID.wheel());
00157 }
00158 }
00159 }
00160 }
00161 }
00162 }
00163
00164
00165
00166
00167
00168 if(doSynchNoise) {
00169 LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00170 << "[DTNoiseAnalysisTest]: fill summaries for synch noise" << endl;
00171 summarySynchNoiseHisto->Reset();
00172 for(int wheel = -2; wheel != 3; ++wheel) {
00173
00174 MonitorElement * histoNoiseSynch = dbe->get(getSynchNoiseMEName(wheel));
00175 if(histoNoiseSynch != 0) {
00176 for(int sect = 1; sect != 13; ++sect) {
00177 TH2F * histo = histoNoiseSynch->getTH2F();
00178 for(int sta = 1; sta != 5; ++sta) {
00179 LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00180 << " Wheel: " << wheel << " sect: " << sect
00181 << " station: " << sta
00182 << " rate is: " << histo->GetBinContent(sect, sta)/(float)nevents << endl;
00183 if(histo->GetBinContent(sect, sta)/(float)nevents > maxSynchNoiseRate) {
00184 summarySynchNoiseHisto->Fill(sect,wheel,1);
00185 } else {
00186 summarySynchNoiseHisto->Fill(sect,wheel,0);
00187 }
00188 }
00189 }
00190 } else {
00191 LogWarning("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00192 << " Histo: " << getSynchNoiseMEName(wheel) << " not found!" << endl;
00193 }
00194 }
00195
00196 }
00197
00198 }
00199
00200
00201 string DTNoiseAnalysisTest::getMEName(const DTChamberId & chID) {
00202
00203 stringstream wheel; wheel << chID.wheel();
00204 stringstream station; station << chID.station();
00205 stringstream sector; sector << chID.sector();
00206
00207 string folderName =
00208 "DT/05-Noise/Wheel" + wheel.str() +
00209
00210 "/Sector" + sector.str() + "/";
00211
00212 string histoname = folderName + string("NoiseRate")
00213 + "_W" + wheel.str()
00214 + "_St" + station.str()
00215 + "_Sec" + sector.str();
00216
00217 return histoname;
00218
00219 }
00220
00221
00222 void DTNoiseAnalysisTest::bookHistos() {
00223
00224 dbe->setCurrentFolder("DT/05-Noise");
00225 string histoName;
00226
00227 for(int wh=-2; wh<=2; wh++){
00228 stringstream wheel; wheel << wh;
00229 histoName = "NoiseRateSummary_W" + wheel.str();
00230 noiseHistos[wh] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
00231 noiseHistos[wh]->setAxisTitle("rate (Hz)",1);
00232 noiseHistos[wh]->setAxisTitle("entries",2);
00233 }
00234 histoName = "NoiseRateSummary";
00235 noiseHistos[3] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
00236 noiseHistos[3]->setAxisTitle("rate (Hz)",1);
00237 noiseHistos[3]->setAxisTitle("entries",2);
00238
00239
00240 for(int wh=-2; wh<=2; wh++){
00241 stringstream wheel; wheel << wh;
00242 histoName = "NoiseSummary_W" + wheel.str();
00243 noisyCellHistos[wh] = dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,4,1,5);
00244 noisyCellHistos[wh]->setBinLabel(1,"MB1",2);
00245 noisyCellHistos[wh]->setBinLabel(2,"MB2",2);
00246 noisyCellHistos[wh]->setBinLabel(3,"MB3",2);
00247 noisyCellHistos[wh]->setBinLabel(4,"MB4",2);
00248 noisyCellHistos[wh]->setAxisTitle("Sector",1);
00249 }
00250
00251 histoName = "NoiseSummary";
00252 summaryNoiseHisto = dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,5,-2,3);
00253 summaryNoiseHisto->setAxisTitle("Sector",1);
00254 summaryNoiseHisto->setAxisTitle("Wheel",2);
00255
00256
00257 if(doSynchNoise) {
00258 dbe->setCurrentFolder("DT/05-Noise/SynchNoise/");
00259 histoName = "SynchNoiseSummary";
00260 summarySynchNoiseHisto = dbe->book2D(histoName.c_str(),"Summary Synch. Noise",12,1,13,5,-2,3);
00261 summarySynchNoiseHisto->setAxisTitle("Sector",1);
00262 summarySynchNoiseHisto->setAxisTitle("Wheel",2);
00263 }
00264
00265 }
00266
00267
00268
00269 string DTNoiseAnalysisTest::getSynchNoiseMEName(int wheelId) const {
00270
00271 stringstream wheel; wheel << wheelId;
00272 string folderName =
00273 "DT/05-Noise/SynchNoise/";
00274 string histoname = folderName + string("SyncNoiseEvents")
00275 + "_W" + wheel.str();
00276
00277 return histoname;
00278
00279 }