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