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