CMS 3D CMS Logo

DTResolutionTest.cc
Go to the documentation of this file.
1 
2 
3 /*
4  * See header file for a description of this class.
5  *
6  * \author G. Mila - INFN Torino
7  *
8  * threadsafe version (//-) oct/nov 2014 - WATWanAbdullah -ncpp-um-my
9  *
10  */
11 
13 
14 // Framework
20 
21 // Geometry
24 
27 
28 #include <iostream>
29 #include <cstdio>
30 #include <string>
31 #include <sstream>
32 #include <cmath>
33 #include "TF1.h"
34 
35 using namespace edm;
36 using namespace std;
37 
39  : muonGeomToken_(esConsumes<edm::Transition::EndLuminosityBlock>()) {
40  edm::LogVerbatim("resolution") << "[DTResolutionTest]: Constructor";
41  parameters = ps;
42 
43  //FR: no idea if this input file needs to be used! comment it for now
44  //- if(ps.getUntrackedParameter<bool>("readFile", false))
45  //- dbe->open(ps.getUntrackedParameter<string>("inputFile", "residuals.root"));
46 
47  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
48 
49  percentual = parameters.getUntrackedParameter<int>("BadSLpercentual", 10);
50 
51  nevents = 0;
52 
53  bookingdone = false;
54 }
55 
57  edm::LogVerbatim("resolution") << "DTResolutionTest: analyzed " << nevents << " events";
58 }
59 
61  DQMStore::IGetter& igetter,
62  edm::LuminosityBlock const& lumiSeg,
63  edm::EventSetup const& context) {
64  // counts number of updates (online mode) or number of events (standalone mode)
65  //nevents++;
66  // if running in standalone perform diagnostic only after a reasonalbe amount of events
67  //if ( parameters.getUntrackedParameter<bool>("runningStandalone", false) &&
68  // nevents%parameters.getUntrackedParameter<int>("diagnosticPrescale", 1000) != 0 ) return;
69  //edm::LogVerbatim ("resolution") << "[DTResolutionTest]: "<<nevents<<" updates";
70 
71  if (!bookingdone) {
72  // Get the geometry
73  muonGeom = &context.getData(muonGeomToken_);
74  // book the histos
75  for (int wheel = -2; wheel < 3; wheel++) {
76  bookHistos(ibooker, wheel);
77  }
78  vector<const DTChamber*> chambers = muonGeom->chambers();
79  for (vector<const DTChamber*>::const_iterator chamber = chambers.begin(); chamber != chambers.end(); ++chamber) {
80  bookHistos(ibooker, (*chamber)->id());
81  }
82  }
83  bookingdone = true;
84 
85  edm::LogVerbatim("resolution") << "[DTResolutionTest]: End of LS transition, performing the DQM client operation";
86 
87  // counts number of lumiSegs
88  nLumiSegs = lumiSeg.id().luminosityBlock();
89 
90  // prescale factor
91  if (nLumiSegs % prescaleFactor != 0)
92  return;
93 
94  for (map<int, MonitorElement*>::const_iterator histo = wheelMeanHistos.begin(); histo != wheelMeanHistos.end();
95  histo++) {
96  (*histo).second->Reset();
97  }
98  if (parameters.getUntrackedParameter<bool>("sigmaTest")) {
99  for (map<int, MonitorElement*>::const_iterator histo = wheelSigmaHistos.begin(); histo != wheelSigmaHistos.end();
100  histo++) {
101  (*histo).second->Reset();
102  }
103  }
104  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
105  for (map<int, MonitorElement*>::const_iterator histo = wheelSlopeHistos.begin(); histo != wheelSlopeHistos.end();
106  histo++) {
107  (*histo).second->Reset();
108  }
109  }
110 
111  cmsMeanHistos.clear();
112  for (int i = -2; i < 3; i++) {
113  for (int j = 1; j < 15; j++) {
114  MeanFilled[make_pair(i, j)] = false;
115  }
116  }
117  if (parameters.getUntrackedParameter<bool>("sigmaTest")) {
118  cmsSigmaHistos.clear();
119  for (int i = -2; i < 3; i++) {
120  for (int j = 1; j < 15; j++) {
121  SigmaFilled[make_pair(i, j)] = false;
122  }
123  }
124  }
125  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
126  cmsSlopeHistos.clear();
127  for (int i = -2; i < 3; i++) {
128  for (int j = 1; j < 15; j++) {
129  SlopeFilled[make_pair(i, j)] = false;
130  }
131  }
132  }
133 
134  // summary histos initialization
135  for (int wh = -2; wh <= 3; wh++) {
136  if (wh != 3) {
137  for (int xBin = 0; xBin < 14; xBin++) {
138  for (int yBin = 0; yBin < 11; yBin++) {
139  wheelMeanHistos[wh]->setBinContent(xBin, yBin, 0);
140  if (parameters.getUntrackedParameter<bool>("sigmaTest"))
141  wheelSigmaHistos[wh]->setBinContent(xBin, yBin, 0);
142  if (parameters.getUntrackedParameter<bool>("slopeTest"))
143  wheelSlopeHistos[wh]->setBinContent(xBin, yBin, 0);
144  }
145  }
146  } else {
147  for (int xBin = 0; xBin < 14; xBin++) {
148  for (int yBin = -2; yBin < 3; yBin++) {
149  wheelMeanHistos[wh]->setBinContent(xBin, yBin, 0);
150  if (parameters.getUntrackedParameter<bool>("sigmaTest"))
151  wheelSigmaHistos[wh]->setBinContent(xBin, yBin, 0);
152  if (parameters.getUntrackedParameter<bool>("slopeTest"))
153  wheelSlopeHistos[wh]->setBinContent(xBin, yBin, 0);
154  }
155  }
156  }
157  }
158 
159  edm::LogVerbatim("resolution") << "[DTResolutionTest]: " << nLumiSegs << " updates";
160 
161  vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
162  vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
163 
164  edm::LogVerbatim("resolution") << "[DTResolutionTest]: Residual Distribution tests results";
165 
166  for (; ch_it != ch_end; ++ch_it) {
167  DTChamberId chID = (*ch_it)->id();
168 
169  // Fill the test histos
170  int entry = -1;
171  if (chID.station() == 1)
172  entry = 0;
173  if (chID.station() == 2)
174  entry = 3;
175  if (chID.station() == 3)
176  entry = 6;
177  if (chID.station() == 4)
178  entry = 9;
179 
180  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
181  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
182 
183  for (; sl_it != sl_end; ++sl_it) {
184  DTSuperLayerId slID = (*sl_it)->id();
185 
186  edm::LogVerbatim("resolution") << "[DTResolutionTest]: Superlayer: " << slID;
187 
188  stringstream wheel;
189  wheel << slID.wheel();
190  stringstream station;
191  station << slID.station();
192  stringstream sector;
193  sector << slID.sector();
194  stringstream superLayer;
195  superLayer << slID.superlayer();
196 
197  string HistoName = "W" + wheel.str() + "_Sec" + sector.str();
198  string supLayer = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str();
199 
200  MonitorElement* res_histo = igetter.get(getMEName(slID));
201  if (res_histo) {
202  // gaussian test
203  string GaussianCriterionName =
204  parameters.getUntrackedParameter<string>("resDistributionTestName", "ResidualsDistributionGaussianTest");
205  const QReport* GaussianReport = res_histo->getQReport(GaussianCriterionName);
206  if (GaussianReport) {
207  // FIXE ME: if the quality test fails this cout returns a null pointer
208  //edm::LogWarning ("resolution") << "-------- SuperLayer : "<<supLayer<<" "
209  // <<GaussianReport->getMessage()<<" ------- "<<GaussianReport->getStatus();
210  }
211  int BinNumber = entry + slID.superLayer();
212  if (BinNumber == 12)
213  BinNumber = 11;
214  float mean = (*res_histo).getMean(1);
215  float sigma = (*res_histo).getRMS(1);
216  MeanHistos.find(make_pair(slID.wheel(), slID.sector()))->second->setBinContent(BinNumber, mean);
217  if (parameters.getUntrackedParameter<bool>("sigmaTest"))
218  SigmaHistos.find(make_pair(slID.wheel(), slID.sector()))->second->setBinContent(BinNumber, sigma);
219  }
220 
221  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
222  MonitorElement* res_histo_2D = igetter.get(getMEName2D(slID));
223  if (res_histo_2D) {
224  TH2F* res_histo_2D_root = res_histo_2D->getTH2F();
225  int BinNumber = entry + slID.superLayer();
226  if (BinNumber == 12)
227  BinNumber = 11;
228  TProfile* prof = res_histo_2D_root->ProfileX();
229  prof->GetXaxis()->SetRangeUser(0, 2);
230  //prof->Fit("pol1","Q0");
231  //need our own copy to avoid threading problems
232  TF1 fitting("mypol1", "pol1");
233  try {
234  prof->Fit(&fitting, "Q0");
235  } catch (cms::Exception& iException) {
236  edm::LogError("resolution") << "[DTResolutionTest]: Exception when fitting..."
237  << "SuperLayer : " << slID << "\n"
238  << " STEP : "
239  << parameters.getUntrackedParameter<string>("STEP", "STEP3") << "\n"
240  << "Filling slope histogram with standard value -99. for bin " << BinNumber;
241  SlopeHistos.find(make_pair(slID.wheel(), slID.sector()))->second->setBinContent(BinNumber, -99.);
242  continue;
243  }
244  double slope = fitting.GetParameter(1);
245  SlopeHistos.find(make_pair(slID.wheel(), slID.sector()))->second->setBinContent(BinNumber, slope);
246  }
247  }
248  }
249  }
250 
251  // Mean test
252  string MeanCriterionName = parameters.getUntrackedParameter<string>("meanTestName", "ResidualsMeanInRange");
253  for (map<pair<int, int>, MonitorElement*>::const_iterator hMean = MeanHistos.begin(); hMean != MeanHistos.end();
254  hMean++) {
255  const QReport* theMeanQReport = (*hMean).second->getQReport(MeanCriterionName);
256  stringstream wheel;
257  wheel << (*hMean).first.first;
258  stringstream sector;
259  sector << (*hMean).first.second;
260  // Report the channels failing the test on the mean
261  if (theMeanQReport) {
262  vector<dqm::me_util::Channel> badChannels = theMeanQReport->getBadChannels();
263  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
264  channel++) {
265  edm::LogError("resolution") << "Bad mean channel: wh: " << wheel.str()
266  << " st: " << stationFromBin((*channel).getBin()) << " sect: " << sector.str()
267  << " sl: " << slFromBin((*channel).getBin())
268  << " mean (cm): " << (*channel).getContents();
269  string HistoName = "W" + wheel.str() + "_Sec" + sector.str();
270  if (parameters.getUntrackedParameter<bool>("meanWrongHisto")) {
271  MeanHistosSetRange.find(HistoName)->second->Fill((*channel).getBin());
272  MeanHistosSetRange2D.find(HistoName)->second->Fill((*channel).getBin(), (*channel).getContents());
273  }
274  // fill the wheel summary histos if the SL has not passed the test
275  if (abs((*channel).getContents()) < parameters.getUntrackedParameter<double>("meanMaxLimit"))
276  wheelMeanHistos[(*hMean).first.first]->Fill(((*hMean).first.second) - 1, (*channel).getBin() - 1, 1);
277  else
278  wheelMeanHistos[(*hMean).first.first]->Fill(((*hMean).first.second) - 1, (*channel).getBin() - 1, 2);
279  // fill the cms summary histo if the percentual of SL which have not passed the test
280  // is more than a predefined treshold
281  if (abs((*channel).getContents()) > parameters.getUntrackedParameter<double>("meanMaxLimit")) {
282  cmsMeanHistos[make_pair((*hMean).first.first, (*hMean).first.second)]++;
283  if (((*hMean).first.second < 13 &&
284  double(cmsMeanHistos[make_pair((*hMean).first.first, (*hMean).first.second)]) / 11 >
285  double(percentual) / 100 &&
286  MeanFilled[make_pair((*hMean).first.first, (*hMean).first.second)] == false) ||
287  ((*hMean).first.first >= 13 &&
288  double(cmsMeanHistos[make_pair((*hMean).first.first, (*hMean).first.second)]) / 2 >
289  double(percentual) / 100 &&
290  MeanFilled[make_pair((*hMean).first.first, (*hMean).first.second)] == false)) {
291  MeanFilled[make_pair((*hMean).first.first, (*hMean).first.second)] = true;
292  wheelMeanHistos[3]->Fill(((*hMean).first.second) - 1, (*hMean).first.first);
293  }
294  }
295  }
296  }
297  }
298 
299  // Sigma test
300  if (parameters.getUntrackedParameter<bool>("sigmaTest")) {
301  string SigmaCriterionName = parameters.getUntrackedParameter<string>("sigmaTestName", "ResidualsSigmaInRange");
302  for (map<pair<int, int>, MonitorElement*>::const_iterator hSigma = SigmaHistos.begin(); hSigma != SigmaHistos.end();
303  hSigma++) {
304  const QReport* theSigmaQReport = (*hSigma).second->getQReport(SigmaCriterionName);
305  stringstream wheel;
306  wheel << (*hSigma).first.first;
307  stringstream sector;
308  sector << (*hSigma).first.second;
309  if (theSigmaQReport) {
310  vector<dqm::me_util::Channel> badChannels = theSigmaQReport->getBadChannels();
311  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
312  channel++) {
313  edm::LogError("resolution") << "Bad sigma: wh: " << wheel.str()
314  << " st: " << stationFromBin((*channel).getBin()) << " sect: " << sector.str()
315  << " sl: " << slFromBin((*channel).getBin())
316  << " sigma (cm): " << (*channel).getContents();
317  string HistoName = "W" + wheel.str() + "_Sec" + sector.str();
318  SigmaHistosSetRange.find(HistoName)->second->Fill((*channel).getBin());
319  SigmaHistosSetRange2D.find(HistoName)->second->Fill((*channel).getBin(), (*channel).getContents());
320  // fill the wheel summary histos if the SL has not passed the test
321  wheelSigmaHistos[(*hSigma).first.first]->Fill(((*hSigma).first.second) - 1, (*channel).getBin() - 1);
322  // fill the cms summary histo if the percentual of SL which have not passed the test
323  // is more than a predefined treshold
324  cmsSigmaHistos[make_pair((*hSigma).first.first, (*hSigma).first.second)]++;
325  if (((*hSigma).first.second < 13 &&
326  double(cmsSigmaHistos[make_pair((*hSigma).first.first, (*hSigma).first.second)]) / 11 >
327  double(percentual) / 100 &&
328  SigmaFilled[make_pair((*hSigma).first.first, (*hSigma).first.second)] == false) ||
329  ((*hSigma).first.first >= 13 &&
330  double(cmsSigmaHistos[make_pair((*hSigma).first.first, (*hSigma).first.second)]) / 2 >
331  double(percentual) / 100 &&
332  SigmaFilled[make_pair((*hSigma).first.first, (*hSigma).first.second)] == false)) {
333  SigmaFilled[make_pair((*hSigma).first.first, (*hSigma).first.second)] = true;
334  wheelSigmaHistos[3]->Fill((*hSigma).first.second - 1, (*hSigma).first.first);
335  }
336  }
337  }
338  }
339  }
340 
341  // Slope test
342  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
343  string SlopeCriterionName = parameters.getUntrackedParameter<string>("slopeTestName", "ResidualsSlopeInRange");
344  for (map<pair<int, int>, MonitorElement*>::const_iterator hSlope = SlopeHistos.begin(); hSlope != SlopeHistos.end();
345  hSlope++) {
346  const QReport* theSlopeQReport = (*hSlope).second->getQReport(SlopeCriterionName);
347  stringstream wheel;
348  wheel << (*hSlope).first.first;
349  stringstream sector;
350  sector << (*hSlope).first.second;
351  if (theSlopeQReport) {
352  vector<dqm::me_util::Channel> badChannels = theSlopeQReport->getBadChannels();
353  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
354  channel++) {
355  edm::LogError("resolution") << "Bad slope: wh: " << wheel.str()
356  << " st: " << stationFromBin((*channel).getBin()) << " sect: " << sector.str()
357  << " sl: " << slFromBin((*channel).getBin())
358  << " slope: " << (*channel).getContents();
359  string HistoName = "W" + wheel.str() + "_Sec" + sector.str();
360  SlopeHistosSetRange.find(HistoName)->second->Fill((*channel).getBin());
361  SlopeHistosSetRange2D.find(HistoName)->second->Fill((*channel).getBin(), (*channel).getContents());
362  // fill the wheel summary histos if the SL has not passed the test
363  wheelSlopeHistos[(*hSlope).first.first]->Fill(((*hSlope).first.second) - 1, (*channel).getBin() - 1);
364  // fill the cms summary histo if the percentual of SL which have not passed the test
365  // is more than a predefined treshold
366  cmsSlopeHistos[make_pair((*hSlope).first.first, (*hSlope).first.second)]++;
367  if (((*hSlope).first.second < 13 &&
368  double(cmsSlopeHistos[make_pair((*hSlope).first.first, (*hSlope).first.second)]) / 11 >
369  double(percentual) / 100 &&
370  SlopeFilled[make_pair((*hSlope).first.first, (*hSlope).first.second)] == false) ||
371  ((*hSlope).first.first >= 13 &&
372  double(cmsSlopeHistos[make_pair((*hSlope).first.first, (*hSlope).first.second)]) / 2 >
373  double(percentual) / 100 &&
374  SlopeFilled[make_pair((*hSlope).first.first, (*hSlope).first.second)] == false)) {
375  SlopeFilled[make_pair((*hSlope).first.first, (*hSlope).first.second)] = true;
376  wheelSlopeHistos[3]->Fill((*hSlope).first.second - 1, (*hSlope).first.first);
377  }
378  }
379  }
380  }
381  }
382 }
383 
385  edm::LogVerbatim("resolution") << "[DTResolutionTest] endjob called!";
386 
387  //FR: no idea if this output file needs to be written!! comment it for now
388  //bool outputMEsInRootFile = parameters.getParameter<bool>("OutputMEsInRootFile");
389  //if(outputMEsInRootFile){
390  // std::string outputFileName = parameters.getParameter<std::string>("OutputFileName");
391  // dbe->save(outputFileName,"DT/CalibrationSummary");
392  //}
393 }
394 
396  stringstream wheel;
397  wheel << slID.wheel();
398  stringstream station;
399  station << slID.station();
400  stringstream sector;
401  sector << slID.sector();
402  stringstream superLayer;
403  superLayer << slID.superlayer();
404 
405  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
406  string folderName;
407 
408  if (parameters.getUntrackedParameter<bool>("calibModule", false)) {
409  folderName = folderRoot + "DT/DTCalibValidation/Wheel" + wheel.str() + "/Station" + station.str() + "/Sector" +
410  sector.str() + "/";
411  } else {
412  folderName = folderRoot + "DT/DTResolutionAnalysisTask/Wheel" + wheel.str() + "/Station" + station.str() +
413  "/Sector" + sector.str() + "/";
414  }
415 
416  string histoTag = parameters.getUntrackedParameter<string>("histoTag", "hResDist");
417 
418  string histoname = folderName + histoTag + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() +
419  "_SL" + superLayer.str();
420 
421  return histoname;
422 }
423 
425  stringstream wheel;
426  wheel << slID.wheel();
427  stringstream station;
428  station << slID.station();
429  stringstream sector;
430  sector << slID.sector();
431  stringstream superLayer;
432  superLayer << slID.superlayer();
433 
434  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
435  string folderName;
436 
437  if (parameters.getUntrackedParameter<bool>("calibModule", false)) {
438  folderName = folderRoot + "DT/DTCalibValidation/Wheel" + wheel.str() + "/Station" + station.str() + "/Sector" +
439  sector.str() + "/";
440  } else {
441  folderName = folderRoot + "DT/DTResolutionAnalysisTask/Wheel" + wheel.str() + "/Station" + station.str() +
442  "/Sector" + sector.str() + "/";
443  }
444 
445  string histoTag2D = parameters.getUntrackedParameter<string>("histoTag2D", "hResDistVsDist");
446 
447  string histoname = folderName + histoTag2D + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() +
448  "_SL" + superLayer.str();
449 
450  return histoname;
451 }
452 
454  stringstream wheel;
455  wheel << ch.wheel();
456  stringstream sector;
457  sector << ch.sector();
458 
459  string MeanHistoName = "MeanTest_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" + wheel.str() +
460  "_Sec" + sector.str();
461  string SigmaHistoName = "SigmaTest_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
462  wheel.str() + "_Sec" + sector.str();
463  string SlopeHistoName = "SlopeTest_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
464  wheel.str() + "_Sec" + sector.str();
465 
466  ibooker.setCurrentFolder("DT/Tests/DTResolution");
467 
468  // Book the histo for the mean value and set the axis labels
469 
470  MeanHistos[make_pair(ch.wheel(), ch.sector())] =
471  ibooker.book1D(MeanHistoName.c_str(), MeanHistoName.c_str(), 11, 0, 11);
472  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(1, "MB1_SL1", 1);
473  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(2, "MB1_SL2", 1);
474  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(3, "MB1_SL3", 1);
475  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(4, "MB2_SL1", 1);
476  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(5, "MB2_SL2", 1);
477  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(6, "MB2_SL3", 1);
478  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(7, "MB3_SL1", 1);
479  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(8, "MB3_SL2", 1);
480  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(9, "MB3_SL3", 1);
481  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(10, "MB4_SL1", 1);
482  (MeanHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(11, "MB4_SL3", 1);
483 
484  // Book the histo for the sigma value and set the axis labels
485  if (parameters.getUntrackedParameter<bool>("sigmaTest")) {
486  SigmaHistos[make_pair(ch.wheel(), ch.sector())] =
487  ibooker.book1D(SigmaHistoName.c_str(), SigmaHistoName.c_str(), 11, 0, 11);
488  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(1, "MB1_SL1", 1);
489  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(2, "MB1_SL2", 1);
490  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(3, "MB1_SL3", 1);
491  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(4, "MB2_SL1", 1);
492  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(5, "MB2_SL2", 1);
493  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(6, "MB2_SL3", 1);
494  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(7, "MB3_SL1", 1);
495  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(8, "MB3_SL2", 1);
496  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(9, "MB3_SL3", 1);
497  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(10, "MB4_SL1", 1);
498  (SigmaHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(11, "MB4_SL3", 1);
499  }
500 
501  // Book the histo for the slope value and set the axis labels
502  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
503  SlopeHistos[make_pair(ch.wheel(), ch.sector())] =
504  ibooker.book1D(SlopeHistoName.c_str(), SlopeHistoName.c_str(), 11, 0, 11);
505  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(1, "MB1_SL1", 1);
506  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(2, "MB1_SL2", 1);
507  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(3, "MB1_SL3", 1);
508  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(4, "MB2_SL1", 1);
509  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(5, "MB2_SL2", 1);
510  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(6, "MB2_SL3", 1);
511  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(7, "MB3_SL1", 1);
512  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(8, "MB3_SL2", 1);
513  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(9, "MB3_SL3", 1);
514  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(10, "MB4_SL1", 1);
515  (SlopeHistos[make_pair(ch.wheel(), ch.sector())])->setBinLabel(11, "MB4_SL3", 1);
516  }
517 
518  string HistoName = "W" + wheel.str() + "_Sec" + sector.str();
519 
520  if (parameters.getUntrackedParameter<bool>("meanWrongHisto")) {
521  string MeanHistoNameSetRange = "MeanWrong_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
522  wheel.str() + "_Sec" + sector.str() + "_SetRange";
523 
525  ibooker.book1D(MeanHistoNameSetRange.c_str(), MeanHistoNameSetRange.c_str(), 11, 0.5, 11.5);
526  string MeanHistoNameSetRange2D = "MeanWrong_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
527  wheel.str() + "_Sec" + sector.str() + "_SetRange" + "_2D";
529  MeanHistoNameSetRange2D.c_str(), MeanHistoNameSetRange2D.c_str(), 11, 0.5, 11.5, 100, -0.05, 0.05);
530  }
531 
532  if (parameters.getUntrackedParameter<bool>("sigmaTest")) {
533  string SigmaHistoNameSetRange = "SigmaWrong_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
534  wheel.str() + "_Sec" + sector.str() + "_SetRange";
535 
537  ibooker.book1D(SigmaHistoNameSetRange.c_str(), SigmaHistoNameSetRange.c_str(), 11, 0.5, 11.5);
538  string SigmaHistoNameSetRange2D = "SigmaWrong_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
539  wheel.str() + "_Sec" + sector.str() + "_SetRange" + "_2D";
540 
542  ibooker.book2D(SigmaHistoNameSetRange2D.c_str(), SigmaHistoNameSetRange2D.c_str(), 11, 0.5, 11.5, 500, 0, 0.5);
543  }
544 
545  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
546  string SlopeHistoNameSetRange = "SlopeWrong_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
547  wheel.str() + "_Sec" + sector.str() + "_SetRange";
548 
550  ibooker.book1D(SlopeHistoNameSetRange.c_str(), SlopeHistoNameSetRange.c_str(), 11, 0.5, 11.5);
551  string SlopeHistoNameSetRange2D = "SlopeWrong_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" +
552  wheel.str() + "_Sec" + sector.str() + "_SetRange" + "_2D";
553 
555  SlopeHistoNameSetRange2D.c_str(), SlopeHistoNameSetRange2D.c_str(), 11, 0.5, 11.5, 200, -0.1, 0.1);
556  }
557 }
558 
560  ibooker.setCurrentFolder("DT/CalibrationSummary");
561 
562  if (wheelMeanHistos.find(3) == wheelMeanHistos.end()) {
563  string histoName =
564  "MeanSummaryRes_testFailedByAtLeastBadSL_" + parameters.getUntrackedParameter<string>("STEP", "STEP3");
565 
566  wheelMeanHistos[3] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 14, 0, 14, 5, -2, 3);
567  wheelMeanHistos[3]->setBinLabel(1, "Sector1", 1);
568  wheelMeanHistos[3]->setBinLabel(1, "Sector1", 1);
569  wheelMeanHistos[3]->setBinLabel(2, "Sector2", 1);
570  wheelMeanHistos[3]->setBinLabel(3, "Sector3", 1);
571  wheelMeanHistos[3]->setBinLabel(4, "Sector4", 1);
572  wheelMeanHistos[3]->setBinLabel(5, "Sector5", 1);
573  wheelMeanHistos[3]->setBinLabel(6, "Sector6", 1);
574  wheelMeanHistos[3]->setBinLabel(7, "Sector7", 1);
575  wheelMeanHistos[3]->setBinLabel(8, "Sector8", 1);
576  wheelMeanHistos[3]->setBinLabel(9, "Sector9", 1);
577  wheelMeanHistos[3]->setBinLabel(10, "Sector10", 1);
578  wheelMeanHistos[3]->setBinLabel(11, "Sector11", 1);
579  wheelMeanHistos[3]->setBinLabel(12, "Sector12", 1);
580  wheelMeanHistos[3]->setBinLabel(13, "Sector13", 1);
581  wheelMeanHistos[3]->setBinLabel(14, "Sector14", 1);
582  wheelMeanHistos[3]->setBinLabel(1, "Wheel-2", 2);
583  wheelMeanHistos[3]->setBinLabel(2, "Wheel-1", 2);
584  wheelMeanHistos[3]->setBinLabel(3, "Wheel0", 2);
585  wheelMeanHistos[3]->setBinLabel(4, "Wheel+1", 2);
586  wheelMeanHistos[3]->setBinLabel(5, "Wheel+2", 2);
587  }
588 
589  if (parameters.getUntrackedParameter<bool>("sigmaTest")) {
590  if (wheelSigmaHistos.find(3) == wheelSigmaHistos.end()) {
591  string histoName =
592  "SigmaSummaryRes_testFailedByAtLeastBadSL_" + parameters.getUntrackedParameter<string>("STEP", "STEP3");
593 
594  wheelSigmaHistos[3] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 14, 0, 14, 5, -2, 3);
595  wheelSigmaHistos[3]->setBinLabel(1, "Sector1", 1);
596  wheelSigmaHistos[3]->setBinLabel(1, "Sector1", 1);
597  wheelSigmaHistos[3]->setBinLabel(2, "Sector2", 1);
598  wheelSigmaHistos[3]->setBinLabel(3, "Sector3", 1);
599  wheelSigmaHistos[3]->setBinLabel(4, "Sector4", 1);
600  wheelSigmaHistos[3]->setBinLabel(5, "Sector5", 1);
601  wheelSigmaHistos[3]->setBinLabel(6, "Sector6", 1);
602  wheelSigmaHistos[3]->setBinLabel(7, "Sector7", 1);
603  wheelSigmaHistos[3]->setBinLabel(8, "Sector8", 1);
604  wheelSigmaHistos[3]->setBinLabel(9, "Sector9", 1);
605  wheelSigmaHistos[3]->setBinLabel(10, "Sector10", 1);
606  wheelSigmaHistos[3]->setBinLabel(11, "Sector11", 1);
607  wheelSigmaHistos[3]->setBinLabel(12, "Sector12", 1);
608  wheelSigmaHistos[3]->setBinLabel(13, "Sector13", 1);
609  wheelSigmaHistos[3]->setBinLabel(14, "Sector14", 1);
610  wheelSigmaHistos[3]->setBinLabel(1, "Wheel-2", 2);
611  wheelSigmaHistos[3]->setBinLabel(2, "Wheel-1", 2);
612  wheelSigmaHistos[3]->setBinLabel(3, "Wheel0", 2);
613  wheelSigmaHistos[3]->setBinLabel(4, "Wheel+1", 2);
614  wheelSigmaHistos[3]->setBinLabel(5, "Wheel+2", 2);
615  }
616  }
617 
618  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
619  if (wheelSlopeHistos.find(3) == wheelSlopeHistos.end()) {
620  string histoName =
621  "SlopeSummaryRes_testFailedByAtLeastBadSL_" + parameters.getUntrackedParameter<string>("STEP", "STEP3");
622 
623  wheelSlopeHistos[3] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 14, 0, 14, 5, -2, 3);
624  wheelSlopeHistos[3]->setBinLabel(1, "Sector1", 1);
625  wheelSlopeHistos[3]->setBinLabel(1, "Sector1", 1);
626  wheelSlopeHistos[3]->setBinLabel(2, "Sector2", 1);
627  wheelSlopeHistos[3]->setBinLabel(3, "Sector3", 1);
628  wheelSlopeHistos[3]->setBinLabel(4, "Sector4", 1);
629  wheelSlopeHistos[3]->setBinLabel(5, "Sector5", 1);
630  wheelSlopeHistos[3]->setBinLabel(6, "Sector6", 1);
631  wheelSlopeHistos[3]->setBinLabel(7, "Sector7", 1);
632  wheelSlopeHistos[3]->setBinLabel(8, "Sector8", 1);
633  wheelSlopeHistos[3]->setBinLabel(9, "Sector9", 1);
634  wheelSlopeHistos[3]->setBinLabel(10, "Sector10", 1);
635  wheelSlopeHistos[3]->setBinLabel(11, "Sector11", 1);
636  wheelSlopeHistos[3]->setBinLabel(12, "Sector12", 1);
637  wheelSlopeHistos[3]->setBinLabel(13, "Sector13", 1);
638  wheelSlopeHistos[3]->setBinLabel(14, "Sector14", 1);
639  wheelSlopeHistos[3]->setBinLabel(1, "Wheel-2", 2);
640  wheelSlopeHistos[3]->setBinLabel(2, "Wheel-1", 2);
641  wheelSlopeHistos[3]->setBinLabel(3, "Wheel0", 2);
642  wheelSlopeHistos[3]->setBinLabel(4, "Wheel+1", 2);
643  wheelSlopeHistos[3]->setBinLabel(5, "Wheel+2", 2);
644  }
645  }
646 
647  stringstream wheel;
648  wheel << wh;
649 
650  if (wheelMeanHistos.find(wh) == wheelMeanHistos.end()) {
651  string histoName =
652  "MeanSummaryRes_testFailed_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") + "_W" + wheel.str();
653 
654  wheelMeanHistos[wh] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 14, 0, 14, 11, 0, 11);
655  wheelMeanHistos[wh]->setBinLabel(1, "Sector1", 1);
656  wheelMeanHistos[wh]->setBinLabel(2, "Sector2", 1);
657  wheelMeanHistos[wh]->setBinLabel(3, "Sector3", 1);
658  wheelMeanHistos[wh]->setBinLabel(4, "Sector4", 1);
659  wheelMeanHistos[wh]->setBinLabel(5, "Sector5", 1);
660  wheelMeanHistos[wh]->setBinLabel(6, "Sector6", 1);
661  wheelMeanHistos[wh]->setBinLabel(7, "Sector7", 1);
662  wheelMeanHistos[wh]->setBinLabel(8, "Sector8", 1);
663  wheelMeanHistos[wh]->setBinLabel(9, "Sector9", 1);
664  wheelMeanHistos[wh]->setBinLabel(10, "Sector10", 1);
665  wheelMeanHistos[wh]->setBinLabel(11, "Sector11", 1);
666  wheelMeanHistos[wh]->setBinLabel(12, "Sector12", 1);
667  wheelMeanHistos[wh]->setBinLabel(13, "Sector13", 1);
668  wheelMeanHistos[wh]->setBinLabel(14, "Sector14", 1);
669  wheelMeanHistos[wh]->setBinLabel(1, "MB1_SL1", 2);
670  wheelMeanHistos[wh]->setBinLabel(2, "MB1_SL2", 2);
671  wheelMeanHistos[wh]->setBinLabel(3, "MB1_SL3", 2);
672  wheelMeanHistos[wh]->setBinLabel(4, "MB2_SL1", 2);
673  wheelMeanHistos[wh]->setBinLabel(5, "MB2_SL2", 2);
674  wheelMeanHistos[wh]->setBinLabel(6, "MB2_SL3", 2);
675  wheelMeanHistos[wh]->setBinLabel(7, "MB3_SL1", 2);
676  wheelMeanHistos[wh]->setBinLabel(8, "MB3_SL2", 2);
677  wheelMeanHistos[wh]->setBinLabel(9, "MB3_SL3", 2);
678  wheelMeanHistos[wh]->setBinLabel(10, "MB4_SL1", 2);
679  wheelMeanHistos[wh]->setBinLabel(11, "MB4_SL3", 2);
680  }
681 
682  if (parameters.getUntrackedParameter<bool>("sigmaTest")) {
683  if (wheelSigmaHistos.find(wh) == wheelSigmaHistos.end()) {
684  string histoName = "SigmaSummaryRes_testFailed_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") +
685  "_W" + wheel.str();
686 
687  wheelSigmaHistos[wh] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 14, 0, 14, 11, 0, 11);
688  wheelSigmaHistos[wh]->setBinLabel(1, "Sector1", 1);
689  wheelSigmaHistos[wh]->setBinLabel(2, "Sector2", 1);
690  wheelSigmaHistos[wh]->setBinLabel(3, "Sector3", 1);
691  wheelSigmaHistos[wh]->setBinLabel(4, "Sector4", 1);
692  wheelSigmaHistos[wh]->setBinLabel(5, "Sector5", 1);
693  wheelSigmaHistos[wh]->setBinLabel(6, "Sector6", 1);
694  wheelSigmaHistos[wh]->setBinLabel(7, "Sector7", 1);
695  wheelSigmaHistos[wh]->setBinLabel(8, "Sector8", 1);
696  wheelSigmaHistos[wh]->setBinLabel(9, "Sector9", 1);
697  wheelSigmaHistos[wh]->setBinLabel(10, "Sector10", 1);
698  wheelSigmaHistos[wh]->setBinLabel(11, "Sector11", 1);
699  wheelSigmaHistos[wh]->setBinLabel(12, "Sector12", 1);
700  wheelSigmaHistos[wh]->setBinLabel(13, "Sector13", 1);
701  wheelSigmaHistos[wh]->setBinLabel(14, "Sector14", 1);
702  wheelSigmaHistos[wh]->setBinLabel(1, "MB1_SL1", 2);
703  wheelSigmaHistos[wh]->setBinLabel(2, "MB1_SL2", 2);
704  wheelSigmaHistos[wh]->setBinLabel(3, "MB1_SL3", 2);
705  wheelSigmaHistos[wh]->setBinLabel(4, "MB2_SL1", 2);
706  wheelSigmaHistos[wh]->setBinLabel(5, "MB2_SL2", 2);
707  wheelSigmaHistos[wh]->setBinLabel(6, "MB2_SL3", 2);
708  wheelSigmaHistos[wh]->setBinLabel(7, "MB3_SL1", 2);
709  wheelSigmaHistos[wh]->setBinLabel(8, "MB3_SL2", 2);
710  wheelSigmaHistos[wh]->setBinLabel(9, "MB3_SL3", 2);
711  wheelSigmaHistos[wh]->setBinLabel(10, "MB4_SL1", 2);
712  wheelSigmaHistos[wh]->setBinLabel(11, "MB4_SL3", 2);
713  }
714  }
715 
716  if (parameters.getUntrackedParameter<bool>("slopeTest")) {
717  if (wheelSlopeHistos.find(wh) == wheelSlopeHistos.end()) {
718  string histoName = "SlopeSummaryRes_testFailed_" + parameters.getUntrackedParameter<string>("STEP", "STEP3") +
719  "_W" + wheel.str();
720 
721  wheelSlopeHistos[wh] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 14, 0, 14, 11, 0, 11);
722  wheelSlopeHistos[wh]->setBinLabel(1, "Sector1", 1);
723  wheelSlopeHistos[wh]->setBinLabel(2, "Sector2", 1);
724  wheelSlopeHistos[wh]->setBinLabel(3, "Sector3", 1);
725  wheelSlopeHistos[wh]->setBinLabel(4, "Sector4", 1);
726  wheelSlopeHistos[wh]->setBinLabel(5, "Sector5", 1);
727  wheelSlopeHistos[wh]->setBinLabel(6, "Sector6", 1);
728  wheelSlopeHistos[wh]->setBinLabel(7, "Sector7", 1);
729  wheelSlopeHistos[wh]->setBinLabel(8, "Sector8", 1);
730  wheelSlopeHistos[wh]->setBinLabel(9, "Sector9", 1);
731  wheelSlopeHistos[wh]->setBinLabel(10, "Sector10", 1);
732  wheelSlopeHistos[wh]->setBinLabel(11, "Sector11", 1);
733  wheelSlopeHistos[wh]->setBinLabel(12, "Sector12", 1);
734  wheelSlopeHistos[wh]->setBinLabel(13, "Sector13", 1);
735  wheelSlopeHistos[wh]->setBinLabel(14, "Sector14", 1);
736  wheelSlopeHistos[wh]->setBinLabel(1, "MB1_SL1", 2);
737  wheelSlopeHistos[wh]->setBinLabel(2, "MB1_SL2", 2);
738  wheelSlopeHistos[wh]->setBinLabel(3, "MB1_SL3", 2);
739  wheelSlopeHistos[wh]->setBinLabel(4, "MB2_SL1", 2);
740  wheelSlopeHistos[wh]->setBinLabel(5, "MB2_SL2", 2);
741  wheelSlopeHistos[wh]->setBinLabel(6, "MB2_SL3", 2);
742  wheelSlopeHistos[wh]->setBinLabel(7, "MB3_SL1", 2);
743  wheelSlopeHistos[wh]->setBinLabel(8, "MB3_SL2", 2);
744  wheelSlopeHistos[wh]->setBinLabel(9, "MB3_SL3", 2);
745  wheelSlopeHistos[wh]->setBinLabel(10, "MB4_SL1", 2);
746  wheelSlopeHistos[wh]->setBinLabel(11, "MB4_SL3", 2);
747  }
748  }
749 }
750 
751 int DTResolutionTest::stationFromBin(int bin) const { return (int)(bin / 3.1) + 1; }
752 
754  int ret = bin % 3;
755  if (ret == 0 || bin == 11)
756  ret = 3;
757 
758  return ret;
759 }
Log< level::Info, true > LogVerbatim
DTResolutionTest(const edm::ParameterSet &ps)
Constructor.
int station() const
Return the station number.
Definition: DTChamberId.h:42
~DTResolutionTest() override
Destructor.
std::map< std::pair< int, int >, int > cmsMeanHistos
std::map< std::string, MonitorElement * > MeanHistosSetRange
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
LuminosityBlockNumber_t luminosityBlock() const
edm::ParameterSet parameters
int superLayer() const
Return the superlayer number.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
ret
prodAgent to be discontinued
static const double slope[3]
const std::vector< DQMChannel > & getBadChannels() const
std::map< std::pair< int, int >, MonitorElement * > MeanHistos
std::map< std::pair< int, int >, MonitorElement * > SlopeHistos
Log< level::Error, false > LogError
std::map< std::pair< int, int >, bool > MeanFilled
std::map< std::string, MonitorElement * > SigmaHistosSetRange2D
std::string getMEName(const DTSuperLayerId &slID)
Get the ME name.
std::map< std::pair< int, int >, int > cmsSigmaHistos
T getUntrackedParameter(std::string const &, T const &) const
std::map< std::pair< int, int >, MonitorElement * > SigmaHistos
void bookHistos(DQMStore::IBooker &, const DTChamberId &ch)
book the new ME
std::map< std::string, MonitorElement * > MeanHistosSetRange2D
virtual TH2F * getTH2F() const
unsigned int nLumiSegs
int slFromBin(int bin) const
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Endjob.
const MonitorElementData::QReport * getQReport(const std::string &qtname) const
get QReport corresponding to <qtname> (null pointer if QReport does not exist)
int stationFromBin(int bin) const
std::map< std::string, MonitorElement * > SlopeHistosSetRange2D
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Transition
Definition: Transition.h:12
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::map< std::pair< int, int >, int > cmsSlopeHistos
int superlayer() const
Return the superlayer number (deprecated method name)
LuminosityBlockID id() const
std::map< std::string, MonitorElement * > SigmaHistosSetRange
std::string getMEName2D(const DTSuperLayerId &slID)
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:212
std::map< int, MonitorElement * > wheelMeanHistos
std::map< int, MonitorElement * > wheelSigmaHistos
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:697
std::map< std::pair< int, int >, bool > SigmaFilled
std::string HistoName
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
HLT enums.
int sector() const
Definition: DTChamberId.h:49
const DTGeometry * muonGeom
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
std::map< std::string, MonitorElement * > SlopeHistosSetRange
std::map< int, MonitorElement * > wheelSlopeHistos
std::map< std::pair< int, int >, bool > SlopeFilled