00001 #include "DQM/SiStripMonitorClient/interface/SiStripQualityChecker.h"
00002 #include "FWCore/ServiceRegistry/interface/Service.h"
00003 #include "DQMServices/Core/interface/DQMStore.h"
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "DQMServices/Core/interface/QReport.h"
00006
00007 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00008
00009 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
00010
00011 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00012 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00013 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00014
00015 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00016 #include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
00017
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020
00021
00022 #include <iomanip>
00023
00024
00025
00026 SiStripQualityChecker::SiStripQualityChecker(edm::ParameterSet const& ps):pSet_(ps) {
00027 edm::LogInfo("SiStripQualityChecker") <<
00028 " Creating SiStripQualityChecker " << "\n" ;
00029
00030 bookedStripStatus_ = false;
00031 bookedTrackingStatus_ = false;
00032
00033 SubDetFolderMap.insert(std::pair<std::string, std::string>("TIB", "TIB"));
00034 SubDetFolderMap.insert(std::pair<std::string, std::string>("TOB", "TOB"));
00035 SubDetFolderMap.insert(std::pair<std::string, std::string>("TECF", "TEC/side_2"));
00036 SubDetFolderMap.insert(std::pair<std::string, std::string>("TECB", "TEC/side_1"));
00037 SubDetFolderMap.insert(std::pair<std::string, std::string>("TIDF", "TID/side_2"));
00038 SubDetFolderMap.insert(std::pair<std::string, std::string>("TIDB", "TID/side_1"));
00039 badModuleList.clear();
00040
00041 if(!edm::Service<TkDetMap>().isAvailable()){
00042 edm::LogError("TkHistoMap") <<
00043 "\n------------------------------------------"
00044 "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
00045 "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
00046 "\n------------------------------------------";
00047 }
00048 tkDetMap_=edm::Service<TkDetMap>().operator->();
00049
00050 TrackingMEs tracking_mes;
00051 edm::ParameterSet TkPSet;
00052
00053 TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackRatePSet");
00054 tracking_mes.TrackingFlag = 0;
00055 tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
00056 tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
00057 tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
00058 TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>("Rate", tracking_mes));
00059
00060 TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackChi2PSet");
00061 tracking_mes.TrackingFlag = 0;
00062 tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
00063 tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
00064 tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
00065 TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>("Chi2", tracking_mes));
00066
00067 TkPSet = pSet_.getParameter<edm::ParameterSet>("TrackHitPSet");
00068 tracking_mes.TrackingFlag = 0;
00069 tracking_mes.HistoName = TkPSet.getParameter<std::string>("Name");
00070 tracking_mes.LowerCut = TkPSet.getParameter<double>("LowerCut");
00071 tracking_mes.UpperCut = TkPSet.getParameter<double>("UpperCut");
00072 TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>("RecHits", tracking_mes));
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 useGoodTracks_ = pSet_.getUntrackedParameter<bool>("UseGoodTracks", false);
00097 if (useGoodTracks_) edm::LogInfo("SiStripQualityChecker") << " use GoodTrack histograms for certification " << "\n" ;
00098 }
00099
00100
00101
00102 SiStripQualityChecker::~SiStripQualityChecker() {
00103 edm::LogInfo("SiStripQualityChecker") <<
00104 " Deleting SiStripQualityChecker " << "\n" ;
00105 }
00106
00107
00108
00109 void SiStripQualityChecker::bookStatus(DQMStore* dqm_store) {
00110
00111 if (!bookedStripStatus_) {
00112 dqm_store->cd();
00113 std::string strip_dir = "";
00114 SiStripUtility::getTopFolderPath(dqm_store, "SiStrip", strip_dir);
00115 if (strip_dir.size() == 0) strip_dir = "SiStrip";
00116
00117
00118
00119 dqm_store->setCurrentFolder(strip_dir+"/MechanicalView");
00120
00121 std::string hname, htitle;
00122 hname = "detFractionReportMap";
00123 htitle = "SiStrip Report for Good Detector Fraction";
00124 DetFractionReportMap = dqm_store->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
00125 DetFractionReportMap->setAxisTitle("Sub Detector Type", 1);
00126 DetFractionReportMap->setAxisTitle("Layer/Disc Number", 2);
00127 hname = "sToNReportMap";
00128 htitle = "SiStrip Report for Signal-to-Noise";
00129 SToNReportMap = dqm_store->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
00130 SToNReportMap->setAxisTitle("Sub Detector Type", 1);
00131 SToNReportMap->setAxisTitle("Layer/Disc Number", 2);
00132
00133
00134 dqm_store->setCurrentFolder(strip_dir+"/EventInfo");
00135
00136 hname = "reportSummaryMap";
00137 htitle = "SiStrip Report Summary Map";
00138 SummaryReportMap = dqm_store->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
00139 SummaryReportMap->setAxisTitle("Sub Detector Type", 1);
00140 SummaryReportMap->setAxisTitle("Layer/Disc Number", 2);
00141
00142 SummaryReportGlobal = dqm_store->bookFloat("reportSummary");
00143 int ibin = 0;
00144
00145 dqm_store->setCurrentFolder(strip_dir+"/EventInfo/reportSummaryContents");
00146 for (std::map<std::string, std::string>::const_iterator it = SubDetFolderMap.begin();
00147 it != SubDetFolderMap.end(); it++) {
00148 ibin++;
00149 std::string det = it->first;
00150 DetFractionReportMap->setBinLabel(ibin,det);
00151 SToNReportMap->setBinLabel(ibin,det);
00152 SummaryReportMap->setBinLabel(ibin,det);
00153
00154 SubDetMEs local_mes;
00155
00156 if (det == "TECF") local_mes.detectorTag = "TEC+";
00157 else if (det == "TECB") local_mes.detectorTag = "TEC-";
00158 else if (det == "TIDF") local_mes.detectorTag = "TID+";
00159 else if (det == "TIDB") local_mes.detectorTag = "TID-";
00160 else local_mes.detectorTag = det;
00161
00162 std::string me_name;
00163 me_name = "SiStrip_" + det;
00164 local_mes.SummaryFlag = dqm_store->bookFloat(me_name);
00165
00166 me_name = "SiStrip_DetFraction_" + det;
00167 local_mes.DetFraction = dqm_store->bookFloat(me_name);
00168
00169 me_name = "SiStrip_SToNFlag_" + det;
00170 local_mes.SToNFlag = dqm_store->bookFloat(me_name);
00171 SubDetMEsMap.insert(std::pair<std::string, SubDetMEs>(det, local_mes));
00172 }
00173 bookedStripStatus_ = true;
00174 }
00175 if (!bookedTrackingStatus_) {
00176 dqm_store->cd();
00177 std::string tracking_dir = "";
00178 SiStripUtility::getTopFolderPath(dqm_store, "Tracking", tracking_dir);
00179 if (tracking_dir.size() == 0) tracking_dir = "Tracking";
00180 dqm_store->setCurrentFolder(tracking_dir+"/EventInfo");
00181
00182 TrackSummaryReportGlobal = dqm_store->bookFloat("reportSummary");
00183
00184 std::string hname, htitle;
00185 hname = "reportSummaryMap";
00186 htitle = "Tracking Report Summary Map";
00187
00188 TrackSummaryReportMap = dqm_store->book2D(hname, htitle, 3,0.5,3.5,1,0.5,1.5);
00189 TrackSummaryReportMap->setAxisTitle("Track Quality Type", 1);
00190 TrackSummaryReportMap->setAxisTitle("QTest Flag", 2);
00191 TrackSummaryReportMap->setBinLabel(1,"Rate");
00192 TrackSummaryReportMap->setBinLabel(2,"Chi2");
00193 TrackSummaryReportMap->setBinLabel(3,"RecHits");
00194
00195 dqm_store->setCurrentFolder(tracking_dir+"/EventInfo/reportSummaryContents");
00196 int ibin = 0;
00197 for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
00198 it != TrackingMEsMap.end(); it++) {
00199 ibin++;
00200 std::string name = it->first;
00201 it->second.TrackingFlag = dqm_store->bookFloat("Track"+name);
00202 TrackSummaryReportMap->setBinLabel(ibin,name);
00203 }
00204 bookedTrackingStatus_ = true;
00205 dqm_store->cd();
00206 }
00207 }
00208
00209
00210
00211 void SiStripQualityChecker::fillDummyStatus(){
00212
00213 resetStatus();
00214 if (bookedStripStatus_) {
00215 for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
00216 it != SubDetMEsMap.end(); it++) {
00217 SubDetMEs local_mes = it->second;
00218 local_mes.DetFraction->Fill(-1.0);
00219 local_mes.SToNFlag->Fill(-1.0);
00220 local_mes.SummaryFlag->Fill(-1.0);
00221 }
00222
00223 for (int xbin = 1; xbin < SummaryReportMap->getNbinsX()+1; xbin++) {
00224 for (int ybin = 1; ybin < SummaryReportMap->getNbinsY()+1; ybin++) {
00225 DetFractionReportMap->Fill(xbin, ybin, -1.0);
00226 SToNReportMap->Fill(xbin, ybin, -1.0);
00227 SummaryReportMap->Fill(xbin, ybin, -1.0);
00228 }
00229 }
00230 SummaryReportGlobal->Fill(-1.0);
00231 }
00232 if (bookedTrackingStatus_) {
00233 TrackSummaryReportGlobal->Fill(-1.0);
00234 for (int xbin = 1; xbin < TrackSummaryReportMap->getNbinsX()+1; xbin++) {
00235 for (int ybin = 1; ybin < TrackSummaryReportMap->getNbinsY()+1; ybin++) {
00236 TrackSummaryReportMap->Fill(xbin, ybin, -1.0);
00237 }
00238 }
00239 for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
00240 it != TrackingMEsMap.end(); it++) {
00241 it->second.TrackingFlag->Fill(-1.0);
00242 }
00243
00244
00245
00246
00247
00248
00249 }
00250 }
00251
00252
00253
00254 void SiStripQualityChecker::resetStatus() {
00255 if (bookedStripStatus_) {
00256 for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
00257 it != SubDetMEsMap.end(); it++) {
00258 SubDetMEs local_mes = it->second;
00259 local_mes.DetFraction->Reset();
00260 local_mes.SToNFlag->Reset();
00261 local_mes.SummaryFlag->Reset();
00262 }
00263
00264 DetFractionReportMap->Reset();
00265 SToNReportMap->Reset();
00266 SummaryReportMap->Reset();
00267
00268 SummaryReportGlobal->Reset();
00269 }
00270 if (bookedTrackingStatus_) {
00271 TrackSummaryReportGlobal->Reset();
00272 TrackSummaryReportMap->Reset();
00273 for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
00274 it != TrackingMEsMap.end(); it++) {
00275 it->second.TrackingFlag->Reset();
00276 }
00277
00278
00279
00280
00281
00282
00283 }
00284 }
00285
00286
00287
00288 void SiStripQualityChecker::fillStatus(DQMStore* dqm_store, const edm::ESHandle< SiStripDetCabling >& cabling, const edm::EventSetup& eSetup) {
00289 if (!bookedStripStatus_ || !bookedTrackingStatus_) bookStatus(dqm_store);
00290
00291 fillDummyStatus();
00292 fillDetectorStatus(dqm_store, cabling);
00293 fillTrackingStatus(dqm_store);
00294
00295 int faulty_moduleflag = pSet_.getUntrackedParameter<bool>("PrintFaultyModuleList", false);
00296 if (faulty_moduleflag) fillFaultyModuleStatus(dqm_store, eSetup);
00297 }
00298
00299
00300
00301 void SiStripQualityChecker::fillDetectorStatus(DQMStore* dqm_store, const edm::ESHandle< SiStripDetCabling >& cabling) {
00302 unsigned int xbin = 0;
00303 float global_flag = 0;
00304 dqm_store->cd();
00305 std::string mdir = "MechanicalView";
00306 if (!SiStripUtility::goToDir(dqm_store, mdir)) return;
00307 std::string mechanicalview_dir = dqm_store->pwd();
00308
00309 initialiseBadModuleList();
00310 for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
00311 it != SubDetMEsMap.end(); it++) {
00312 std::string det = it->first;
00313 std::map<std::string, std::string>::const_iterator cPos = SubDetFolderMap.find(det);
00314 if (cPos == SubDetFolderMap.end()) continue;
00315 std::string dname = mechanicalview_dir + "/" + cPos->second;
00316 if (!dqm_store->dirExists(dname)) continue;
00317 dqm_store->cd(dname);
00318 SubDetMEs local_mes = it->second;
00319 xbin++;
00320 float flag;
00321 fillSubDetStatus(dqm_store, cabling, local_mes, xbin,flag);
00322 global_flag += flag;
00323 }
00324 global_flag = global_flag/xbin*1.0;
00325 if (SummaryReportGlobal) SummaryReportGlobal->Fill(global_flag);
00326 dqm_store->cd();
00327 }
00328
00329
00330
00331 void SiStripQualityChecker::fillTrackingStatus(DQMStore* dqm_store) {
00332
00333 dqm_store->cd();
00334 std::string dir = "Tracking";
00335 if (!SiStripUtility::goToDir(dqm_store, dir)) return;
00336 dir = "TrackParameters";
00337 if (!SiStripUtility::goToDir(dqm_store, dir)) return;
00338
00339 std::vector<MonitorElement*> meVec1;
00340 std::vector<MonitorElement*> meVec2;
00341 if (useGoodTracks_){
00342 meVec1 = dqm_store->getContents(dqm_store->pwd()+"/GeneralProperties/GoodTracks");
00343 meVec2 = dqm_store->getContents(dqm_store->pwd()+"/HitProperties/GoodTracks");
00344 }else{
00345 meVec1 = dqm_store->getContents(dqm_store->pwd()+"/GeneralProperties");
00346 meVec2 = dqm_store->getContents(dqm_store->pwd()+"/HitProperties");
00347 }
00348 std::vector<MonitorElement*> meVec(meVec1.size() + meVec2.size());
00349 std::merge(meVec1.begin(), meVec1.end(), meVec2.begin(), meVec2.end(), meVec.begin());
00350
00351 float gstatus = 1.0;
00352 for (std::vector<MonitorElement*>::const_iterator itME = meVec.begin(); itME != meVec.end(); itME++) {
00353 MonitorElement * me = (*itME);
00354 if (!me) continue;
00355 std::vector<QReport *> qt_reports = me->getQReports();
00356 if (qt_reports.size() == 0) continue;
00357 std::string name = me->getName();
00358
00359 float status = 1.0;
00360
00361 int ibin = 0;
00362 for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
00363 it != TrackingMEsMap.end(); it++) {
00364 ibin++;
00365 std::string hname = it->second.HistoName;
00366 if (name.find(hname) != std::string::npos) {
00367 status = qt_reports[0]->getQTresult();
00368 it->second.TrackingFlag->Fill(status);
00369 fillStatusHistogram(TrackSummaryReportMap, ibin, 1, status);
00370 break;
00371 }
00372 }
00373 gstatus = gstatus * status;
00374 }
00375 TrackSummaryReportGlobal->Fill(gstatus);
00376 dqm_store->cd();
00377 }
00378
00379
00380
00381 void SiStripQualityChecker::fillSubDetStatus(DQMStore* dqm_store,
00382 const edm::ESHandle< SiStripDetCabling >& cabling,
00383 SubDetMEs& mes, unsigned int xbin, float& gflag) {
00384 int status_flag = pSet_.getUntrackedParameter<int>("GlobalStatusFilling", 1);
00385
00386 if (status_flag < 1) return;
00387
00388 std::vector<std::string> subDirVec = dqm_store->getSubdirs();
00389
00390 unsigned int ybin = 0;
00391 int tot_ndet = 0;
00392 int tot_errdet = 0;
00393 float tot_ston_stat = 0;
00394
00395 for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
00396 ic != subDirVec.end(); ic++) {
00397 std::string dname = (*ic);
00398 if (dname.find("BadModuleList") != std::string::npos) continue;
00399 std::vector<MonitorElement*> meVec;
00400 ybin++;
00401 dqm_store->cd((*ic));
00402 meVec = dqm_store->getContents((*ic));
00403 uint16_t ndet = 100;
00404 int errdet = 0;
00405
00406 int ston_stat = 1;
00407 int lnum = atoi(dname.substr(dname.find_last_of("_")+1).c_str());
00408 ndet = cabling->connectedNumber(mes.detectorTag, lnum);
00409
00410 getModuleStatus(dqm_store, meVec, errdet);
00411
00412 for (std::vector<MonitorElement*>::const_iterator it = meVec.begin();
00413 it != meVec.end(); it++) {
00414 MonitorElement * me = (*it);
00415 if (!me) continue;
00416 std::vector<QReport *> reports = me->getQReports();
00417
00418 if (reports.size() == 0) continue;
00419 std::string name = me->getName();
00420
00421 if( name.find("Summary_ClusterStoNCorr__OnTrack") != std::string::npos){
00422 int istat = SiStripUtility::getMEStatus((*it));
00423 if (reports[0]->getQTresult() == -1) {
00424 ston_stat =-1;
00425 } else {
00426 if (istat == dqm::qstatus::ERROR) ston_stat = 0;
00427 else if (istat == dqm::qstatus::STATUS_OK) ston_stat = 1;
00428 }
00429 }
00430 }
00431 if (ndet > 0) {
00432 float eff_fac = 1 - (errdet*1.0/ndet);
00433 fillStatusHistogram(SToNReportMap, xbin, ybin, ston_stat);
00434 fillStatusHistogram(DetFractionReportMap, xbin, ybin, eff_fac);
00435 if (ston_stat < 0) fillStatusHistogram(SummaryReportMap, xbin, ybin, eff_fac);
00436 else fillStatusHistogram(SummaryReportMap, xbin, ybin, ston_stat*eff_fac);
00437
00438 tot_ndet += ndet;
00439 tot_errdet += errdet;
00440 tot_ston_stat += ston_stat;
00441 }
00442 dqm_store->cd((*ic));
00443 }
00444 if (tot_ndet > 0) {
00445 float tot_eff_fac = 1 - (tot_errdet*1.0/tot_ndet);
00446 if (mes.DetFraction) mes.DetFraction->Fill(tot_eff_fac);
00447 float tot_ston_fac = tot_ston_stat/ybin;
00448 if (mes.SToNFlag) mes.SToNFlag->Fill(tot_ston_fac);
00449 if (tot_ston_fac < 0){
00450 gflag = tot_eff_fac;
00451 }else{
00452 gflag = std::min(tot_eff_fac,tot_ston_fac);
00453 }
00454 if (mes.SummaryFlag) mes.SummaryFlag->Fill(gflag);
00455 }
00456 }
00457
00458
00459
00460 void SiStripQualityChecker::printStatusReport() {
00461 std::ostringstream det_summary_str;
00462 for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
00463 it != SubDetMEsMap.end(); it++) {
00464 std::string det = it->first;
00465 det_summary_str << std::setprecision(4);
00466 det_summary_str << std::setiosflags(std::ios::fixed);
00467
00468 det_summary_str << " Printing Status for " << det << " : " << std::endl;
00469 SubDetMEs local_mes = it->second;
00470
00471 std::string sval;
00472 float fval1, fval2, fval3;
00473 fval1 = fval2 = fval3 = -1.0;
00474
00475
00476 SiStripUtility::getMEValue(local_mes.DetFraction, sval);
00477 if (sval.size() > 0) fval1 = atof(sval.c_str());
00478 SiStripUtility::getMEValue(local_mes.SToNFlag, sval);
00479 if (sval.size() > 0) fval2 = atof(sval.c_str());
00480 SiStripUtility::getMEValue(local_mes.SummaryFlag, sval);
00481 if (sval.size() > 0) fval3 = atof(sval.c_str());
00482
00483 det_summary_str << std::setw(7) << " % of good detectors " << fval1
00484 << " SToN Flag " << fval2
00485 << " Summary Flag " << fval3 << std::endl;
00486 }
00487 }
00488
00489
00490
00491 void SiStripQualityChecker::getModuleStatus(DQMStore* dqm_store, std::vector<MonitorElement*>& layer_mes,int& errdet) {
00492
00493 std::string lname;
00494 std::map<uint32_t,uint16_t> bad_modules;
00495 for (std::vector<MonitorElement*>::const_iterator it = layer_mes.begin();
00496 it != layer_mes.end(); it++) {
00497 MonitorElement * me = (*it);
00498 if (!me) continue;
00499 std::vector<QReport *> qreports = me->getQReports();
00500 if (qreports.size() == 0) continue;
00501 std::string name = me->getName();
00502 std::vector<DQMChannel> bad_channels_me;
00503 if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) {
00504 bad_channels_me = qreports[0]->getBadChannels();
00505 lname = "";
00506 } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D && name.find("TkHMap") != std::string::npos) {
00507 bad_channels_me = qreports[0]->getBadChannels();
00508 lname = name.substr(name.find("TkHMap_")+7);
00509 lname = lname.substr(lname.find("_T")+1);
00510
00511 }
00512 for (std::vector<DQMChannel>::iterator it = bad_channels_me.begin(); it != bad_channels_me.end(); it++){
00513 int xval = (*it).getBinX();
00514 int yval = (*it).getBinY();
00515 uint32_t detId = tkDetMap_->getDetFromBin(lname, xval, yval);
00516 std::map<uint32_t,uint16_t>::iterator iPos = bad_modules.find(detId);
00517 uint16_t flag;
00518 if (iPos != bad_modules.end()){
00519 flag = iPos->second;
00520 SiStripUtility::setBadModuleFlag(name,flag);
00521 iPos->second = flag;
00522 } else {
00523
00524
00525
00526 std::ostringstream detid_str;
00527 detid_str << detId;
00528
00529 std::string currentdir = dqm_store->pwd();
00530 std::string thisMEpath = currentdir.substr( 0 , currentdir.rfind( "/" ) ) + "/BadModuleList/" + detid_str.str() ;
00531
00532 MonitorElement *meBadModule = dqm_store->get ( thisMEpath );
00533 if ( meBadModule )
00534 {
00535 std::string val_str;
00536 SiStripUtility::getMEValue ( meBadModule , val_str );
00537 flag = atoi ( val_str.c_str() );
00538 }
00539 else
00540 flag = 0;
00541
00542 SiStripUtility::setBadModuleFlag(name,flag);
00543 bad_modules.insert(std::pair<uint32_t,uint16_t>(detId,flag));
00544 }
00545 }
00546 }
00547 for(std::map<uint32_t,uint16_t>::const_iterator it = bad_modules.begin();
00548 it != bad_modules.end(); it++) {
00549 uint32_t detId = it->first;
00550 uint16_t flag = it->second;
00551 std::map<uint32_t,uint16_t>::iterator iPos = badModuleList.find(detId);
00552 if (iPos != badModuleList.end()){
00553 iPos->second = flag;
00554 } else {
00555 badModuleList.insert(std::pair<uint32_t,uint16_t>(detId,flag));
00556 }
00557 }
00558 errdet = bad_modules.size();
00559 }
00560
00561
00562
00563 void SiStripQualityChecker::fillStatusHistogram(MonitorElement* me, int xbin, int ybin, float val){
00564 if (me && me->kind() == MonitorElement::DQM_KIND_TH2F) {
00565 TH2F* th2d = me->getTH2F();
00566 th2d->SetBinContent(xbin, ybin, val);
00567 }
00568 }
00569
00570
00571
00572 void SiStripQualityChecker::fillFaultyModuleStatus(DQMStore* dqm_store, const edm::EventSetup& eSetup) {
00573 if (badModuleList.size() == 0) return;
00574
00575
00576 edm::ESHandle<TrackerTopology> tTopoHandle;
00577 eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
00578 const TrackerTopology* const tTopo = tTopoHandle.product();
00579
00580 dqm_store->cd();
00581 std::string mdir = "MechanicalView";
00582 if (!SiStripUtility::goToDir(dqm_store, mdir)) return;
00583 std::string mechanical_dir = dqm_store->pwd();
00584
00585 SiStripFolderOrganizer folder_organizer;
00586 for (std::map<uint32_t,uint16_t>::const_iterator it = badModuleList.begin() ; it != badModuleList.end(); it++) {
00587 uint32_t detId = it->first;
00588 std::string subdet_folder ;
00589 folder_organizer.getSubDetFolder(detId,tTopo,subdet_folder);
00590 if (!dqm_store->dirExists(subdet_folder)) {
00591 subdet_folder = mechanical_dir + subdet_folder.substr(subdet_folder.find("MechanicalView")+14);
00592 if (!dqm_store->dirExists(subdet_folder)) continue;
00593 }
00594 std::string bad_module_folder = subdet_folder + "/" + "BadModuleList";
00595 dqm_store->setCurrentFolder(bad_module_folder);
00596
00597 std::ostringstream detid_str;
00598 detid_str << detId;
00599 std::string full_path = bad_module_folder + "/" + detid_str.str();
00600 MonitorElement* me = dqm_store->get(full_path);
00601 if (me) me->Reset();
00602 else me = dqm_store->bookInt(detid_str.str());
00603 me->Fill(it->second);
00604 }
00605 dqm_store->cd();
00606 }
00607
00608
00609
00610 void SiStripQualityChecker::initialiseBadModuleList() {
00611 for (std::map<uint32_t,uint16_t>::iterator it=badModuleList.begin(); it!=badModuleList.end(); it++) {
00612 it->second = 0;
00613 }
00614 }
00615
00616
00617
00618 void SiStripQualityChecker::fillStatusAtLumi(DQMStore* dqm_store){
00619 if (!bookedStripStatus_ || !bookedTrackingStatus_) bookStatus(dqm_store);
00620 fillDummyStatus();
00621 fillDetectorStatusAtLumi(dqm_store);
00622 fillTrackingStatusAtLumi(dqm_store);
00623 }
00624
00625
00626
00627 void SiStripQualityChecker::fillDetectorStatusAtLumi(DQMStore* dqm_store){
00628 dqm_store->cd();
00629 std::string rdir = "ReadoutView";
00630 if (!SiStripUtility::goToDir(dqm_store, rdir)) return;
00631 std::string fullpath = dqm_store->pwd()
00632 + "/FedSummary/PerLumiSection/"
00633 + "lumiErrorFraction";
00634 MonitorElement* me = dqm_store->get(fullpath);
00635 if (me && me->kind() == MonitorElement::DQM_KIND_TH1F) {
00636 TH1F* th1 = me->getTH1F();
00637 float global_fraction = 0.0;
00638 float dets = 0.0;
00639 for (int ibin = 1; ibin <= th1->GetNbinsX(); ibin++) {
00640 std::string label = th1->GetXaxis()->GetBinLabel(ibin);
00641 std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(label);
00642 if (iPos != SubDetMEsMap.end()) {
00643 float fraction = 1.0 - th1->GetBinContent(ibin);
00644 global_fraction += fraction;
00645 dets++;
00646 iPos->second.DetFraction->Fill(fraction);
00647 iPos->second.SToNFlag->Fill(-1.0);
00648 iPos->second.SummaryFlag->Fill(fraction);
00649 }
00650 }
00651 global_fraction = global_fraction/dets;
00652 if (SummaryReportGlobal) SummaryReportGlobal->Fill(global_fraction);
00653 }
00654 dqm_store->cd();
00655 }
00656
00657
00658
00659 void SiStripQualityChecker::fillTrackingStatusAtLumi(DQMStore* dqm_store){
00660 dqm_store->cd();
00661 std::string dir = "Tracking";
00662 if (!SiStripUtility::goToDir(dqm_store, dir)) return;
00663 dir = "TrackParameters";
00664 if (!SiStripUtility::goToDir(dqm_store, dir)) return;
00665
00666 std::vector<MonitorElement*> meVec1;
00667 std::vector<MonitorElement*> meVec2;
00668 if (useGoodTracks_){
00669 meVec1 = dqm_store->getContents(dqm_store->pwd()+"/LSanalysis");
00670
00671 }else{
00672 meVec1 = dqm_store->getContents(dqm_store->pwd()+"/GeneralProperties");
00673 meVec2 = dqm_store->getContents(dqm_store->pwd()+"/HitProperties");
00674 }
00675 std::vector<MonitorElement*> meVec(meVec1.size() + meVec2.size());
00676 std::merge(meVec1.begin(), meVec1.end(), meVec2.begin(), meVec2.end(), meVec.begin());
00677
00678 float gstatus = 1.0;
00679 for (std::vector<MonitorElement*>::const_iterator itME = meVec.begin(); itME != meVec.end(); itME++) {
00680 MonitorElement * me = (*itME);
00681 if (!me) continue;
00682 std::string name = me->getName();
00683
00684 float status = -1.0;
00685 int ibin = 0;
00686 for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
00687 it != TrackingMEsMap.end(); it++) {
00688 ibin++;
00689 std::string hname = it->second.HistoName+"lumiFlag_";
00690 float lower_cut = it->second.LowerCut;
00691 float upper_cut = it->second.UpperCut;
00692 if (name.find(hname) != std::string::npos) {
00693 if (me->getMean() <= lower_cut || me->getMean() > upper_cut) status = 0.0;
00694 else status = 1.0;
00695 it->second.TrackingFlag->Fill(status);
00696 fillStatusHistogram(TrackSummaryReportMap, ibin, 1, status);
00697 break;
00698 } else {
00699 }
00700 }
00701 if (status == -1.0) gstatus = -1.0;
00702 else gstatus = gstatus * status;
00703 }
00704 TrackSummaryReportGlobal->Fill(gstatus);
00705 dqm_store->cd();
00706 }