CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripQualityChecker.cc
Go to the documentation of this file.
6 
8 
10 
14 
17 
20 
21 
22 #include <iomanip>
23 //
24 // -- Constructor
25 //
27  edm::LogInfo("SiStripQualityChecker") <<
28  " Creating SiStripQualityChecker " << "\n" ;
29 
30  bookedStripStatus_ = false;
31  bookedTrackingStatus_ = false;
32 
33  SubDetFolderMap.insert(std::pair<std::string, std::string>("TIB", "TIB"));
34  SubDetFolderMap.insert(std::pair<std::string, std::string>("TOB", "TOB"));
35  SubDetFolderMap.insert(std::pair<std::string, std::string>("TECF", "TEC/side_2"));
36  SubDetFolderMap.insert(std::pair<std::string, std::string>("TECB", "TEC/side_1"));
37  SubDetFolderMap.insert(std::pair<std::string, std::string>("TIDF", "TID/side_2"));
38  SubDetFolderMap.insert(std::pair<std::string, std::string>("TIDB", "TID/side_1"));
39  badModuleList.clear();
40 
41  if(!edm::Service<TkDetMap>().isAvailable()){
42  edm::LogError("TkHistoMap") <<
43  "\n------------------------------------------"
44  "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
45  "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
46  "\n------------------------------------------";
47  }
49 
50  TrackingMEs tracking_mes;
51  edm::ParameterSet TkPSet;
52 
53  TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackRatePSet");
54  tracking_mes.TrackingFlag = 0;
55  tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
56  tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
57  tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
58  TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>("Rate", tracking_mes));
59 
60  TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackChi2PSet");
61  tracking_mes.TrackingFlag = 0;
62  tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
63  tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
64  tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
65  TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>("Chi2", tracking_mes));
66 
67  TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackHitPSet");
68  tracking_mes.TrackingFlag = 0;
69  tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
70  tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
71  tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
72  TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>("RecHits", tracking_mes));
73 
74 // // LS analysis
75 // TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackRateLSPSet");
76 // tracking_mes.TrackingFlag = 0;
77 // tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
78 // tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
79 // tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
80 // TrackingMEsLSMap.insert(std::pair<std::string, TrackingMEs>("Rate", tracking_mes));
81 //
82 // TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackChi2LSPSet");
83 // tracking_mes.TrackingFlag = 0;
84 // tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
85 // tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
86 // tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
87 // TrackingMEsLSMap.insert(std::pair<std::string, TrackingMEs>("Chi2", tracking_mes));
88 //
89 // TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackHitLSPSet");
90 // tracking_mes.TrackingFlag = 0;
91 // tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
92 // tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
93 // tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
94 // TrackingMEsLSMap.insert(std::pair<std::string, TrackingMEs>("RecHits", tracking_mes));
95 
96  useGoodTracks_ = pSet_.getUntrackedParameter<bool>("UseGoodTracks", false);
97  if (useGoodTracks_) edm::LogInfo("SiStripQualityChecker") << " use GoodTrack histograms for certification " << "\n" ;
98 }
99 //
100 // -- Destructor
101 //
103  edm::LogInfo("SiStripQualityChecker") <<
104  " Deleting SiStripQualityChecker " << "\n" ;
105 }
106 //
107 // -- create reportSummary MEs
108 //
110 
111  if (!bookedStripStatus_) {
112  dqm_store->cd();
113  std::string strip_dir = "";
114  SiStripUtility::getTopFolderPath(dqm_store, "SiStrip", strip_dir);
115  if (strip_dir.size() == 0) strip_dir = "SiStrip";
116 
117  // Non Standard Plots and should be put outside EventInfo folder
118 
119  dqm_store->setCurrentFolder(strip_dir+"/MechanicalView");
120 
121  std::string hname, htitle;
122  hname = "detFractionReportMap";
123  htitle = "SiStrip Report for Good Detector Fraction";
124  DetFractionReportMap = dqm_store->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
125  DetFractionReportMap->setAxisTitle("Sub Detector Type", 1);
126  DetFractionReportMap->setAxisTitle("Layer/Disc Number", 2);
127  hname = "sToNReportMap";
128  htitle = "SiStrip Report for Signal-to-Noise";
129  SToNReportMap = dqm_store->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
130  SToNReportMap->setAxisTitle("Sub Detector Type", 1);
131  SToNReportMap->setAxisTitle("Layer/Disc Number", 2);
132 
133  // this is the main reportSummary 2D plot and should be in EventInfo
134  dqm_store->setCurrentFolder(strip_dir+"/EventInfo");
135 
136  hname = "reportSummaryMap";
137  htitle = "SiStrip Report Summary Map";
138  SummaryReportMap = dqm_store->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
139  SummaryReportMap->setAxisTitle("Sub Detector Type", 1);
140  SummaryReportMap->setAxisTitle("Layer/Disc Number", 2);
141 
142  SummaryReportGlobal = dqm_store->bookFloat("reportSummary");
143  int ibin = 0;
144 
145  dqm_store->setCurrentFolder(strip_dir+"/EventInfo/reportSummaryContents");
146  for (std::map<std::string, std::string>::const_iterator it = SubDetFolderMap.begin();
147  it != SubDetFolderMap.end(); it++) {
148  ibin++;
149  std::string det = it->first;
151  SToNReportMap->setBinLabel(ibin,det);
152  SummaryReportMap->setBinLabel(ibin,det);
153 
154  SubDetMEs local_mes;
155 
156  if (det == "TECF") local_mes.detectorTag = "TEC+";
157  else if (det == "TECB") local_mes.detectorTag = "TEC-";
158  else if (det == "TIDF") local_mes.detectorTag = "TID+";
159  else if (det == "TIDB") local_mes.detectorTag = "TID-";
160  else local_mes.detectorTag = det;
161 
162  std::string me_name;
163  me_name = "SiStrip_" + det;
164  local_mes.SummaryFlag = dqm_store->bookFloat(me_name);
165 
166  me_name = "SiStrip_DetFraction_" + det;
167  local_mes.DetFraction = dqm_store->bookFloat(me_name);
168 
169  me_name = "SiStrip_SToNFlag_" + det;
170  local_mes.SToNFlag = dqm_store->bookFloat(me_name);
171  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs>(det, local_mes));
172  }
173  bookedStripStatus_ = true;
174  }
175  if (!bookedTrackingStatus_) {
176  dqm_store->cd();
177  std::string tracking_dir = "";
178  SiStripUtility::getTopFolderPath(dqm_store, "Tracking", tracking_dir);
179  if (tracking_dir.size() == 0) tracking_dir = "Tracking";
180  dqm_store->setCurrentFolder(tracking_dir+"/EventInfo");
181 
182  TrackSummaryReportGlobal = dqm_store->bookFloat("reportSummary");
183 
184  std::string hname, htitle;
185  hname = "reportSummaryMap";
186  htitle = "Tracking Report Summary Map";
187 
188  TrackSummaryReportMap = dqm_store->book2D(hname, htitle, 3,0.5,3.5,1,0.5,1.5);
189  TrackSummaryReportMap->setAxisTitle("Track Quality Type", 1);
190  TrackSummaryReportMap->setAxisTitle("QTest Flag", 2);
193  TrackSummaryReportMap->setBinLabel(3,"RecHits");
194 
195  dqm_store->setCurrentFolder(tracking_dir+"/EventInfo/reportSummaryContents");
196  int ibin = 0;
197  for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
198  it != TrackingMEsMap.end(); it++) {
199  ibin++;
200  std::string name = it->first;
201  it->second.TrackingFlag = dqm_store->bookFloat("Track"+name);
203  }
204  bookedTrackingStatus_ = true;
205  dqm_store->cd();
206  }
207 }
208 //
209 // -- Fill Dummy Status
210 //
212 
213  resetStatus();
214  if (bookedStripStatus_) {
215  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
216  it != SubDetMEsMap.end(); it++) {
217  SubDetMEs local_mes = it->second;
218  local_mes.DetFraction->Fill(-1.0);
219  local_mes.SToNFlag->Fill(-1.0);
220  local_mes.SummaryFlag->Fill(-1.0);
221  }
222 
223  for (int xbin = 1; xbin < SummaryReportMap->getNbinsX()+1; xbin++) {
224  for (int ybin = 1; ybin < SummaryReportMap->getNbinsY()+1; ybin++) {
225  DetFractionReportMap->Fill(xbin, ybin, -1.0);
226  SToNReportMap->Fill(xbin, ybin, -1.0);
227  SummaryReportMap->Fill(xbin, ybin, -1.0);
228  }
229  }
230  SummaryReportGlobal->Fill(-1.0);
231  }
232  if (bookedTrackingStatus_) {
234  for (int xbin = 1; xbin < TrackSummaryReportMap->getNbinsX()+1; xbin++) {
235  for (int ybin = 1; ybin < TrackSummaryReportMap->getNbinsY()+1; ybin++) {
236  TrackSummaryReportMap->Fill(xbin, ybin, -1.0);
237  }
238  }
239  for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
240  it != TrackingMEsMap.end(); it++) {
241  it->second.TrackingFlag->Fill(-1.0);
242  }
243  /*
244  for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsLSMap.begin();
245  it != TrackingMEsLSMap.end(); it++) {
246  it->second.TrackingFlag->Fill(-1.0);
247  }
248  */
249  }
250 }
251 //
252 // -- Reset Status
253 //
255  if (bookedStripStatus_) {
256  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
257  it != SubDetMEsMap.end(); it++) {
258  SubDetMEs local_mes = it->second;
259  local_mes.DetFraction->Reset();
260  local_mes.SToNFlag->Reset();
261  local_mes.SummaryFlag->Reset();
262  }
263 
265  SToNReportMap->Reset();
267 
269  }
270  if (bookedTrackingStatus_) {
273  for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
274  it != TrackingMEsMap.end(); it++) {
275  it->second.TrackingFlag->Reset();
276  }
277  /*
278  for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsLSMap.begin();
279  it != TrackingMEsLSMap.end(); it++) {
280  it->second.TrackingFlag->Reset();
281  }
282  */
283  }
284 }
285 //
286 // -- Fill Status
287 //
290 
291  fillDummyStatus();
292  fillDetectorStatus(dqm_store, cabling);
293  fillTrackingStatus(dqm_store);
294 
295  int faulty_moduleflag = pSet_.getUntrackedParameter<bool>("PrintFaultyModuleList", false);
296  if (faulty_moduleflag) fillFaultyModuleStatus(dqm_store, eSetup);
297 }
298 //
299 // Fill Detector Status
300 //
302  unsigned int xbin = 0;
303  float global_flag = 0;
304  dqm_store->cd();
305  std::string mdir = "MechanicalView";
306  if (!SiStripUtility::goToDir(dqm_store, mdir)) return;
307  std::string mechanicalview_dir = dqm_store->pwd();
308 
310  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
311  it != SubDetMEsMap.end(); it++) {
312  std::string det = it->first;
313  std::map<std::string, std::string>::const_iterator cPos = SubDetFolderMap.find(det);
314  if (cPos == SubDetFolderMap.end()) continue;
315  std::string dname = mechanicalview_dir + "/" + cPos->second;
316  if (!dqm_store->dirExists(dname)) continue;
317  dqm_store->cd(dname);
318  SubDetMEs local_mes = it->second;
319  xbin++;
320  float flag;
321  fillSubDetStatus(dqm_store, cabling, local_mes, xbin,flag);
322  global_flag += flag;
323  }
324  global_flag = global_flag/xbin*1.0;
325  if (SummaryReportGlobal) SummaryReportGlobal->Fill(global_flag);
326  dqm_store->cd();
327 }
328 //
329 // -- Fill Tracking Status
330 //
332 
333  dqm_store->cd();
334  std::string dir = "Tracking";
335  if (!SiStripUtility::goToDir(dqm_store, dir)) return;
336  dir = "TrackParameters";
337  if (!SiStripUtility::goToDir(dqm_store, dir)) return;
338 
339  std::vector<MonitorElement*> meVec1;
340  std::vector<MonitorElement*> meVec2;
341  if (useGoodTracks_){
342  meVec1 = dqm_store->getContents(dqm_store->pwd()+"/GeneralProperties/GoodTracks");
343  meVec2 = dqm_store->getContents(dqm_store->pwd()+"/HitProperties/GoodTracks");
344  }else{
345  meVec1 = dqm_store->getContents(dqm_store->pwd()+"/GeneralProperties");
346  meVec2 = dqm_store->getContents(dqm_store->pwd()+"/HitProperties");
347  }
348  std::vector<MonitorElement*> meVec(meVec1.size() + meVec2.size());
349  std::merge(meVec1.begin(), meVec1.end(), meVec2.begin(), meVec2.end(), meVec.begin());
350 
351  float gstatus = 1.0;
352  for (std::vector<MonitorElement*>::const_iterator itME = meVec.begin(); itME != meVec.end(); itME++) {
353  MonitorElement * me = (*itME);
354  if (!me) continue;
355  std::vector<QReport *> qt_reports = me->getQReports();
356  if (qt_reports.size() == 0) continue;
357  std::string name = me->getName();
358 
359  float status = 1.0;
360 
361  int ibin = 0;
362  for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
363  it != TrackingMEsMap.end(); it++) {
364  ibin++;
365  std::string hname = it->second.HistoName;
366  if (name.find(hname) != std::string::npos) {
367  status = qt_reports[0]->getQTresult();
368  it->second.TrackingFlag->Fill(status);
369  fillStatusHistogram(TrackSummaryReportMap, ibin, 1, status);
370  break;
371  }
372  }
373  gstatus = gstatus * status;
374  }
375  TrackSummaryReportGlobal->Fill(gstatus);
376  dqm_store->cd();
377 }
378 //
379 // -- Fill Sub detector Reports
380 //
382  const edm::ESHandle< SiStripDetCabling >& cabling,
383  SubDetMEs& mes, unsigned int xbin, float& gflag) {
384  int status_flag = pSet_.getUntrackedParameter<int>("GlobalStatusFilling", 1);
385 
386  if (status_flag < 1) return;
387 
388  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
389 
390  unsigned int ybin = 0;
391  int tot_ndet = 0;
392  int tot_errdet = 0;
393  float tot_ston_stat = 0;
394 
395  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
396  ic != subDirVec.end(); ic++) {
397  std::string dname = (*ic);
398  if (dname.find("BadModuleList") != std::string::npos) continue;
399  std::vector<MonitorElement*> meVec;
400  ybin++;
401  dqm_store->cd((*ic));
402  meVec = dqm_store->getContents((*ic));
403  uint16_t ndet = 100;
404  int errdet = 0;
405 
406  int ston_stat = 1;
407  int lnum = atoi(dname.substr(dname.find_last_of("_")+1).c_str());
408  ndet = cabling->connectedNumber(mes.detectorTag, lnum);
409 
410  getModuleStatus(dqm_store, meVec, errdet);
411 
412  for (std::vector<MonitorElement*>::const_iterator it = meVec.begin();
413  it != meVec.end(); it++) {
414  MonitorElement * me = (*it);
415  if (!me) continue;
416  std::vector<QReport *> reports = me->getQReports();
417 
418  if (reports.size() == 0) continue;
419  std::string name = me->getName();
420 
421  if( name.find("Summary_ClusterStoNCorr__OnTrack") != std::string::npos){
422  int istat = SiStripUtility::getMEStatus((*it));
423  if (reports[0]->getQTresult() == -1) {
424  ston_stat =-1;
425  } else {
426  if (istat == dqm::qstatus::ERROR) ston_stat = 0;
427  else if (istat == dqm::qstatus::STATUS_OK) ston_stat = 1;
428  }
429  }
430  }
431  if (ndet > 0) {
432  float eff_fac = 1 - (errdet*1.0/ndet);
433  fillStatusHistogram(SToNReportMap, xbin, ybin, ston_stat);
434  fillStatusHistogram(DetFractionReportMap, xbin, ybin, eff_fac);
435  if (ston_stat < 0) fillStatusHistogram(SummaryReportMap, xbin, ybin, eff_fac);
436  else fillStatusHistogram(SummaryReportMap, xbin, ybin, ston_stat*eff_fac);
437 
438  tot_ndet += ndet;
439  tot_errdet += errdet;
440  tot_ston_stat += ston_stat;
441  }
442  dqm_store->cd((*ic));
443  }
444  if (tot_ndet > 0) {
445  float tot_eff_fac = 1 - (tot_errdet*1.0/tot_ndet);
446  if (mes.DetFraction) mes.DetFraction->Fill(tot_eff_fac);
447  float tot_ston_fac = tot_ston_stat/ybin;
448  if (mes.SToNFlag) mes.SToNFlag->Fill(tot_ston_fac);
449  if (tot_ston_fac < 0){
450  gflag = tot_eff_fac;
451  }else{
452  gflag = std::min(tot_eff_fac,tot_ston_fac);
453  }
454  if (mes.SummaryFlag) mes.SummaryFlag->Fill(gflag);
455  }
456 }
457 //
458 // -- Print Status Report
459 //
461  std::ostringstream det_summary_str;
462  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
463  it != SubDetMEsMap.end(); it++) {
464  std::string det = it->first;
465  det_summary_str << std::setprecision(4);
466  det_summary_str << std::setiosflags(std::ios::fixed);
467 
468  det_summary_str << " Printing Status for " << det << " : " << std::endl;
469  SubDetMEs local_mes = it->second;
470 
471  std::string sval;
472  float fval1, fval2, fval3;
473  fval1 = fval2 = fval3 = -1.0;
474 
475 
476  SiStripUtility::getMEValue(local_mes.DetFraction, sval);
477  if (sval.size() > 0) fval1 = atof(sval.c_str());
478  SiStripUtility::getMEValue(local_mes.SToNFlag, sval);
479  if (sval.size() > 0) fval2 = atof(sval.c_str());
480  SiStripUtility::getMEValue(local_mes.SummaryFlag, sval);
481  if (sval.size() > 0) fval3 = atof(sval.c_str());
482 
483  det_summary_str << std::setw(7) << " % of good detectors " << fval1
484  << " SToN Flag " << fval2
485  << " Summary Flag " << fval3 << std::endl;
486  }
487 }
488 //
489 // -- Get Module Status from Layer Level Histograms
490 //
491 void SiStripQualityChecker::getModuleStatus(DQMStore* dqm_store, std::vector<MonitorElement*>& layer_mes,int& errdet) {
492 
493  std::string lname;
494  std::map<uint32_t,uint16_t> bad_modules;
495  for (std::vector<MonitorElement*>::const_iterator it = layer_mes.begin();
496  it != layer_mes.end(); it++) {
497  MonitorElement * me = (*it);
498  if (!me) continue;
499  std::vector<QReport *> qreports = me->getQReports();
500  if (qreports.size() == 0) continue;
501  std::string name = me->getName();
502  std::vector<DQMChannel> bad_channels_me;
504  bad_channels_me = qreports[0]->getBadChannels();
505  lname = "";
506  } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D && name.find("TkHMap") != std::string::npos) {
507  bad_channels_me = qreports[0]->getBadChannels();
508  lname = name.substr(name.find("TkHMap_")+7);
509  lname = lname.substr(lname.find("_T")+1);
510 
511  }
512  for (std::vector<DQMChannel>::iterator it = bad_channels_me.begin(); it != bad_channels_me.end(); it++){
513  int xval = (*it).getBinX();
514  int yval = (*it).getBinY();
515  uint32_t detId = tkDetMap_->getDetFromBin(lname, xval, yval);
516  std::map<uint32_t,uint16_t>::iterator iPos = bad_modules.find(detId);
517  uint16_t flag;
518  if (iPos != bad_modules.end()){
519  flag = iPos->second;
521  iPos->second = flag;
522  } else {
523  //
524  //if not in the local bad module list, check the BadModuleList dir
525  //
526  std::ostringstream detid_str;
527  detid_str << detId;
528  //now in the layer/wheel dir
529  std::string currentdir = dqm_store->pwd();
530  std::string thisMEpath = currentdir.substr( 0 , currentdir.rfind( "/" ) ) + "/BadModuleList/" + detid_str.str() ;
531 
532  MonitorElement *meBadModule = dqm_store->get ( thisMEpath );
533  if ( meBadModule )
534  {
535  std::string val_str;
536  SiStripUtility::getMEValue ( meBadModule , val_str );
537  flag = atoi ( val_str.c_str() );
538  }
539  else
540  flag = 0;
541 
543  bad_modules.insert(std::pair<uint32_t,uint16_t>(detId,flag));
544  }
545  }
546  }
547  for(std::map<uint32_t,uint16_t>::const_iterator it = bad_modules.begin();
548  it != bad_modules.end(); it++) {
549  uint32_t detId = it->first;
550  uint16_t flag = it->second;
551  std::map<uint32_t,uint16_t>::iterator iPos = badModuleList.find(detId);
552  if (iPos != badModuleList.end()){
553  iPos->second = flag;
554  } else {
555  badModuleList.insert(std::pair<uint32_t,uint16_t>(detId,flag));
556  }
557  }
558  errdet = bad_modules.size();
559 }
560 //
561 // -- Fill Report Summary Map
562 //
563  void SiStripQualityChecker::fillStatusHistogram(MonitorElement* me, int xbin, int ybin, float val){
564  if (me && me->kind() == MonitorElement::DQM_KIND_TH2F) {
565  TH2F* th2d = me->getTH2F();
566  th2d->SetBinContent(xbin, ybin, val);
567  }
568  }
569 //
570 // -- Create Monitor Elements for Modules
571 //
573  if (badModuleList.size() == 0) return;
574 
575  //Retrieve tracker topology from geometry
576  edm::ESHandle<TrackerTopology> tTopoHandle;
577  eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
578  const TrackerTopology* const tTopo = tTopoHandle.product();
579 
580  dqm_store->cd();
581  std::string mdir = "MechanicalView";
582  if (!SiStripUtility::goToDir(dqm_store, mdir)) return;
583  std::string mechanical_dir = dqm_store->pwd();
584 
585  SiStripFolderOrganizer folder_organizer;
586  for (std::map<uint32_t,uint16_t>::const_iterator it = badModuleList.begin() ; it != badModuleList.end(); it++) {
587  uint32_t detId = it->first;
588  std::string subdet_folder ;
589  folder_organizer.getSubDetFolder(detId,tTopo,subdet_folder);
590  if (!dqm_store->dirExists(subdet_folder)) {
591  subdet_folder = mechanical_dir + subdet_folder.substr(subdet_folder.find("MechanicalView")+14);
592  if (!dqm_store->dirExists(subdet_folder)) continue;
593  }
594  std::string bad_module_folder = subdet_folder + "/" + "BadModuleList";
595  dqm_store->setCurrentFolder(bad_module_folder);
596 
597  std::ostringstream detid_str;
598  detid_str << detId;
599  std::string full_path = bad_module_folder + "/" + detid_str.str();
600  MonitorElement* me = dqm_store->get(full_path);
601  if (me) me->Reset();
602  else me = dqm_store->bookInt(detid_str.str());
603  me->Fill(it->second);
604  }
605  dqm_store->cd();
606 }
607 //
608 // -- Initialise Bad Module List
609 //
611  for (std::map<uint32_t,uint16_t>::iterator it=badModuleList.begin(); it!=badModuleList.end(); it++) {
612  it->second = 0;
613  }
614 }
615 //
616 // -- Fill Status information and the lumi block
617 //
620  fillDummyStatus();
621  fillDetectorStatusAtLumi(dqm_store);
622  fillTrackingStatusAtLumi(dqm_store);
623 }
624 //
625 // Fill Detector Status MEs at the Lumi block
626 //
628  dqm_store->cd();
629  std::string rdir = "ReadoutView";
630  if (!SiStripUtility::goToDir(dqm_store, rdir)) return;
631  std::string fullpath = dqm_store->pwd()
632  + "/FedSummary/PerLumiSection/"
633  + "lumiErrorFraction";
634  MonitorElement* me = dqm_store->get(fullpath);
635  if (me && me->kind() == MonitorElement::DQM_KIND_TH1F) {
636  TH1F* th1 = me->getTH1F();
637  float global_fraction = 0.0;
638  float dets = 0.0;
639  for (int ibin = 1; ibin <= th1->GetNbinsX(); ibin++) {
640  std::string label = th1->GetXaxis()->GetBinLabel(ibin);
641  std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(label);
642  if (iPos != SubDetMEsMap.end()) {
643  float fraction = 1.0 - th1->GetBinContent(ibin);
644  global_fraction += fraction;
645  dets++;
646  iPos->second.DetFraction->Fill(fraction);
647  iPos->second.SToNFlag->Fill(-1.0);
648  iPos->second.SummaryFlag->Fill(fraction);
649  }
650  }
651  global_fraction = global_fraction/dets;
652  if (SummaryReportGlobal) SummaryReportGlobal->Fill(global_fraction);
653  }
654  dqm_store->cd();
655 }
656 //
657 // Fill Tracking Status MEs at the Lumi block
658 //
660  dqm_store->cd();
661  std::string dir = "Tracking";
662  if (!SiStripUtility::goToDir(dqm_store, dir)) return;
663  dir = "TrackParameters";
664  if (!SiStripUtility::goToDir(dqm_store, dir)) return;
665 
666  std::vector<MonitorElement*> meVec1;
667  std::vector<MonitorElement*> meVec2;
668  if (useGoodTracks_){
669  meVec1 = dqm_store->getContents(dqm_store->pwd()+"/LSanalysis");
670  // meVec2 = dqm_store->getContents(dqm_store->pwd()+"/HitProperties/LSanalysis");
671  }else{
672  meVec1 = dqm_store->getContents(dqm_store->pwd()+"/GeneralProperties");
673  meVec2 = dqm_store->getContents(dqm_store->pwd()+"/HitProperties");
674  }
675  std::vector<MonitorElement*> meVec(meVec1.size() + meVec2.size());
676  std::merge(meVec1.begin(), meVec1.end(), meVec2.begin(), meVec2.end(), meVec.begin());
677 
678  float gstatus = 1.0;
679  for (std::vector<MonitorElement*>::const_iterator itME = meVec.begin(); itME != meVec.end(); itME++) {
680  MonitorElement * me = (*itME);
681  if (!me) continue;
682  std::string name = me->getName();
683 
684  float status = -1.0;
685  int ibin = 0;
686  for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
687  it != TrackingMEsMap.end(); it++) {
688  ibin++;
689  std::string hname = it->second.HistoName+"lumiFlag_";
690  float lower_cut = it->second.LowerCut;
691  float upper_cut = it->second.UpperCut;
692  if (name.find(hname) != std::string::npos) {
693  if (me->getMean() <= lower_cut || me->getMean() > upper_cut) status = 0.0;
694  else status = 1.0;
695  it->second.TrackingFlag->Fill(status);
696  fillStatusHistogram(TrackSummaryReportMap, ibin, 1, status);
697  break;
698  } else {
699  }
700  }
701  if (status == -1.0) gstatus = -1.0;
702  else gstatus = gstatus * status;
703  }
704  TrackSummaryReportGlobal->Fill(gstatus);
705  dqm_store->cd();
706 }
void fillStatus(DQMStore *dqm_store, const edm::ESHandle< SiStripDetCabling > &cabling, const edm::EventSetup &eSetup)
static void setBadModuleFlag(std::string &hname, uint16_t &flg)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
long int flag
Definition: mlp_lapack.h:47
uint32_t getDetFromBin(int layer, int ix, int iy)
Definition: TkDetMap.h:126
void getSubDetFolder(const uint32_t &detid, const TrackerTopology *tTopo, std::string &folder_name)
void bookStatus(DQMStore *dqm_store)
void fillDetectorStatusAtLumi(DQMStore *dqm_store)
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1424
void fillDetectorStatus(DQMStore *dqm_store, const edm::ESHandle< SiStripDetCabling > &cabling)
static void getMEValue(MonitorElement *me, std::string &val)
std::map< std::string, std::string > SubDetFolderMap
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:411
void getModuleStatus(DQMStore *dqm_store, std::vector< MonitorElement * > &layer_mes, int &errdet)
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)
#define min(a, b)
Definition: mlp_lapack.h:161
tuple currentdir
parse figure configuration if found
Definition: lumiPlot.py:48
void fillTrackingStatusAtLumi(DQMStore *dqm_store)
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
SiStripQualityChecker(edm::ParameterSet const &ps)
int getNbinsY(void) const
get # of bins in Y-axis
void Fill(long long x)
std::map< std::string, SubDetMEs > SubDetMEsMap
void fillFaultyModuleStatus(DQMStore *dqm_store, const edm::EventSetup &eSetup)
Kind kind(void) const
Get the type of the monitor element.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1502
MonitorElement * DetFractionReportMap
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:498
std::vector< QReport * > getQReports(void) const
get map of QReports
static int getMEStatus(MonitorElement *me)
const T & get() const
Definition: EventSetup.h:55
MonitorElement * TrackSummaryReportGlobal
T const * product() const
Definition: ESHandle.h:62
TH1F * getTH1F(void) const
void fillStatusAtLumi(DQMStore *dqm_store)
MonitorElement * SummaryReportMap
MonitorElement * SummaryReportGlobal
MonitorElement * SToNReportMap
void fillTrackingStatus(DQMStore *dqm_store)
int getNbinsX(void) const
get # of bins in X-axis
static const int STATUS_OK
MonitorElement * TrackSummaryReportMap
std::map< uint32_t, uint16_t > badModuleList
std::map< std::string, TrackingMEs > TrackingMEsMap
dbl *** dir
Definition: mlp_gen.cc:35
tuple status
Definition: ntuplemaker.py:245
TH2F * getTH2F(void) const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:629
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:850
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
void fillSubDetStatus(DQMStore *dqm_store, const edm::ESHandle< SiStripDetCabling > &cabling, SubDetMEs &mes, unsigned int xbin, float &gflag)
static bool goToDir(DQMStore *dqm_store, std::string name)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
static const int ERROR
void fillStatusHistogram(MonitorElement *, int xbin, int ybin, float val)
const std::string & pwd(void) const
Definition: DQMStore.cc:406
static void getTopFolderPath(DQMStore *dqm_store, std::string type, std::string &path)