00001
00002 #include "DQM/SiStripMonitorClient/interface/SiStripInformationExtractor.h"
00003 #include "DQMServices/Core/interface/DQMStore.h"
00004 #include "DQMServices/Core/interface/QTest.h"
00005 #include "DQMServices/Core/interface/QReport.h"
00006 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00007 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00008
00009 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00010 #include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
00011 #include "DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h"
00012 #include "DQM/SiStripMonitorClient/interface/SiStripConfigParser.h"
00013 #include "DQM/SiStripMonitorClient/interface/SiStripHistoPlotter.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "FWCore/ParameterSet/interface/FileInPath.h"
00016
00017
00018 #include <iostream>
00019 using namespace std;
00020
00021
00022
00023
00024 SiStripInformationExtractor::SiStripInformationExtractor() {
00025 edm::LogInfo("SiStripInformationExtractor") <<
00026 " Creating SiStripInformationExtractor " << "\n" ;
00027 layoutParser_ = 0;
00028 layoutMap.clear();
00029 histoPlotter_=0;
00030 histoPlotter_ = new SiStripHistoPlotter();
00031 readConfiguration();
00032 }
00033
00034
00035
00036 SiStripInformationExtractor::~SiStripInformationExtractor() {
00037 edm::LogInfo("SiStripInformationExtractor") <<
00038 " Deleting SiStripInformationExtractor " << "\n" ;
00039 if (layoutParser_) delete layoutParser_;
00040 if (histoPlotter_) delete histoPlotter_;
00041
00042 }
00043
00044
00045
00046 void SiStripInformationExtractor::readConfiguration() {
00047 string localPath = string("DQM/SiStripMonitorClient/data/sistrip_plot_layout.xml");
00048 if (layoutParser_ == 0) {
00049 layoutParser_ = new SiStripLayoutParser();
00050 layoutParser_->getDocument(edm::FileInPath(localPath).fullPath());
00051 }
00052 if (layoutParser_->getAllLayouts(layoutMap)) {
00053 edm::LogInfo("SiStripInformationExtractor") <<
00054 " Layouts correctly readout " << "\n" ;
00055 } else edm::LogInfo("SiStripInformationExtractor") <<
00056 " Problem in reading Layout " << "\n" ;
00057 if (layoutParser_) delete layoutParser_;
00058
00059 }
00060
00061
00062
00063 void SiStripInformationExtractor::printSummaryHistoList(DQMStore * dqm_store, ostringstream& str_val){
00064 static string indent_str = "";
00065
00066 string currDir = dqm_store->pwd();
00067 string dname = currDir.substr(currDir.find_last_of("/")+1);
00068 if (dname.find("module_") ==0) return;
00069 str_val << "<li><a href=\"#\" id=\""
00070 << currDir << "\">" << dname << "</a>" << endl;
00071 vector<MonitorElement *> meVec = dqm_store->getContents(currDir);
00072 vector<string> subDirVec = dqm_store->getSubdirs();
00073 if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
00074 str_val << "</li> "<< endl;
00075 return;
00076 }
00077 str_val << "<ul>" << endl;
00078 for (vector<MonitorElement *>::const_iterator it = meVec.begin();
00079 it != meVec.end(); it++) {
00080 MonitorElement* me = (*it);
00081 if (!me) continue;
00082 string name = (*it)->getName();
00083
00084 str_val << "<li class=\"dhtmlgoodies_sheet.gif\">"
00085 << " <a href=\"javascript:RequestHistos.DrawSingleHisto('"
00086 << currDir
00087 << "')\">" << name
00088 << "</a></li>" << endl;
00089
00090 }
00091
00092 string mtag ="Modules: ";
00093 for (vector<string>::const_iterator ic = subDirVec.begin();
00094 ic != subDirVec.end(); ic++) {
00095 dqm_store->cd(*ic);
00096 string titl = (*ic);
00097 if (titl.find("module_") == 0) {
00098 titl = titl.substr(titl.find("module_")+7);
00099 mtag += titl + " ";
00100 }
00101 printSummaryHistoList(dqm_store, str_val);
00102 dqm_store->goUp();
00103 }
00104 if (mtag.size() > 10) {
00105 str_val << "<li class=\"note.gif\"><a href=\"#\">" << mtag << "</a></li>" << endl;
00106 }
00107 str_val << "</ul> "<< endl;
00108 str_val << "</li> "<< endl;
00109 }
00110
00111
00112
00113 void SiStripInformationExtractor::printAlarmList(DQMStore * dqm_store, ostringstream& str_val){
00114 static string indent_str = "";
00115
00116 string currDir = dqm_store->pwd();
00117 string dname = currDir.substr(currDir.find_last_of("/")+1);
00118 string image_name;
00119 selectImage(image_name,dqm_store->getStatus(currDir));
00120 str_val << "<li><a href=\"#\" id=\""
00121 << currDir << "\">" << dname << "</a> <img src=\""
00122 << image_name << "\"></img>" << endl;
00123 vector<string> subDirVec = dqm_store->getSubdirs();
00124
00125 vector<MonitorElement *> meVec = dqm_store->getContents(currDir);
00126
00127 if (subDirVec.size() == 0 && meVec.size() == 0) {
00128 str_val << "</li> "<< endl;
00129 return;
00130 }
00131 str_val << "<ul>" << endl;
00132 if (dname.find("module_") != string::npos) {
00133 if (meVec.size() > 0) {
00134 for (vector<MonitorElement *>::const_iterator it = meVec.begin();
00135 it != meVec.end(); it++) {
00136 MonitorElement * me = (*it);
00137 if (!me) continue;
00138 vector<QReport*> q_reports = me->getQReports();
00139 if (q_reports.size() > 0) {
00140 string image_name1;
00141 selectImage(image_name1,q_reports);
00142 str_val << "<li class=\"dhtmlgoodies_sheet.gif\">"
00143 << " <a href=\"javascript:RequestHistos.ReadStatus('"
00144 << currDir
00145 << "')\">" << me->getName()
00146 << "</a><img src=\"" << image_name1 << "\"></img>"
00147 << " </li>" << endl;
00148 }
00149 }
00150 }
00151 }
00152 for (vector<string>::const_iterator ic = subDirVec.begin();
00153 ic != subDirVec.end(); ic++) {
00154 dqm_store->cd(*ic);
00155 printAlarmList(dqm_store, str_val);
00156 dqm_store->goUp();
00157 }
00158 str_val << "</ul> "<< endl;
00159 str_val << "</li> "<< endl;
00160 }
00161
00162
00163
00164 void SiStripInformationExtractor::getSingleModuleHistos(DQMStore * dqm_store,
00165 const multimap<string, string>& req_map, xgi::Output * out){
00166
00167 vector<string> hlist;
00168 getItemList(req_map,"histo", hlist);
00169
00170 uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
00171
00172 int width = atoi(getItemValue(req_map, "width").c_str());
00173 int height = atoi(getItemValue(req_map, "height").c_str());
00174
00175 string opt =" ";
00176
00177 SiStripFolderOrganizer folder_organizer;
00178 string path;
00179 folder_organizer.getFolderName(detId,path);
00180
00181 vector<MonitorElement*> all_mes = dqm_store->getContents(path);
00182 setHTMLHeader(out);
00183 *out << path << " ";
00184
00185 for (vector<string>::const_iterator ih = hlist.begin();
00186 ih != hlist.end(); ih++) {
00187 for (vector<MonitorElement *>::const_iterator it = all_mes.begin();
00188 it!= all_mes.end(); it++) {
00189 MonitorElement * me = (*it);
00190 if (!me) continue;
00191 string hname = me->getName();
00192 string name = hname.substr(0, hname.find("__det__"));
00193 if (name == (*ih)) {
00194 string full_path = path + "/" + hname;
00195 histoPlotter_->setNewPlot(full_path, opt, width, height);
00196 *out << hname << " " ;
00197 }
00198 }
00199 }
00200 }
00201
00202
00203
00204 void SiStripInformationExtractor::getGlobalHistos(DQMStore* dqm_store, const multimap<string, string>& req_map, xgi::Output * out) {
00205
00206 vector<string> hlist;
00207 getItemList(req_map,"histo", hlist);
00208
00209 string path = getItemValue(req_map, "GlobalFolder");
00210
00211 int width = atoi(getItemValue(req_map, "width").c_str());
00212 int height = atoi(getItemValue(req_map, "height").c_str());
00213
00214 string opt =" ";
00215
00216 vector<MonitorElement *> all_mes = dqm_store->getContents(path);
00217
00218 setHTMLHeader(out);
00219 *out << path << " ";
00220
00221 for (vector<string>::const_iterator ih = hlist.begin();
00222 ih != hlist.end(); ih++) {
00223 for (vector<MonitorElement *>::const_iterator it = all_mes.begin();
00224 it!= all_mes.end(); it++) {
00225 MonitorElement * me = (*it);
00226 if (!me) continue;
00227 string hname = me->getName();
00228 string name = hname.substr(0, hname.find("__det__"));
00229 if (name == (*ih)) {
00230 string full_path = path + "/" + hname;
00231 histoPlotter_->setNewPlot(full_path, opt, width, height);
00232 *out << hname << " " ;
00233 }
00234 }
00235 }
00236 }
00237
00238
00239
00240 void SiStripInformationExtractor::getHistosFromPath(DQMStore * dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
00241
00242 string path = getItemValue(req_map,"Path");
00243
00244 if (path.size() == 0) return;
00245
00246 int width = atoi(getItemValue(req_map, "width").c_str());
00247 int height = atoi(getItemValue(req_map, "height").c_str());
00248
00249 string opt =" ";
00250
00251 setHTMLHeader(out);
00252 vector<MonitorElement*> all_mes = dqm_store->getContents(path);
00253 *out << path << " " ;
00254 for(vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
00255 MonitorElement* me = (*it);
00256 if (!me) continue;
00257 string name = me->getName();
00258 string full_path = path + "/" + name;
00259
00260 histoPlotter_->setNewPlot(full_path, opt, width, height);
00261 *out << name << " ";
00262 }
00263 }
00264
00265
00266
00267 void SiStripInformationExtractor::plotHistosFromLayout(DQMStore * dqm_store){
00268 if (layoutMap.size() == 0) return;
00269
00270 ofstream image_file;
00271 ofstream title_file;
00272
00273 for (map<std::string, std::vector< std::string > >::iterator it = layoutMap.begin() ; it != layoutMap.end(); it++) {
00274 int ival = 0;
00275 string image_list = "images/" + it->first +".lis";
00276 image_file.open(image_list.c_str(), ios::out);
00277 if (!image_file) return;
00278
00279 string title_list = "images/" + it->first +"_titles.lis";
00280 title_file.open(title_list.c_str(), ios::out);
00281 if (!title_file) return;
00282
00283 image_file << "[";
00284 title_file << "[";
00285 for (vector<string>::iterator im = it->second.begin();
00286 im != it->second.end(); im++) {
00287 string path_name = (*im);
00288 if (path_name.size() == 0) continue;
00289 MonitorElement* me = dqm_store->get(path_name);
00290 ival++;
00291 ostringstream fname, ftitle;
00292 if (!me) {
00293 fname << "images/EmptyPlot.png";
00294 ftitle << "EmptyPlot";
00295
00296 } else {
00297 fname << "images/" << it->first << "_" <<ival << ".png";
00298 ftitle << me->getName();
00299 histoPlotter_->createStaticPlot(me, fname.str());
00300 }
00301 if (ival != it->second.size()) {
00302 image_file << "\"" << fname.str() << "\","<< endl;
00303 title_file << "\"" << ftitle.str() << "\","<< endl;
00304 } else {
00305 image_file << "\"" << fname.str() << "\"" << endl;
00306 title_file << "\"" << ftitle.str() << "\""<< endl;
00307 }
00308 }
00309 image_file << "]" << endl;
00310 image_file.close();
00311 title_file << "]" << endl;
00312 title_file.close();
00313 }
00314 }
00315
00316
00317
00318 void SiStripInformationExtractor::getTrackerMapHistos(DQMStore* dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out) {
00319
00320 vector<string> hlist;
00321 string tkmap_name;
00322 SiStripConfigParser config_parser;
00323 string localPath = string("DQM/SiStripMonitorClient/data/sistrip_monitorelement_config.xml");
00324 config_parser.getDocument(edm::FileInPath(localPath).fullPath());
00325 if (!config_parser.getMENamesForTrackerMap(tkmap_name, hlist)) return;
00326 if (hlist.size() == 0) return;
00327
00328 uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
00329
00330 int width = atoi(getItemValue(req_map, "width").c_str());
00331 int height = atoi(getItemValue(req_map, "height").c_str());
00332
00333 string opt =" ";
00334
00335 SiStripFolderOrganizer folder_organizer;
00336 string path;
00337 folder_organizer.getFolderName(detId,path);
00338
00339 vector<MonitorElement*> all_mes = dqm_store->getContents(path);
00340 setHTMLHeader(out);
00341 *out << path << " ";
00342 for (vector<string>::iterator ih = hlist.begin();
00343 ih != hlist.end(); ih++) {
00344 for (vector<MonitorElement *>::const_iterator it = all_mes.begin();
00345 it!= all_mes.end(); it++) {
00346 MonitorElement * me = (*it);
00347 if (!me) continue;
00348 string hname = me->getName();
00349 string name = hname.substr(0, hname.find("__det__"));
00350 if (name == (*ih)) {
00351 string full_path = path + "/" + hname;
00352 histoPlotter_->setNewPlot(full_path, opt, width, height);
00353 *out << hname << " " ;
00354 }
00355 }
00356 }
00357 }
00358
00359
00360
00361 void SiStripInformationExtractor::getCondDBHistos(DQMStore * dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
00362
00363 string sname = getItemValue(req_map,"StructureName");
00364 int width = atoi(getItemValue(req_map, "width").c_str());
00365 int height = atoi(getItemValue(req_map, "height").c_str());
00366
00367 string path;
00368 uint32_t detId;
00369 if (hasItem(req_map,string("ModId"))) {
00370 detId = atoi(getItemValue(req_map,"ModId").c_str());
00371 SiStripFolderOrganizer folder_organizer;
00372 folder_organizer.getFolderName(detId,path);
00373 } else {
00374 path = "SiStrip/" + sname;
00375 }
00376 string opt = getItemValue(req_map,"option");
00377 vector<string> htypes;
00378 SiStripUtility::split(opt, htypes, ",");
00379
00380 histoPlotter_->setNewCondDBPlot(path, opt, width, height);
00381 setHTMLHeader(out);
00382 *out << path << " ";
00383
00384 for (vector<string>::const_iterator ih = htypes.begin();
00385 ih != htypes.end(); ih++) {
00386 if ((*ih).size() > 0) {
00387 *out << (*ih) << " " ;
00388 }
00389 }
00390 }
00391
00392
00393
00394 void SiStripInformationExtractor::getIMGCImage(const multimap<string, string>& req_map, xgi::Output * out){
00395
00396 string path = getItemValue(req_map,"Path");
00397 string image;
00398 histoPlotter_->getNamedImageBuffer(path, image);
00399
00400 out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
00401 out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
00402 out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
00403 out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
00404 *out << image;
00405
00406 }
00407
00408
00409
00410 void SiStripInformationExtractor::readLayoutNames(multimap<string, string>& req_map, xgi::Output * out){
00411 if (layoutMap.size() > 0) {
00412 setXMLHeader(out);
00413 *out << "<LayoutList>" << endl;
00414 for (map<string, vector< string > >::iterator it = layoutMap.begin();
00415 it != layoutMap.end(); it++) {
00416 *out << "<LName>" << it->first << "</LName>" << endl;
00417 }
00418 *out << "</LayoutList>" << endl;
00419 }
00420 }
00421
00422
00423
00424 void SiStripInformationExtractor::readModuleAndHistoList(DQMStore* dqm_store, string& sname, const edm::ESHandle<SiStripDetCabling>& detcabling, xgi::Output * out) {
00425
00426 std::vector<uint32_t> SelectedDetIds;
00427 detcabling->addActiveDetectorsRawIds(SelectedDetIds);
00428
00429 setXMLHeader(out);
00430 *out << "<ModuleAndHistoList>" << endl;
00431
00432
00433 *out << "<ModuleList>" << endl;
00434 uint32_t aDetId = 0;
00435 for (std::vector<uint32_t>::const_iterator idetid=SelectedDetIds.begin(), iEnd=SelectedDetIds.end();idetid!=iEnd;++idetid){
00436 uint32_t detId = *idetid;
00437 if (detId == 0 || detId == 0xFFFFFFFF) continue;
00438 if (aDetId == 0) aDetId = detId;
00439 StripSubdetector subdet(*idetid);
00440 if ( (sname == "ALL") ||
00441 (sname == "TIB" && subdet.subdetId() == StripSubdetector::TIB) ||
00442 (sname == "TOB" && subdet.subdetId() == StripSubdetector::TOB) ||
00443 (sname == "TID" && subdet.subdetId() == StripSubdetector::TID) ||
00444 (sname == "TEC" && subdet.subdetId() == StripSubdetector::TEC) ) {
00445
00446 ostringstream detIdStr;
00447 detIdStr << detId;
00448 *out << "<ModuleNum>" << detIdStr.str() << "</ModuleNum>" << endl;
00449 }
00450 }
00451 *out << "</ModuleList>" << endl;
00452
00453 *out << "<HistoList>" << endl;
00454
00455 SiStripFolderOrganizer folder_organizer;
00456 string dir_path;
00457 folder_organizer.getFolderName(aDetId,dir_path);
00458 vector<MonitorElement*> detector_mes = dqm_store->getContents(dir_path);
00459 for (vector<MonitorElement *>::const_iterator it = detector_mes.begin();
00460 it!= detector_mes.end(); it++) {
00461 MonitorElement * me = (*it);
00462 if (!me) continue;
00463 string hname_full = me->getName();
00464 string hname = hname_full.substr(0, hname_full.find("__det__"));
00465 *out << "<Histo>" << hname << "</Histo>" << endl;
00466 }
00467 *out << "</HistoList>" << endl;
00468 *out << "</ModuleAndHistoList>" << endl;
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491 }
00492
00493
00494
00495 void SiStripInformationExtractor::readGlobalHistoList(DQMStore* dqm_store, std::string& str_name,xgi::Output * out) {
00496 std::vector<std::string> hnames;
00497 string dname = str_name;
00498
00499 setXMLHeader(out);
00500 *out << "<GlobalHistoList>" << endl;
00501 if (dqm_store->dirExists(dname)) {
00502 vector<MonitorElement*> meVec = dqm_store->getContents(dname);
00503 for (vector<MonitorElement *>::const_iterator it = meVec.begin();
00504 it != meVec.end(); it++) {
00505 MonitorElement* me = (*it);
00506 if (!me) continue;
00507 *out << "<GHisto>" << (*it)->getName() << "</GHisto>" << endl;
00508 }
00509 } else {
00510 *out << "<GHisto>" << " Desired directory : " << "</GHisto>" << endl;
00511 *out << "<GHisto>" << dname << "</GHisto>" << endl;
00512 *out << "<GHisto>" << " does not exist!!!! " << "</GHisto>" << endl;
00513 }
00514 *out << "</GlobalHistoList>" << endl;
00515 }
00516
00517
00518
00519 void SiStripInformationExtractor::readSummaryHistoTree(DQMStore* dqm_store, string& str_name, xgi::Output * out) {
00520 ostringstream sumtree;
00521 string dname = "SiStrip/" + str_name;
00522 if (dqm_store->dirExists(dname)) {
00523 dqm_store->cd(dname);
00524 sumtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
00525 printSummaryHistoList(dqm_store,sumtree);
00526 sumtree <<"</ul>" << endl;
00527 } else {
00528 sumtree << " Desired Directory : " << endl;
00529 sumtree << dname << endl;
00530 sumtree << " does not exist !!!! " << endl;
00531 }
00532 setPlainHeader(out);
00533 *out << sumtree.str();
00534 dqm_store->cd();
00535 }
00536
00537
00538
00539 void SiStripInformationExtractor::readAlarmTree(DQMStore* dqm_store,
00540 string& str_name, xgi::Output * out){
00541 ostringstream alarmtree;
00542 string dname = "SiStrip/" + str_name;
00543 if (dqm_store->dirExists(dname)) {
00544 dqm_store->cd(dname);
00545 alarmtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
00546 printAlarmList(dqm_store,alarmtree);
00547 alarmtree <<"</ul>" << endl;
00548 } else {
00549 alarmtree << "Desired Directory : " << endl;
00550 alarmtree << dname << endl;
00551 alarmtree << " does not exist !!!! " << endl;
00552 }
00553 setPlainHeader(out);
00554 *out << alarmtree.str();
00555 dqm_store->cd();
00556 }
00557
00558
00559
00560 void SiStripInformationExtractor::getItemList(const multimap<string, string>& req_map, string item_name,vector<string>& items) {
00561 items.clear();
00562 for (multimap<string, string>::const_iterator it = req_map.begin();
00563 it != req_map.end(); it++) {
00564
00565 if (it->first == item_name) {
00566 items.push_back(it->second);
00567 }
00568 }
00569 }
00570
00571
00572
00573 bool SiStripInformationExtractor::hasItem(const multimap<string,string>& req_map,
00574 string item_name){
00575 multimap<string,string>::const_iterator pos = req_map.find(item_name);
00576 if (pos != req_map.end()) return true;
00577 return false;
00578 }
00579
00580
00581
00582 string SiStripInformationExtractor::getItemValue(const multimap<string,string>& req_map,
00583 std::string item_name){
00584 multimap<string,string>::const_iterator pos = req_map.find(item_name);
00585 string value = " ";
00586 if (pos != req_map.end()) {
00587 value = pos->second;
00588 }
00589 return value;
00590 }
00591
00592
00593
00594 void SiStripInformationExtractor::selectColor(string& col, int status){
00595 if (status == dqm::qstatus::STATUS_OK) col = "#00ff00";
00596 else if (status == dqm::qstatus::WARNING) col = "#ffff00";
00597 else if (status == dqm::qstatus::ERROR) col = "#ff0000";
00598 else if (status == dqm::qstatus::OTHER) col = "#ffa500";
00599 else col = "#0000ff";
00600 }
00601
00602
00603
00604 void SiStripInformationExtractor::selectColor(string& col, vector<QReport*>& reports){
00605 int istat = 999;
00606 int status = 0;
00607 for (vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
00608 it++) {
00609 status = (*it)->getStatus();
00610 if (status > istat) istat = status;
00611 }
00612 selectColor(col, status);
00613 }
00614
00615
00616
00617 void SiStripInformationExtractor::selectImage(string& name, int status){
00618 if (status == dqm::qstatus::STATUS_OK) name="images/LI_green.gif";
00619 else if (status == dqm::qstatus::WARNING) name="images/LI_yellow.gif";
00620 else if (status == dqm::qstatus::ERROR) name="images/LI_red.gif";
00621 else if (status == dqm::qstatus::OTHER) name="images/LI_orange.gif";
00622 else name="images/LI_blue.gif";
00623 }
00624
00625
00626
00627 void SiStripInformationExtractor::selectImage(string& name, vector<QReport*>& reports){
00628 int istat = 999;
00629 int status = 0;
00630 for (vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
00631 it++) {
00632 status = (*it)->getStatus();
00633 if (status > istat) istat = status;
00634 }
00635 selectImage(name, status);
00636 }
00637
00638
00639
00640 void SiStripInformationExtractor::readStatusMessage(DQMStore* dqm_store, std::multimap<std::string, std::string>& req_map, xgi::Output * out){
00641
00642 string path = getItemValue(req_map,"Path");
00643
00644 int width = atoi(getItemValue(req_map, "width").c_str());
00645 int height = atoi(getItemValue(req_map, "height").c_str());
00646
00647 string opt =" ";
00648
00649 ostringstream test_status;
00650
00651 setXMLHeader(out);
00652 *out << "<StatusAndPath>" << endl;
00653 *out << "<PathList>" << endl;
00654 if (path.size() == 0) {
00655 *out << "<HPath>" << "NONE" << "</HPath>" << endl;
00656 test_status << " ME Does not exist ! " << endl;
00657 } else {
00658 vector<MonitorElement*> all_mes = dqm_store->getContents(path);
00659 *out << "<HPath>" << path << "</HPath>" << endl;
00660 for(vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
00661 MonitorElement* me = (*it);
00662 if (!me) continue;
00663 string name = me->getName();
00664
00665 vector<QReport*> q_reports = me->getQReports();
00666 if (q_reports.size() == 0 && name.find("StripQualityFromCondDB") == string::npos) continue;
00667 string full_path = path + "/" + name;
00668 histoPlotter_->setNewPlot(full_path, opt, width, height);
00669
00670 if (q_reports.size() != 0) {
00671 test_status << " QTest Status for " << name << " : " << endl;
00672 test_status << " ======================================================== " << endl;
00673 for (vector<QReport*>::const_iterator it = q_reports.begin(); it != q_reports.end();
00674 it++) {
00675 int status = (*it)->getStatus();
00676 if (status == dqm::qstatus::WARNING) test_status << " Warning ";
00677 else if (status == dqm::qstatus::ERROR) test_status << " Error ";
00678 else if (status == dqm::qstatus::STATUS_OK) test_status << " Ok ";
00679 else if (status == dqm::qstatus::OTHER) test_status << " Other(" << status << ") ";
00680 string mess_str = (*it)->getMessage();
00681 test_status << "<br/>";
00682 mess_str = mess_str.substr(mess_str.find(" Test")+5);
00683 test_status << " QTest Name : " << mess_str.substr(0, mess_str.find(")")+1) << endl;
00684 test_status << "<br/>";
00685 test_status << " QTest Detail : " << mess_str.substr(mess_str.find(")")+2) << endl;
00686 }
00687 test_status << " ======================================================== " << endl;
00688 }
00689 *out << "<HPath>" << name << "</HPath>" << endl;
00690 }
00691 }
00692 *out << "</PathList>" << endl;
00693 *out << "<StatusList>" << endl;
00694 *out << "<Status>" << test_status.str() << "</Status>" << endl;
00695 *out << "</StatusList>" << endl;
00696 *out << "</StatusAndPath>" << endl;
00697 }
00698
00699
00700
00701 void SiStripInformationExtractor::readQTestSummary(DQMStore* dqm_store, string type, const edm::ESHandle<SiStripDetCabling>& detcabling, xgi::Output * out) {
00702 std::vector<uint32_t> SelectedDetIds;
00703 detcabling->addActiveDetectorsRawIds(SelectedDetIds);
00704
00705 int nDetsWithError = 0;
00706 int nDetsWithWarning = 0;
00707 int nTotalError = 0;
00708 int nTotalWarning = 0;
00709 int nDetsTotal = 0;
00710 ostringstream qtest_summary, lite_summary;
00711
00712 SiStripFolderOrganizer folder_organizer;
00713 for (std::vector<uint32_t>::const_iterator idetid=SelectedDetIds.begin(), iEnd=SelectedDetIds.end();idetid!=iEnd;++idetid){
00714 uint32_t detId = *idetid;
00715 if (detId == 0 || detId == 0xFFFFFFFF){
00716 edm::LogError("SiStripInformationExtractor")
00717 <<"SiStripInformationExtractor::readQTestSummary: "
00718 << "Wrong DetId !!!!!! " << detId << " Neglecting !!!!!! ";
00719 continue;
00720 }
00721 nDetsTotal++;
00722 string dir_path;
00723 folder_organizer.getFolderName(detId, dir_path);
00724 vector<MonitorElement*> detector_mes = dqm_store->getContents(dir_path);
00725 int error_me = 0;
00726 int warning_me = 0;
00727 for (vector<MonitorElement *>::const_iterator it = detector_mes.begin();
00728 it!= detector_mes.end(); it++) {
00729 MonitorElement * me = (*it);
00730 if (!me) continue;
00731 vector<QReport*> q_reports = me->getQReports();
00732 if (!me->hasError() && !me->hasWarning() ) continue;
00733 if (q_reports.size() == 0) continue;
00734 if (me->hasError()) error_me++;
00735 if (me->hasWarning()) warning_me++;
00736 if (error_me == 1 || warning_me == 1) {
00737 qtest_summary << " Module = " << me->getPathname() << endl;
00738 qtest_summary << "====================================================================="<< endl;
00739 }
00740 qtest_summary << me->getName() << endl;
00741 for (vector<QReport*>::const_iterator it = q_reports.begin(); it != q_reports.end();
00742 it++) {
00743 int status = (*it)->getStatus();
00744 string mess_str = (*it)->getMessage();
00745
00746 if (status == dqm::qstatus::STATUS_OK || status == dqm::qstatus::OTHER) continue;
00747 if (status == dqm::qstatus::ERROR) qtest_summary << " ERROR => ";
00748 else if (status == dqm::qstatus::WARNING) qtest_summary << " WARNING => ";
00749 qtest_summary << mess_str.substr(0, mess_str.find(")")+1)
00750 << " Result : " << mess_str.substr(mess_str.find(")")+2) << endl;
00751 }
00752 }
00753 if (error_me > 0) {
00754 nDetsWithError++;
00755 nTotalError += error_me;
00756 }
00757 if (warning_me > 0) {
00758 nDetsWithWarning++;
00759 nTotalWarning += warning_me;
00760 }
00761 }
00762 lite_summary << " Total Detectors " << nDetsTotal << endl;
00763 lite_summary << " # of Detectors with Warning " << nDetsWithWarning << endl;
00764 lite_summary << " # of Detectors with Error " << nDetsWithError << endl;
00765 lite_summary << endl;
00766 lite_summary << endl;
00767 lite_summary << " Total # MEs with Warning " << nTotalWarning << endl;
00768 lite_summary << " Total # MEs with Error " << nTotalError << endl;
00769
00770
00771 setPlainHeader(out);
00772 if (type == "Lite") *out << lite_summary.str();
00773 else {
00774 if (nDetsWithWarning == 0 && nDetsWithError ==0) *out << lite_summary.str();
00775 else *out << qtest_summary.str();
00776 }
00777
00778
00779 }
00780
00781
00782
00783 void SiStripInformationExtractor::createImages(DQMStore* dqm_store){
00784 if (histoPlotter_->plotsToMake()) histoPlotter_->createPlots(dqm_store);
00785 if (histoPlotter_->condDBPlotsToMake()) histoPlotter_->createCondDBPlots(dqm_store);
00786 }
00787
00788
00789
00790 void SiStripInformationExtractor::setHTMLHeader(xgi::Output * out) {
00791 out->getHTTPResponseHeader().addHeader("Content-Type", "text/html");
00792 out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
00793 out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
00794 out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
00795 }
00796
00797
00798
00799 void SiStripInformationExtractor::setXMLHeader(xgi::Output * out) {
00800 out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
00801 out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
00802 out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
00803 out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
00804 *out << "<?xml version=\"1.0\" ?>" << std::endl;
00805
00806 }
00807
00808
00809
00810 void SiStripInformationExtractor::setPlainHeader(xgi::Output * out) {
00811 out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
00812 out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
00813 out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
00814 out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
00815
00816 }
00817
00818
00819
00820 void SiStripInformationExtractor::readNonGeomHistoTree(DQMStore* dqm_store, string& fld_name, xgi::Output * out) {
00821 ostringstream sumtree;
00822 string dname = "SiStrip/" + fld_name;
00823 if (dqm_store->dirExists(dname)) {
00824 dqm_store->cd(dname);
00825 sumtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
00826 printNonGeomHistoList(dqm_store,sumtree);
00827 sumtree <<"</ul>" << endl;
00828 } else {
00829 sumtree << " Desired Directory : " << endl;
00830 sumtree << dname << endl;
00831 sumtree << " does not exist !!!! " << endl;
00832 }
00833 cout << sumtree.str() << endl;
00834 setPlainHeader(out);
00835 *out << sumtree.str();
00836 dqm_store->cd();
00837 }
00838
00839
00840
00841 void SiStripInformationExtractor::printNonGeomHistoList(DQMStore * dqm_store, ostringstream& str_val){
00842 static string indent_str = "";
00843
00844 string currDir = dqm_store->pwd();
00845 string dname = currDir.substr(currDir.find_last_of("/")+1);
00846 str_val << "<li><a href=\"#\" id=\""
00847 << currDir << "\">" << dname << "</a>" << endl;
00848 vector<MonitorElement *> meVec = dqm_store->getContents(currDir);
00849 vector<string> subDirVec = dqm_store->getSubdirs();
00850 if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
00851 str_val << "</li> "<< endl;
00852 return;
00853 }
00854 str_val << "<ul>" << endl;
00855 for (vector<MonitorElement *>::const_iterator it = meVec.begin();
00856 it != meVec.end(); it++) {
00857 MonitorElement* me = (*it);
00858 if (!me) continue;
00859 string name = (*it)->getName();
00860 str_val << "<li class=\"dhtmlgoodies_sheet.gif\">"
00861 << " <a href=\"javascript:RequestHistos.DrawSingleHisto('"
00862 << currDir
00863 << "')\">" << name
00864 << "</a></li>" << endl;
00865 }
00866 for (vector<string>::const_iterator ic = subDirVec.begin();
00867 ic != subDirVec.end(); ic++) {
00868 dqm_store->cd(*ic);
00869 printNonGeomHistoList(dqm_store, str_val);
00870 dqm_store->goUp();
00871 }
00872 str_val << "</ul> "<< endl;
00873 str_val << "</li> "<< endl;
00874 }