00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <DQM/DTMonitorClient/src/DTChamberEfficiencyClient.h>
00010 #include <DQMServices/Core/interface/MonitorElement.h>
00011 #include <DQMServices/Core/interface/DQMStore.h>
00012
00013 #include <FWCore/Framework/interface/EventSetup.h>
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015
00016 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00017 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00018
00019 #include <stdio.h>
00020 #include <sstream>
00021 #include <math.h>
00022
00023 using namespace edm;
00024 using namespace std;
00025
00026
00027
00028
00029 DTChamberEfficiencyClient::DTChamberEfficiencyClient(const ParameterSet& pSet)
00030 {
00031
00032 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00033 << "DTChamberEfficiencyClient: Constructor called";
00034
00035 dbe = Service<DQMStore>().operator->();
00036
00037 prescaleFactor = pSet.getUntrackedParameter<int>("diagnosticPrescale", 1);
00038 }
00039
00040 DTChamberEfficiencyClient::~DTChamberEfficiencyClient()
00041 {
00042 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00043 << "DTChamberEfficiencyClient: Destructor called";
00044 }
00045
00046 void DTChamberEfficiencyClient::beginJob()
00047 {
00048 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00049 << "DTChamberEfficiencyClient: BeginJob";
00050
00051 nevents = 0;
00052
00053 bookHistos();
00054
00055 return;
00056 }
00057
00058 void DTChamberEfficiencyClient::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context)
00059 {
00060 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00061 << "[DTChamberEfficiencyClient]: Begin of LS transition";
00062
00063 return;
00064 }
00065
00066 void DTChamberEfficiencyClient::beginRun(const Run& run, const EventSetup& setup)
00067 {
00068 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00069 << "DTChamberEfficiencyClient: beginRun";
00070
00071
00072 setup.get<MuonGeometryRecord>().get(muonGeom);
00073
00074 return;
00075 }
00076
00077 void DTChamberEfficiencyClient::analyze(const Event& e, const EventSetup& context)
00078 {
00079
00080 nevents++;
00081 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00082 << "[DTChamberEfficiencyClient]: " << nevents << " events";
00083 return;
00084 }
00085
00086 void DTChamberEfficiencyClient::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context)
00087 {
00088 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00089 << "DTChamberEfficiencyClient: endluminosityBlock";
00090 }
00091
00092
00093 void DTChamberEfficiencyClient::endRun(Run const& run, EventSetup const& context)
00094 {
00095 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00096 << "DTChamberEfficiencyClient: endRun";
00097
00098 globalEffSummary->Reset();
00099
00100
00101 for(int wheel=-2;wheel<=2;wheel++){
00102 stringstream wheel_str; wheel_str << wheel;
00103
00104
00105
00106 MonitorElement* MECountAll = dbe->get("DT/05-ChamberEff/Task/hCountSectVsChamb_All_W" + wheel_str.str());
00107 MonitorElement* MECountQual = dbe->get("DT/05-ChamberEff/Task/hCountSectVsChamb_Qual_W" + wheel_str.str());
00108 MonitorElement* MEExtrap = dbe->get("DT/05-ChamberEff/Task/hExtrapSectVsChamb_W" + wheel_str.str());
00109
00110
00111 TH2F* hCountAll = MECountAll->getTH2F();
00112 TH2F* hCountQual = MECountQual->getTH2F();
00113 TH2F* hExtrap = MEExtrap->getTH2F();
00114
00115 const int nBinX = summaryHistos[wheel+2][0]->getNbinsX();
00116 const int nBinY = summaryHistos[wheel+2][0]->getNbinsY();
00117
00118 for(int j=1;j<=nBinX;j++){
00119 for(int k=1;k<=nBinY;k++){
00120 summaryHistos[wheel+2][0]->setBinContent(j,k,0.);
00121 summaryHistos[wheel+2][1]->setBinContent(j,k,0.);
00122
00123 const float numerAll = hCountAll->GetBinContent(j,k);
00124 const float numerQual = hCountQual->GetBinContent(j,k);
00125 const float denom = hExtrap->GetBinContent(j,k);
00126
00127 if(denom != 0.){
00128 const float effAll= numerAll/denom;
00129 const float eff_error_All = sqrt((effAll+effAll*effAll)/denom);
00130
00131 const float effQual= numerQual/denom;
00132 const float eff_error_Qual = sqrt((effQual+effQual*effQual)/denom);
00133
00134
00135
00136 summaryHistos[wheel+2][0]->setBinContent(j,k,effAll);
00137 summaryHistos[wheel+2][0]->setBinError(j,k,eff_error_All);
00138
00139 summaryHistos[wheel+2][1]->setBinContent(j,k,effQual);
00140 summaryHistos[wheel+2][1]->setBinError(j,k,eff_error_Qual);
00141 }
00142 }
00143 }
00144 }
00145
00146
00147
00148 for(int wheel=-2; wheel<=2; wheel++) {
00149
00150 MonitorElement * segmentWheelSummary = summaryHistos[wheel+2][0];
00151 if(segmentWheelSummary != 0) {
00152
00153 for(int sector=1; sector<=12; sector++) {
00154 float nFailingChambers = 0.;
00155
00156 double meaneff = 0.;
00157 double errorsum = 0.;
00158
00159 for(int station = 1; station != 5; ++station) {
00160
00161 const double tmpefficiency = segmentWheelSummary->getBinContent(sector, station);
00162 const double tmpvariance = pow(segmentWheelSummary->getBinError(sector, station),2);
00163
00164
00165
00166 if(tmpefficiency < 0.2 || tmpvariance == 0){
00167 nFailingChambers++;
00168 continue;
00169 }
00170
00171 meaneff += tmpefficiency/tmpvariance;
00172 errorsum += 1./tmpvariance;
00173
00174 LogTrace("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00175 << "Wheel: " << wheel << " Stat: " << station
00176 << " Sect: " << sector << " status: " << meaneff/errorsum << endl;
00177 }
00178
00179 if(sector == 4 || sector == 10) {
00180 int whichSector = (sector == 4) ? 13 : 14;
00181
00182 const double tmpefficiency = segmentWheelSummary->getBinContent(whichSector, 4);
00183 const double tmpvariance = pow(segmentWheelSummary->getBinError(whichSector, 4),2);
00184
00185 if(tmpefficiency > 0.2 && tmpvariance != 0) {
00186 meaneff += tmpefficiency/tmpvariance;
00187 errorsum += 1./tmpvariance;
00188 }
00189 else nFailingChambers++;
00190
00191 }
00192
00193 double eff_result = 0;
00194 if(errorsum != 0) eff_result = meaneff/errorsum;
00195
00196 if(nFailingChambers != 0) {
00197 if(sector != 4 && sector != 10) eff_result = eff_result*(4.-nFailingChambers)/4.;
00198 else eff_result = eff_result*(5.-nFailingChambers)/5.;
00199 }
00200
00201 if(eff_result > 0.7) globalEffSummary->Fill(sector,wheel,1.);
00202 else if(eff_result < 0.7 && eff_result > 0.5) globalEffSummary->Fill(sector,wheel,0.6);
00203 else if(eff_result < 0.5 && eff_result > 0.3) globalEffSummary->Fill(sector,wheel,0.4);
00204 else if(eff_result < 0.3 && eff_result > 0.) globalEffSummary->Fill(sector,wheel,0.15);
00205
00206
00207
00208
00209 }
00210 }
00211 }
00212 return;
00213 }
00214
00215 void DTChamberEfficiencyClient::endJob()
00216 {
00217 LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
00218 << "DTChamberEfficiencyClient: endJob";
00219 return;
00220 }
00221
00222 void DTChamberEfficiencyClient::bookHistos()
00223 {
00224
00225 dbe->setCurrentFolder("DT/05-ChamberEff");
00226 globalEffSummary = dbe->book2D("EfficiencyGlbSummary","Efficiency Summary",12,1,13,5,-2,3);
00227 globalEffSummary->setAxisTitle("sector",1);
00228 globalEffSummary->setAxisTitle("wheel",2);
00229
00230
00231
00232 for(int wh=-2; wh<=2; wh++){
00233 stringstream wheel; wheel << wh;
00234 string histoNameAll = "EfficiencyMap_All_W" + wheel.str();
00235 string histoTitleAll = "Efficiency map for all segments for wheel " + wheel.str();
00236
00237 string histoNameQual = "EfficiencyMap_Qual_W" + wheel.str();
00238 string histoTitleQual = "Efficiency map for quality segments for wheel " + wheel.str();
00239
00240
00241 dbe->setCurrentFolder("DT/05-ChamberEff");
00242
00243 summaryHistos[wh+2][0] = dbe->book2D(histoNameAll.c_str(),histoTitleAll.c_str(),14,1.,15.,4,1.,5.);
00244 summaryHistos[wh+2][0]->setAxisTitle("Sector",1);
00245 summaryHistos[wh+2][0]->setBinLabel(1,"MB1",2);
00246 summaryHistos[wh+2][0]->setBinLabel(2,"MB2",2);
00247 summaryHistos[wh+2][0]->setBinLabel(3,"MB3",2);
00248 summaryHistos[wh+2][0]->setBinLabel(4,"MB4",2);
00249
00250 dbe->setCurrentFolder("DT/05-ChamberEff/HighQual");
00251
00252 summaryHistos[wh+2][1] = dbe->book2D(histoNameQual.c_str(),histoTitleQual.c_str(),14,1.,15.,4,1.,5.);
00253 summaryHistos[wh+2][1]->setAxisTitle("Sector",1);
00254 summaryHistos[wh+2][1]->setBinLabel(1,"MB1",2);
00255 summaryHistos[wh+2][1]->setBinLabel(2,"MB2",2);
00256 summaryHistos[wh+2][1]->setBinLabel(3,"MB3",2);
00257 summaryHistos[wh+2][1]->setBinLabel(4,"MB4",2);
00258 }
00259
00260 return;
00261 }