CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalBaseDQClient.cc
Go to the documentation of this file.
5 #include <iostream>
6 #include <fstream>
7 
9 {
10  name_=s;
11  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
12  debug_ = ps.getUntrackedParameter<int>("debug",0);
13  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
14  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
15  prefixME_.append("/");
16 
17  validHtmlOutput_ = ps.getUntrackedParameter<bool>("validHtmlOutput",true);
18  Online_ = ps.getUntrackedParameter<bool>("online",false);
19 
20  subdir_="HcalInfo/";
21  subdir_=prefixME_+subdir_;
22 
23  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
25  enoughevents_=true;
26  minerrorrate_=0;
27  minevents_=0;
28 
29  ProblemCells=0;
31 }
32 
34 {
36  if (debug_>0)
37  {
38  std::cout <<"<HcalBaseDQClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
40  }
41 }
42 
43 void HcalBaseDQClient::setStatusMap(std::map<HcalDetId, unsigned int>& map)
44  {
45  /* Get the list of all bad channels in the status map,
46  and combine it with the bad cell requirements for the particular task
47  to form a new map
48  */
49 
50  if (debug_>1) std::cout <<"<HcalBaseDQClient::setStatusMap> Input map size = "<<map.size()<<std::endl;
51  for (std::map<HcalDetId, unsigned int>::const_iterator iter = map.begin();
52  iter!=map.end();++iter)
53  {
54  if ((iter->second & badChannelStatusMask_) == 0 ) continue; // channel not marked as bad by this test
55  badstatusmap[iter->first]=iter->second;
56  }
57 
58  if (debug_>1) std::cout <<"<HcalBaseDQClient::setStatusMap> "<<name_<<" Output map size = "<<badstatusmap.size()<<std::endl;
59  } // void HcalBaseDQClient::getStatusMap
60 
61 
63 {
64  return validHtmlOutput_;
65 }
66 
67 void HcalBaseDQClient::htmlOutput(std::string htmlDir)
68 {
69  if (dqmStore_==0)
70  {
71  if (debug_>0) std::cout <<"<HcalBaseDQClient::htmlOutput> dqmStore object does not exist!"<<std::endl;
72  return;
73  }
74 
75  if (debug_>2) std::cout <<"\t<HcalBaseDQClient::htmlOutput> Preparing html for task: "<<name_<<std::endl;
76  int pcol_error[105];
77  for( int i=0; i<105; ++i )
78  {
79 
80  TColor* color = gROOT->GetColor( 901+i );
81  if( ! color ) color = new TColor( 901+i, 0, 0, 0, "" );
82  if (i<5)
83  color->SetRGB(i/5.,1.,0);
84  else if (i>100)
85  color->SetRGB(0,0,0);
86  else
87  color->SetRGB(1,1-0.01*i,0);
88  pcol_error[i]=901+i;
89  } // for (int i=0;i<105;++i)
90 
91  ofstream htmlFile;
92  std::string outfile=htmlDir+name_+".html";
93  htmlFile.open(outfile.c_str());
94 
95  // html page header
96  htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
97  htmlFile << "<html> " << std::endl;
98  htmlFile << "<head> " << std::endl;
99  htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
100  htmlFile << " http-equiv=\"content-type\"> " << std::endl;
101  htmlFile << " <title>Monitor: Hcal "<<name_<<" output</title> " << std::endl;
102  htmlFile << "</head> " << std::endl;
103  htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
104  htmlFile << "<body> " << std::endl;
105  htmlFile << "<br> " << std::endl;
106  htmlFile << "<hr>" << std::endl;
107 
108  gStyle->SetPalette(105,pcol_error);
109  gStyle->SetNumberContours(105);
110  gROOT->ForceStyle();
111 
112  if (debug_>0) std::cout <<"<HcalBaseDQClient::htmlOutput> Writing html output for client "<<this->name()<<std::endl;
113  if (ProblemCells!=0)
114  {
115  (ProblemCells->getTH2F())->SetMaximum(1.05);
116  (ProblemCells->getTH2F())->SetMinimum(0.);
117  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
118  htmlFile << "cellpadding=\"10\"> " << std::endl;
119  htmlFile<<"<tr align=\"center\">"<<std::endl;
120  htmlAnyHisto(-1,ProblemCells->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
121  htmlFile<<"</tr>"<<std::endl;
122  htmlFile<<"</table>"<<std::endl;
123  }
124  if (ProblemCellsByDepth!=0)
125  {
126  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
127  htmlFile << "cellpadding=\"10\"> " << std::endl;
128  for (unsigned int i=0;i<ProblemCellsByDepth->depth.size()/2;++i)
129  {
130  if (ProblemCellsByDepth->depth[2*i]==0) continue;
131  if (ProblemCellsByDepth->depth[2*i+1]==0) continue;
132  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMaximum(1.05);
133  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMinimum(0.);
134  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMaximum(1.05);
135  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMinimum(0.);
136  htmlFile<<"<tr align=\"center\">"<<std::endl;
137  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
138  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i+1]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
139 
140  htmlFile<<"</tr>"<<std::endl;
141  }
142  htmlFile<<"</table>"<<std::endl;
143  }
144 
145  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
146  htmlFile << "cellpadding=\"10\"> " << std::endl;
147 
148 
149  std::vector<MonitorElement*> hists = dqmStore_->getAllContents(subdir_);
150  gStyle->SetPalette(1);
151 
152  int counter=0;
153  for (unsigned int i=0;i<hists.size();++i)
154  {
155  if (hists[i]->kind()==MonitorElement::DQM_KIND_TH1F)
156  {
157  ++counter;
158  if (counter%2==1)
159  htmlFile << "<tr align=\"center\">" << std::endl;
160  htmlAnyHisto(-1,(hists[i]->getTH1F()),"","", 92, htmlFile, htmlDir,debug_);
161  if (counter%2==2)
162  htmlFile <<"</tr>"<<std::endl;
163  }
164 
165  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TH2F)
166  {
167  std::string histname=hists[i]->getName();
168  bool isproblem=false;
169  for (unsigned int j=0;j<problemnames_.size();++j)
170  {
171  if (problemnames_[j]==histname)
172  {
173  isproblem=true;
174  if (debug_>1) std::cout <<"<HcalBaseDQClient::htmlOutput> Found Problem Histogram '"<<histname<<"' in list of histograms"<<std::endl;
175  break;
176  }
177  }
178  if (isproblem) continue; // don't redraw problem histograms
179  ++counter;
180  if (counter%2==1)
181  htmlFile << "<tr align=\"center\">" << std::endl;
182  htmlAnyHisto(-1,(hists[i]->getTH2F()),"","", 92, htmlFile, htmlDir,debug_);
183  if (counter%2==2)
184  htmlFile <<"</tr>"<<std::endl;
185  }
186 
187  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TPROFILE)
188  {
189  ++counter;
190  if (counter%2==1)
191  htmlFile << "<tr align=\"center\">" << std::endl;
192  htmlAnyHisto(-1,(hists[i]->getTProfile()),"","", 92, htmlFile, htmlDir,debug_);
193  if (counter%2==2)
194  htmlFile <<"</tr>"<<std::endl;
195  }
196  }
197  htmlFile<<"</table>"<<std::endl;
198  htmlFile << "</body> " << std::endl;
199  htmlFile << "</html> " << std::endl;
200  htmlFile.close();
201  return;
202 }
virtual void beginJob(void)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * ProblemCells
std::string name()
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
void htmlAnyHisto(int runNo, myHist *hist, const char *xlab, const char *ylab, int width, ofstream &htmlFile, std::string htmlDir, int debug=0)
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1469
list outfile
Definition: EdgesToViz.py:91
std::vector< MonitorElement * > depth
std::vector< std::string > problemnames_
EtaPhiHists * ProblemCellsByDepth
virtual bool validHtmlOutput()
int j
Definition: DBlmapReader.cc:9
TH1F * getTH1F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
virtual void setStatusMap(std::map< HcalDetId, unsigned int > &map)
virtual void htmlOutput(std::string htmlDir)
std::string subdir_
std::map< HcalDetId, unsigned int > badstatusmap
std::string prefixME_
TH2F * getTH2F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
tuple cout
Definition: gather_cfg.py:41
string s
Definition: asciidump.py:422
void showDirStructure(void) const
Definition: DQMStore.cc:2554
TH2F * getTH2F(void) const
DQMStore * dqmStore_