CMS 3D CMS Logo

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