00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <DQM/DTMonitorClient/src/DTDeadChannelTest.h>
00012
00013
00014 #include <FWCore/Framework/interface/EventSetup.h>
00015
00016
00017
00018 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00019 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00020 #include "Geometry/DTGeometry/interface/DTLayer.h"
00021 #include "Geometry/DTGeometry/interface/DTTopology.h"
00022
00023 #include <CondFormats/DTObjects/interface/DTTtrig.h>
00024 #include <CondFormats/DataRecord/interface/DTTtrigRcd.h>
00025
00026 #include "DQMServices/Core/interface/DQMStore.h"
00027 #include "DQMServices/Core/interface/MonitorElement.h"
00028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00029
00030 #include <stdio.h>
00031 #include <sstream>
00032 #include <math.h>
00033
00034
00035 using namespace edm;
00036 using namespace std;
00037
00038
00039 DTDeadChannelTest::DTDeadChannelTest(const edm::ParameterSet& ps){
00040
00041 edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: Constructor";
00042
00043 parameters = ps;
00044
00045 dbe = edm::Service<DQMStore>().operator->();
00046
00047 prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
00048
00049 }
00050
00051 DTDeadChannelTest::~DTDeadChannelTest(){
00052
00053 edm::LogVerbatim ("deadChannel") << "DTDeadChannelTest: analyzed " << nevents << " events";
00054
00055 }
00056
00057
00058 void DTDeadChannelTest::beginJob(const edm::EventSetup& context){
00059
00060 edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: BeginJob";
00061
00062 nevents = 0;
00063
00064
00065 context.get<MuonGeometryRecord>().get(muonGeom);
00066
00067 }
00068
00069
00070
00071 void DTDeadChannelTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00072
00073 edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: Begin of LS transition";
00074
00075
00076 run = lumiSeg.run();
00077
00078 }
00079
00080
00081
00082 void DTDeadChannelTest::analyze(const edm::Event& e, const edm::EventSetup& context){
00083
00084 nevents++;
00085 edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: "<<nevents<<" events";
00086
00087 }
00088
00089
00090
00091 void DTDeadChannelTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: End of LS transition, performing the DQM client operation";
00102
00103
00104 nLumiSegs = lumiSeg.id().luminosityBlock();
00105
00106
00107 if ( nLumiSegs%prescaleFactor != 0 ) return;
00108
00109 edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: "<<nLumiSegs<<" updates";
00110
00111
00112 vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
00113 vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
00114
00115 edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: Occupancy tests results";
00116
00117
00118 for (; ch_it != ch_end; ++ch_it) {
00119 DTChamberId chID = (*ch_it)->id();
00120 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
00121 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
00122
00123 stringstream wheel; wheel << chID.wheel();
00124 stringstream station; station << chID.station();
00125 stringstream sector; sector << chID.sector();
00126
00127 context.get<DTTtrigRcd>().get(tTrigMap);
00128
00129 string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
00130
00131
00132 MonitorElement * noise_histo = dbe->get(getMEName("OccupancyNoise_perCh", chID));
00133 MonitorElement * hitInTime_histo = dbe->get(getMEName("OccupancyInTimeHits_perCh", chID));
00134
00135
00136 if(noise_histo && hitInTime_histo) {
00137 TH2F * noise_histo_root = noise_histo->getTH2F();
00138 TH2F * hitInTime_histo_root = hitInTime_histo->getTH2F();
00139
00140
00141 for(; sl_it != sl_end; ++sl_it) {
00142 DTSuperLayerId slID = (*sl_it)->id();
00143 vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
00144 vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
00145
00146
00147 float tTrig, tTrigRMS;
00148 tTrigMap->get(slID, tTrig, tTrigRMS, DTTimeUnits::counts);
00149
00150
00151 for(; l_it != l_end; ++l_it) {
00152 DTLayerId lID = (*l_it)->id();
00153
00154
00155 stringstream superLayer; superLayer << slID.superlayer();
00156 stringstream layer; layer << lID.layer();
00157 string HistoNameTest = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() + "_L" + layer.str();
00158
00159 const int firstWire = muonGeom->layer(lID)->specificTopology().firstChannel();
00160 const int lastWire = muonGeom->layer(lID)->specificTopology().lastChannel();
00161
00162 int entry=-1;
00163 if(slID.superlayer() == 1) entry=0;
00164 if(slID.superlayer() == 2) entry=4;
00165 if(slID.superlayer() == 3) entry=8;
00166 int YBinNumber = entry+lID.layer();
00167
00168
00169
00170 for(int bin=firstWire; bin <= lastWire; bin++) {
00171 if (OccupancyDiffHistos.find(HistoNameTest) == OccupancyDiffHistos.end()) bookHistos(lID, firstWire, lastWire);
00172
00173 float tMax = 450.0;
00174
00175 float difference = (hitInTime_histo_root->GetBinContent(bin, YBinNumber) / tMax)
00176 - (noise_histo_root->GetBinContent(bin, YBinNumber) / tTrig);
00177 OccupancyDiffHistos.find(HistoNameTest)->second->setBinContent(bin, difference);
00178 }
00179 }
00180 }
00181 }
00182 }
00183
00184
00185 string OccupancyDiffCriterionName = parameters.getUntrackedParameter<string>("OccupancyDiffTestName","OccupancyDiffInRange");
00186 for(map<string, MonitorElement*>::const_iterator hOccDiff = OccupancyDiffHistos.begin();
00187 hOccDiff != OccupancyDiffHistos.end();
00188 hOccDiff++) {
00189 const QReport * theOccupancyDiffQReport = (*hOccDiff).second->getQReport(OccupancyDiffCriterionName);
00190 if(theOccupancyDiffQReport) {
00191 vector<dqm::me_util::Channel> badChannels = theOccupancyDiffQReport->getBadChannels();
00192 for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
00193 channel != badChannels.end(); channel++) {
00194 edm::LogError ("deadChannel") << "Layer : "<<(*hOccDiff).first<<" Bad occupancy difference channels: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents();
00195 }
00196
00197
00198 }
00199 }
00200
00201 }
00202
00203
00204 void DTDeadChannelTest::endJob(){
00205
00206 edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest] endjob called!";
00207
00208 dbe->rmdir("DT/Tests/DTDeadChannel");
00209
00210 }
00211
00212 string DTDeadChannelTest::getMEName(string histoTag, const DTChamberId & chId) {
00213
00214 stringstream wheel; wheel << chId.wheel();
00215 stringstream station; station << chId.station();
00216 stringstream sector; sector << chId.sector();
00217
00218 string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
00219 string folderName =
00220 folderRoot + "DT/DTDigiTask/Wheel" + wheel.str() +
00221 "/Station" + station.str() +
00222 "/Sector" + sector.str() +
00223 "/Occupancies" + "/";
00224
00225 string histoname = folderName + histoTag
00226 + "_W" + wheel.str()
00227 + "_St" + station.str()
00228 + "_Sec" + sector.str();
00229
00230 return histoname;
00231
00232 }
00233
00234
00235 void DTDeadChannelTest::bookHistos(const DTLayerId & lId, int firstWire, int lastWire) {
00236
00237 stringstream wheel; wheel << lId.superlayerId().wheel();
00238 stringstream station; station << lId.superlayerId().station();
00239 stringstream sector; sector << lId.superlayerId().sector();
00240 stringstream superLayer; superLayer << lId.superlayerId().superlayer();
00241 stringstream layer; layer << lId.layer();
00242
00243 string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() + "_L" + layer.str();
00244 string OccupancyDiffHistoName = "OccupancyDiff_" + HistoName;
00245
00246 dbe->setCurrentFolder("DT/Tests/DTDeadChannel/Wheel" + wheel.str() +
00247 "/Station" + station.str() +
00248 "/Sector" + sector.str());
00249
00250 OccupancyDiffHistos[HistoName] = dbe->book1D(OccupancyDiffHistoName.c_str(),OccupancyDiffHistoName.c_str(),lastWire-firstWire+1, firstWire-0.5, lastWire+0.5);
00251
00252 }