CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripInformationExtractor.cc
Go to the documentation of this file.
7 
15 
16 
17 #include <iostream>
18 
19 //
20 // -- Constructor
21 //
23  edm::LogInfo("SiStripInformationExtractor") <<
24  " Creating SiStripInformationExtractor " << "\n" ;
25  layoutParser_ = 0;
26  layoutMap.clear();
27  histoPlotter_=0;
30 }
31 //
32 // -- Destructor
33 //
35  edm::LogInfo("SiStripInformationExtractor") <<
36  " Deleting SiStripInformationExtractor " << "\n" ;
37  if (layoutParser_) delete layoutParser_;
38  if (histoPlotter_) delete histoPlotter_;
39 
40 }
41 //
42 // -- Read Configurationn File
43 //
45  std::string localPath = std::string("DQM/SiStripMonitorClient/data/sistrip_plot_layout.xml");
46  if (layoutParser_ == 0) {
48  layoutParser_->getDocument(edm::FileInPath(localPath).fullPath());
49  }
51  edm::LogInfo("SiStripInformationExtractor") <<
52  " Layouts correctly readout " << "\n" ;
53  } else edm::LogInfo("SiStripInformationExtractor") <<
54  " Problem in reading Layout " << "\n" ;
55  if (layoutParser_) delete layoutParser_;
56 
57  subdetVec.push_back("SiStrip/MechanicalView/TIB");
58  subdetVec.push_back("SiStrip/MechanicalView/TOB");
59  subdetVec.push_back("SiStrip/MechanicalView/TID/side_2");
60  subdetVec.push_back("SiStrip/MechanicalView/TID/side_1");
61  subdetVec.push_back("SiStrip/MechanicalView/TEC/side_2");
62  subdetVec.push_back("SiStrip/MechanicalView/TEC/side_1");
63 
64 }
65 //
66 // -- Fill Summary Histo List
67 //
68 void SiStripInformationExtractor::printSummaryHistoList(DQMStore * dqm_store, std::ostringstream& str_val){
69  static std::string indent_str = "";
70 
71  std::string currDir = dqm_store->pwd();
72  std::string dname = currDir.substr(currDir.find_last_of("/")+1);
73  if (dname.find("module_") ==0) return;
74  // str_val << "<li><a href=\"#\" id=\"" << currDir << "\">" << dname << "</a>" << std::endl;
75  str_val << "<li><span class=\"folder\">" << dname << "</span>" << std::endl;
76  std::vector<MonitorElement *> meVec = dqm_store->getContents(currDir);
77  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
78  if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
79  str_val << "</li> "<< std::endl;
80  return;
81  }
82  str_val << "<ul>" << std::endl;
83  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
84  it != meVec.end(); it++) {
85  MonitorElement* me = (*it);
86  if (!me) continue;
87  std::string name = (*it)->getName();
88  str_val << "<li> <span class=\"file\"><a href=\"javascript:RequestHistos.DrawSummaryHistogram('"
89  << currDir
90  << "')\">" << name << "</a></span></li>" << std::endl;
91  }
92 
93  std::string mtag ="Modules: ";
94  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
95  ic != subDirVec.end(); ic++) {
96  dqm_store->cd(*ic);
97  std::string titl = (*ic);
98  if (titl.find("module_") == 0) {
99  titl = titl.substr(titl.find("module_")+7);
100  mtag += titl + " ";
101  }
102  printSummaryHistoList(dqm_store, str_val);
103  dqm_store->goUp();
104  }
105  if (mtag.size() > 10) {
106  // str_val << "<li class=\"note.gif\"><a href=\"#\">" << mtag << "</a></li>" << std::endl;
107  str_val << "<li> <span class=\"file\"><a href=\"#\">" << mtag << "</a></span></li>" << std::endl;
108  }
109  str_val << "</ul> "<< std::endl;
110  str_val << "</li> "<< std::endl;
111 }
112 //
113 // -- Fill Alarm List
114 //
115 void SiStripInformationExtractor::printAlarmList(DQMStore * dqm_store, std::ostringstream& str_val){
116  static std::string indent_str = "";
117 
118  std::string currDir = dqm_store->pwd();
119  std::string dname = currDir.substr(currDir.find_last_of("/")+1);
120  std::string image_name;
121  selectImage(image_name,dqm_store->getStatus(currDir));
122  str_val << "<li><span class=\"folder\">"
123  << dname << "<img src=\""
124  << image_name << "\"></span>" << std::endl;
125  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
126  std::vector<MonitorElement *> meVec = dqm_store->getContents(currDir);
127 
128  if (subDirVec.size() == 0 && meVec.size() == 0) {
129  str_val << "</li> "<< std::endl;
130  return;
131  }
132  str_val << "<ul>" << std::endl;
133  if (dname.find("module_") != std::string::npos) {
134  if (meVec.size() > 0) {
135  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
136  it != meVec.end(); it++) {
137  MonitorElement * me = (*it);
138  if (!me) continue;
139  std::vector<QReport*> q_reports = me->getQReports();
140  if (q_reports.size() > 0) {
141  std::string image_name1;
142  selectImage(image_name1,q_reports);
143  str_val << "<li><span class=\"file\"><a href=\"javascript:RequestHistos.ReadAlarmStatus('"
144  << currDir << "')\">"<<me->getName()
145  << "</a><img src=\""
146  << image_name1 << "\">"
147  << "</span></li>" << std::endl;
148  }
149  }
150  }
151  }
152  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
153  ic != subDirVec.end(); ic++) {
154  dqm_store->cd(*ic);
155  printAlarmList(dqm_store, str_val);
156  dqm_store->goUp();
157  }
158  str_val << "</ul> "<< std::endl;
159  str_val << "</li> "<< std::endl;
160 }
161 //
162 // -- Select Histograms for a given module
163 //
165  const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
166 
167  std::vector<std::string> hlist;
168  getItemList(req_map,"histo", hlist);
169 
170  uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
171 
172  int width = atoi(getItemValue(req_map, "width").c_str());
173  int height = atoi(getItemValue(req_map, "height").c_str());
174 
175  std::string opt =" ";
176 
177  SiStripFolderOrganizer folder_organizer;
178  std::string path;
179  folder_organizer.getFolderName(detId,path);
180 
181  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
182  setXMLHeader(out);
183  *out << "<HPathAndHNameList>" << std::endl;
184  *out << "<HPath>" << path << "</HPath>" << std::endl;
185 
186  for (std::vector<std::string>::const_iterator ih = hlist.begin();
187  ih != hlist.end(); ih++) {
188  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
189  it!= all_mes.end(); it++) {
190  MonitorElement * me = (*it);
191  if (!me) continue;
192  std::string hname = me->getName();
193  std::string name = hname.substr(0, hname.find("__det__"));
194  if (name == (*ih)) {
195  std::string full_path = path + "/" + hname;
196  histoPlotter_->setNewPlot(full_path, opt, width, height);
197  *out << "<HName>" << hname << "</HName>" << std::endl;
198  }
199  }
200  }
201  *out << "</HPathAndHNameList>" << std::endl;
202 }
203 //
204 // -- Select Histograms from Global folder
205 //
206 void SiStripInformationExtractor::getGlobalHistos(DQMStore* dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out) {
207 
208  std::vector<std::string> hlist;
209  getItemList(req_map,"histo", hlist);
210 
211  std::string path = getItemValue(req_map, "GlobalFolder");
212 
213  int width = atoi(getItemValue(req_map, "width").c_str());
214  int height = atoi(getItemValue(req_map, "height").c_str());
215 
216  std::string opt =" ";
217 
218  std::vector<MonitorElement *> all_mes = dqm_store->getContents(path);
219 
220  setXMLHeader(out);
221  *out << "<HPathAndHNameList>" << std::endl;
222  *out << "<HPath>" << path << "</HPath>" << std::endl;
223 
224  for (std::vector<std::string>::const_iterator ih = hlist.begin();
225  ih != hlist.end(); ih++) {
226  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
227  it!= all_mes.end(); it++) {
228  MonitorElement * me = (*it);
229  if (!me) continue;
230  std::string hname = me->getName();
231  std::string name = hname.substr(0, hname.find("__det__"));
232  if (name == (*ih)) {
233  std::string full_path = path + "/" + hname;
234  histoPlotter_->setNewPlot(full_path, opt, width, height);
235  *out << "<HName>" << name << "</HName>" << std::endl;
236  }
237  }
238  }
239  *out << "</HPathAndHNameList>" << std::endl;
240 }
241 //
242 // -- Get All histograms from a Path
243 //
244 void SiStripInformationExtractor::getHistosFromPath(DQMStore * dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
245 
246  std::string path = getItemValue(req_map,"Path");
247 
248  if (path.size() == 0) return;
249 
250  int width = atoi(getItemValue(req_map, "width").c_str());
251  int height = atoi(getItemValue(req_map, "height").c_str());
252 
253  std::string opt =" ";
254 
255  setXMLHeader(out);
256  *out << "<HPathAndHNameList>" << std::endl;
257  *out << "<HPath>" << path << "</HPath>" << std::endl;
258 
259  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
260  for(std::vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
261  MonitorElement* me = (*it);
262  if (!me) continue;
263  std::string name = me->getName();
264  std::string full_path = path + "/" + name;
265  histoPlotter_->setNewPlot(full_path, opt, width, height);
266  *out << "<HName>" << name << "</HName>" << std::endl;
267  }
268  *out << "</HPathAndHNameList>" << std::endl;
269 }
270 //
271 // plot Histograms from Layout
272 //
274  if (layoutMap.size() == 0) return;
275 
276  ofstream image_file;
277 
278  for (std::map<std::string, std::vector< std::string > >::iterator it = layoutMap.begin() ; it != layoutMap.end(); it++) {
279  unsigned int ival = 0;
280  std::string image_list = "images/" + it->first +".lis";
281  image_file.open(image_list.c_str(), std::ios::out);
282  if (!image_file) return;
283 
284  image_file << "[";
285  for (std::vector<std::string>::iterator im = it->second.begin();
286  im != it->second.end(); im++) {
287  std::string path_name = (*im);
288  if (path_name.size() == 0) continue;
289  MonitorElement* me = dqm_store->get(path_name);
290  ival++;
291  std::ostringstream fname, ftitle;
292  if (!me) {
293  fname << "images/EmptyPlot.png";
294  ftitle << "EmptyPlot";
295  } else {
296  fname << "images/" << it->first << "_" <<ival << ".png";
297  ftitle << me->getName();
298  histoPlotter_->createStaticPlot(me, fname.str());
299  }
300  image_file << "["<< "\"" << fname.str() << "\",\"" << path_name << "\"]";
301  if (ival != it->second.size()) image_file << ","<< std::endl;
302  }
303  image_file << "]" << std::endl;
304  image_file.close();
305  }
306 }
307 //
308 // -- Plot Tracker Map MEs
309 //
310 void SiStripInformationExtractor::getTrackerMapHistos(DQMStore* dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out) {
311 
312  uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
313 
314  int width = atoi(getItemValue(req_map, "width").c_str());
315  int height = atoi(getItemValue(req_map, "height").c_str());
316 
317  std::string opt =" ";
318 
319  SiStripFolderOrganizer folder_organizer;
320  std::string path;
321  folder_organizer.getFolderName(detId,path);
322 
323  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
324  setXMLHeader(out);
325  *out << "<HPathAndHNameList>" << std::endl;
326  *out << "<HPath>" << path << "</HPath>" << std::endl;
327  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
328  it!= all_mes.end(); it++) {
329  MonitorElement * me = (*it);
330  if (!me) continue;
331  std::string hname = me->getName();
332  std::string full_path;
333  full_path = path + "/" + hname;
334  histoPlotter_->setNewPlot(full_path, opt, width, height);
335  *out << "<HName>" << hname << "</HName>" << std::endl;
336  }
337  *out << "</HPathAndHNameList>" << std::endl;
338 
339 }
340 //
341 // -- Select Histograms for a given module
342 //
343 void SiStripInformationExtractor::getCondDBHistos(DQMStore * dqm_store, bool& plot_flag, const std::multimap<std::string, std::string>& req_map,xgi::Output * out){
344 
345  plot_flag = true;
346  std::string sname = getItemValue(req_map,"StructureName");
347  int width = atoi(getItemValue(req_map, "width").c_str());
348  int height = atoi(getItemValue(req_map, "height").c_str());
349 
350  std::string path = "";
351  uint32_t detId;
352  if (hasItem(req_map,std::string("ModId"))) {
353  detId = atoi(getItemValue(req_map,"ModId").c_str());
354  if (detId != 0) {
355  SiStripFolderOrganizer folder_organizer;
356  folder_organizer.getFolderName(detId,path);
357  }
358  } else {
359  if (sname.size() > 0) path = "SiStrip/" + sname;
360  }
361  if (path.size() == 0) path = "dummy_path";
362 
363  setXMLHeader(out);
364  *out << "<HPathAndHNameList>" << std::endl;
365  *out << "<HPath>" << path << "</HPath>" << std::endl;
366 
367  if (path == "dummy_path") {
368  *out << "<HName>" << "Dummy" << "</HName>" << std::endl;
369  plot_flag = false;
370  } else {
371  std::string opt = getItemValue(req_map,"option");
372  std::vector<std::string> htypes;
373  SiStripUtility::split(opt, htypes, ",");
374  // Check if CondDB histograms already exists
375  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
376  for (std::vector<std::string>::const_iterator ih = htypes.begin();
377  ih!= htypes.end(); ih++) {
378  std::string type = (*ih);
379  if (type.size() == 0) continue;
380  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
381  it!= all_mes.end(); it++) {
382  MonitorElement * me = (*it);
383  if (!me) continue;
384  std::string hname = me->getName();
385  if (hname.find(type) != std::string::npos) {
386  plot_flag = false;
387  break;
388  }
389  }
390  if (plot_flag == false) break;
391  }
392  histoPlotter_->setNewCondDBPlot(path, opt, width, height);
393  for (std::vector<std::string>::const_iterator ih = htypes.begin();
394  ih != htypes.end(); ih++) {
395  if ((*ih).size() > 0) {
396  *out << "<HName>" << (*ih) << "</HName>" << std::endl;
397  }
398  }
399  }
400  *out << "</HPathAndHNameList>" << std::endl;
401 }
402 //
403 // -- Get a tagged image
404 //
405 void SiStripInformationExtractor::getImage(const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
406 
407  std::string path = getItemValue(req_map,"Path");
408  std::string image;
409  histoPlotter_->getNamedImageBuffer(path, image);
410  out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
411  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
412  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
413  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
414  *out << image;
415 
416 }
417 //
418 // -- Read Layout Group names
419 //
421  setXMLHeader(out);
422  *out << "<LayoutAndTKMapList>" << std::endl;
423  if (layoutMap.size() > 0) {
424  *out << "<LayoutList>" << std::endl;
425  for (std::map<std::string, std::vector< std::string > >::iterator it = layoutMap.begin();
426  it != layoutMap.end(); it++) {
427  *out << "<LName>" << it->first << "</LName>" << std::endl;
428  }
429  *out << "</LayoutList>" << std::endl;
430  }
431  dqm_store->cd();
432  *out << "<TKMapOptionList>" << std::endl;
433  *out << "<TkMapOption>" << "QTestAlarm" << "</TkMapOption>" << std::endl;
434 
435  for (std::vector<std::string>::const_iterator isubdet = subdetVec.begin(); isubdet != subdetVec.end(); isubdet++) {
436  std::string dname = (*isubdet);
437  if (!dqm_store->dirExists(dname)) continue;
438  dqm_store->cd(dname);
439  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
440  if (subDirVec.size() == 0) continue;
441  for (std::vector<std::string>::const_iterator ilayer = subDirVec.begin(); ilayer != subDirVec.end(); ilayer++) {
442  std::string lname = (*ilayer);
443  if (lname.find("BadModuleList") != std::string::npos) continue;
444  dqm_store->cd(lname);
445  break;
446  }
447  std::vector<std::string> meVec = dqm_store->getMEs();
448  for (std::vector<std::string>::const_iterator it = meVec.begin();
449  it != meVec.end(); it++) {
450  std::string hname = (*it);
451  if (hname.find("TkHMap_") != std::string::npos) {
452  std::string name = hname.substr(hname.find("TkHMap_")+7);
453  name = name.substr(0,name.find_first_of("_"));
454  *out << "<TkMapOption>" << name << "</TkMapOption>" << std::endl;
455  }
456  }
457  break;
458  }
459  *out << "</TKMapOptionList>" << std::endl;
460  *out << "</LayoutAndTKMapList>" << std::endl;
461  dqm_store->cd();
462 }
463 //
464 // read the Module And HistoList
465 //
467 
468  std::string dname = "SiStrip/" + sname;
469  if (!dqm_store->dirExists(dname)) return;
470 
471  dqm_store->cd(dname);
472  std::vector<std::string> mids;
473  SiStripUtility::getModuleFolderList(dqm_store, mids);
474  dqm_store->cd();
475 
476  setXMLHeader(out);
477  *out << "<ModuleAndHistoList>" << std::endl;
478 
479  // Fill Module List
480  *out << "<ModuleList>" << std::endl;
481  uint32_t aDetId = 0;
482  for (std::vector<std::string>::const_iterator it=mids.begin(); it != mids.end(); it++){
483  std::string moduleId = (*it);
484  moduleId = moduleId.substr(moduleId.find("module_")+7);
485  *out << "<ModuleNum>" << moduleId << "</ModuleNum>" << std::endl;
486  if (aDetId == 0) aDetId = atoi(moduleId.c_str());
487  }
488 
489  *out << "</ModuleList>" << std::endl;
490  // Fill Histo list
491  *out << "<HistoList>" << std::endl;
492 
493  std::vector<MonitorElement*> detector_mes = dqm_store->getContents(mids[0]);
494  for (std::vector<MonitorElement *>::const_iterator it = detector_mes.begin();
495  it!= detector_mes.end(); it++) {
496  MonitorElement * me = (*it);
497  if (!me) continue;
498  std::string hname_full = me->getName();
499  std::string hname = hname_full.substr(0, hname_full.find("__det__"));
500  *out << "<Histo>" << hname << "</Histo>" << std::endl;
501  }
502  *out << "</HistoList>" << std::endl;
503  *out << "</ModuleAndHistoList>" << std::endl;
504 }
505 //
506 // Global Histogram List
507 //
509  std::vector<std::string> hnames;
510  std::string dname = str_name;
511 
512  setXMLHeader(out);
513  *out << "<GlobalHistoList>" << std::endl;
514  if (dqm_store->dirExists(dname)) {
515  std::vector<MonitorElement*> meVec = dqm_store->getContents(dname);
516  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
517  it != meVec.end(); it++) {
518  MonitorElement* me = (*it);
519  if (!me) continue;
520  *out << "<GHisto>" << (*it)->getName() << "</GHisto>" << std::endl;
521  }
522  } else {
523  *out << "<GHisto>" << " Desired directory : " << "</GHisto>" << std::endl;
524  *out << "<GHisto>" << dname << "</GHisto>" << std::endl;
525  *out << "<GHisto>" << " does not exist!!!! " << "</GHisto>" << std::endl;
526  }
527  *out << "</GlobalHistoList>" << std::endl;
528 }
529 //
530 // read the Structure And SummaryHistogram List
531 //
532 void SiStripInformationExtractor::readSummaryHistoTree(DQMStore* dqm_store, std::string& str_name, xgi::Output * out) {
533  std::ostringstream sumtree;
534  std::string dname = "SiStrip/" + str_name;
535  if (dqm_store->dirExists(dname)) {
536  dqm_store->cd(dname);
537  sumtree << "<ul id=\"summary_histo_tree\" class=\"filetree\">" << std::endl;
538  printSummaryHistoList(dqm_store,sumtree);
539  sumtree <<"</ul>" << std::endl;
540  } else {
541  sumtree << " Desired Directory : " << std::endl;
542  sumtree << dname << std::endl;
543  sumtree << " does not exist !!!! " << std::endl;
544  }
545  setPlainHeader(out);
546  *out << sumtree.str();
547  dqm_store->cd();
548 }
549 //
550 // read the Structure And Alarm Tree
551 //
553  std::string& str_name, xgi::Output * out){
554  std::ostringstream alarmtree;
555  std::string dname = "SiStrip/" + str_name;
556  if (dqm_store->dirExists(dname)) {
557  dqm_store->cd(dname);
558  alarmtree << "<ul id=\"alarm_tree\" class=\"filetree\">" << std::endl;
559  printAlarmList(dqm_store,alarmtree);
560  alarmtree <<"</ul>" << std::endl;
561  } else {
562  alarmtree << "Desired Directory : " << std::endl;
563  alarmtree << dname << std::endl;
564  alarmtree << " does not exist !!!! " << std::endl;
565  }
566  setPlainHeader(out);
567  *out << alarmtree.str();
568  dqm_store->cd();
569 }
570 //
571 // Get elements from multi map
572 //
573 void SiStripInformationExtractor::getItemList(const std::multimap<std::string, std::string>& req_map, std::string item_name,std::vector<std::string>& items) {
574  items.clear();
575  for (std::multimap<std::string, std::string>::const_iterator it = req_map.begin();
576  it != req_map.end(); it++) {
577 
578  if (it->first == item_name) {
579  items.push_back(it->second);
580  }
581  }
582 }
583 //
584 // check a specific item in the map
585 //
586 bool SiStripInformationExtractor::hasItem(const std::multimap<std::string,std::string>& req_map,
587  std::string item_name){
588  std::multimap<std::string,std::string>::const_iterator pos = req_map.find(item_name);
589  if (pos != req_map.end()) return true;
590  return false;
591 }
592 //
593 // check the value of an item in the map
594 //
595 std::string SiStripInformationExtractor::getItemValue(const std::multimap<std::string,std::string>& req_map,
596  std::string item_name){
597  std::multimap<std::string,std::string>::const_iterator pos = req_map.find(item_name);
598  std::string value = " ";
599  if (pos != req_map.end()) {
600  value = pos->second;
601  }
602  return value;
603 }
604 //
605 // -- Get color name from status
606 //
608  if (status == dqm::qstatus::STATUS_OK) col = "#00ff00";
609  else if (status == dqm::qstatus::WARNING) col = "#ffff00";
610  else if (status == dqm::qstatus::ERROR) col = "#ff0000";
611  else if (status == dqm::qstatus::OTHER) col = "#ffa500";
612  else col = "#0000ff";
613 }
614 //
615 // -- Get Image name from ME
616 //
617 void SiStripInformationExtractor::selectColor(std::string& col, std::vector<QReport*>& reports){
618  int istat = 999;
619  int status = 0;
620  for (std::vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
621  it++) {
622  status = (*it)->getStatus();
623  if (status > istat) istat = status;
624  }
625  selectColor(col, status);
626 }
627 //
628 // -- Get Image name from status
629 //
631  if (status == dqm::qstatus::STATUS_OK) name="images/LI_green.gif";
632  else if (status == dqm::qstatus::WARNING) name="images/LI_yellow.gif";
633  else if (status == dqm::qstatus::ERROR) name="images/LI_red.gif";
634  else if (status == dqm::qstatus::OTHER) name="images/LI_orange.gif";
635  else name="images/LI_blue.gif";
636 }
637 //
638 // -- Get Image name from ME
639 //
640 void SiStripInformationExtractor::selectImage(std::string& name, std::vector<QReport*>& reports){
641  int istat = 999;
642  int status = 0;
643  for (std::vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
644  it++) {
645  status = (*it)->getStatus();
646  if (status > istat) istat = status;
647  }
648  selectImage(name, status);
649 }
650 //
651 // -- Get Warning/Error Messages
652 //
653 void SiStripInformationExtractor::readStatusMessage(DQMStore* dqm_store, std::multimap<std::string, std::string>& req_map, xgi::Output * out){
654 
655  std::string path = getItemValue(req_map,"Path");
656 
657  int width = atoi(getItemValue(req_map, "width").c_str());
658  int height = atoi(getItemValue(req_map, "height").c_str());
659 
660  std::string opt =" ";
661 
662  std::ostringstream test_status;
663 
664  setXMLHeader(out);
665  *out << "<StatusAndPath>" << std::endl;
666  *out << "<PathList>" << std::endl;
667  if (path.size() == 0) {
668  *out << "<HPath>" << "NONE" << "</HPath>" << std::endl;
669  test_status << " ME Does not exist ! " << std::endl;
670  } else {
671  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
672  *out << "<HPath>" << path << "</HPath>" << std::endl;
673  for(std::vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
674  MonitorElement* me = (*it);
675  if (!me) continue;
676  std::string name = me->getName();
677 
678  std::vector<QReport*> q_reports = me->getQReports();
679  if (q_reports.size() == 0 && name.find("StripQualityFromCondDB") == std::string::npos) continue;
680  std::string full_path = path + "/" + name;
681  histoPlotter_->setNewPlot(full_path, opt, width, height);
682 
683  if (q_reports.size() != 0) {
684  test_status << " QTest Status for " << name << " : " << std::endl;
685  test_status << " ======================================================== " << std::endl;
686  for (std::vector<QReport*>::const_iterator it = q_reports.begin(); it != q_reports.end();
687  it++) {
688  int status = (*it)->getStatus();
689  if (status == dqm::qstatus::WARNING) test_status << " Warning ";
690  else if (status == dqm::qstatus::ERROR) test_status << " Error ";
691  else if (status == dqm::qstatus::STATUS_OK) test_status << " Ok ";
692  else if (status == dqm::qstatus::OTHER) test_status << " Other(" << status << ") ";
693  std::string mess_str = (*it)->getMessage();
694  test_status << " &lt;br/&gt;";
695  mess_str = mess_str.substr(mess_str.find(" Test")+5);
696  test_status << " QTest Name : " << mess_str.substr(0, mess_str.find(")")+1) << std::endl;
697  test_status << " &lt;br/&gt;";
698  test_status << " QTest Detail : " << mess_str.substr(mess_str.find(")")+2) << std::endl;
699  }
700  test_status << " ======================================================== " << std::endl;
701  }
702  *out << "<HName>" << name << "</HName>" << std::endl;
703  }
704  }
705  *out << "</PathList>" << std::endl;
706  *out << "<StatusList>" << std::endl;
707  *out << "<Status>" << test_status.str() << "</Status>" << std::endl;
708  *out << "</StatusList>" << std::endl;
709  *out << "</StatusAndPath>" << std::endl;
710 }
711 //
712 // -- Read the text Summary of QTest result
713 //
715 
716  int nDetsWithError = 0;
717  int nDetsTotal = 0;
718  std::ostringstream qtest_summary, lite_summary;
719 
720  dqm_store->cd();
721  SiStripFolderOrganizer folder_organizer;
722  for (std::vector<std::string>::const_iterator isubdet = subdetVec.begin(); isubdet != subdetVec.end(); isubdet++) {
723  std::string dname = (*isubdet);
724  std::string bad_module_folder = dname + "/" + "BadModuleList";
725  if (!dqm_store->dirExists(dname)) continue;
726 
727  dqm_store->cd(dname);
728  std::vector<std::string> mids;
729  SiStripUtility::getModuleFolderList(dqm_store, mids);
730 
731  int ndet = mids.size();
732  int errdet = 0;
733  dqm_store->cd();
734  dqm_store->cd(dname);
735 
736  qtest_summary << dname.substr(dname.find("View/")+5) << " : <br/>";
737  qtest_summary << "=============================="<< "<br/>";
738  if (dqm_store->dirExists(bad_module_folder)) {
739 
740  std::vector<MonitorElement *> meVec = dqm_store->getContents(bad_module_folder);
741  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
742  it != meVec.end(); it++) {
743  errdet++;
744  int flag = (*it)->getIntValue();
745  std::string message;
746  SiStripUtility::getBadModuleStatus(flag, message);
747  qtest_summary << " Module Id " << (*it)->getName() << " has "<< message << "<br/>";
748  }
749  }
750  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
751  qtest_summary << " Detectors : Total "<< ndet
752  << " with Error " << errdet << "<br/>";
753  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
754  nDetsWithError += errdet;
755  nDetsTotal += ndet;
756  }
757  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
758  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
759  qtest_summary << " Total Detectors " << nDetsTotal;
760  qtest_summary << " # of Detectors with Error " << nDetsWithError << "<br/>";
761  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
762  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
763 
764  lite_summary << " Total Detectors " << nDetsTotal << "<br/>";
765  lite_summary << " # of Detectors with Error " << nDetsWithError << "<br/>";
766 
767  setHTMLHeader(out);
768  if (type == "Lite") *out << lite_summary.str();
769  else {
770  *out << qtest_summary.str();
771  }
772  dqm_store->cd();
773 }
774 //
775 // -- Create Images
776 //
780 }
781 //
782 // -- Set HTML Header in xgi output
783 //
785  out->getHTTPResponseHeader().addHeader("Content-Type", "text/html");
786  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
787  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
788  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
789 }
790 //
791 // -- Set XML Header in xgi output
792 //
794  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
795  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
796  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
797  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
798  *out << "<?xml version=\"1.0\" ?>" << std::endl;
799 
800 }
801 //
802 // -- Set Plain Header in xgi output
803 //
805  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
806  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
807  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
808  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
809 
810 }
811 //
812 // read the Structure And Readout/Control Histogram List
813 //
814 void SiStripInformationExtractor::readNonGeomHistoTree(DQMStore* dqm_store, std::string& fld_name, xgi::Output * out) {
815  std::ostringstream sumtree;
816  std::string dname = "SiStrip/" + fld_name;
817  if (dqm_store->dirExists(dname)) {
818  dqm_store->cd(dname);
819  sumtree << "<ul id=\"non_geo_tree\" class=\"filetree\">" << std::endl;
820  printNonGeomHistoList(dqm_store,sumtree);
821  sumtree <<"</ul>" << std::endl;
822  } else {
823  sumtree << " Desired Directory : " << std::endl;
824  sumtree << dname << std::endl;
825  sumtree << " does not exist !!!! " << std::endl;
826  }
827  setPlainHeader(out);
828  *out << sumtree.str();
829  dqm_store->cd();
830 }
831 //
832 // -- Fill Readout/Control Histo List
833 //
834 void SiStripInformationExtractor::printNonGeomHistoList(DQMStore * dqm_store, std::ostringstream& str_val){
835  static std::string indent_str = "";
836 
837  std::string currDir = dqm_store->pwd();
838  std::string dname = currDir.substr(currDir.find_last_of("/")+1);
839  str_val << "<li><span class=\"folder\">" << dname << "</span>" << std::endl;
840  std::vector<MonitorElement *> meVec = dqm_store->getContents(currDir);
841  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
842  if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
843  str_val << "</li> "<< std::endl;
844  return;
845  }
846  str_val << "<ul>" << std::endl;
847  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
848  it != meVec.end(); it++) {
849  MonitorElement* me = (*it);
850  if (!me) continue;
851  std::string name = (*it)->getName();
852  str_val << "<li> <span class=\"file\"><a href=\"javascript:RequestHistos.DrawSummaryHistogram('"
853  << currDir
854  << "')\">" << name << "</a></span></li>" << std::endl;
855  }
856  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
857  ic != subDirVec.end(); ic++) {
858  dqm_store->cd(*ic);
859  printNonGeomHistoList(dqm_store, str_val);
860  dqm_store->goUp();
861  }
862  str_val << "</ul> "<< std::endl;
863  str_val << "</li> "<< std::endl;
864 }
void readSummaryHistoTree(DQMStore *dqm_store, std::string &str_name, xgi::Output *out)
type
Definition: HCALResponse.h:22
void getSingleModuleHistos(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
const std::string & getName(void) const
get name of ME
long int flag
Definition: mlp_lapack.h:47
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:2703
static const int OTHER
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1419
void plotHistosFromLayout(DQMStore *dqm_store)
void getCondDBHistos(DQMStore *dqm_store, bool &plot_flag, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void createPlots(DQMStore *dqm_store)
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:406
void getTrackerMapHistos(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void printAlarmList(DQMStore *dqm_store, std::ostringstream &str_val)
static const int WARNING
void setNewCondDBPlot(std::string &path, std::string &option, int width, int height)
static void getBadModuleStatus(uint16_t flag, std::string &message)
static void split(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
dictionary map
Definition: Association.py:205
void createStaticPlot(MonitorElement *me, const std::string &file_name)
void selectColor(std::string &col, int status)
void readModuleAndHistoList(DQMStore *dqm_store, std::string &sname, const edm::ESHandle< SiStripDetCabling > &detcabling, xgi::Output *out)
list path
Definition: scaleCards.py:51
std::vector< std::string > subdetVec
void getNamedImageBuffer(const std::string &path, std::string &image)
std::map< std::string, std::vector< std::string > > layoutMap
void readStatusMessage(DQMStore *dqm_store, std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void createCondDBPlots(DQMStore *dqm_store)
void createImages(DQMStore *dqm_store)
void printNonGeomHistoList(DQMStore *dqm_store, std::ostringstream &str_val)
void readGlobalHistoList(DQMStore *dqm_store, std::string &dname, xgi::Output *out)
void getImage(const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1497
void readLayoutNames(DQMStore *dqm_store, xgi::Output *out)
void printSummaryHistoList(DQMStore *dqm_store, std::ostringstream &str_val)
void getGlobalHistos(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:493
tuple out
Definition: dbtoconf.py:99
void getFolderName(int32_t rawdetid, std::string &lokal_folder)
void getHistosFromPath(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
std::vector< QReport * > getQReports(void) const
get map of QReports
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1442
string fname
main script
void selectImage(std::string &name, int status)
#define Output(cl)
Definition: vmac.h:193
void readQTestSummary(DQMStore *dqm_store, std::string type, xgi::Output *out)
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:440
std::string getItemValue(const std::multimap< std::string, std::string > &req_map, std::string item_name)
bool getAllLayouts(std::map< std::string, std::vector< std::string > > &me_names)
static const int STATUS_OK
void setNewPlot(std::string &path, std::string &option, int width, int height)
tuple status
Definition: ntuplemaker.py:245
static void getModuleFolderList(DQMStore *dqm_store, std::vector< std::string > &m_ids)
bool hasItem(const std::multimap< std::string, std::string > &req_map, std::string item_name)
void readNonGeomHistoTree(DQMStore *dqm_store, std::string &fld_name, xgi::Output *out)
static const int ERROR
void getItemList(const std::multimap< std::string, std::string > &req_map, std::string item_name, std::vector< std::string > &items)
const std::string & pwd(void) const
Definition: DQMStore.cc:401
void readAlarmTree(DQMStore *dqm_store, std::string &str_name, xgi::Output *out)