CMS 3D CMS Logo

DTChamberEfficiencyClient.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author M. Pelliccioni - INFN Torino
5  *
6  * threadsafe version (//-) oct/nov 2014 - WATWanAbdullah ncpp-um-my
7  *
8  */
9 
12 
15 
18 
19 #include <cstdio>
20 #include <sstream>
21 #include <cmath>
22 
23 using namespace edm;
24 using namespace std;
25 
26 //two words about conventions: "All" histograms are those made for all segments
27 //while "Qual" histograms are those for segments with at least 12 hits
28 
30  LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyClient") << "DTChamberEfficiencyClient: Constructor called";
31 
32  prescaleFactor = pSet.getUntrackedParameter<int>("diagnosticPrescale", 1);
33 }
34 
36  LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyClient") << "DTChamberEfficiencyClient: Destructor called";
37 }
38 
40  // Get the DT Geometry
41  setup.get<MuonGeometryRecord>().get(muonGeom);
42 }
43 
45  DQMStore::IGetter& igetter,
46  edm::LuminosityBlock const& lumiSeg,
47  edm::EventSetup const& setup) {
48  LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyClient") << "DTChamberEfficiencyClient: endluminosityBlock";
49 }
50 
52  LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyClient") << "DTChamberEfficiencyClient: endRun";
53 
54  bookHistos(ibooker);
55 
56  // reset the global summary
57  globalEffSummary->Reset();
58 
59  //Loop over the wheels
60  for (int wheel = -2; wheel <= 2; wheel++) {
61  stringstream wheel_str;
62  wheel_str << wheel;
63 
64  // Get the ME produced by EfficiencyTask Source
65  // All means no selection on segments, Qual means segments with at least 12 hits
66 
67  MonitorElement* MECountAll = igetter.get("DT/05-ChamberEff/Task/hCountSectVsChamb_All_W" + wheel_str.str());
68  MonitorElement* MECountQual = igetter.get("DT/05-ChamberEff/Task/hCountSectVsChamb_Qual_W" + wheel_str.str());
69  MonitorElement* MEExtrap = igetter.get("DT/05-ChamberEff/Task/hExtrapSectVsChamb_W" + wheel_str.str());
70 
71  //get the TH2F
72  if (!MECountAll || !(MECountAll->getTH2F())) {
73  edm::LogWarning("DTChamberEfficiencyClient") << "ME not available" << std::endl;
74  return;
75  }
76 
77  TH2F* hCountAll = MECountAll->getTH2F();
78  TH2F* hCountQual = MECountQual->getTH2F();
79  TH2F* hExtrap = MEExtrap->getTH2F();
80 
81  const int nBinX = summaryHistos[wheel + 2][0]->getNbinsX();
82  const int nBinY = summaryHistos[wheel + 2][0]->getNbinsY();
83 
84  for (int j = 1; j <= nBinX; j++) {
85  for (int k = 1; k <= nBinY; k++) {
86  summaryHistos[wheel + 2][0]->setBinContent(j, k, 0.);
87  summaryHistos[wheel + 2][1]->setBinContent(j, k, 0.);
88 
89  const float numerAll = hCountAll->GetBinContent(j, k);
90  const float numerQual = hCountQual->GetBinContent(j, k);
91  const float denom = hExtrap->GetBinContent(j, k);
92 
93  if (denom != 0.) {
94  const float effAll = numerAll / denom;
95  const float eff_error_All = sqrt((effAll + effAll * effAll) / denom);
96 
97  const float effQual = numerQual / denom;
98  const float eff_error_Qual = sqrt((effQual + effQual * effQual) / denom);
99 
100  summaryHistos[wheel + 2][0]->setBinContent(j, k, effAll);
101  summaryHistos[wheel + 2][0]->setBinError(j, k, eff_error_All);
102 
103  summaryHistos[wheel + 2][1]->setBinContent(j, k, effQual);
104  summaryHistos[wheel + 2][1]->setBinError(j, k, eff_error_Qual);
105 
106  // Fill 1D eff distributions
107  globalEffDistr->Fill(effAll);
108  EffDistrPerWh[wheel + 2]->Fill(effAll);
109  }
110  }
111  }
112  }
113 
114  // fill the global eff. summary
115  // problems at a granularity smaller than the chamber are ignored
116  for (int wheel = -2; wheel <= 2; wheel++) { // loop over wheels
117  // retrieve the chamber efficiency summary
118  MonitorElement* segmentWheelSummary = summaryHistos[wheel + 2][0];
119  if (segmentWheelSummary != nullptr) {
120  for (int sector = 1; sector <= 12; sector++) { // loop over sectors
121  float nFailingChambers = 0.;
122 
123  double meaneff = 0.;
124  double errorsum = 0.;
125 
126  for (int station = 1; station != 5; ++station) { // loop over stations
127 
128  const double tmpefficiency = segmentWheelSummary->getBinContent(sector, station);
129  const double tmpvariance = pow(segmentWheelSummary->getBinError(sector, station), 2);
130 
131  if (tmpefficiency < 0.2 || tmpvariance == 0) {
132  nFailingChambers++;
133  continue;
134  }
135 
136  meaneff += tmpefficiency / tmpvariance;
137  errorsum += 1. / tmpvariance;
138 
139  LogTrace("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
140  << "Wheel: " << wheel << " Stat: " << station << " Sect: " << sector << " status: " << meaneff / errorsum
141  << endl;
142  }
143 
144  if (sector == 4 || sector == 10) {
145  int whichSector = (sector == 4) ? 13 : 14;
146 
147  const double tmpefficiency = segmentWheelSummary->getBinContent(whichSector, 4);
148  const double tmpvariance = pow(segmentWheelSummary->getBinError(whichSector, 4), 2);
149 
150  if (tmpefficiency > 0.2 && tmpvariance != 0) {
151  meaneff += tmpefficiency / tmpvariance;
152  errorsum += 1. / tmpvariance;
153  } else
154  nFailingChambers++;
155  }
156 
157  double eff_result = 0;
158  if (errorsum != 0)
159  eff_result = meaneff / errorsum;
160 
161  if (nFailingChambers != 0) {
162  if (sector != 4 && sector != 10)
163  eff_result = eff_result * (4. - nFailingChambers) / 4.;
164  else
165  eff_result = eff_result * (5. - nFailingChambers) / 5.;
166  }
167 
168  if (eff_result > 0.7)
169  globalEffSummary->Fill(sector, wheel, 1.);
170  else if (eff_result < 0.7 && eff_result > 0.5)
171  globalEffSummary->Fill(sector, wheel, 0.6);
172  else if (eff_result < 0.5 && eff_result > 0.3)
173  globalEffSummary->Fill(sector, wheel, 0.4);
174  else if (eff_result < 0.3 && eff_result > 0.)
175  globalEffSummary->Fill(sector, wheel, 0.15);
176  else
177  globalEffSummary->Fill(sector, wheel, 0.01);
178  }
179  }
180  }
181  return;
182 }
183 
185  ibooker.setCurrentFolder("DT/05-ChamberEff");
186 
187  globalEffSummary = ibooker.book2D("EfficiencyGlbSummary", "Efficiency Summary", 12, 1, 13, 5, -2, 3);
188  globalEffSummary->setAxisTitle("sector", 1);
189  globalEffSummary->setAxisTitle("wheel", 2);
190 
191  globalEffDistr = ibooker.book1D("TotalEfficiency", "Total efficiency", 51, 0., 1.02);
192  globalEffDistr->setAxisTitle("Eff", 1);
193 
194  for (int wh = -2; wh <= 2; wh++) {
195  stringstream wheel;
196  wheel << wh;
197  string histoNameAll = "EfficiencyMap_All_W" + wheel.str();
198  string histoTitleAll = "Efficiency map for all segments for wheel " + wheel.str();
199 
200  string histoNameQual = "EfficiencyMap_Qual_W" + wheel.str();
201  string histoTitleQual = "Efficiency map for quality segments for wheel " + wheel.str();
202 
203  string histoNameEff = "Efficiency_W" + wheel.str();
204  string histoTitleEff = "Segment efficiency, wheel " + wheel.str();
205 
206  ibooker.setCurrentFolder("DT/05-ChamberEff");
207 
208  summaryHistos[wh + 2][0] = ibooker.book2D(histoNameAll.c_str(), histoTitleAll.c_str(), 14, 1., 15., 4, 1., 5.);
209  summaryHistos[wh + 2][0]->setAxisTitle("Sector", 1);
210  summaryHistos[wh + 2][0]->setBinLabel(1, "MB1", 2);
211  summaryHistos[wh + 2][0]->setBinLabel(2, "MB2", 2);
212  summaryHistos[wh + 2][0]->setBinLabel(3, "MB3", 2);
213  summaryHistos[wh + 2][0]->setBinLabel(4, "MB4", 2);
214 
215  EffDistrPerWh[wh + 2] = ibooker.book1D(histoNameEff.c_str(), histoTitleEff.c_str(), 51, 0., 1.02);
216  EffDistrPerWh[wh + 2]->setAxisTitle("Eff", 1);
217 
218  ibooker.setCurrentFolder("DT/05-ChamberEff/HighQual");
219 
220  summaryHistos[wh + 2][1] = ibooker.book2D(histoNameQual.c_str(), histoTitleQual.c_str(), 14, 1., 15., 4, 1., 5.);
221  summaryHistos[wh + 2][1]->setAxisTitle("Sector", 1);
222  summaryHistos[wh + 2][1]->setBinLabel(1, "MB1", 2);
223  summaryHistos[wh + 2][1]->setBinLabel(2, "MB2", 2);
224  summaryHistos[wh + 2][1]->setBinLabel(3, "MB3", 2);
225  summaryHistos[wh + 2][1]->setBinLabel(4, "MB4", 2);
226  }
227 
228  return;
229 }
MessageLogger.h
makePileupJSON.denom
denom
Definition: makePileupJSON.py:147
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
DTChamberEfficiencyClient::DTChamberEfficiencyClient
DTChamberEfficiencyClient(const edm::ParameterSet &ps)
Constructor.
Definition: DTChamberEfficiencyClient.cc:29
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DTChamberEfficiencyClient::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DTChamberEfficiencyClient.cc:39
bookHistos
void bookHistos()
Definition: Histogram.h:33
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DTGeometry.h
edm::LogWarning
Definition: MessageLogger.h:141
anotherprimaryvertexanalyzer_cfi.nBinY
nBinY
Definition: anotherprimaryvertexanalyzer_cfi.py:13
edm::ParameterSet
Definition: ParameterSet.h:36
DTChamberEfficiencyClient.h
DTChamberEfficiencyClient::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: DTChamberEfficiencyClient.cc:51
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
Skims_PDWG_cff.prescaleFactor
prescaleFactor
Definition: Skims_PDWG_cff.py:25
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
DTChamberEfficiencyClient::~DTChamberEfficiencyClient
~DTChamberEfficiencyClient() override
Destructor.
Definition: DTChamberEfficiencyClient.cc:35
anotherprimaryvertexanalyzer_cfi.nBinX
nBinX
Definition: anotherprimaryvertexanalyzer_cfi.py:12
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
DTChamberEfficiencyClient::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: DTChamberEfficiencyClient.cc:44
MuonGeometryRecord.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
dqm::impl::MonitorElement::getBinError
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
Definition: MonitorElement.cc:610
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
DTChamberEfficiencyClient::bookHistos
void bookHistos(DQMStore::IBooker &)
book the report summary
Definition: DTChamberEfficiencyClient.cc:184
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:490