CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelInformationExtractor.cc
Go to the documentation of this file.
1 
13 
16 
19 
27 
30 
36 
37 #include "TClass.h"
38 #include "TText.h"
39 #include "TROOT.h"
40 #include "TPad.h"
41 #include "TStyle.h"
42 #include "TSystem.h"
43 #include "TString.h"
44 #include "TImage.h"
45 #include "TPaveText.h"
46 #include "TImageDump.h"
47 #include "TRandom.h"
48 #include "TStopwatch.h"
49 #include "TAxis.h"
50 #include "TPaveLabel.h"
51 #include "Rtypes.h"
52 #include "TH1F.h"
53 #include "TH2F.h"
54 #include "TProfile.h"
55 
56 #include <iostream>
57 #include <math.h>
58 #include <map>
59 
60 #include <cstdlib> // for free() - Root can allocate with malloc() - sigh...
61 
62 using namespace std;
63 using namespace edm;
64 
65 //------------------------------------------------------------------------------
69 SiPixelInformationExtractor::SiPixelInformationExtractor(bool offlineXMLfile) : offlineXMLfile_(offlineXMLfile) {
70  edm::LogInfo("SiPixelInformationExtractor") <<
71  " Creating SiPixelInformationExtractor " << "\n" ;
72 
73  readReference_ = false;
74  histoPlotter_=0;
76 }
77 
78 //------------------------------------------------------------------------------
83  edm::LogInfo("SiPixelInformationExtractor") <<
84  " Deleting SiPixelInformationExtractor " << "\n" ;
85 
86  if (histoPlotter_) delete histoPlotter_;
87 }
88 
89 //------------------------------------------------------------------------------
94 
95 //
96 // -- Select Histograms for a given module
97 //
98 /*Removing xdaq deps
99 void SiPixelInformationExtractor::getSingleModuleHistos(DQMStore * bei,
100  const multimap<string, string>& req_map,
101  xgi::Output * out,
102  bool isUpgrade){
103  //cout<<"In SiPixelInformationExtractor::getSingleModuleHistos: "<<endl;
104  vector<string> hlist;
105  getItemList(req_map,"histo", hlist);
106 
107  uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
108 
109  int width = atoi(getItemValue(req_map, "width").c_str());
110  int height = atoi(getItemValue(req_map, "height").c_str());
111 
112  string opt =" ";
113 
114  SiPixelFolderOrganizer folder_organizer;
115  string path;
116  folder_organizer.getModuleFolder(detId,path,isUpgrade);
117 
118  if((bei->pwd()).find("Module_") == string::npos &&
119  (bei->pwd()).find("FED_") == string::npos){
120  cout<<"This is not a pixel module or FED!"<<endl;
121  return;
122  }
123 
124  vector<MonitorElement*> all_mes = bei->getContents(path);
125  setHTMLHeader(out);
126  *out << path << " ";
127 
128  string theME ;
129  for (vector<string>::const_iterator ih = hlist.begin();
130  ih != hlist.end(); ih++) {
131  for (vector<MonitorElement *>::const_iterator it = all_mes.begin();
132  it!= all_mes.end(); it++) {
133  MonitorElement * me = (*it);
134  if (!me) continue;
135  theME = me->getName();
136  string temp_s ;
137  if(theME.find("siPixel")!=string::npos || theME.find("ctfWithMaterialTracks")!=string::npos) { temp_s = theME.substr(0,theME.find_first_of("_")); }
138  //cout<<"should be the variable name: temp_s= "<<temp_s<<endl;
139  if (temp_s == (*ih)) {
140  string full_path = path + "/" + me->getName();
141  histoPlotter_->setNewPlot(full_path, opt, width, height);
142  *out << me->getName() << " " ;
143  }
144  }
145  }
146 }
147 */
148 //
149 // -- Plot Tracker Map MEs
150 //
151 /* removing xdaq deps
152 void SiPixelInformationExtractor::getTrackerMapHistos(DQMStore* bei,
153  const std::multimap<std::string, std::string>& req_map,
154  xgi::Output * out,
155  bool isUpgrade) {
156 
157 // cout << __LINE__ << ACYellow << ACBold
158 // << "[SiPixelInformationExtractor::getTrackerMapHistos] " << ACPlain << endl ;
159 // cout<<"I am in this dir: "<<bei->pwd()<<endl;
160  vector<string> hlist;
161  string tkmap_name;
162  SiPixelConfigParser config_parser;
163  string localPath;
164  if(offlineXMLfile_) localPath = string("DQM/SiPixelMonitorClient/test/sipixel_tier0_config.xml");
165  else localPath = string("DQM/SiPixelMonitorClient/test/sipixel_monitorelement_config.xml");
166  config_parser.getDocument(edm::FileInPath(localPath).fullPath());
167 // if (!config_parser.getMENamesForTrackerMap(tkmap_name, hlist)) return;
168 // if (hlist.size() == 0) return;
169  if (!config_parser.getMENamesForTrackerMap(tkmap_name, hlist))
170  {
171  cout << __LINE__ << ACYellow << ACBold
172  << "[SiPixelInformationExtractor::getTrackerMapHistos] "
173  << ACPlain << ACRed << ACPlain
174  << "getMENamesForTrackerMap return false "
175  << ACPlain << endl ; assert(0) ;
176  return;
177  }
178  if (hlist.size() == 0)
179  {
180  cout << __LINE__ << ACYellow << ACBold
181  << "[SiPixelInformationExtractor::getTrackerMapHistos] "
182  << ACPlain << ACRed << ACPlain
183  << "hlist.size() == 0 "
184  << ACPlain << endl ; assert(0) ;
185  return;
186  }
187 
188 
189  uint32_t detId = atoi(getItemValue(req_map,"ModId").c_str());
190 
191  int width = atoi(getItemValue(req_map, "width").c_str());
192  int height = atoi(getItemValue(req_map, "height").c_str());
193 
194  string opt =" ";
195 
196  SiPixelFolderOrganizer folder_organizer;
197  string path;
198 
199  folder_organizer.getModuleFolder(detId,path,isUpgrade);
200  string currDir = bei->pwd();
201 // cout<<"detId= "<<detId<<" , path= "<<path<<" , and now I am in "<<currDir<<endl;
202 
203 
204  if((bei->pwd()).find("Module_") == string::npos &&
205  (bei->pwd()).find("FED_") == string::npos){
206  cout<<"This is not a pixel module or FED!"<<endl;
207  cout << __LINE__ << ACYellow << ACBold
208  << "[SiPixelInformationExtractor::getTrackerMapHistos] "
209  << ACPlain << ACRed << ACPlain
210  << "This is not a pixel module or FED!"
211  << ACPlain << endl ; assert(0) ;
212  return;
213  }
214 
215  vector<MonitorElement*> all_mes = bei->getContents(path);
216  setXMLHeader(out);
217 
218  cout << __LINE__ << ACCyan << ACBold
219  << " [SiPixelInformationExtractor::getTrackerMapHistos()] path "
220  << ACPlain << path << endl ;
221  cout << __LINE__ << ACCyan << ACBold
222  << " [SiPixelInformationExtractor::getTrackerMapHistos()] all_mes.size() "
223  << ACPlain << all_mes.size() << endl ;
224 
225  string theME ;
226  *out << "<pathList>" << endl ;
227  for (vector<string>::iterator ih = hlist.begin();
228  ih != hlist.end(); ih++) {
229  //cout<<"ih iterator (hlist): "<<(*ih)<<endl;
230  for (vector<MonitorElement *>::const_iterator it = all_mes.begin();
231  it!= all_mes.end(); it++) {
232  MonitorElement * me = (*it);
233  if (!me)
234  {
235  cout << __LINE__ << ACCyan << ACBold
236  << " [SiPixelInformationExtractor::getTrackerMapHistos()] skipping "
237  << ACPlain << *ih << endl ;
238  continue;
239  }
240  theME = me->getName();
241  //cout<<"ME iterator (all_mes): "<<theME<<endl;
242  string temp_s ;
243  if(theME.find("siPixel")!=string::npos || theME.find("ctfWithMaterialTracks")!=string::npos) { temp_s = theME.substr(0,theME.find_first_of("_")); }
244  //cout << __LINE__ << ACCyan << ACBold
245  // << " [SiPixelInformationExtractor::getTrackerMapHistos()] temp_s "
246  // << ACPlain << temp_s << " <--> " << *ih << " |" << theME << "|" << endl ;
247  if (temp_s == (*ih)) {
248  string full_path = path + "/" + me->getName();
249  histoPlotter_->setNewPlot(full_path, opt, width, height);
250 //cout << __LINE__ << ACRed << ACBold
251 // << " [SiPixelInformationExtractor::getTrackerMapHistos()] fullPath: "
252 // << ACPlain << full_path << endl ;
253  *out << " <pathElement path='" << full_path << "' />" << endl ;
254  }
255  }
256  }
257  *out << "</pathList>" << endl ;
258 //cout << __LINE__ << " [SiPixelInformationExtractor::getTrackerMapHistos()] endlist: " << endl ;
259 }
260 */
261 //============================================================================================================
262 // -- Return type of ME
263 //
265 {
266  string qtype = theMe->getRootObject()->IsA()->GetName() ;
267  if( qtype.find("TH1") != string::npos )
268  {
269  return "TH1" ;
270  } else if ( qtype.find("TH2") != string::npos ) {
271  return "TH2" ;
272  } else if ( qtype.find("TH3") != string::npos ) {
273  return "TH3" ;
274  }
275  return "TH1" ;
276 }
277 
278 //------------------------------------------------------------------------------
283 /*removing xdaq deps
284 void SiPixelInformationExtractor::readModuleAndHistoList(DQMStore* bei,
285  xgi::Output * out) {
286 //cout<<"entering SiPixelInformationExtractor::readModuleAndHistoList"<<endl;
287  bei->cd("Pixel");
288  std::map<std::string,std::string> hnames;
289  std::vector<std::string> mod_names;
290  fillModuleAndHistoList(bei, mod_names, hnames);
291  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
292  *out << "<?xml version=\"1.0\" ?>" << std::endl;
293  *out << "<ModuleAndHistoList>" << endl;
294  *out << "<ModuleList>" << endl;
295  for (std::vector<std::string>::iterator im = mod_names.begin();
296  im != mod_names.end(); im++) {
297  *out << "<ModuleNum>" << *im << "</ModuleNum>" << endl;
298  }
299  *out << "</ModuleList>" << endl;
300  *out << "<HistoList>" << endl;
301 
302  for (std::map<std::string,std::string>::iterator ih = hnames.begin();
303  ih != hnames.end(); ih++) {
304  *out << "<Histo type=\""
305  << ih->second
306  << "\">"
307  << ih->first
308  << "</Histo>"
309  << endl;
310  }
311  *out << "</HistoList>" << endl;
312  *out << "</ModuleAndHistoList>" << endl;
313 //cout<<"leaving SiPixelInformationExtractor::readModuleAndHistoList"<<endl;
314 }
315 */
316 
317 //------------------------------------------------------------------------------
323  vector<string> & modules,
324  map<string,string> & histos) {
325 //cout<<"entering SiPixelInformationExtractor::fillModuleAndHistoList"<<endl;
326  string currDir = bei->pwd();
327  //cout<<"currDir= "<<currDir<<endl;
328  if(currDir.find("Module_") != string::npos){
329  if(histos.size() == 0){
330  vector<string> contents = bei->getMEs();
331  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++) {
332  string hname = (*it).substr(0, (*it).find("_siPixel"));
333  if(hname==" ") hname = (*it).substr(0, (*it).find("_generalTracks"));
334  string fullpathname = bei->pwd() + "/" + (*it);
335  // cout<<"fullpathname="<<fullpathname<<endl;
336  MonitorElement * me = bei->get(fullpathname);
337  string htype = "undefined" ;
338  if(me) htype = me->getRootObject()->IsA()->GetName() ;
339  //cout<<"hname="<<hname<<endl;
340  //if(htype=="TH1F" || htype=="TH1D"){
341  histos[hname] = htype ;
342  string mId=" ";
343  if(hname.find("ndigis") !=string::npos) mId = (*it).substr((*it).find("ndigis_siPixelDigis_")+20, 9);
344  if(mId==" " && hname.find("nclusters") !=string::npos) mId = (*it).substr((*it).find("nclusters_siPixelClusters_")+26, 9);
345  if(mId==" " && hname.find("residualX") !=string::npos) mId = (*it).substr((*it).find("residualX_ctfWithMaterialTracks_")+32, 9);
346  if(mId==" " && hname.find("NErrors") !=string::npos) mId = (*it).substr((*it).find("NErrors_siPixelDigis_")+21, 9);
347  if(mId==" " && hname.find("ClustX") !=string::npos) mId = (*it).substr((*it).find("ClustX_siPixelRecHit_")+21, 9);
348  if(mId==" " && hname.find("pixelAlive") !=string::npos) mId = (*it).substr((*it).find("pixelAlive_siPixelCalibDigis_")+29, 9);
349  if(mId==" " && hname.find("Gain1d") !=string::npos) mId = (*it).substr((*it).find("Gain1d_siPixelCalibDigis_")+25, 9);
350  if(mId!=" ") modules.push_back(mId);
351  //cout<<"mId="<<mId<<endl;
352  //}
353  }
354  }
355  } else {
356  vector<string> subdirs = bei->getSubdirs();
357  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
358  if((bei->pwd()).find("Barrel")==string::npos && (bei->pwd()).find("Endcap")==string::npos) bei->goUp();
359  bei->cd(*it);
360  fillModuleAndHistoList(bei, modules, histos);
361  bei->goUp();
362  }
363  }
364 // fillBarrelList(bei, modules, histos);
365 //cout<<"leaving SiPixelInformationExtractor::fillModuleAndHistoList"<<endl;
366 }
367 
368 //------------------------------------------------------------------------------
373 /* removing xdaq deps
374 void SiPixelInformationExtractor::readModuleHistoTree(DQMStore* bei,
375  string& str_name,
376  xgi::Output * out) {
377 //cout<<"entering SiPixelInformationExtractor::readModuleHistoTree"<<endl;
378  ostringstream modtree;
379  if (goToDir(bei, str_name)) {
380  modtree << "<form name=\"IMGCanvasItemsSelection\" "
381  << "action=\"javascript:void%200\">"
382  << endl ;
383  modtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
384  printModuleHistoList(bei,modtree);
385  modtree <<"</ul>" << endl;
386  modtree <<"</form>" << endl;
387  } else {
388  modtree << "Desired Directory does not exist";
389  }
390  cout << ACYellow << ACBold
391  << "[SiPixelInformationExtractor::readModuleHistoTree()]"
392  << ACPlain << endl ;
393  // << "html string follows: " << endl ;
394  //cout << modtree.str() << endl ;
395  //cout << ACYellow << ACBold
396  // << "[SiPixelInformationExtractor::readModuleHistoTree()]"
397  // << ACPlain
398  // << "String complete " << endl ;
399  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
400  *out << modtree.str();
401  bei->cd();
402 //cout<<"leaving SiPixelInformationExtractor::readModuleHistoTree"<<endl;
403 }
404 */
405 
406 //------------------------------------------------------------------------------
412  ostringstream& str_val){
413 //cout<<"entering SiPixelInformationExtractor::printModuleHistoList"<<endl;
414  string currDir = bei->pwd();
415  string dname = currDir.substr(currDir.find_last_of("/")+1);
416  str_val << " <li>\n"
417  << " <a href=\"#\" id=\"" << currDir << "\">\n "
418  << dname << "\n"
419  << " </a>\n"
420  << endl << endl;
421 
422  vector<string> meVec = bei->getMEs();
423 
424  vector<string> subDirVec = bei->getSubdirs();
425  if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
426  str_val << " </li>" << endl;
427  return;
428  }
429  str_val << "\n <ul>" << endl;
430  for (vector<string>::const_iterator it = meVec.begin();
431  it != meVec.end(); it++) {
432  if ((*it).find("_siPixel")!=string::npos ||
433  (*it).find("_ctfWithMaterialTracks")!=string::npos) {
434  string qit = (*it) ;
435  string temp_s;
436  if(qit.find("siPixel")!=string::npos || qit.find("ctfWithMaterialTracks")!=string::npos) { temp_s = qit.substr(0,qit.find_first_of("_")); }
437  str_val << " <li class=\"dhtmlgoodies_sheet.gif\">\n"
438  << " <input id = \"selectedME\""
439  << " folder = \"" << currDir << "\""
440  << " type = \"checkbox\""
441  << " name = \"selected\""
442  << " class = \"smallCheckBox\""
443  << " value = \"" << (*it) << "\""
444  << " onclick = \"javascript:IMGC.selectedIMGCItems()\" />\n"
445 // << " <a href=\"javascript:IMGC.updateIMGC('" << currDir << "')\">\n "
446  << " <a href=\"javascript:IMGC.plotFromPath('" << currDir << "')\">\n "
447 // << temp_s << "\n"
448  << (*it) << "\n"
449  << " </a>\n"
450  << " </li>"
451  << endl;
452  }
453  }
454  for (vector<string>::const_iterator ic = subDirVec.begin();
455  ic != subDirVec.end(); ic++) {
456  bei->cd(*ic);
457  printModuleHistoList(bei, str_val);
458  bei->goUp();
459  }
460  str_val << " </ul>" << endl;
461  str_val << " </li>" << endl;
462 //cout<<"leaving SiPixelInformationExtractor::printModuleHistoList"<<endl;
463 }
464 
465 //------------------------------------------------------------------------------
470 /* removing xdaq deps
471 void SiPixelInformationExtractor::readSummaryHistoTree(DQMStore* bei,
472  string& str_name,
473  xgi::Output * out) {
474 //cout<<"entering SiPixelInformationExtractor::readSummaryHistoTree"<<endl;
475  ostringstream sumtree;
476  if (goToDir(bei, str_name)) {
477  sumtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
478  printSummaryHistoList(bei,sumtree);
479  sumtree <<"</ul>" << endl;
480  } else {
481  sumtree << "Desired Directory does not exist";
482  }
483  cout << ACYellow << ACBold
484  << "[SiPixelInformationExtractor::readSummaryHistoTree()]"
485  << ACPlain << endl ;
486  // << "html string follows: " << endl ;
487  //cout << sumtree.str() << endl ;
488  //cout << ACYellow << ACBold
489  // << "[SiPixelInformationExtractor::readSummaryHistoTree()]"
490  // << ACPlain
491  // << "String complete " << endl ;
492  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
493  *out << sumtree.str();
494  bei->cd();
495 //cout<<"leaving SiPixelInformationExtractor::readSummaryHistoTree"<<endl;
496 }
497 */
498 
499 //------------------------------------------------------------------------------
507  ostringstream& str_val){
508 //cout<<"entering SiPixelInformationExtractor::printSummaryHistoList"<<endl;
509  string currDir = bei->pwd();
510  string dname = currDir.substr(currDir.find_last_of("/")+1);
511  if (dname.find("Module_") ==0 || dname.find("FED_")==0) return;
512  str_val << " <li>\n"
513  << " <a href=\"#\" id=\"" << currDir << "\">\n "
514  << dname
515  << " </a>"
516  << endl;
517 
518  vector<string> meVec = bei->getMEs();
519 
520  vector<string> subDirVec = bei->getSubdirs();
521  if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
522  str_val << " </li> "<< endl;
523  return;
524  }
525  str_val << "\n <ul>" << endl;
526  for (vector<string>::const_iterator it = meVec.begin();
527  it != meVec.end(); it++) {
528  if ((*it).find("SUM") == 0) {
529  str_val << " <li class=\"dhtmlgoodies_sheet.gif\">\n"
530  << " <input id = \"selectedME\""
531  << " folder = \"" << currDir << "\""
532  << " type = \"checkbox\""
533  << " name = \"selected\""
534  << " class = \"smallCheckBox\""
535  << " value = \"" << (*it) << "\""
536  << " onclick = \"javascript:IMGC.selectedIMGCItems()\" />\n"
537 // << " <a href=\"javascript:IMGC.updateIMGC('" << currDir << "')\">\n "
538  << " <a href=\"javascript:IMGC.plotFromPath('" << currDir << "')\">\n "
539  << (*it) << "\n"
540  << " </a>\n"
541  << " </li>"
542  << endl;
543  }
544  }
545 
546  for (vector<string>::const_iterator ic = subDirVec.begin();
547  ic != subDirVec.end(); ic++) {
548  bei->cd(*ic);
549  printSummaryHistoList(bei, str_val);
550  bei->goUp();
551  }
552  str_val << " </ul> "<< endl;
553  str_val << " </li> "<< endl;
554 //cout<<"leaving SiPixelInformationExtractor::printSummaryHistoList"<<endl;
555 }
556 
557 
558 //------------------------------------------------------------------------------
563 /* removing xdaq deps
564 void SiPixelInformationExtractor::readAlarmTree(DQMStore* bei,
565  string& str_name,
566  xgi::Output * out){
567 //cout<<"entering SiPixelInformationExtractor::readAlarmTree"<<endl;
568  ostringstream alarmtree;
569  if (goToDir(bei, str_name)) {
570  alarmtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
571  alarmCounter_=0;
572  printAlarmList(bei,alarmtree);
573  if(alarmCounter_==0) alarmtree <<"<li>No problematic modules found, all ok!</li>" << endl;
574  alarmtree <<"</ul>" << endl;
575  } else {
576  alarmtree << "Desired Directory does not exist";
577  }
578  cout << ACYellow << ACBold
579  << "[SiPixelInformationExtractor::readAlarmTree()]"
580  << ACPlain << endl ;
581  // << "html string follows: " << endl ;
582  //cout << alarmtree.str() << endl ;
583  //cout << ACYellow << ACBold
584  // << "[SiPixelInformationExtractor::readAlarmTree()]"
585  // << ACPlain
586  // << "String complete " << endl ;
587  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
588  *out << alarmtree.str();
589  bei->cd();
590  cout << ACYellow << ACBold
591  << "[SiPixelInformationExtractor::readAlarmTree()]"
592  << ACPlain
593  << " Done!"
594  << endl ;
595 //cout<<"leaving SiPixelInformationExtractor::readAlarmTree"<<endl;
596 }
597 */
598 //------------------------------------------------------------------------------
606  ostringstream& str_val){
607 //cout<<"entering SiPixelInformationExtractor::printAlarmList"<<endl;
608 // cout << ACRed << ACBold
609 // << "[SiPixelInformationExtractor::printAlarmList()]"
610 // << ACPlain
611 // << " Enter"
612 // << endl ;
613  string currDir = bei->pwd();
614  string dname = currDir.substr(currDir.find_last_of("/")+1);
615  string image_name;
616  selectImage(image_name,bei->getStatus(currDir));
617  if(image_name!="images/LI_green.gif")
618  str_val << " <li>\n"
619  << " <a href=\"#\" id=\"" << currDir << "\">\n "
620  << dname
621  << " </a>\n"
622  << " <img src=\""
623  << image_name
624  << "\">" << endl;
625  vector<string> subDirVec = bei->getSubdirs();
626 
627  vector<string> meVec = bei->getMEs();
628 
629  if (subDirVec.size() == 0 && meVec.size() == 0) {
630  str_val << "</li> "<< endl;
631  return;
632  }
633  str_val << "<ul>" << endl;
634  for (vector<string>::const_iterator it = meVec.begin();
635  it != meVec.end(); it++) {
636  string full_path = currDir + "/" + (*it);
637 
638  MonitorElement * me = bei->get(full_path);
639 
640  if (!me) continue;
641  std::vector<QReport *> my_map = me->getQReports();
642  if (my_map.size() > 0) {
643  string image_name1;
644  selectImage(image_name1,my_map);
645  if(image_name1!="images/LI_green.gif") {
646  alarmCounter_++;
647  str_val << " <li class=\"dhtmlgoodies_sheet.gif\">\n"
648  << " <input id = \"selectedME\""
649  << " folder = \"" << currDir << "\""
650  << " type = \"checkbox\""
651  << " name = \"selected\""
652  << " class = \"smallCheckBox\""
653  << " value = \"" << (*it) << "\""
654  << " onclick = \"javascript:IMGC.selectedIMGCItems()\" />\n"
655 // << " <a href=\"javascript:IMGC.updateIMGC('" << currDir << "')\">\n "
656  << " <a href=\"javascript:IMGC.plotFromPath('" << currDir << "')\">\n "
657  << (*it) << "\n"
658  << " </a>\n"
659  << " <img src=\""
660  << image_name1
661  << "\">"
662  << " </li>"
663  << endl;
664  }
665  }
666  }
667  for (vector<string>::const_iterator ic = subDirVec.begin();
668  ic != subDirVec.end(); ic++) {
669  bei->cd(*ic);
670  printAlarmList(bei, str_val);
671  bei->goUp();
672  }
673  str_val << "</ul> "<< endl;
674  str_val << "</li> "<< endl;
675 // cout << ACGreen << ACBold
676 // << "[SiPixelInformationExtractor::printAlarmList()]"
677 // << ACPlain
678 // << " Done"
679 // << endl ;
680 //cout<<"leaving SiPixelInformationExtractor::printAlarmList"<<endl;
681 }
682 
683 
684 //------------------------------------------------------------------------------
689 void SiPixelInformationExtractor::getItemList(const multimap<string, string>& req_map,
690  string item_name,
691  vector<string>& items) {
692 //cout<<"entering SiPixelInformationExtractor::getItemList"<<endl;
693  items.clear();
694  for (multimap<string, string>::const_iterator it = req_map.begin();
695  it != req_map.end(); it++) {
696  if (it->first == item_name) {
697  items.push_back(it->second);
698  }
699  }
700 //cout<<"leaving SiPixelInformationExtractor::getItemList"<<endl;
701 }
702 
703 //------------------------------------------------------------------------------
708 bool SiPixelInformationExtractor::hasItem(multimap<string,string>& req_map,
709  string item_name){
710 //cout<<"entering SiPixelInformationExtractor::hasItem"<<endl;
711  multimap<string,string>::iterator pos = req_map.find(item_name);
712  if (pos != req_map.end()) return true;
713  return false;
714 //cout<<"leaving SiPixelInformationExtractor::hasItem"<<endl;
715 }
716 
717 //------------------------------------------------------------------------------
722 std::string SiPixelInformationExtractor::getItemValue(const std::multimap<std::string,std::string>& req_map,
723  std::string item_name){
724 //cout<<"entering SiPixelInformationExtractor::getItemValue for item: "<<item_name<<endl;
725  std::multimap<std::string,std::string>::const_iterator pos = req_map.find(item_name);
726  std::string value = " ";
727  if (pos != req_map.end()) {
728  value = pos->second;
729  }
730 // cout<<"value = "<<value<<endl;
731  return value;
732 //cout<<"leaving SiPixelInformationExtractor::getItemValue"<<endl;
733 }
734 std::string SiPixelInformationExtractor::getItemValue(std::multimap<std::string,std::string>& req_map,
735  std::string item_name){
736 //cout<<"entering SiPixelInformationExtractor::getItemValue for item: "<<item_name<<endl;
737  std::multimap<std::string,std::string>::iterator pos = req_map.find(item_name);
738  std::string value = " ";
739  if (pos != req_map.end()) {
740 // cout<<"item found!"<<endl;
741  value = pos->second;
742  }
743 // cout<<"value = "<<value<<endl;
744  return value;
745 //cout<<"leaving SiPixelInformationExtractor::getItemValue"<<endl;
746 }
747 
748 //
749 // -- Get color name from status
750 //
752  if (status == dqm::qstatus::STATUS_OK) col = "#00ff00";
753  else if (status == dqm::qstatus::WARNING) col = "#ffff00";
754  else if (status == dqm::qstatus::ERROR) col = "#ff0000";
755  else if (status == dqm::qstatus::OTHER) col = "#ffa500";
756  else col = "#0000ff";
757 }
758 //
759 // -- Get Image name from ME
760 //
761 void SiPixelInformationExtractor::selectColor(string& col, vector<QReport*>& reports){
762  int istat = 999;
763  int status = 0;
764  for (vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
765  it++) {
766  status = (*it)->getStatus();
767  if (status > istat) istat = status;
768  }
769  selectColor(col, status);
770 }
771 //
772 // -- Get Image name from status
773 //
774 void SiPixelInformationExtractor::selectImage(string& name, int status){
775  if (status == dqm::qstatus::STATUS_OK) name="images/LI_green.gif";
776  else if (status == dqm::qstatus::WARNING) name="images/LI_yellow.gif";
777  else if (status == dqm::qstatus::ERROR) name="images/LI_red.gif";
778  else if (status == dqm::qstatus::OTHER) name="images/LI_orange.gif";
779  else name="images/LI_blue.gif";
780 }
781 //
782 // -- Get Image name from ME
783 //
784 void SiPixelInformationExtractor::selectImage(string& name, vector<QReport*>& reports){
785  int istat = 999;
786  int status = 0;
787  for (vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
788  it++) {
789  status = (*it)->getStatus();
790  if (status > istat) istat = status;
791  }
792  selectImage(name, status);
793 }
794 
795 //
796 // -- Get a tagged image
797 //
798 /* removing xdaq deps
799 void SiPixelInformationExtractor::getIMGCImage(const multimap<string, string>& req_map,
800  xgi::Output * out){
801  string path = getItemValue(req_map,"Path");
802  string image;
803  histoPlotter_->getNamedImageBuffer(path, image);
804 
805  out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
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  *out << image;
810 }
811 */
812 /* removing xdaq deps
813 void SiPixelInformationExtractor::getIMGCImage(multimap<string, string>& req_map,
814  xgi::Output * out){
815 
816  string path = getItemValue(req_map,"Path");
817  string image;
818  histoPlotter_->getNamedImageBuffer(path, image);
819 
820  out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
821  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
822  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
823  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
824  *out << image;
825 
826 }
827 */
828 
829 //------------------------------------------------------------------------------
835  string& sname){
836 //cout<<"entering SiPixelInformationExtractor::goToDir"<<endl;
837  bei->cd();
838  //if(flg) bei->cd("Collector/Collated");
839  bei->cd(sname);
840  string dirName = bei->pwd();
841  if (dirName.find(sname) != string::npos) return true;
842  else return false;
843 //cout<<"leaving SiPixelInformationExtractor::goToDir"<<endl;
844 }
845 
846 //
847 // -- Get Warning/Error Messages
848 //
849 /* removing xdaq deps
850 void SiPixelInformationExtractor::readStatusMessage(DQMStore* bei,
851  std::multimap<std::string, std::string>& req_map,
852  xgi::Output * out){
853 
854  string path = getItemValue(req_map,"Path");
855 
856  int width = atoi(getItemValue(req_map, "width").c_str());
857  int height = atoi(getItemValue(req_map, "height").c_str());
858 
859  string opt =" ";
860 
861  ostringstream test_status;
862 
863  setXMLHeader(out);
864  *out << "<StatusAndPath>" << endl;
865  *out << "<PathList>" << endl;
866  if (path.size() == 0) {
867  *out << "<HPath>" << "NONE" << "</HPath>" << endl;
868  test_status << " ME Does not exist ! " << endl;
869  } else {
870  vector<MonitorElement*> all_mes = bei->getContents(path);
871  *out << "<HPath>" << path << "</HPath>" << endl;
872  for(vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
873  MonitorElement* me = (*it);
874  if (!me) continue;
875  string name = me->getName();
876 
877  vector<QReport*> q_reports = me->getQReports();
878  if (q_reports.size() == 0) continue;
879  string full_path = path + "/" + name;
880  histoPlotter_->setNewPlot(full_path, opt, width, height);
881 
882  if (q_reports.size() != 0) {
883  test_status << " QTest Status for " << name << " : " << endl;
884  test_status << " ======================================================== " << endl;
885  for (vector<QReport*>::const_iterator it = q_reports.begin(); it != q_reports.end();
886  it++) {
887  int status = (*it)->getStatus();
888  if (status == dqm::qstatus::WARNING) test_status << " Warning ";
889  else if (status == dqm::qstatus::ERROR) test_status << " Error ";
890  else if (status == dqm::qstatus::STATUS_OK) test_status << " Ok ";
891  else if (status == dqm::qstatus::OTHER) test_status << " Other(" << status << ") ";
892  string mess_str = (*it)->getMessage();
893  test_status << "&lt;br/&gt;";
894  mess_str = mess_str.substr(mess_str.find(" Test")+5);
895  test_status << " QTest Name : " << mess_str.substr(0, mess_str.find(")")+1) << endl;
896  test_status << "&lt;br/&gt;";
897  test_status << " QTest Detail : " << mess_str.substr(mess_str.find(")")+2) << endl;
898  }
899  test_status << " ======================================================== " << endl;
900  }
901  *out << "<HPath>" << name << "</HPath>" << endl;
902  }
903  }
904  *out << "</PathList>" << endl;
905  *out << "<StatusList>" << endl;
906  *out << "<Status>" << test_status.str() << "</Status>" << endl;
907  *out << "</StatusList>" << endl;
908  *out << "</StatusAndPath>" << endl;
909 }
910 */
911 
912 //------------------------------------------------------------------------------
917  double & colorValue,
918  pair<double,double> & norm)
919 {
920  double normalizationX = 1 ;
921  double normalizationY = 1 ;
922  double meanX = 0 ;
923  double meanY = 0 ;
924 
925  colorValue = 0 ;
926 
927  pair<double,double> normX ;
928  pair<double,double> normY ;
929 
930  string theMEType = getMEType(theME) ;
931 
932 // cout << ACRed << ACReverse
933 // << "[SiPixelInformationExtractor::computeStatus()]"
934 // << ACPlain
935 // << " Computing average for "
936 // << theME->getName()
937 // << endl ;
938 
939  if( theMEType.find("TH1") != string::npos)
940  {
941  meanX = (double)theME->getMean();
942  getNormalization(theME, normX, "TH1") ;
943  normalizationX = fabs( normX.second - normX.first) ;
944  if( normalizationX == 0 ) {normalizationX=1.E-20;}
945  colorValue = meanX / normalizationX ;
946  norm.first = normX.first ;
947  norm.second = normX.second ;
948  }
949 
950  if( theMEType.find("TH2") != string::npos)
951  {
952  meanX = (double)theME->getMean(1);
953  meanY = (double)theME->getMean(2);
954  getNormalization2D(theME, normX, normY, "TH2") ;
955  normalizationX = fabs( normX.second - normX.first) ;
956  normalizationY = fabs( normY.second - normY.first) ;
957  if( normalizationX == 0 ) {normalizationX=1.E-20;}
958  if( normalizationY == 0 ) {normalizationY=1.E-20;}
959  double cVX = meanX / normalizationX ;
960  double cVY = meanY / normalizationY ;
961  colorValue = sqrt(cVX*cVX + cVY*cVY) ;
962  if( normalizationX >= normalizationY )
963  {
964  norm.first = normX.first;
965  norm.second = normX.second ;
966  } else {
967  norm.first = normY.first;
968  norm.second = normY.second ;
969  }
970 // cout << ACBlue << ACBold << ACReverse
971 // << "[SiPixelInformationExtractor::computeStatus()]"
972 // << ACPlain << " "
973 // << theME->getName()
974 // << " meanX:Y "
975 // << meanX << ":" << meanY
976 // << " normX:Y "
977 // << norm.first << ":" << norm.second
978 // << endl ;
979  }
980 
981  return ;
982 }
983 
984 //------------------------------------------------------------------------------
989  pair<double,double>& norm,
990  std::string theMEType)
991 {
992  double normLow = 0 ;
993  double normHigh = 0 ;
994 
995  if( theMEType.find("TH1") != string::npos)
996  {
997  normHigh = (double)theME->getNbinsX() ;
998  norm.first = normLow ;
999  norm.second = normHigh ;
1000  }
1001 }
1002 
1003 //------------------------------------------------------------------------------
1008  pair<double,double>& normX,
1009  pair<double,double>& normY,
1010  std::string theMEType)
1011 {
1012  double normLow = 0 ;
1013  double normHigh = 0 ;
1014 
1015  if( theMEType.find("TH2") != string::npos )
1016  {
1017  normHigh = (double)theME->getNbinsX() ;
1018  normX.first = normLow ;
1019  normX.second = normHigh ;
1020  normHigh = (double)theME->getNbinsY() ;
1021  normY.first = normLow ;
1022  normY.second = normHigh ;
1023 // cout << ACCyan << ACBold << ACReverse
1024 // << "[SiPixelInformationExtractor::getNormalization2D()]"
1025 // << ACPlain << " "
1026 // << theME->getName()
1027 // << " normX: "
1028 // << normX.first << ":" << normX.second
1029 // << " normY: "
1030 // << normY.first << ":" << normY.second
1031 // << endl ;
1032  }
1033 }
1034 
1035 //------------------------------------------------------------------------------
1041  string & theMEName,
1042  vector<MonitorElement*> & mes)
1043 {
1044 // cout<<"In SiPixelInformationExtractor::selectMEList: "<<endl;
1045  string currDir = bei->pwd();
1046 
1047  string theME ;
1048 
1049  // Get ME from Collector/FU0/Tracker/PixelEndcap/HalfCylinder_pX/Disk_X/Blade_XX/Panel_XX/Module_XX
1050  if (currDir.find("Module_") != string::npos ||
1051  currDir.find("FED_") != string::npos)
1052  {
1053  vector<string> contents = bei->getMEs();
1054 
1055  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++)
1056  {
1057  theME = (*it) ;
1058  if(theME.find("siPixel")==string::npos && theME.find("ctfWithMaterialTracks")==string::npos) {continue ;} // If the ME is not a siPixel or ctfWithMaterialTrack one, skip
1059  string temp_s = theME.substr(0,theME.find_first_of("_"));
1060  //cout<<"should be the variable name: temp_s= "<<temp_s<<endl;
1061  if (temp_s == theMEName)
1062  {
1063  string full_path = currDir + "/" + (*it);
1064 
1065  MonitorElement * me = bei->get(full_path.c_str());
1066 
1067  if (me) {mes.push_back(me);}
1068  }
1069  }
1070  return;
1071  } else { // If not yet reached the desired level in the directory tree, recursively go down one level more
1072  vector<string> subdirs = bei->getSubdirs();
1073  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++)
1074  {
1075  bei->cd(*it);
1076  selectMEList(bei, theMEName, mes);
1077  bei->goUp();
1078  }
1079  }
1080 }
1081 
1082 //------------------------------------------------------------------------------
1086 /* removing xdaq dependencies
1087 void SiPixelInformationExtractor::sendTkUpdatedStatus(DQMStore * bei,
1088  xgi::Output * out,
1089  std::string & theMEName,
1090  std::string & theTKType)
1091 {
1092 // cout<<"In SiPixelInformationExtractor::sendTkUpdatedStatus: "<<endl;
1093  int rval, gval, bval;
1094  vector<string> colorMap ;
1095  vector<MonitorElement*> me_list;
1096  pair<double,double> norm ;
1097  double sts ;
1098 
1099  bei->cd();
1100  selectMEList(bei, theMEName, me_list) ;
1101  bei->cd();
1102 
1103  string detId = "undefined";
1104 
1105  cout << ACYellow << ACBold
1106  << "[SiPixelInformationExtractor::sendTkUpdatedStatus()] "
1107  << ACPlain
1108  << "Preparing color map update for "
1109  << theMEName
1110  << " type "
1111  << theTKType
1112  << " - List size: "
1113  << me_list.size()
1114  << endl ;
1115 
1116  int maxEntries = 0 ;
1117  if( theTKType == "Entries") // In this case find the ME with the highest number of entries
1118  { // first and use that as a vertical scale normalization
1119  for(vector<MonitorElement*>::iterator it=me_list.begin(); it!=me_list.end(); it++)
1120  {
1121  int entries = (int)(*it)->getEntries() ;
1122  if( entries > maxEntries ) maxEntries = entries ;
1123  }
1124  }
1125 
1126  int entries = 0 ;
1127  stringstream jsSnippet ;
1128  for(vector<MonitorElement*>::iterator it=me_list.begin(); it!=me_list.end(); it++)
1129  {
1130  string meName = (*it)->getName();
1131  string theMEType = getMEType(*it);
1132  if( meName.find("_3") != string::npos )
1133  {
1134  string detIdString = meName.substr(meName.find_last_of("_")+1,9);
1135  std::istringstream isst;
1136  isst.str(detIdString);
1137  isst>>detId;
1138  entries = (int)(*it)->getEntries() ;
1139  if( theTKType == "Averages")
1140  {
1141  computeStatus(*it, sts, norm) ;
1142  SiPixelUtility::getStatusColor(sts, rval, gval, bval);
1143  } else if( theTKType == "Entries") {
1144  sts = (double)entries / (double)maxEntries ;
1145  SiPixelUtility::getStatusColor(sts, rval, gval, bval);
1146  if( entries > maxEntries ) maxEntries = entries ;
1147  norm.first = 0 ;
1148  norm.second = maxEntries ;
1149  } else {
1150  int status = SiPixelUtility::getStatus((*it));
1151  if( status == dqm::qstatus::ERROR )
1152  {
1153  rval = 255; gval = 0; bval = 0;
1154  } else if (status == dqm::qstatus::WARNING ) {
1155  rval = 255; gval = 255; bval = 0;
1156  } else if (status == dqm::qstatus::OTHER) {
1157  rval = 0; gval = 0; bval = 255;
1158  } else if (status == dqm::qstatus::STATUS_OK) {
1159  rval = 0; gval = 255; bval = 0;
1160  } else {
1161  rval = 255; gval = 255; bval = 255;
1162  }
1163  }
1164  jsSnippet.str("") ;
1165  jsSnippet << " <DetInfo DetId='"
1166  << detId
1167  << "' red='"
1168  << rval
1169  << "' green='"
1170  << gval
1171  << "' blue='"
1172  << bval
1173  << "' entries='"
1174  << entries
1175  << "'/>" ;
1176  colorMap.push_back(jsSnippet.str()) ;
1177 // if( it == me_list.begin()) // The first should be equal to all others...
1178 // {
1179 // getNormalization((*it), norm, theMEType.latin1()) ;
1180 // }
1181  }
1182  }
1183 
1184 // delete random ;
1185 
1186  cout << ACYellow << ACBold
1187  << "[SiPixelInformationExtractor::sendTkUpdatedStatus()] "
1188  << ACPlain
1189  << "Color map consists of "
1190  << colorMap.size()
1191  << " snippets: start shipping back"
1192  << endl ;
1193 
1194  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
1195  *out << "<?xml version=\"1.0\" ?>" << endl;
1196  *out << "<TrackerMapUpdate>" << endl;
1197 
1198  for(vector<string>::iterator it=colorMap.begin(); it!=colorMap.end(); it++)
1199  {
1200  *out << *it << endl;
1201  }
1202 
1203  *out << " <theLimits id=\"normalizationLimits\" normLow=\""
1204  << norm.first
1205  << "\" normHigh=\""
1206  << norm.second
1207  << "\" />"
1208  << endl;
1209  *out << "</TrackerMapUpdate>"
1210  << endl;
1211 
1212  cout << ACYellow << ACBold
1213  << "[SiPixelInformationExtractor::sendTkUpdatedStatus()] "
1214  << ACPlain
1215  << "Color map updated within range "
1216  << norm.first
1217  << "-"
1218  << norm.second
1219  << endl ;
1220 
1221 }
1222 */
1223 //------------------------------------------------------------------------------
1229 {
1230 //cout<<"In SiPixelInformationExtractor::getDetId: for ME= "<<mE->getName()<<endl;
1231  string mEName = mE->getName();
1232 
1233  int detId = 0;
1234 
1235  if( mEName.find("_3") != string::npos )
1236  {
1237  string detIdString = mEName.substr((mEName.find_last_of("_"))+1,9);
1238  //cout<<"string: "<<detIdString<<endl;
1239  std::istringstream isst;
1240  isst.str(detIdString);
1241  isst>>detId;
1242 // } else {
1243 // cout << ACYellow << ACBold
1244 // << "[SiPixelInformationExtractor::getDetId()] "
1245 // << ACPlain
1246 // << "Could not extract detId from "
1247 // << mEName
1248 // << endl ;
1249  }
1250  //cout<<"returning with: "<<detId<<endl;
1251  return detId ;
1252 
1253 }
1254 
1255 //------------------------------------------------------------------------------
1260  map<string, int> & mEHash)
1261 {
1262  string currDir = bei->pwd();
1263 
1264 // cout << ACRed << ACBold
1265 // << "[SiPixelInformationExtractor::getMEList()]"
1266 // << ACPlain
1267 // << " Requesting ME list in "
1268 // << currDir
1269 // << endl ;
1270 
1271  string theME ;
1272 
1273  // Get ME from Collector/FU0/Tracker/PixelEndcap/HalfCylinder_pX/Disk_X/Blade_XX/Panel_XX/Module_XX
1274  if (currDir.find("Module_") != string::npos ||
1275  currDir.find("FED_") != string::npos)
1276  {
1277  vector<string> contents = bei->getMEs();
1278 
1279  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++)
1280  {
1281  theME = (*it) ;
1282 // cout << ACRed << ACReverse
1283 // << "[SiPixelInformationExtractor::getMEList()]"
1284 // << ACPlain
1285 // << " ME: "
1286 // << (*it)
1287 // << endl ;
1288  if(theME.find("siPixel")==string::npos && theME.find("ctfWithMaterialTracks")==string::npos)
1289  {
1290  cout << ACRed << ACBold
1291  << "[SiPixelInformationExtractor::getMEList()]"
1292  << ACPlain
1293  << " ----> Skipping "
1294  << (*it)
1295  << endl ;
1296  continue ;
1297  } // If the ME is not a Pixel one, skip
1298  string full_path = currDir + "/" + (*it);
1299  string mEName = theME.substr(0,theME.find_first_of("_"));
1300  mEHash[mEName]++ ;
1301  }
1302 
1303  return;
1304  } else { // If not yet reached the desired level in the directory tree, recursively go down one level more
1305  vector<string> subdirs = bei->getSubdirs();
1306  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++)
1307  {
1308  bei->cd(*it);
1309  getMEList(bei, mEHash);
1310  bei->goUp();
1311  }
1312  }
1313 }
1314 
1315 //
1316 // -- Get All histograms from a Path
1317 //
1318 /* removing xdaq deps
1319 void SiPixelInformationExtractor::getHistosFromPath(DQMStore * bei,
1320  const std::multimap<std::string, std::string>& req_map,
1321  xgi::Output * out){
1322 //cout<<"Entering SiPixelInformationExtractor::getHistosFromPath: "<<endl;
1323  string path = getItemValue(req_map,"Path");
1324 //cout<<"Path is: "<<path<<endl;
1325  if (path.size() == 0) return;
1326 
1327  int width = atoi(getItemValue(req_map, "width").c_str());
1328  int height = atoi(getItemValue(req_map, "height").c_str());
1329 
1330  string opt =" ";
1331 
1332  setHTMLHeader(out);
1333  vector<MonitorElement*> all_mes = bei->getContents(path);
1334  *out << path << " " ;
1335  for(vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
1336  MonitorElement* me = (*it);
1337  //cout<<"I'm in the loop now..."<<endl;
1338  if (!me) continue;
1339  string name = me->getName();
1340  string full_path = path + "/" + name;
1341 //cout<<"Calling HP::setNewPlot now for "<<full_path<<endl;
1342  histoPlotter_->setNewPlot(full_path, opt, width, height);
1343  *out << name << " ";
1344  }
1345 // cout<<"... leaving SiPixelInformationExtractor::getHistosFromPath!"<<endl;
1346 }
1347 */
1349 
1350 void SiPixelInformationExtractor::bookNoisyPixels(DQMStore * bei, float noiseRate_,bool Tier0Flag) {
1351 //std::cout<<"BOOK NOISY PIXEL MEs!"<<std::endl;
1352  bei->cd();
1353  if(noiseRate_>=0.){
1354  bei->setCurrentFolder("Pixel/Barrel");
1355  EventRateBarrelPixels = bei->book1D("barrelEventRate","Digi event rate for all Barrel pixels",1000,0.,0.01);
1356  EventRateBarrelPixels->setAxisTitle("Event Rate",1);
1357  EventRateBarrelPixels->setAxisTitle("Number of Pixels",2);
1358  bei->cd();
1359  bei->setCurrentFolder("Pixel/Endcap");
1360  EventRateEndcapPixels = bei->book1D("endcapEventRate","Digi event rate for all Endcap pixels",1000,0.,0.01);
1361  EventRateEndcapPixels->setAxisTitle("Event Rate",1);
1362  EventRateEndcapPixels->setAxisTitle("Number of Pixels",2);
1363  }
1364 }
1365 
1366 
1368 
1369 void SiPixelInformationExtractor::findNoisyPixels(DQMStore * bei, bool init, float noiseRate_, int noiseRateDenominator_, edm::EventSetup const& eSetup)
1370 {
1371 //cout<<"Entering SiPixelInformationExtractor::findNoisyPixels with noiseRate set to "<<noiseRate_<<endl;
1372 
1373 
1374  if(init){
1375  endOfModules_=false;
1376  nevents_=noiseRateDenominator_;
1377  if(nevents_ == -1){
1378  bei->cd();
1379  bei->setCurrentFolder("Pixel/EventInfo");
1380  nevents_ = (bei->get("Pixel/EventInfo/processedEvents"))->getIntValue();
1381  }
1382  bei->cd();
1383  myfile_.open ("NoisyPixelList.txt", ios::app);
1384  myfile_ << "Noise summary, ran over " << nevents_ << " events, threshold was set to " << noiseRate_ << std::endl;
1385  }
1386  string currDir = bei->pwd();
1387  string dname = currDir.substr(currDir.find_last_of("/")+1);
1388 
1389 
1390  if(dname.find("Module_")!=string::npos){
1391  vector<string> meVec = bei->getMEs();
1392  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1393  string full_path = currDir + "/" + (*it);
1394  if(full_path.find("hitmap_siPixelDigis")!=string::npos){
1395  //broken HV bond:
1396  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_01/Panel_2/Module_2")!=string::npos) continue;
1397  //?noisy?
1398  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_1/Module_4")!=string::npos) continue;
1399  //ROG with HV problem (short?):
1400  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_1/Module_3")!=string::npos) continue;
1401  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_1/Module_4")!=string::npos) continue;
1402  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_2/Module_2")!=string::npos) continue;
1403  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_2/Module_3")!=string::npos) continue;
1404  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_1/Module_3")!=string::npos) continue;
1405  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_1/Module_4")!=string::npos) continue;
1406  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_2/Module_2")!=string::npos) continue;
1407  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_2/Module_3")!=string::npos) continue;
1408  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_1/Module_3")!=string::npos) continue;
1409  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_1/Module_4")!=string::npos) continue;
1410  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_2/Module_2")!=string::npos) continue;
1411  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_2/Module_3")!=string::npos) continue;
1412  MonitorElement * me = bei->get(full_path);
1413  if (!me) continue;
1414  int detid=getDetId(me); int pixcol=-1; int pixrow=-1;
1415 
1416  //cout<<"detid= "<<detid<<endl;
1417  std::vector<std::pair<std::pair<int, int>, float> > noisyPixelsInModule;
1418  TH2F * hothisto = me->getTH2F();
1419  if(hothisto){
1420  for(int i=1; i!=hothisto->GetNbinsX()+1; i++){
1421  for(int j=1; j!=hothisto->GetNbinsY()+1; j++){
1422  float value = (hothisto->GetBinContent(i,j))/float(nevents_);
1423  if(me->getPathname().find("Barrel")!=string::npos){
1424  EventRateBarrelPixels = bei->get("Pixel/Barrel/barrelEventRate");
1426  }else if(me->getPathname().find("Endcap")!=string::npos){
1427  EventRateEndcapPixels = bei->get("Pixel/Endcap/endcapEventRate");
1429  }
1430  if(value > noiseRate_){
1431  pixcol = i-1;
1432  pixrow = j-1;
1433  //cout<<"pixcol= "<<pixcol<<" , pixrow= "<<pixrow<<" , value= "<<value<<endl;
1434 
1435  std::pair<int, int> address(pixcol, pixrow);
1436  std::pair<std::pair<int, int>, float> PixelStats(address, value);
1437  noisyPixelsInModule.push_back(PixelStats);
1438  }
1439  }
1440  }
1441  }
1442  noisyDetIds_[detid] = noisyPixelsInModule;
1443  //if(noisyPixelsInModule.size()>=20) cout<<"This module has 20 or more hot pixels: "<<detid<<","<<bei->pwd()<<","<<noisyPixelsInModule.size()<<endl;
1444  }
1445  }
1446  }
1447  vector<string> subDirVec = bei->getSubdirs();
1448  for (vector<string>::const_iterator ic = subDirVec.begin();
1449  ic != subDirVec.end(); ic++) {
1450  if((*ic).find("AdditionalPixelErrors")!=string::npos) continue;
1451  bei->cd(*ic);
1452  init=false;
1453  findNoisyPixels(bei,init,noiseRate_,noiseRateDenominator_,eSetup);
1454  bei->goUp();
1455  }
1456 
1457  if(bei->pwd().find("EventInfo")!=string::npos) endOfModules_ = true;
1458 
1459  if(!endOfModules_) return;
1460  // myfile_ <<"am in "<<bei->pwd()<<" now!"<<endl;
1461  if(currDir == "Pixel/EventInfo/reportSummaryContents"){
1462  eSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap);
1463  std::vector<std::pair<sipixelobjects::DetectorIndex,double> > pixelvec;
1464  std::map<uint32_t,int> myfedmap;
1465  std::map<uint32_t,std::string> mynamemap;
1466  int realfedID = -1;
1467  //int Nnoisies = noisyDetIds_.size();
1468  //cout<<"Number of noisy modules: "<<Nnoisies<<endl;
1469  int counter = 0;
1470  int n_noisyrocs_all = 0;
1471  int n_noisyrocs_barrel = 0;
1472  int n_noisyrocs_endcap = 0;
1473  int n_verynoisyrocs_all = 0;
1474  int n_verynoisyrocs_barrel = 0;
1475  int n_verynoisyrocs_endcap = 0;
1476 
1477  for(int fid = 0; fid < 40; fid++){
1478  for(std::map<uint32_t, std::vector< std::pair<std::pair<int, int>, float> > >::const_iterator it = noisyDetIds_.begin();
1479  it != noisyDetIds_.end(); it++){
1480  uint32_t detid = (*it).first;
1481  std::vector< std::pair<std::pair<int, int>, float> > noisyPixels = (*it).second;
1482  //cout<<noisyPixels.size()<<" noisy pixels in a module: "<<detid<<endl;
1483  // now convert into online conventions:
1484  for(int fedid=0; fedid<=40; ++fedid){
1485  SiPixelFrameConverter converter(theCablingMap.product(),fedid);
1486  uint32_t newDetId = detid;
1487  if(converter.hasDetUnit(newDetId)){
1488  realfedID=fedid;
1489  break;
1490  }
1491  }
1492  if(fid == realfedID){
1493  //cout<<"FED ID is = "<<realfedID<<endl;
1494  if(realfedID==-1) continue;
1495  DetId detId(detid);
1496  uint32_t detSubId = detId.subdetId();
1497  std::string outputname;
1498  bool HalfModule = false;
1499  if (detSubId == 2){ //FPIX
1500  PixelEndcapName nameworker(detid);
1501  outputname = nameworker.name();
1502  } else if(detSubId == 1){ //BPIX
1503  PixelBarrelName nameworker(detid);
1504  outputname = nameworker.name();
1505  HalfModule = nameworker.isHalfModule();
1506 
1507  } else{
1508  continue;
1509  }
1510  std::map<int,int> myrocmap;
1511  myfedmap[detid]=realfedID;
1512  mynamemap[detid]=outputname;
1513 
1514  for(std::vector< std::pair< std::pair<int,int>, float> >::const_iterator pxl = noisyPixels.begin();
1515  pxl != noisyPixels.end(); pxl++){
1516  std::pair<int,int> offlineaddress = (*pxl).first;
1517  float Noise_frac = (*pxl).second;
1518  int offlineColumn = offlineaddress.first;
1519  int offlineRow = offlineaddress.second;
1520  counter++;
1521  //cout<<"noisy pixel counter: "<<counter<<endl;
1522 
1525  sipixelobjects::DetectorIndex detector = {detid, offlineRow, offlineColumn};
1526  formatter.toCabling(cabling,detector);
1527  // cabling should now contain cabling.roc and cabling.dcol and cabling.pxid
1528  // however, the coordinates now need to be converted from dcl,pxid to the row,col coordinates used in the calibration info
1530  loc.dcol = cabling.dcol;
1531  loc.pxid = cabling.pxid;
1532 
1533 
1534  // OLD version, not 31X compatible:
1535 // const sipixelobjects::PixelFEDCabling *theFed= theCablingMap.product()->fed(realfedID);
1536 // const sipixelobjects::PixelFEDLink * link = theFed->link(cabling.link);
1537 // const sipixelobjects::PixelROC *theRoc = link->roc(cabling.roc);
1538 // sipixelobjects::LocalPixel locpixel(loc);
1539 
1540 
1541  // FIX to adhere to new cabling map. To be replaced with CalibTracker/SiPixelTools detid - > hardware id classes ASAP.
1542  // const sipixelobjects::PixelFEDCabling *theFed= theCablingMap.product()->fed(realfedID);
1543  // const sipixelobjects::PixelFEDLink * link = theFed->link(cabling.link);
1544  // const sipixelobjects::PixelROC *theRoc = link->roc(cabling.roc);
1545  sipixelobjects::LocalPixel locpixel(loc);
1546  assert(realfedID >= 0);
1547  assert(cabling.link >= 0);
1548  assert(cabling.roc >= 0);
1549  sipixelobjects::CablingPathToDetUnit path = {static_cast<unsigned int>(realfedID),
1550  static_cast<unsigned int>(cabling.link),
1551  static_cast<unsigned int>(cabling.roc)};
1552  const sipixelobjects::PixelROC *theRoc = theCablingMap->findItem(path);
1553  // END of FIX
1554 
1555  int onlineColumn = locpixel.rocCol();
1556  int onlineRow= locpixel.rocRow();
1557  myrocmap[(theRoc->idInDetUnit())]++;
1558 
1559  // ROC numbers in the barrel go from 8 to 15 instead of 0 to 7 in half modules. This is a
1560  // fix to get the roc number, and add 8 to it if:
1561  // it's a Barrel module AND on the minus side AND a Half module
1562 
1563  int rocnumber = -1;
1564 
1565  if((detSubId == 1) && (outputname.find("mO")!=string::npos || outputname.find("mI")!=string::npos) && (HalfModule)){
1566  rocnumber = theRoc->idInDetUnit() + 8;
1567  }
1568  else{
1569  rocnumber = theRoc->idInDetUnit();
1570  }
1571 
1572  //cout<<counter<<" : \t detid= "<<detid<<" , OFF col,row= "<<offlineColumn<<","<<offlineRow<<" , ON roc,col,row= "<<theRoc->idInDetUnit()<<","<<onlineColumn<<","<<onlineRow<<endl;
1573  myfile_ <<"NAME: "<<outputname<<" , DETID: "<<detid<<" , OFFLINE: col,row: "<<offlineColumn<<","<<offlineRow<<" \t , ONLINE: roc,col,row: "<<rocnumber<<","<<onlineColumn<<","<<onlineRow<< " \t , fed,dcol,pixid,link: "<<realfedID<<","<<loc.dcol<<","<<loc.pxid<<","<<cabling.link << ", Noise fraction: " << Noise_frac << std::endl;
1574  }
1575  for(std::map<int, int>::const_iterator nrc = myrocmap.begin(); nrc != myrocmap.end(); nrc++){
1576  if((*nrc).second > 0){
1577  n_noisyrocs_all++;
1578  if(detSubId == 2){
1579  n_noisyrocs_endcap++;
1580  } else if(detSubId == 1){
1581  n_noisyrocs_barrel++;}
1582  }
1583  if((*nrc).second > 40){
1584  n_verynoisyrocs_all++;
1585  if(detSubId == 2){
1586  n_verynoisyrocs_endcap++;
1587  } else if(detSubId == 1){
1588  n_verynoisyrocs_barrel++;}
1589  }
1590  }
1591  }
1592 
1593  }
1594  }
1595  myfile_ << "There are " << n_noisyrocs_all << " noisy ROCs (ROCs with at least 1 noisy pixel) in the entire detector. " << n_noisyrocs_endcap << " are in the FPIX and " << n_noisyrocs_barrel << " are in the BPIX. " << endl;
1596  myfile_ << "There are " << n_verynoisyrocs_all << " highly noisy ROCs (ROCs with at least 10% of all pixels passing the noise threshold) in the entire detector. " << n_verynoisyrocs_endcap << " are in the FPIX and " << n_verynoisyrocs_barrel << " are in the BPIX. " << endl;
1597 
1598  }
1599  myfile_.close();
1600 //cout<<"...leaving SiPixelInformationExtractor::findNoisyPixels!"<<endl;
1601  return;
1602 }
1603 
1604 
1605 //
1606 // -- Create Images
1607 //
1609  histoPlotter_->createPlots(bei);
1610 }
1611 
1612 //
1613 // -- Set HTML Header in xgi output
1614 //
1615 /* removing xdaq deps
1616 void SiPixelInformationExtractor::setHTMLHeader(xgi::Output * out) {
1617  out->getHTTPResponseHeader().addHeader("Content-Type", "text/html");
1618  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
1619  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
1620  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
1621 }
1622 */
1623 //
1624 // -- Set XML Header in xgi output
1625 //
1626 /* removing xdaq deps
1627 void SiPixelInformationExtractor::setXMLHeader(xgi::Output * out) {
1628  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
1629  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
1630  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
1631  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
1632  *out << "<?xml version=\"1.0\" ?>" << std::endl;
1633 
1634 }
1635 */
1636 //
1637 // -- Set Plain Header in xgi output
1638 //
1639 /* removing xdaq deps
1640 void SiPixelInformationExtractor::setPlainHeader(xgi::Output * out) {
1641  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
1642  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
1643  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
1644  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
1645 
1646 }
1647 */
SiPixelInformationExtractor(bool offlineXMLfile)
Constructor of the SiPixelInformationExtractor class.
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
#define ACRed
Definition: ANSIColors.h:15
void fillModuleAndHistoList(DQMStore *bei, std::vector< std::string > &modules, std::map< std::string, std::string > &histos)
(Documentation under construction).
void getNormalization(MonitorElement *mE, std::pair< double, double > &norm, std::string theMEType)
(Documentation under construction).
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:3274
static const int OTHER
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1659
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:644
int init
Definition: HydjetWrapper.h:62
void computeStatus(MonitorElement *mE, double &colorValue, std::pair< double, double > &norm)
(Documentation under construction).
static const int WARNING
void getMEList(DQMStore *bei, std::map< std::string, int > &mEHash)
(Documentation under construction).
std::map< uint32_t, std::vector< std::pair< std::pair< int, int >, float > > > noisyDetIds_
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool hasItem(std::multimap< std::string, std::string > &req_map, std::string item_name)
(Documentation under construction).
identify pixel inside single ROC
Definition: LocalPixel.h:7
void readConfiguration()
Read Configuration File.
return((rh^lh)&mask)
int getNbinsY(void) const
get # of bins in Y-axis
void Fill(long long x)
const std::string & getPathname(void) const
get pathname of parent folder
void printAlarmList(DQMStore *bei, std::ostringstream &str_val)
(Documentation under construction).
tuple path
else: Piece not in the list, fine.
bool isHalfModule() const
full or half module
T sqrt(T t)
Definition: SSEVec.h:48
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:39
void printSummaryHistoList(DQMStore *bei, std::ostringstream &str_val)
(Documentation under construction).
int j
Definition: DBlmapReader.cc:9
void selectImage(std::string &name, int status)
void getNormalization2D(MonitorElement *mE, std::pair< double, double > &normX, std::pair< double, double > &normY, std::string theMEType)
(Documentation under construction).
std::string getMEType(MonitorElement *mE)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1708
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
void selectMEList(DQMStore *bei, std::string &name, std::vector< MonitorElement * > &mes)
(Documentation under construction).
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:22
void printModuleHistoList(DQMStore *bei, std::ostringstream &str_val)
(Documentation under construction).
Definition: DetId.h:18
void createPlots(DQMStore *bei)
TObject * getRootObject(void) const
virtual std::string name() const
from base class
std::vector< QReport * > getQReports(void) const
get map of QReports
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::string getItemValue(const std::multimap< std::string, std::string > &req_map, std::string item_name)
(Documentation under construction).
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1682
bool goToDir(DQMStore *bei, std::string &sname)
(Documentation under construction).
void selectColor(std::string &col, int status)
void getItemList(const std::multimap< std::string, std::string > &req_map, std::string item_name, std::vector< std::string > &items)
(Documentation under construction).
virtual std::string name() const
from base class
int getDetId(MonitorElement *mE)
(Documentation under construction).
static std::atomic< unsigned int > counter
tuple formatter
Definition: fff_deleter.py:293
int getNbinsX(void) const
get # of bins in X-axis
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:678
static const int STATUS_OK
~SiPixelInformationExtractor()
Destructor of the SiPixelInformationExtractor class.
tuple cout
Definition: gather_cfg.py:121
void findNoisyPixels(DQMStore *bei, bool init, float noiseRate, int noiseRateDenominator, edm::EventSetup const &eSetup)
#define ACPlain
Definition: ANSIColors.h:28
tuple status
Definition: ntuplemaker.py:245
TH2F * getTH2F(void) const
int col
Definition: cuy.py:1008
edm::ESHandle< SiPixelFedCablingMap > theCablingMap
void bookNoisyPixels(DQMStore *bei, float noiseRate, bool Tier0Flag)
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
list fid
Definition: NewTree.py:51
#define ACBold
Definition: ANSIColors.h:29
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
static const int ERROR
const std::string & pwd(void) const
Definition: DQMStore.cc:639