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  string currDir = bei->pwd();
406  string dname = currDir.substr(currDir.find_last_of("/")+1);
407  str_val << " <li>\n"
408  << " <a href=\"#\" id=\"" << currDir << "\">\n "
409  << dname << "\n"
410  << " </a>\n"
411  << endl << endl;
412 
413  vector<string> meVec = bei->getMEs();
414 
415  vector<string> subDirVec = bei->getSubdirs();
416  if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
417  str_val << " </li>" << endl;
418  return;
419  }
420  str_val << "\n <ul>" << endl;
421  for (vector<string>::const_iterator it = meVec.begin();
422  it != meVec.end(); it++) {
423  if ((*it).find("_siPixel")!=string::npos ||
424  (*it).find("_ctfWithMaterialTracks")!=string::npos) {
425  string qit = (*it) ;
426  string temp_s;
427  if(qit.find("siPixel")!=string::npos || qit.find("ctfWithMaterialTracks")!=string::npos) { temp_s = qit.substr(0,qit.find_first_of("_")); }
428  str_val << " <li class=\"dhtmlgoodies_sheet.gif\">\n"
429  << " <input id = \"selectedME\""
430  << " folder = \"" << currDir << "\""
431  << " type = \"checkbox\""
432  << " name = \"selected\""
433  << " class = \"smallCheckBox\""
434  << " value = \"" << (*it) << "\""
435  << " onclick = \"javascript:IMGC.selectedIMGCItems()\" />\n"
436 // << " <a href=\"javascript:IMGC.updateIMGC('" << currDir << "')\">\n "
437  << " <a href=\"javascript:IMGC.plotFromPath('" << currDir << "')\">\n "
438 // << temp_s << "\n"
439  << (*it) << "\n"
440  << " </a>\n"
441  << " </li>"
442  << endl;
443  }
444  }
445  for (vector<string>::const_iterator ic = subDirVec.begin();
446  ic != subDirVec.end(); ic++) {
447  bei->cd(*ic);
448  printModuleHistoList(bei, str_val);
449  bei->goUp();
450  }
451  str_val << " </ul>" << endl;
452  str_val << " </li>" << endl;
453 //cout<<"leaving SiPixelInformationExtractor::printModuleHistoList"<<endl;
454 }
455 
456 //------------------------------------------------------------------------------
462  string& str_name,
463  xgi::Output * out) {
464 //cout<<"entering SiPixelInformationExtractor::readSummaryHistoTree"<<endl;
465  ostringstream sumtree;
466  if (goToDir(bei, str_name)) {
467  sumtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
468  printSummaryHistoList(bei,sumtree);
469  sumtree <<"</ul>" << endl;
470  } else {
471  sumtree << "Desired Directory does not exist";
472  }
473  cout << ACYellow << ACBold
474  << "[SiPixelInformationExtractor::readSummaryHistoTree()]"
475  << ACPlain << endl ;
476  // << "html string follows: " << endl ;
477  //cout << sumtree.str() << endl ;
478  //cout << ACYellow << ACBold
479  // << "[SiPixelInformationExtractor::readSummaryHistoTree()]"
480  // << ACPlain
481  // << "String complete " << endl ;
482  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
483  *out << sumtree.str();
484  bei->cd();
485 //cout<<"leaving SiPixelInformationExtractor::readSummaryHistoTree"<<endl;
486 }
487 //------------------------------------------------------------------------------
495  ostringstream& str_val){
496 //cout<<"entering SiPixelInformationExtractor::printSummaryHistoList"<<endl;
497  string currDir = bei->pwd();
498  string dname = currDir.substr(currDir.find_last_of("/")+1);
499  if (dname.find("Module_") ==0 || dname.find("FED_")==0) return;
500  str_val << " <li>\n"
501  << " <a href=\"#\" id=\"" << currDir << "\">\n "
502  << dname
503  << " </a>"
504  << endl;
505 
506  vector<string> meVec = bei->getMEs();
507 
508  vector<string> subDirVec = bei->getSubdirs();
509  if ( meVec.size()== 0 && subDirVec.size() == 0 ) {
510  str_val << " </li> "<< endl;
511  return;
512  }
513  str_val << "\n <ul>" << endl;
514  for (vector<string>::const_iterator it = meVec.begin();
515  it != meVec.end(); it++) {
516  if ((*it).find("SUM") == 0) {
517  str_val << " <li class=\"dhtmlgoodies_sheet.gif\">\n"
518  << " <input id = \"selectedME\""
519  << " folder = \"" << currDir << "\""
520  << " type = \"checkbox\""
521  << " name = \"selected\""
522  << " class = \"smallCheckBox\""
523  << " value = \"" << (*it) << "\""
524  << " onclick = \"javascript:IMGC.selectedIMGCItems()\" />\n"
525 // << " <a href=\"javascript:IMGC.updateIMGC('" << currDir << "')\">\n "
526  << " <a href=\"javascript:IMGC.plotFromPath('" << currDir << "')\">\n "
527  << (*it) << "\n"
528  << " </a>\n"
529  << " </li>"
530  << endl;
531  }
532  }
533 
534  for (vector<string>::const_iterator ic = subDirVec.begin();
535  ic != subDirVec.end(); ic++) {
536  bei->cd(*ic);
537  printSummaryHistoList(bei, str_val);
538  bei->goUp();
539  }
540  str_val << " </ul> "<< endl;
541  str_val << " </li> "<< endl;
542 //cout<<"leaving SiPixelInformationExtractor::printSummaryHistoList"<<endl;
543 }
544 
545 
546 //------------------------------------------------------------------------------
552  string& str_name,
553  xgi::Output * out){
554 //cout<<"entering SiPixelInformationExtractor::readAlarmTree"<<endl;
555  ostringstream alarmtree;
556  if (goToDir(bei, str_name)) {
557  alarmtree << "<ul id=\"dhtmlgoodies_tree\" class=\"dhtmlgoodies_tree\">" << endl;
558  alarmCounter_=0;
559  printAlarmList(bei,alarmtree);
560  if(alarmCounter_==0) alarmtree <<"<li>No problematic modules found, all ok!</li>" << endl;
561  alarmtree <<"</ul>" << endl;
562  } else {
563  alarmtree << "Desired Directory does not exist";
564  }
565  cout << ACYellow << ACBold
566  << "[SiPixelInformationExtractor::readAlarmTree()]"
567  << ACPlain << endl ;
568  // << "html string follows: " << endl ;
569  //cout << alarmtree.str() << endl ;
570  //cout << ACYellow << ACBold
571  // << "[SiPixelInformationExtractor::readAlarmTree()]"
572  // << ACPlain
573  // << "String complete " << endl ;
574  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
575  *out << alarmtree.str();
576  bei->cd();
577  cout << ACYellow << ACBold
578  << "[SiPixelInformationExtractor::readAlarmTree()]"
579  << ACPlain
580  << " Done!"
581  << endl ;
582 //cout<<"leaving SiPixelInformationExtractor::readAlarmTree"<<endl;
583 }
584 //------------------------------------------------------------------------------
592  ostringstream& str_val){
593 //cout<<"entering SiPixelInformationExtractor::printAlarmList"<<endl;
594 // cout << ACRed << ACBold
595 // << "[SiPixelInformationExtractor::printAlarmList()]"
596 // << ACPlain
597 // << " Enter"
598 // << endl ;
599  string currDir = bei->pwd();
600  string dname = currDir.substr(currDir.find_last_of("/")+1);
601  string image_name;
602  selectImage(image_name,bei->getStatus(currDir));
603  if(image_name!="images/LI_green.gif")
604  str_val << " <li>\n"
605  << " <a href=\"#\" id=\"" << currDir << "\">\n "
606  << dname
607  << " </a>\n"
608  << " <img src=\""
609  << image_name
610  << "\">" << endl;
611  vector<string> subDirVec = bei->getSubdirs();
612 
613  vector<string> meVec = bei->getMEs();
614 
615  if (subDirVec.size() == 0 && meVec.size() == 0) {
616  str_val << "</li> "<< endl;
617  return;
618  }
619  str_val << "<ul>" << endl;
620  for (vector<string>::const_iterator it = meVec.begin();
621  it != meVec.end(); it++) {
622  string full_path = currDir + "/" + (*it);
623 
624  MonitorElement * me = bei->get(full_path);
625 
626  if (!me) continue;
627  std::vector<QReport *> my_map = me->getQReports();
628  if (my_map.size() > 0) {
629  string image_name1;
630  selectImage(image_name1,my_map);
631  if(image_name1!="images/LI_green.gif") {
632  alarmCounter_++;
633  str_val << " <li class=\"dhtmlgoodies_sheet.gif\">\n"
634  << " <input id = \"selectedME\""
635  << " folder = \"" << currDir << "\""
636  << " type = \"checkbox\""
637  << " name = \"selected\""
638  << " class = \"smallCheckBox\""
639  << " value = \"" << (*it) << "\""
640  << " onclick = \"javascript:IMGC.selectedIMGCItems()\" />\n"
641 // << " <a href=\"javascript:IMGC.updateIMGC('" << currDir << "')\">\n "
642  << " <a href=\"javascript:IMGC.plotFromPath('" << currDir << "')\">\n "
643  << (*it) << "\n"
644  << " </a>\n"
645  << " <img src=\""
646  << image_name1
647  << "\">"
648  << " </li>"
649  << endl;
650  }
651  }
652  }
653  for (vector<string>::const_iterator ic = subDirVec.begin();
654  ic != subDirVec.end(); ic++) {
655  bei->cd(*ic);
656  printAlarmList(bei, str_val);
657  bei->goUp();
658  }
659  str_val << "</ul> "<< endl;
660  str_val << "</li> "<< endl;
661 // cout << ACGreen << ACBold
662 // << "[SiPixelInformationExtractor::printAlarmList()]"
663 // << ACPlain
664 // << " Done"
665 // << endl ;
666 //cout<<"leaving SiPixelInformationExtractor::printAlarmList"<<endl;
667 }
668 
669 
670 //------------------------------------------------------------------------------
675 void SiPixelInformationExtractor::getItemList(const multimap<string, string>& req_map,
676  string item_name,
677  vector<string>& items) {
678 //cout<<"entering SiPixelInformationExtractor::getItemList"<<endl;
679  items.clear();
680  for (multimap<string, string>::const_iterator it = req_map.begin();
681  it != req_map.end(); it++) {
682  if (it->first == item_name) {
683  items.push_back(it->second);
684  }
685  }
686 //cout<<"leaving SiPixelInformationExtractor::getItemList"<<endl;
687 }
688 
689 //------------------------------------------------------------------------------
694 bool SiPixelInformationExtractor::hasItem(multimap<string,string>& req_map,
695  string item_name){
696 //cout<<"entering SiPixelInformationExtractor::hasItem"<<endl;
697  multimap<string,string>::iterator pos = req_map.find(item_name);
698  if (pos != req_map.end()) return true;
699  return false;
700 //cout<<"leaving SiPixelInformationExtractor::hasItem"<<endl;
701 }
702 
703 //------------------------------------------------------------------------------
708 std::string SiPixelInformationExtractor::getItemValue(const std::multimap<std::string,std::string>& req_map,
709  std::string item_name){
710 //cout<<"entering SiPixelInformationExtractor::getItemValue for item: "<<item_name<<endl;
711  std::multimap<std::string,std::string>::const_iterator pos = req_map.find(item_name);
712  std::string value = " ";
713  if (pos != req_map.end()) {
714  value = pos->second;
715  }
716 // cout<<"value = "<<value<<endl;
717  return value;
718 //cout<<"leaving SiPixelInformationExtractor::getItemValue"<<endl;
719 }
720 std::string SiPixelInformationExtractor::getItemValue(std::multimap<std::string,std::string>& req_map,
721  std::string item_name){
722 //cout<<"entering SiPixelInformationExtractor::getItemValue for item: "<<item_name<<endl;
723  std::multimap<std::string,std::string>::iterator pos = req_map.find(item_name);
724  std::string value = " ";
725  if (pos != req_map.end()) {
726 // cout<<"item found!"<<endl;
727  value = pos->second;
728  }
729 // cout<<"value = "<<value<<endl;
730  return value;
731 //cout<<"leaving SiPixelInformationExtractor::getItemValue"<<endl;
732 }
733 
734 //
735 // -- Get color name from status
736 //
737 void SiPixelInformationExtractor::selectColor(string& col, int status){
738  if (status == dqm::qstatus::STATUS_OK) col = "#00ff00";
739  else if (status == dqm::qstatus::WARNING) col = "#ffff00";
740  else if (status == dqm::qstatus::ERROR) col = "#ff0000";
741  else if (status == dqm::qstatus::OTHER) col = "#ffa500";
742  else col = "#0000ff";
743 }
744 //
745 // -- Get Image name from ME
746 //
747 void SiPixelInformationExtractor::selectColor(string& col, vector<QReport*>& reports){
748  int istat = 999;
749  int status = 0;
750  for (vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
751  it++) {
752  status = (*it)->getStatus();
753  if (status > istat) istat = status;
754  }
755  selectColor(col, status);
756 }
757 //
758 // -- Get Image name from status
759 //
760 void SiPixelInformationExtractor::selectImage(string& name, int status){
761  if (status == dqm::qstatus::STATUS_OK) name="images/LI_green.gif";
762  else if (status == dqm::qstatus::WARNING) name="images/LI_yellow.gif";
763  else if (status == dqm::qstatus::ERROR) name="images/LI_red.gif";
764  else if (status == dqm::qstatus::OTHER) name="images/LI_orange.gif";
765  else name="images/LI_blue.gif";
766 }
767 //
768 // -- Get Image name from ME
769 //
770 void SiPixelInformationExtractor::selectImage(string& name, vector<QReport*>& reports){
771  int istat = 999;
772  int status = 0;
773  for (vector<QReport*>::const_iterator it = reports.begin(); it != reports.end();
774  it++) {
775  status = (*it)->getStatus();
776  if (status > istat) istat = status;
777  }
778  selectImage(name, status);
779 }
780 
781 //
782 // -- Get a tagged image
783 //
784 void SiPixelInformationExtractor::getIMGCImage(const multimap<string, string>& req_map,
785  xgi::Output * out){
786  string path = getItemValue(req_map,"Path");
787  string image;
788  histoPlotter_->getNamedImageBuffer(path, image);
789 
790  out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
791  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
792  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
793  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
794  *out << image;
795 }
796 
797 void SiPixelInformationExtractor::getIMGCImage(multimap<string, string>& req_map,
798  xgi::Output * out){
799 
800  string path = getItemValue(req_map,"Path");
801  string image;
802  histoPlotter_->getNamedImageBuffer(path, image);
803 
804  out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
805  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
806  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
807  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
808  *out << image;
809 
810 }
811 
812 
813 //------------------------------------------------------------------------------
819  string& sname){
820 //cout<<"entering SiPixelInformationExtractor::goToDir"<<endl;
821  bei->cd();
822  //if(flg) bei->cd("Collector/Collated");
823  bei->cd(sname);
824  string dirName = bei->pwd();
825  if (dirName.find(sname) != string::npos) return true;
826  else return false;
827 //cout<<"leaving SiPixelInformationExtractor::goToDir"<<endl;
828 }
829 
830 //
831 // -- Get Warning/Error Messages
832 //
834  std::multimap<std::string, std::string>& req_map,
835  xgi::Output * out){
836 
837  string path = getItemValue(req_map,"Path");
838 
839  int width = atoi(getItemValue(req_map, "width").c_str());
840  int height = atoi(getItemValue(req_map, "height").c_str());
841 
842  string opt =" ";
843 
844  ostringstream test_status;
845 
846  setXMLHeader(out);
847  *out << "<StatusAndPath>" << endl;
848  *out << "<PathList>" << endl;
849  if (path.size() == 0) {
850  *out << "<HPath>" << "NONE" << "</HPath>" << endl;
851  test_status << " ME Does not exist ! " << endl;
852  } else {
853  vector<MonitorElement*> all_mes = bei->getContents(path);
854  *out << "<HPath>" << path << "</HPath>" << endl;
855  for(vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
856  MonitorElement* me = (*it);
857  if (!me) continue;
858  string name = me->getName();
859 
860  vector<QReport*> q_reports = me->getQReports();
861  if (q_reports.size() == 0) continue;
862  string full_path = path + "/" + name;
863  histoPlotter_->setNewPlot(full_path, opt, width, height);
864 
865  if (q_reports.size() != 0) {
866  test_status << " QTest Status for " << name << " : " << endl;
867  test_status << " ======================================================== " << endl;
868  for (vector<QReport*>::const_iterator it = q_reports.begin(); it != q_reports.end();
869  it++) {
870  int status = (*it)->getStatus();
871  if (status == dqm::qstatus::WARNING) test_status << " Warning ";
872  else if (status == dqm::qstatus::ERROR) test_status << " Error ";
873  else if (status == dqm::qstatus::STATUS_OK) test_status << " Ok ";
874  else if (status == dqm::qstatus::OTHER) test_status << " Other(" << status << ") ";
875  string mess_str = (*it)->getMessage();
876  test_status << "&lt;br/&gt;";
877  mess_str = mess_str.substr(mess_str.find(" Test")+5);
878  test_status << " QTest Name : " << mess_str.substr(0, mess_str.find(")")+1) << endl;
879  test_status << "&lt;br/&gt;";
880  test_status << " QTest Detail : " << mess_str.substr(mess_str.find(")")+2) << endl;
881  }
882  test_status << " ======================================================== " << endl;
883  }
884  *out << "<HPath>" << name << "</HPath>" << endl;
885  }
886  }
887  *out << "</PathList>" << endl;
888  *out << "<StatusList>" << endl;
889  *out << "<Status>" << test_status.str() << "</Status>" << endl;
890  *out << "</StatusList>" << endl;
891  *out << "</StatusAndPath>" << endl;
892 }
893 
894 //------------------------------------------------------------------------------
899  double & colorValue,
900  pair<double,double> & norm)
901 {
902  double normalizationX = 1 ;
903  double normalizationY = 1 ;
904  double meanX = 0 ;
905  double meanY = 0 ;
906 
907  colorValue = 0 ;
908 
909  pair<double,double> normX ;
910  pair<double,double> normY ;
911 
912  string theMEType = getMEType(theME) ;
913 
914 // cout << ACRed << ACReverse
915 // << "[SiPixelInformationExtractor::computeStatus()]"
916 // << ACPlain
917 // << " Computing average for "
918 // << theME->getName()
919 // << endl ;
920 
921  if( theMEType.find("TH1") != string::npos)
922  {
923  meanX = (double)theME->getMean();
924  getNormalization(theME, normX, "TH1") ;
925  normalizationX = fabs( normX.second - normX.first) ;
926  if( normalizationX == 0 ) {normalizationX=1.E-20;}
927  colorValue = meanX / normalizationX ;
928  norm.first = normX.first ;
929  norm.second = normX.second ;
930  }
931 
932  if( theMEType.find("TH2") != string::npos)
933  {
934  meanX = (double)theME->getMean(1);
935  meanY = (double)theME->getMean(2);
936  getNormalization2D(theME, normX, normY, "TH2") ;
937  normalizationX = fabs( normX.second - normX.first) ;
938  normalizationY = fabs( normY.second - normY.first) ;
939  if( normalizationX == 0 ) {normalizationX=1.E-20;}
940  if( normalizationY == 0 ) {normalizationY=1.E-20;}
941  double cVX = meanX / normalizationX ;
942  double cVY = meanY / normalizationY ;
943  colorValue = sqrt(cVX*cVX + cVY*cVY) ;
944  if( normalizationX >= normalizationY )
945  {
946  norm.first = normX.first;
947  norm.second = normX.second ;
948  } else {
949  norm.first = normY.first;
950  norm.second = normY.second ;
951  }
952 // cout << ACBlue << ACBold << ACReverse
953 // << "[SiPixelInformationExtractor::computeStatus()]"
954 // << ACPlain << " "
955 // << theME->getName()
956 // << " meanX:Y "
957 // << meanX << ":" << meanY
958 // << " normX:Y "
959 // << norm.first << ":" << norm.second
960 // << endl ;
961  }
962 
963  return ;
964 }
965 
966 //------------------------------------------------------------------------------
971  pair<double,double>& norm,
972  std::string theMEType)
973 {
974  double normLow = 0 ;
975  double normHigh = 0 ;
976 
977  if( theMEType.find("TH1") != string::npos)
978  {
979  normHigh = (double)theME->getNbinsX() ;
980  norm.first = normLow ;
981  norm.second = normHigh ;
982  }
983 }
984 
985 //------------------------------------------------------------------------------
990  pair<double,double>& normX,
991  pair<double,double>& normY,
992  std::string theMEType)
993 {
994  double normLow = 0 ;
995  double normHigh = 0 ;
996 
997  if( theMEType.find("TH2") != string::npos )
998  {
999  normHigh = (double)theME->getNbinsX() ;
1000  normX.first = normLow ;
1001  normX.second = normHigh ;
1002  normHigh = (double)theME->getNbinsY() ;
1003  normY.first = normLow ;
1004  normY.second = normHigh ;
1005 // cout << ACCyan << ACBold << ACReverse
1006 // << "[SiPixelInformationExtractor::getNormalization2D()]"
1007 // << ACPlain << " "
1008 // << theME->getName()
1009 // << " normX: "
1010 // << normX.first << ":" << normX.second
1011 // << " normY: "
1012 // << normY.first << ":" << normY.second
1013 // << endl ;
1014  }
1015 }
1016 
1017 //------------------------------------------------------------------------------
1023  string & theMEName,
1024  vector<MonitorElement*> & mes)
1025 {
1026 // cout<<"In SiPixelInformationExtractor::selectMEList: "<<endl;
1027  string currDir = bei->pwd();
1028 
1029  string theME ;
1030 
1031  // Get ME from Collector/FU0/Tracker/PixelEndcap/HalfCylinder_pX/Disk_X/Blade_XX/Panel_XX/Module_XX
1032  if (currDir.find("Module_") != string::npos ||
1033  currDir.find("FED_") != string::npos)
1034  {
1035  vector<string> contents = bei->getMEs();
1036 
1037  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++)
1038  {
1039  theME = (*it) ;
1040  if(theME.find("siPixel")==string::npos && theME.find("ctfWithMaterialTracks")==string::npos) {continue ;} // If the ME is not a siPixel or ctfWithMaterialTrack one, skip
1041  string temp_s = theME.substr(0,theME.find_first_of("_"));
1042  //cout<<"should be the variable name: temp_s= "<<temp_s<<endl;
1043  if (temp_s == theMEName)
1044  {
1045  string full_path = currDir + "/" + (*it);
1046 
1047  MonitorElement * me = bei->get(full_path.c_str());
1048 
1049  if (me) {mes.push_back(me);}
1050  }
1051  }
1052  return;
1053  } else { // If not yet reached the desired level in the directory tree, recursively go down one level more
1054  vector<string> subdirs = bei->getSubdirs();
1055  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++)
1056  {
1057  bei->cd(*it);
1058  selectMEList(bei, theMEName, mes);
1059  bei->goUp();
1060  }
1061  }
1062 }
1063 
1064 //------------------------------------------------------------------------------
1069  xgi::Output * out,
1070  std::string & theMEName,
1071  std::string & theTKType)
1072 {
1073 // cout<<"In SiPixelInformationExtractor::sendTkUpdatedStatus: "<<endl;
1074  int rval, gval, bval;
1075  vector<string> colorMap ;
1076  vector<MonitorElement*> me_list;
1077  pair<double,double> norm ;
1078  double sts ;
1079 
1080  bei->cd();
1081  selectMEList(bei, theMEName, me_list) ;
1082  bei->cd();
1083 
1084  string detId = "undefined";
1085 
1086 /* cout << ACYellow << ACBold
1087  << "[SiPixelInformationExtractor::sendTkUpdatedStatus()] "
1088  << ACPlain
1089  << "Preparing color map update for "
1090  << theMEName
1091  << " type "
1092  << theTKType
1093  << " - List size: "
1094  << me_list.size()
1095  << endl ;
1096 */
1097  int maxEntries = 0 ;
1098  if( theTKType == "Entries") // In this case find the ME with the highest number of entries
1099  { // first and use that as a vertical scale normalization
1100  for(vector<MonitorElement*>::iterator it=me_list.begin(); it!=me_list.end(); it++)
1101  {
1102  int entries = (int)(*it)->getEntries() ;
1103  if( entries > maxEntries ) maxEntries = entries ;
1104  }
1105  }
1106 
1107  int entries = 0 ;
1108  stringstream jsSnippet ;
1109  for(vector<MonitorElement*>::iterator it=me_list.begin(); it!=me_list.end(); it++)
1110  {
1111  string meName = (*it)->getName();
1112  string theMEType = getMEType(*it);
1113  if( meName.find("_3") != string::npos )
1114  {
1115  string detIdString = meName.substr(meName.find_last_of("_")+1,9);
1116  std::istringstream isst;
1117  isst.str(detIdString);
1118  isst>>detId;
1119  entries = (int)(*it)->getEntries() ;
1120  if( theTKType == "Averages")
1121  {
1122  computeStatus(*it, sts, norm) ;
1123  SiPixelUtility::getStatusColor(sts, rval, gval, bval);
1124  } else if( theTKType == "Entries") {
1125  sts = (double)entries / (double)maxEntries ;
1126  SiPixelUtility::getStatusColor(sts, rval, gval, bval);
1127  if( entries > maxEntries ) maxEntries = entries ;
1128  norm.first = 0 ;
1129  norm.second = maxEntries ;
1130  } else {
1131  int status = SiPixelUtility::getStatus((*it));
1132  if( status == dqm::qstatus::ERROR )
1133  {
1134  rval = 255; gval = 0; bval = 0;
1135  } else if (status == dqm::qstatus::WARNING ) {
1136  rval = 255; gval = 255; bval = 0;
1137  } else if (status == dqm::qstatus::OTHER) {
1138  rval = 0; gval = 0; bval = 255;
1139  } else if (status == dqm::qstatus::STATUS_OK) {
1140  rval = 0; gval = 255; bval = 0;
1141  } else {
1142  rval = 255; gval = 255; bval = 255;
1143  }
1144  }
1145  jsSnippet.str("") ;
1146  jsSnippet << " <DetInfo DetId='"
1147  << detId
1148  << "' red='"
1149  << rval
1150  << "' green='"
1151  << gval
1152  << "' blue='"
1153  << bval
1154  << "' entries='"
1155  << entries
1156  << "'/>" ;
1157  colorMap.push_back(jsSnippet.str()) ;
1158 // if( it == me_list.begin()) // The first should be equal to all others...
1159 // {
1160 // getNormalization((*it), norm, theMEType.latin1()) ;
1161 // }
1162  }
1163  }
1164 
1165 // delete random ;
1166 
1167 /* cout << ACYellow << ACBold
1168  << "[SiPixelInformationExtractor::sendTkUpdatedStatus()] "
1169  << ACPlain
1170  << "Color map consists of "
1171  << colorMap.size()
1172  << " snippets: start shipping back"
1173  << endl ;
1174 */
1175  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
1176  *out << "<?xml version=\"1.0\" ?>" << endl;
1177  *out << "<TrackerMapUpdate>" << endl;
1178 
1179  for(vector<string>::iterator it=colorMap.begin(); it!=colorMap.end(); it++)
1180  {
1181  *out << *it << endl;
1182  }
1183 
1184  *out << " <theLimits id=\"normalizationLimits\" normLow=\""
1185  << norm.first
1186  << "\" normHigh=\""
1187  << norm.second
1188  << "\" />"
1189  << endl;
1190  *out << "</TrackerMapUpdate>"
1191  << endl;
1192 
1193 /* cout << ACYellow << ACBold
1194  << "[SiPixelInformationExtractor::sendTkUpdatedStatus()] "
1195  << ACPlain
1196  << "Color map updated within range "
1197  << norm.first
1198  << "-"
1199  << norm.second
1200  << endl ;
1201 */
1202 }
1203 
1204 //------------------------------------------------------------------------------
1210 {
1211 //cout<<"In SiPixelInformationExtractor::getDetId: for ME= "<<mE->getName()<<endl;
1212  string mEName = mE->getName();
1213 
1214  int detId = 0;
1215 
1216  if( mEName.find("_3") != string::npos )
1217  {
1218  string detIdString = mEName.substr((mEName.find_last_of("_"))+1,9);
1219  //cout<<"string: "<<detIdString<<endl;
1220  std::istringstream isst;
1221  isst.str(detIdString);
1222  isst>>detId;
1223 // } else {
1224 // cout << ACYellow << ACBold
1225 // << "[SiPixelInformationExtractor::getDetId()] "
1226 // << ACPlain
1227 // << "Could not extract detId from "
1228 // << mEName
1229 // << endl ;
1230  }
1231  //cout<<"returning with: "<<detId<<endl;
1232  return detId ;
1233 
1234 }
1235 
1236 //------------------------------------------------------------------------------
1241  map<string, int> & mEHash)
1242 {
1243  string currDir = bei->pwd();
1244 
1245 // cout << ACRed << ACBold
1246 // << "[SiPixelInformationExtractor::getMEList()]"
1247 // << ACPlain
1248 // << " Requesting ME list in "
1249 // << currDir
1250 // << endl ;
1251 
1252  string theME ;
1253 
1254  // Get ME from Collector/FU0/Tracker/PixelEndcap/HalfCylinder_pX/Disk_X/Blade_XX/Panel_XX/Module_XX
1255  if (currDir.find("Module_") != string::npos ||
1256  currDir.find("FED_") != string::npos)
1257  {
1258  vector<string> contents = bei->getMEs();
1259 
1260  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++)
1261  {
1262  theME = (*it) ;
1263 // cout << ACRed << ACReverse
1264 // << "[SiPixelInformationExtractor::getMEList()]"
1265 // << ACPlain
1266 // << " ME: "
1267 // << (*it)
1268 // << endl ;
1269  if(theME.find("siPixel")==string::npos && theME.find("ctfWithMaterialTracks")==string::npos)
1270  {
1271  cout << ACRed << ACBold
1272  << "[SiPixelInformationExtractor::getMEList()]"
1273  << ACPlain
1274  << " ----> Skipping "
1275  << (*it)
1276  << endl ;
1277  continue ;
1278  } // If the ME is not a Pixel one, skip
1279  string full_path = currDir + "/" + (*it);
1280  string mEName = theME.substr(0,theME.find_first_of("_"));
1281  mEHash[mEName]++ ;
1282  }
1283 
1284  return;
1285  } else { // If not yet reached the desired level in the directory tree, recursively go down one level more
1286  vector<string> subdirs = bei->getSubdirs();
1287  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++)
1288  {
1289  bei->cd(*it);
1290  getMEList(bei, mEHash);
1291  bei->goUp();
1292  }
1293  }
1294 }
1295 
1296 //
1297 // -- Get All histograms from a Path
1298 //
1300  const std::multimap<std::string, std::string>& req_map,
1301  xgi::Output * out){
1302 //cout<<"Entering SiPixelInformationExtractor::getHistosFromPath: "<<endl;
1303  string path = getItemValue(req_map,"Path");
1304 //cout<<"Path is: "<<path<<endl;
1305  if (path.size() == 0) return;
1306 
1307  int width = atoi(getItemValue(req_map, "width").c_str());
1308  int height = atoi(getItemValue(req_map, "height").c_str());
1309 
1310  string opt =" ";
1311 
1312  setHTMLHeader(out);
1313  vector<MonitorElement*> all_mes = bei->getContents(path);
1314  *out << path << " " ;
1315  for(vector<MonitorElement*>::iterator it=all_mes.begin(); it!=all_mes.end(); it++){
1316  MonitorElement* me = (*it);
1317  //cout<<"I'm in the loop now..."<<endl;
1318  if (!me) continue;
1319  string name = me->getName();
1320  string full_path = path + "/" + name;
1321 //cout<<"Calling HP::setNewPlot now for "<<full_path<<endl;
1322  histoPlotter_->setNewPlot(full_path, opt, width, height);
1323  *out << name << " ";
1324  }
1325 // cout<<"... leaving SiPixelInformationExtractor::getHistosFromPath!"<<endl;
1326 }
1327 
1329 
1330 void SiPixelInformationExtractor::bookNoisyPixels(DQMStore * bei, float noiseRate_,bool Tier0Flag) {
1331 //std::cout<<"BOOK NOISY PIXEL MEs!"<<std::endl;
1332  bei->cd();
1333  if(noiseRate_>=0.){
1334  bei->setCurrentFolder("Pixel/Barrel");
1335  EventRateBarrelPixels = bei->book1D("barrelEventRate","Digi event rate for all Barrel pixels",1000,0.,0.01);
1336  EventRateBarrelPixels->setAxisTitle("Event Rate",1);
1337  EventRateBarrelPixels->setAxisTitle("Number of Pixels",2);
1338  bei->cd();
1339  bei->setCurrentFolder("Pixel/Endcap");
1340  EventRateEndcapPixels = bei->book1D("endcapEventRate","Digi event rate for all Endcap pixels",1000,0.,0.01);
1341  EventRateEndcapPixels->setAxisTitle("Event Rate",1);
1342  EventRateEndcapPixels->setAxisTitle("Number of Pixels",2);
1343  }
1344 }
1345 
1346 
1348 
1349 void SiPixelInformationExtractor::findNoisyPixels(DQMStore * bei, bool init, float noiseRate_, int noiseRateDenominator_, edm::EventSetup const& eSetup)
1350 {
1351 //cout<<"Entering SiPixelInformationExtractor::findNoisyPixels with noiseRate set to "<<noiseRate_<<endl;
1352 
1353 
1354  if(init){
1355  endOfModules_=false;
1356  nevents_=noiseRateDenominator_;
1357  if(nevents_ == -1){
1358  bei->cd();
1359  bei->setCurrentFolder("Pixel/EventInfo");
1360  nevents_ = (bei->get("Pixel/EventInfo/processedEvents"))->getIntValue();
1361  }
1362  bei->cd();
1363  myfile_.open ("NoisyPixelList.txt", ios::app);
1364  myfile_ << "Noise summary, ran over " << nevents_ << " events, threshold was set to " << noiseRate_ << std::endl;
1365  }
1366  string currDir = bei->pwd();
1367  string dname = currDir.substr(currDir.find_last_of("/")+1);
1368 
1369 
1370  if(dname.find("Module_")!=string::npos){
1371  vector<string> meVec = bei->getMEs();
1372  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1373  string full_path = currDir + "/" + (*it);
1374  if(full_path.find("hitmap_siPixelDigis")!=string::npos){
1375  //broken HV bond:
1376  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_01/Panel_2/Module_2")!=string::npos) continue;
1377  //?noisy?
1378  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_1/Module_4")!=string::npos) continue;
1379  //ROG with HV problem (short?):
1380  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_1/Module_3")!=string::npos) continue;
1381  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_1/Module_4")!=string::npos) continue;
1382  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_2/Module_2")!=string::npos) continue;
1383  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_10/Panel_2/Module_3")!=string::npos) continue;
1384  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_1/Module_3")!=string::npos) continue;
1385  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_1/Module_4")!=string::npos) continue;
1386  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_2/Module_2")!=string::npos) continue;
1387  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_11/Panel_2/Module_3")!=string::npos) continue;
1388  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_1/Module_3")!=string::npos) continue;
1389  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_1/Module_4")!=string::npos) continue;
1390  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_2/Module_2")!=string::npos) continue;
1391  //if(currDir.find("HalfCylinder_mI/Disk_1/Blade_12/Panel_2/Module_3")!=string::npos) continue;
1392  MonitorElement * me = bei->get(full_path);
1393  if (!me) continue;
1394  int detid=getDetId(me); int pixcol=-1; int pixrow=-1;
1395 
1396  //cout<<"detid= "<<detid<<endl;
1397  std::vector<std::pair<std::pair<int, int>, float> > noisyPixelsInModule;
1398  TH2F * hothisto = me->getTH2F();
1399  if(hothisto){
1400  for(int i=1; i!=hothisto->GetNbinsX()+1; i++){
1401  for(int j=1; j!=hothisto->GetNbinsY()+1; j++){
1402  float value = (hothisto->GetBinContent(i,j))/float(nevents_);
1403  if(me->getPathname().find("Barrel")!=string::npos){
1404  EventRateBarrelPixels = bei->get("Pixel/Barrel/barrelEventRate");
1406  }else if(me->getPathname().find("Endcap")!=string::npos){
1407  EventRateEndcapPixels = bei->get("Pixel/Endcap/endcapEventRate");
1409  }
1410  if(value > noiseRate_){
1411  pixcol = i-1;
1412  pixrow = j-1;
1413  //cout<<"pixcol= "<<pixcol<<" , pixrow= "<<pixrow<<" , value= "<<value<<endl;
1414 
1415  std::pair<int, int> address(pixcol, pixrow);
1416  std::pair<std::pair<int, int>, float> PixelStats(address, value);
1417  noisyPixelsInModule.push_back(PixelStats);
1418  }
1419  }
1420  }
1421  }
1422  noisyDetIds_[detid] = noisyPixelsInModule;
1423  //if(noisyPixelsInModule.size()>=20) cout<<"This module has 20 or more hot pixels: "<<detid<<","<<bei->pwd()<<","<<noisyPixelsInModule.size()<<endl;
1424  }
1425  }
1426  }
1427  vector<string> subDirVec = bei->getSubdirs();
1428  for (vector<string>::const_iterator ic = subDirVec.begin();
1429  ic != subDirVec.end(); ic++) {
1430  if((*ic).find("AdditionalPixelErrors")!=string::npos) continue;
1431  bei->cd(*ic);
1432  init=false;
1433  findNoisyPixels(bei,init,noiseRate_,noiseRateDenominator_,eSetup);
1434  bei->goUp();
1435  }
1436 
1437  if(bei->pwd().find("EventInfo")!=string::npos) endOfModules_ = true;
1438 
1439  if(!endOfModules_) return;
1440  // myfile_ <<"am in "<<bei->pwd()<<" now!"<<endl;
1441  if(currDir == "Pixel/EventInfo/reportSummaryContents"){
1442  eSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap);
1443  std::vector<std::pair<sipixelobjects::DetectorIndex,double> > pixelvec;
1444  std::map<uint32_t,int> myfedmap;
1445  std::map<uint32_t,std::string> mynamemap;
1446  int realfedID = -1;
1447  //int Nnoisies = noisyDetIds_.size();
1448  //cout<<"Number of noisy modules: "<<Nnoisies<<endl;
1449  int counter = 0;
1450  int n_noisyrocs_all = 0;
1451  int n_noisyrocs_barrel = 0;
1452  int n_noisyrocs_endcap = 0;
1453  int n_verynoisyrocs_all = 0;
1454  int n_verynoisyrocs_barrel = 0;
1455  int n_verynoisyrocs_endcap = 0;
1456 
1457  for(int fid = 0; fid < 40; fid++){
1458  for(std::map<uint32_t, std::vector< std::pair<std::pair<int, int>, float> > >::const_iterator it = noisyDetIds_.begin();
1459  it != noisyDetIds_.end(); it++){
1460  uint32_t detid = (*it).first;
1461  std::vector< std::pair<std::pair<int, int>, float> > noisyPixels = (*it).second;
1462  //cout<<noisyPixels.size()<<" noisy pixels in a module: "<<detid<<endl;
1463  // now convert into online conventions:
1464  for(int fedid=0; fedid<=40; ++fedid){
1465  SiPixelFrameConverter converter(theCablingMap.product(),fedid);
1466  uint32_t newDetId = detid;
1467  if(converter.hasDetUnit(newDetId)){
1468  realfedID=fedid;
1469  break;
1470  }
1471  }
1472  if(fid == realfedID){
1473  //cout<<"FED ID is = "<<realfedID<<endl;
1474  if(realfedID==-1) continue;
1475  DetId detId(detid);
1476  uint32_t detSubId = detId.subdetId();
1477  std::string outputname;
1478  bool HalfModule = false;
1479  if (detSubId == 2){ //FPIX
1480  PixelEndcapName nameworker(detid);
1481  outputname = nameworker.name();
1482  } else if(detSubId == 1){ //BPIX
1483  PixelBarrelName nameworker(detid);
1484  outputname = nameworker.name();
1485  HalfModule = nameworker.isHalfModule();
1486 
1487  } else{
1488  continue;
1489  }
1490  std::map<int,int> myrocmap;
1491  myfedmap[detid]=realfedID;
1492  mynamemap[detid]=outputname;
1493 
1494  for(std::vector< std::pair< std::pair<int,int>, float> >::const_iterator pxl = noisyPixels.begin();
1495  pxl != noisyPixels.end(); pxl++){
1496  std::pair<int,int> offlineaddress = (*pxl).first;
1497  float Noise_frac = (*pxl).second;
1498  int offlineColumn = offlineaddress.first;
1499  int offlineRow = offlineaddress.second;
1500  counter++;
1501  //cout<<"noisy pixel counter: "<<counter<<endl;
1502 
1504  SiPixelFrameConverter formatter(theCablingMap.product(),realfedID);
1505  sipixelobjects::DetectorIndex detector = {detid, offlineRow, offlineColumn};
1506  formatter.toCabling(cabling,detector);
1507  // cabling should now contain cabling.roc and cabling.dcol and cabling.pxid
1508  // however, the coordinates now need to be converted from dcl,pxid to the row,col coordinates used in the calibration info
1510  loc.dcol = cabling.dcol;
1511  loc.pxid = cabling.pxid;
1512 
1513 
1514  // OLD version, not 31X compatible:
1515 // const sipixelobjects::PixelFEDCabling *theFed= theCablingMap.product()->fed(realfedID);
1516 // const sipixelobjects::PixelFEDLink * link = theFed->link(cabling.link);
1517 // const sipixelobjects::PixelROC *theRoc = link->roc(cabling.roc);
1518 // sipixelobjects::LocalPixel locpixel(loc);
1519 
1520 
1521  // FIX to adhere to new cabling map. To be replaced with CalibTracker/SiPixelTools detid - > hardware id classes ASAP.
1522  // const sipixelobjects::PixelFEDCabling *theFed= theCablingMap.product()->fed(realfedID);
1523  // const sipixelobjects::PixelFEDLink * link = theFed->link(cabling.link);
1524  // const sipixelobjects::PixelROC *theRoc = link->roc(cabling.roc);
1525  sipixelobjects::LocalPixel locpixel(loc);
1526  assert(realfedID >= 0);
1527  assert(cabling.link >= 0);
1528  assert(cabling.roc >= 0);
1529  sipixelobjects::CablingPathToDetUnit path = {static_cast<unsigned int>(realfedID),
1530  static_cast<unsigned int>(cabling.link),
1531  static_cast<unsigned int>(cabling.roc)};
1532  const sipixelobjects::PixelROC *theRoc = theCablingMap->findItem(path);
1533  // END of FIX
1534 
1535  int onlineColumn = locpixel.rocCol();
1536  int onlineRow= locpixel.rocRow();
1537  myrocmap[(theRoc->idInDetUnit())]++;
1538 
1539  // ROC numbers in the barrel go from 8 to 15 instead of 0 to 7 in half modules. This is a
1540  // fix to get the roc number, and add 8 to it if:
1541  // it's a Barrel module AND on the minus side AND a Half module
1542 
1543  int rocnumber = -1;
1544 
1545  if((detSubId == 1) && (outputname.find("mO")!=string::npos || outputname.find("mI")!=string::npos) && (HalfModule)){
1546  rocnumber = theRoc->idInDetUnit() + 8;
1547  }
1548  else{
1549  rocnumber = theRoc->idInDetUnit();
1550  }
1551 
1552  //cout<<counter<<" : \t detid= "<<detid<<" , OFF col,row= "<<offlineColumn<<","<<offlineRow<<" , ON roc,col,row= "<<theRoc->idInDetUnit()<<","<<onlineColumn<<","<<onlineRow<<endl;
1553  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;
1554  }
1555  for(std::map<int, int>::const_iterator nrc = myrocmap.begin(); nrc != myrocmap.end(); nrc++){
1556  if((*nrc).second > 0){
1557  n_noisyrocs_all++;
1558  if(detSubId == 2){
1559  n_noisyrocs_endcap++;
1560  } else if(detSubId == 1){
1561  n_noisyrocs_barrel++;}
1562  }
1563  if((*nrc).second > 40){
1564  n_verynoisyrocs_all++;
1565  if(detSubId == 2){
1566  n_verynoisyrocs_endcap++;
1567  } else if(detSubId == 1){
1568  n_verynoisyrocs_barrel++;}
1569  }
1570  }
1571  }
1572 
1573  }
1574  }
1575  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;
1576  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;
1577 
1578  }
1579  myfile_.close();
1580 //cout<<"...leaving SiPixelInformationExtractor::findNoisyPixels!"<<endl;
1581  return;
1582 }
1583 
1584 
1585 //
1586 // -- Create Images
1587 //
1589  histoPlotter_->createPlots(bei);
1590 }
1591 
1592 //
1593 // -- Set HTML Header in xgi output
1594 //
1596  out->getHTTPResponseHeader().addHeader("Content-Type", "text/html");
1597  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
1598  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
1599  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
1600 }
1601 //
1602 // -- Set XML Header in xgi output
1603 //
1605  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
1606  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
1607  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
1608  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
1609  *out << "<?xml version=\"1.0\" ?>" << std::endl;
1610 
1611 }
1612 //
1613 // -- Set Plain Header in xgi output
1614 //
1616  out->getHTTPResponseHeader().addHeader("Content-Type", "text/plain");
1617  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
1618  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
1619  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
1620 
1621 }
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:2703
char * address
Definition: mlp_lapack.h:14
static const int OTHER
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1419
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
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:406
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)
int getNbinsY(void) const
get # of bins in Y-axis
void Fill(long long x)
list path
Definition: scaleCards.py:51
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:46
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:1468
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:1497
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)
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:1442
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:440
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:121
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:429
static const int ERROR
const std::string & pwd(void) const
Definition: DQMStore.cc:401