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) {
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/PLUS");
60  subdetVec.push_back("SiStrip/MechanicalView/TID/MINUS");
61  subdetVec.push_back("SiStrip/MechanicalView/TEC/PLUS");
62  subdetVec.push_back("SiStrip/MechanicalView/TEC/MINUS");
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 //
164 /* removing xdaq dep
165 void SiStripInformationExtractor::getSingleModuleHistos(DQMStore * dqm_store,
166  const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
167 
168  std::vector<std::string> hlist;
169  getItemList(req_map,"histo", hlist);
170 
171  uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
172 
173  int width = atoi(getItemValue(req_map, "width").c_str());
174  int height = atoi(getItemValue(req_map, "height").c_str());
175 
176  std::string opt =" ";
177 
178  SiStripFolderOrganizer folder_organizer;
179  std::string path;
180  folder_organizer.getFolderName(detId,path);
181 
182  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
183  setXMLHeader(out);
184  *out << "<HPathAndHNameList>" << std::endl;
185  *out << "<HPath>" << path << "</HPath>" << std::endl;
186 
187  for (std::vector<std::string>::const_iterator ih = hlist.begin();
188  ih != hlist.end(); ih++) {
189  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
190  it!= all_mes.end(); it++) {
191  MonitorElement * me = (*it);
192  if (!me) continue;
193  std::string hname = me->getName();
194  std::string name = hname.substr(0, hname.find("__det__"));
195  if (name == (*ih)) {
196  std::string full_path = path + "/" + hname;
197  histoPlotter_->setNewPlot(full_path, opt, width, height);
198  *out << "<HName>" << hname << "</HName>" << std::endl;
199  }
200  }
201  }
202  *out << "</HPathAndHNameList>" << std::endl;
203 }
204 */
205 //
206 // -- Select Histograms from Global folder
207 //
208 /* removing xdaq dep
209 void SiStripInformationExtractor::getGlobalHistos(DQMStore* dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out) {
210 
211  std::vector<std::string> hlist;
212  getItemList(req_map,"histo", hlist);
213 
214  std::string path = getItemValue(req_map, "GlobalFolder");
215 
216  int width = atoi(getItemValue(req_map, "width").c_str());
217  int height = atoi(getItemValue(req_map, "height").c_str());
218 
219  std::string opt =" ";
220 
221  std::vector<MonitorElement *> all_mes = dqm_store->getContents(path);
222 
223  setXMLHeader(out);
224  *out << "<HPathAndHNameList>" << std::endl;
225  *out << "<HPath>" << path << "</HPath>" << std::endl;
226 
227  for (std::vector<std::string>::const_iterator ih = hlist.begin();
228  ih != hlist.end(); ih++) {
229  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
230  it!= all_mes.end(); it++) {
231  MonitorElement * me = (*it);
232  if (!me) continue;
233  std::string hname = me->getName();
234  std::string name = hname.substr(0, hname.find("__det__"));
235  if (name == (*ih)) {
236  std::string full_path = path + "/" + hname;
237  histoPlotter_->setNewPlot(full_path, opt, width, height);
238  *out << "<HName>" << name << "</HName>" << std::endl;
239  }
240  }
241  }
242  *out << "</HPathAndHNameList>" << std::endl;
243 }
244 */
245 //
246 // -- Get All histograms from a Path
247 //
248 /* removing xdaq dep
249 void SiStripInformationExtractor::getHistosFromPath(DQMStore * dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
250 
251  std::string path = getItemValue(req_map,"Path");
252 
253  if (path.size() == 0) return;
254 
255  int width = atoi(getItemValue(req_map, "width").c_str());
256  int height = atoi(getItemValue(req_map, "height").c_str());
257 
258  std::string opt =" ";
259 
260  setXMLHeader(out);
261  *out << "<HPathAndHNameList>" << std::endl;
262  *out << "<HPath>" << path << "</HPath>" << std::endl;
263 
264  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
265  for(std::vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
266  MonitorElement* me = (*it);
267  if (!me) continue;
268  std::string name = me->getName();
269  std::string full_path = path + "/" + name;
270  histoPlotter_->setNewPlot(full_path, opt, width, height);
271  *out << "<HName>" << name << "</HName>" << std::endl;
272  }
273  *out << "</HPathAndHNameList>" << std::endl;
274 }
275 */
276 //
277 // plot Histograms from Layout
278 //
280  if (layoutMap.size() == 0) return;
281 
282  std::ofstream image_file;
283 
284  for (std::map<std::string, std::vector< std::string > >::iterator it = layoutMap.begin() ; it != layoutMap.end(); it++) {
285  unsigned int ival = 0;
286  std::string image_list = "images/" + it->first +".lis";
287  image_file.open(image_list.c_str(), std::ios::out);
288  if (!image_file) return;
289 
290  image_file << "[";
291  for (std::vector<std::string>::iterator im = it->second.begin();
292  im != it->second.end(); im++) {
293  std::string path_name = (*im);
294  if (path_name.size() == 0) continue;
295  MonitorElement* me = dqm_store->get(path_name);
296  ival++;
297  std::ostringstream fname, ftitle;
298  if (!me) {
299  fname << "images/EmptyPlot.png";
300  ftitle << "EmptyPlot";
301  } else {
302  fname << "images/" << it->first << "_" <<ival << ".png";
303  ftitle << me->getName();
304  histoPlotter_->createStaticPlot(me, fname.str());
305  }
306  image_file << "["<< "\"" << fname.str() << "\",\"" << path_name << "\"]";
307  if (ival != it->second.size()) image_file << ","<< std::endl;
308  }
309  image_file << "]" << std::endl;
310  image_file.close();
311  }
312 }
313 //
314 // -- Plot Tracker Map MEs
315 //
316 /* removing xdaq dep
317 void SiStripInformationExtractor::getTrackerMapHistos(DQMStore* dqm_store, const std::multimap<std::string, std::string>& req_map, xgi::Output * out) {
318 
319  uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
320 
321  int width = atoi(getItemValue(req_map, "width").c_str());
322  int height = atoi(getItemValue(req_map, "height").c_str());
323 
324  std::string opt =" ";
325 
326  SiStripFolderOrganizer folder_organizer;
327  std::string path;
328  folder_organizer.getFolderName(detId,path);
329 
330  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
331  setXMLHeader(out);
332  *out << "<HPathAndHNameList>" << std::endl;
333  *out << "<HPath>" << path << "</HPath>" << std::endl;
334  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
335  it!= all_mes.end(); it++) {
336  MonitorElement * me = (*it);
337  if (!me) continue;
338  std::string hname = me->getName();
339  std::string full_path;
340  full_path = path + "/" + hname;
341  histoPlotter_->setNewPlot(full_path, opt, width, height);
342  *out << "<HName>" << hname << "</HName>" << std::endl;
343  }
344  *out << "</HPathAndHNameList>" << std::endl;
345 
346 }
347 */
348 //
349 // -- Select Histograms for a given module
350 //
351 /* removing xdaq dep
352 void SiStripInformationExtractor::getCondDBHistos(DQMStore * dqm_store, bool& plot_flag, const std::multimap<std::string, std::string>& req_map,xgi::Output * out){
353 
354  plot_flag = true;
355  std::string sname = getItemValue(req_map,"StructureName");
356  int width = atoi(getItemValue(req_map, "width").c_str());
357  int height = atoi(getItemValue(req_map, "height").c_str());
358 
359  std::string path = "";
360  uint32_t detId;
361  if (hasItem(req_map,std::string("ModId"))) {
362  detId = atoi(getItemValue(req_map,"ModId").c_str());
363  if (detId != 0) {
364  SiStripFolderOrganizer folder_organizer;
365  folder_organizer.getFolderName(detId,path);
366  }
367  } else {
368  if (sname.size() > 0) path = "SiStrip/" + sname;
369  }
370  if (path.size() == 0) path = "dummy_path";
371 
372  setXMLHeader(out);
373  *out << "<HPathAndHNameList>" << std::endl;
374  *out << "<HPath>" << path << "</HPath>" << std::endl;
375 
376  if (path == "dummy_path") {
377  *out << "<HName>" << "Dummy" << "</HName>" << std::endl;
378  plot_flag = false;
379  } else {
380  std::string opt = getItemValue(req_map,"option");
381  std::vector<std::string> htypes;
382  SiStripUtility::split(opt, htypes, ",");
383  // Check if CondDB histograms already exists
384  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
385  for (std::vector<std::string>::const_iterator ih = htypes.begin();
386  ih!= htypes.end(); ih++) {
387  std::string type = (*ih);
388  if (type.size() == 0) continue;
389  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
390  it!= all_mes.end(); it++) {
391  MonitorElement * me = (*it);
392  if (!me) continue;
393  std::string hname = me->getName();
394  if (hname.find(type) != std::string::npos) {
395  plot_flag = false;
396  break;
397  }
398  }
399  if (plot_flag == false) break;
400  }
401  histoPlotter_->setNewCondDBPlot(path, opt, width, height);
402  for (std::vector<std::string>::const_iterator ih = htypes.begin();
403  ih != htypes.end(); ih++) {
404  if ((*ih).size() > 0) {
405  *out << "<HName>" << (*ih) << "</HName>" << std::endl;
406  }
407  }
408  }
409  *out << "</HPathAndHNameList>" << std::endl;
410 }
411 */
412 //
413 // -- Get a tagged image
414 //
415 /* removing xdaq dep
416 void SiStripInformationExtractor::getImage(const std::multimap<std::string, std::string>& req_map, xgi::Output * out){
417 
418  std::string path = getItemValue(req_map,"Path");
419  std::string image;
420  histoPlotter_->getNamedImageBuffer(path, image);
421  out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
422  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
423  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
424  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
425  *out << image;
426 
427 }
428 */
429 //
430 // -- Read Layout Group names
431 //
432 /* removing xdaq dep
433 void SiStripInformationExtractor::readLayoutNames(DQMStore* dqm_store, xgi::Output * out){
434  setXMLHeader(out);
435  *out << "<LayoutAndTKMapList>" << std::endl;
436  if (layoutMap.size() > 0) {
437  *out << "<LayoutList>" << std::endl;
438  for (std::map<std::string, std::vector< std::string > >::iterator it = layoutMap.begin();
439  it != layoutMap.end(); it++) {
440  *out << "<LName>" << it->first << "</LName>" << std::endl;
441  }
442  *out << "</LayoutList>" << std::endl;
443  }
444  dqm_store->cd();
445  *out << "<TKMapOptionList>" << std::endl;
446  *out << "<TkMapOption>" << "QTestAlarm" << "</TkMapOption>" << std::endl;
447 
448  for (std::vector<std::string>::const_iterator isubdet = subdetVec.begin(); isubdet != subdetVec.end(); isubdet++) {
449  std::string dname = (*isubdet);
450  if (!dqm_store->dirExists(dname)) continue;
451  dqm_store->cd(dname);
452  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
453  if (subDirVec.size() == 0) continue;
454  for (std::vector<std::string>::const_iterator ilayer = subDirVec.begin(); ilayer != subDirVec.end(); ilayer++) {
455  std::string lname = (*ilayer);
456  if (lname.find("BadModuleList") != std::string::npos) continue;
457  dqm_store->cd(lname);
458  break;
459  }
460  std::vector<std::string> meVec = dqm_store->getMEs();
461  for (std::vector<std::string>::const_iterator it = meVec.begin();
462  it != meVec.end(); it++) {
463  std::string hname = (*it);
464  if (hname.find("TkHMap_") != std::string::npos) {
465  std::string name = hname.substr(hname.find("TkHMap_")+7);
466  name = name.substr(0,name.find_first_of("_"));
467  *out << "<TkMapOption>" << name << "</TkMapOption>" << std::endl;
468  }
469  }
470  break;
471  }
472  *out << "</TKMapOptionList>" << std::endl;
473  *out << "</LayoutAndTKMapList>" << std::endl;
474  dqm_store->cd();
475 }
476 */
477 //
478 // read the Module And HistoList
479 //
480 /* removing xdaq dep
481 void SiStripInformationExtractor::readModuleAndHistoList(DQMStore* dqm_store, std::string& sname, const edm::ESHandle<SiStripDetCabling>& detcabling,xgi::Output * out) {
482 
483  std::string dname = "SiStrip/" + sname;
484  if (!dqm_store->dirExists(dname)) return;
485 
486  dqm_store->cd(dname);
487  std::vector<std::string> mids;
488  SiStripUtility::getModuleFolderList(dqm_store, mids);
489  dqm_store->cd();
490 
491  setXMLHeader(out);
492  *out << "<ModuleAndHistoList>" << std::endl;
493 
494  // Fill Module List
495  *out << "<ModuleList>" << std::endl;
496  uint32_t aDetId = 0;
497  for (std::vector<std::string>::const_iterator it=mids.begin(); it != mids.end(); it++){
498  std::string moduleId = (*it);
499  moduleId = moduleId.substr(moduleId.find("module_")+7);
500  *out << "<ModuleNum>" << moduleId << "</ModuleNum>" << std::endl;
501  if (aDetId == 0) aDetId = atoi(moduleId.c_str());
502  }
503 
504  *out << "</ModuleList>" << std::endl;
505  // Fill Histo list
506  *out << "<HistoList>" << std::endl;
507 
508  std::vector<MonitorElement*> detector_mes = dqm_store->getContents(mids[0]);
509  for (std::vector<MonitorElement *>::const_iterator it = detector_mes.begin();
510  it!= detector_mes.end(); it++) {
511  MonitorElement * me = (*it);
512  if (!me) continue;
513  std::string hname_full = me->getName();
514  std::string hname = hname_full.substr(0, hname_full.find("__det__"));
515  *out << "<Histo>" << hname << "</Histo>" << std::endl;
516  }
517  *out << "</HistoList>" << std::endl;
518  *out << "</ModuleAndHistoList>" << std::endl;
519 }
520 */
521 //
522 // Global Histogram List
523 //
524 /* removing xdaq dep
525 void SiStripInformationExtractor::readGlobalHistoList(DQMStore* dqm_store, std::string& str_name,xgi::Output * out) {
526  std::vector<std::string> hnames;
527  std::string dname = str_name;
528 
529  setXMLHeader(out);
530  *out << "<GlobalHistoList>" << std::endl;
531  if (dqm_store->dirExists(dname)) {
532  std::vector<MonitorElement*> meVec = dqm_store->getContents(dname);
533  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
534  it != meVec.end(); it++) {
535  MonitorElement* me = (*it);
536  if (!me) continue;
537  *out << "<GHisto>" << (*it)->getName() << "</GHisto>" << std::endl;
538  }
539  } else {
540  *out << "<GHisto>" << " Desired directory : " << "</GHisto>" << std::endl;
541  *out << "<GHisto>" << dname << "</GHisto>" << std::endl;
542  *out << "<GHisto>" << " does not exist!!!! " << "</GHisto>" << std::endl;
543  }
544  *out << "</GlobalHistoList>" << std::endl;
545 }
546 */
547 //
548 // read the Structure And SummaryHistogram List
549 //
550 /* removing xdaq dep
551 void SiStripInformationExtractor::readSummaryHistoTree(DQMStore* dqm_store, std::string& str_name, xgi::Output * out) {
552  std::ostringstream sumtree;
553  std::string dname = "SiStrip/" + str_name;
554  if (dqm_store->dirExists(dname)) {
555  dqm_store->cd(dname);
556  sumtree << "<ul id=\"summary_histo_tree\" class=\"filetree\">" << std::endl;
557  printSummaryHistoList(dqm_store,sumtree);
558  sumtree <<"</ul>" << std::endl;
559  } else {
560  sumtree << " Desired Directory : " << std::endl;
561  sumtree << dname << std::endl;
562  sumtree << " does not exist !!!! " << std::endl;
563  }
564  setPlainHeader(out);
565  *out << sumtree.str();
566  dqm_store->cd();
567 }
568 */
569 //
570 // read the Structure And Alarm Tree
571 //
572 /* removing xdaq dep
573 void SiStripInformationExtractor::readAlarmTree(DQMStore* dqm_store,
574  std::string& str_name, xgi::Output * out){
575  std::ostringstream alarmtree;
576  std::string dname = "SiStrip/" + str_name;
577  if (dqm_store->dirExists(dname)) {
578  dqm_store->cd(dname);
579  alarmtree << "<ul id=\"alarm_tree\" class=\"filetree\">" << std::endl;
580  printAlarmList(dqm_store,alarmtree);
581  alarmtree <<"</ul>" << std::endl;
582  } else {
583  alarmtree << "Desired Directory : " << std::endl;
584  alarmtree << dname << std::endl;
585  alarmtree << " does not exist !!!! " << std::endl;
586  }
587  setPlainHeader(out);
588  *out << alarmtree.str();
589  dqm_store->cd();
590 }
591 */
592 //
593 // Get elements from multi map
594 //
595 void SiStripInformationExtractor::getItemList(const std::multimap<std::string, std::string>& req_map, std::string item_name,std::vector<std::string>& items) {
596  items.clear();
597  for (std::multimap<std::string, std::string>::const_iterator it = req_map.begin();
598  it != req_map.end(); it++) {
599 
600  if (it->first == item_name) {
601  items.push_back(it->second);
602  }
603  }
604 }
605 //
606 // check a specific item in the map
607 //
608 bool SiStripInformationExtractor::hasItem(const std::multimap<std::string,std::string>& req_map,
609  std::string item_name){
610  std::multimap<std::string,std::string>::const_iterator pos = req_map.find(item_name);
611  if (pos != req_map.end()) return true;
612  return false;
613 }
614 //
615 // check the value of an item in the map
616 //
617 std::string SiStripInformationExtractor::getItemValue(const std::multimap<std::string,std::string>& req_map,
618  std::string item_name){
619  std::multimap<std::string,std::string>::const_iterator pos = req_map.find(item_name);
620  std::string value = " ";
621  if (pos != req_map.end()) {
622  value = pos->second;
623  }
624  return value;
625 }
626 //
627 // -- Get color name from status
628 //
630  if (status == dqm::qstatus::STATUS_OK) col = "#00ff00";
631  else if (status == dqm::qstatus::WARNING) col = "#ffff00";
632  else if (status == dqm::qstatus::ERROR) col = "#ff0000";
633  else if (status == dqm::qstatus::OTHER) col = "#ffa500";
634  else col = "#0000ff";
635 }
636 //
637 // -- Get Image name from ME
638 //
639 void SiStripInformationExtractor::selectColor(std::string& col, std::vector<QReport*>& reports){
640  int istat = 999;
641  int status = 0;
642  for (std::vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
643  it++) {
644  status = (*it)->getStatus();
645  if (status > istat) istat = status;
646  }
647  selectColor(col, status);
648 }
649 //
650 // -- Get Image name from status
651 //
653  if (status == dqm::qstatus::STATUS_OK) name="images/LI_green.gif";
654  else if (status == dqm::qstatus::WARNING) name="images/LI_yellow.gif";
655  else if (status == dqm::qstatus::ERROR) name="images/LI_red.gif";
656  else if (status == dqm::qstatus::OTHER) name="images/LI_orange.gif";
657  else name="images/LI_blue.gif";
658 }
659 //
660 // -- Get Image name from ME
661 //
662 void SiStripInformationExtractor::selectImage(std::string& name, std::vector<QReport*>& reports){
663  int istat = 999;
664  int status = 0;
665  for (std::vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
666  it++) {
667  status = (*it)->getStatus();
668  if (status > istat) istat = status;
669  }
670  selectImage(name, status);
671 }
672 //
673 // -- Get Warning/Error Messages
674 //
675 /* removing xdaq dep
676 void SiStripInformationExtractor::readStatusMessage(DQMStore* dqm_store, std::multimap<std::string, std::string>& req_map, xgi::Output * out){
677 
678  std::string path = getItemValue(req_map,"Path");
679 
680  int width = atoi(getItemValue(req_map, "width").c_str());
681  int height = atoi(getItemValue(req_map, "height").c_str());
682 
683  std::string opt =" ";
684 
685  std::ostringstream test_status;
686 
687  setXMLHeader(out);
688  *out << "<StatusAndPath>" << std::endl;
689  *out << "<PathList>" << std::endl;
690  if (path.size() == 0) {
691  *out << "<HPath>" << "NONE" << "</HPath>" << std::endl;
692  test_status << " ME Does not exist ! " << std::endl;
693  } else {
694  std::vector<MonitorElement*> all_mes = dqm_store->getContents(path);
695  *out << "<HPath>" << path << "</HPath>" << std::endl;
696  for(std::vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
697  MonitorElement* me = (*it);
698  if (!me) continue;
699  std::string name = me->getName();
700 
701  std::vector<QReport*> q_reports = me->getQReports();
702  if (q_reports.size() == 0 && name.find("StripQualityFromCondDB") == std::string::npos) continue;
703  std::string full_path = path + "/" + name;
704  histoPlotter_->setNewPlot(full_path, opt, width, height);
705 
706  if (q_reports.size() != 0) {
707  test_status << " QTest Status for " << name << " : " << std::endl;
708  test_status << " ======================================================== " << std::endl;
709  for (std::vector<QReport*>::const_iterator it = q_reports.begin(); it != q_reports.end();
710  it++) {
711  int status = (*it)->getStatus();
712  if (status == dqm::qstatus::WARNING) test_status << " Warning ";
713  else if (status == dqm::qstatus::ERROR) test_status << " Error ";
714  else if (status == dqm::qstatus::STATUS_OK) test_status << " Ok ";
715  else if (status == dqm::qstatus::OTHER) test_status << " Other(" << status << ") ";
716  std::string mess_str = (*it)->getMessage();
717  test_status << " &lt;br/&gt;";
718  mess_str = mess_str.substr(mess_str.find(" Test")+5);
719  test_status << " QTest Name : " << mess_str.substr(0, mess_str.find(")")+1) << std::endl;
720  test_status << " &lt;br/&gt;";
721  test_status << " QTest Detail : " << mess_str.substr(mess_str.find(")")+2) << std::endl;
722  }
723  test_status << " ======================================================== " << std::endl;
724  }
725  *out << "<HName>" << name << "</HName>" << std::endl;
726  }
727  }
728  *out << "</PathList>" << std::endl;
729  *out << "<StatusList>" << std::endl;
730  *out << "<Status>" << test_status.str() << "</Status>" << std::endl;
731  *out << "</StatusList>" << std::endl;
732  *out << "</StatusAndPath>" << std::endl;
733 }
734 */
735 //
736 // -- Read the text Summary of QTest result
737 //
738 /* removing xdaq dep
739 void SiStripInformationExtractor::readQTestSummary(DQMStore* dqm_store, std::string type, xgi::Output * out) {
740 
741  int nDetsWithError = 0;
742  int nDetsTotal = 0;
743  std::ostringstream qtest_summary, lite_summary;
744 
745  dqm_store->cd();
746  SiStripFolderOrganizer folder_organizer;
747  for (std::vector<std::string>::const_iterator isubdet = subdetVec.begin(); isubdet != subdetVec.end(); isubdet++) {
748  std::string dname = (*isubdet);
749  std::string bad_module_folder = dname + "/" + "BadModuleList";
750  if (!dqm_store->dirExists(dname)) continue;
751 
752  dqm_store->cd(dname);
753  std::vector<std::string> mids;
754  SiStripUtility::getModuleFolderList(dqm_store, mids);
755 
756  int ndet = mids.size();
757  int errdet = 0;
758  dqm_store->cd();
759  dqm_store->cd(dname);
760 
761  qtest_summary << dname.substr(dname.find("View/")+5) << " : <br/>";
762  qtest_summary << "=============================="<< "<br/>";
763  if (dqm_store->dirExists(bad_module_folder)) {
764 
765  std::vector<MonitorElement *> meVec = dqm_store->getContents(bad_module_folder);
766  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
767  it != meVec.end(); it++) {
768  errdet++;
769  int flag = (*it)->getIntValue();
770  std::string message;
771  SiStripUtility::getBadModuleStatus(flag, message);
772  qtest_summary << " Module Id " << (*it)->getName() << " has "<< message << "<br/>";
773  }
774  }
775  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
776  qtest_summary << " Detectors : Total "<< ndet
777  << " with Error " << errdet << "<br/>";
778  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
779  nDetsWithError += errdet;
780  nDetsTotal += ndet;
781  }
782  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
783  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
784  qtest_summary << " Total Detectors " << nDetsTotal;
785  qtest_summary << " # of Detectors with Error " << nDetsWithError << "<br/>";
786  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
787  qtest_summary << "--------------------------------------------------------------------"<< "<br/>";
788 
789  lite_summary << " Total Detectors " << nDetsTotal << "<br/>";
790  lite_summary << " # of Detectors with Error " << nDetsWithError << "<br/>";
791 
792  setHTMLHeader(out);
793  if (type == "Lite") *out << lite_summary.str();
794  else {
795  *out << qtest_summary.str();
796  }
797  dqm_store->cd();
798 }
799 */
800 //
801 // -- Create Images
802 //
806 }
807 //
808 // -- Set HTML Header in xgi output
809 //
810 /* removing xdaq dep
811 void SiStripInformationExtractor::setHTMLHeader(xgi::Output * out) {
812  out->getHTTPResponseHeader().addHeader("Content-Type", "text/html");
813  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
814  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
815  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
816 }
817 */
818 //
819 // -- Set XML Header in xgi output
820 //
821 /* removing xdaq dep
822 void SiStripInformationExtractor::setXMLHeader(xgi::Output * out) {
823  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
824  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
825  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
826  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
827  *out << "<?xml version=\"1.0\" ?>" << std::endl;
828 
829 }
830 */
831 //
832 // -- Set Plain Header in xgi output
833 //
834 /* removing xdaq dep
835 void SiStripInformationExtractor::setPlainHeader(xgi::Output * out) {
836  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
837  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
838  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
839  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
840 
841 }
842 */
843 //
844 // read the Structure And Readout/Control Histogram List
845 //
846 /* removing xdaq dep
847 void SiStripInformationExtractor::readNonGeomHistoTree(DQMStore* dqm_store, std::string& fld_name, xgi::Output * out) {
848  std::ostringstream sumtree;
849  std::string dname = "SiStrip/" + fld_name;
850  if (dqm_store->dirExists(dname)) {
851  dqm_store->cd(dname);
852  sumtree << "<ul id=\"non_geo_tree\" class=\"filetree\">" << std::endl;
853  printNonGeomHistoList(dqm_store,sumtree);
854  sumtree <<"</ul>" << std::endl;
855  } else {
856  sumtree << " Desired Directory : " << std::endl;
857  sumtree << dname << std::endl;
858  sumtree << " does not exist !!!! " << std::endl;
859  }
860  setPlainHeader(out);
861  *out << sumtree.str();
862  dqm_store->cd();
863 }
864 */
865 //
866 // -- Fill Readout/Control Histo List
867 //
868 void SiStripInformationExtractor::printNonGeomHistoList(DQMStore * dqm_store, std::ostringstream& str_val){
869  static std::string indent_str = "";
870 
871  std::string currDir = dqm_store->pwd();
872  std::string dname = currDir.substr(currDir.find_last_of("/")+1);
873  str_val << "<li><span class=\"folder\">" << dname << "</span>" << std::endl;
874  std::vector<MonitorElement *> meVec = dqm_store->getContents(currDir);
875  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
876  if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
877  str_val << "</li> "<< std::endl;
878  return;
879  }
880  str_val << "<ul>" << std::endl;
881  for (std::vector<MonitorElement *>::const_iterator it = meVec.begin();
882  it != meVec.end(); it++) {
883  MonitorElement* me = (*it);
884  if (!me) continue;
885  std::string name = (*it)->getName();
886  str_val << "<li> <span class=\"file\"><a href=\"javascript:RequestHistos.DrawSummaryHistogram('"
887  << currDir
888  << "')\">" << name << "</a></span></li>" << std::endl;
889  }
890  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
891  ic != subDirVec.end(); ic++) {
892  dqm_store->cd(*ic);
893  printNonGeomHistoList(dqm_store, str_val);
894  dqm_store->goUp();
895  }
896  str_val << "</ul> "<< std::endl;
897  str_val << "</li> "<< std::endl;
898 }
899 
const std::string & getName(void) const
get name of ME
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:3339
static const int OTHER
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1699
void plotHistosFromLayout(DQMStore *dqm_store)
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:684
void printAlarmList(DQMStore *dqm_store, std::ostringstream &str_val)
static const int WARNING
void createStaticPlot(MonitorElement *me, const std::string &file_name)
void selectColor(std::string &col, int status)
std::vector< std::string > subdetVec
std::map< std::string, std::vector< std::string > > layoutMap
void createCondDBPlots(DQMStore *dqm_store)
void createImages(DQMStore *dqm_store)
void printNonGeomHistoList(DQMStore *dqm_store, std::ostringstream &str_val)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1748
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1777
void printSummaryHistoList(DQMStore *dqm_store, std::ostringstream &str_val)
tuple out
Definition: dbtoconf.py:99
std::vector< QReport * > getQReports(void) const
get map of QReports
string fname
main script
void selectImage(std::string &name, int status)
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:718
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
tuple status
Definition: ntuplemaker.py:245
int col
Definition: cuy.py:1008
bool hasItem(const std::multimap< std::string, std::string > &req_map, std::string item_name)
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:679