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 {}
35 
37 {
39  if (debug_>0)
40  {
41  std::cout <<"<HcalBaseDQClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
43  }
44 }
45 
46 void HcalBaseDQClient::setStatusMap(std::map<HcalDetId, unsigned int>& map)
47  {
48  /* Get the list of all bad channels in the status map,
49  and combine it with the bad cell requirements for the particular task
50  to form a new map
51  */
52 
53  if (debug_>1) std::cout <<"<HcalBaseDQClient::setStatusMap> Input map size = "<<map.size()<<std::endl;
54  for (std::map<HcalDetId, unsigned int>::const_iterator iter = map.begin();
55  iter!=map.end();++iter)
56  {
57  if ((iter->second & badChannelStatusMask_) == 0 ) continue; // channel not marked as bad by this test
58  badstatusmap[iter->first]=iter->second;
59  }
60 
61  if (debug_>1) std::cout <<"<HcalBaseDQClient::setStatusMap> "<<name_<<" Output map size = "<<badstatusmap.size()<<std::endl;
62  } // void HcalBaseDQClient::getStatusMap
63 
64 
66 {
67  return validHtmlOutput_;
68 }
69 
70 void HcalBaseDQClient::htmlOutput(std::string htmlDir)
71 {
72  if (dqmStore_==0)
73  {
74  if (debug_>0) std::cout <<"<HcalBaseDQClient::htmlOutput> dqmStore object does not exist!"<<std::endl;
75  return;
76  }
77 
78  if (debug_>2) std::cout <<"\t<HcalBaseDQClient::htmlOutput> Preparing html for task: "<<name_<<std::endl;
79  int pcol_error[105];
80  for( int i=0; i<105; ++i )
81  {
82 
83  TColor* color = gROOT->GetColor( 901+i );
84  if( ! color ) color = new TColor( 901+i, 0, 0, 0, "" );
85  if (i<5)
86  color->SetRGB(i/5.,1.,0);
87  else if (i>100)
88  color->SetRGB(0,0,0);
89  else
90  color->SetRGB(1,1-0.01*i,0);
91  pcol_error[i]=901+i;
92  } // for (int i=0;i<105;++i)
93 
94  ofstream htmlFile;
95  std::string outfile=htmlDir+name_+".html";
96  htmlFile.open(outfile.c_str());
97 
98  // html page header
99  htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
100  htmlFile << "<html> " << std::endl;
101  htmlFile << "<head> " << std::endl;
102  htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
103  htmlFile << " http-equiv=\"content-type\"> " << std::endl;
104  htmlFile << " <title>Monitor: Hcal "<<name_<<" output</title> " << std::endl;
105  htmlFile << "</head> " << std::endl;
106  htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
107  htmlFile << "<body> " << std::endl;
108  htmlFile << "<br> " << std::endl;
109  htmlFile << "<hr>" << std::endl;
110 
111  gStyle->SetPalette(105,pcol_error);
112  gStyle->SetNumberContours(105);
113  gROOT->ForceStyle();
114 
115  if (debug_>0) std::cout <<"<HcalBaseDQClient::htmlOutput> Writing html output for client "<<this->name()<<std::endl;
116  if (ProblemCells!=0)
117  {
118  (ProblemCells->getTH2F())->SetMaximum(1.05);
119  (ProblemCells->getTH2F())->SetMinimum(0.);
120  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
121  htmlFile << "cellpadding=\"10\"> " << std::endl;
122  htmlFile<<"<tr align=\"center\">"<<std::endl;
123  htmlAnyHisto(-1,ProblemCells->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
124  htmlFile<<"</tr>"<<std::endl;
125  htmlFile<<"</table>"<<std::endl;
126  }
127  if (ProblemCellsByDepth!=0)
128  {
129  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
130  htmlFile << "cellpadding=\"10\"> " << std::endl;
131  for (unsigned int i=0;i<ProblemCellsByDepth->depth.size()/2;++i)
132  {
133  if (ProblemCellsByDepth->depth[2*i]==0) continue;
134  if (ProblemCellsByDepth->depth[2*i+1]==0) continue;
135  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMaximum(1.05);
136  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMinimum(0.);
137  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMaximum(1.05);
138  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMinimum(0.);
139  htmlFile<<"<tr align=\"center\">"<<std::endl;
140  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
141  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i+1]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
142 
143  htmlFile<<"</tr>"<<std::endl;
144  }
145  htmlFile<<"</table>"<<std::endl;
146  }
147 
148  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
149  htmlFile << "cellpadding=\"10\"> " << std::endl;
150 
151 
152  std::vector<MonitorElement*> hists = dqmStore_->getAllContents(subdir_);
153  gStyle->SetPalette(1);
154 
155  int counter=0;
156  for (unsigned int i=0;i<hists.size();++i)
157  {
158  if (hists[i]->kind()==MonitorElement::DQM_KIND_TH1F)
159  {
160  ++counter;
161  if (counter%2==1)
162  htmlFile << "<tr align=\"center\">" << std::endl;
163  htmlAnyHisto(-1,(hists[i]->getTH1F()),"","", 92, htmlFile, htmlDir,debug_);
164  if (counter%2==2)
165  htmlFile <<"</tr>"<<std::endl;
166  }
167 
168  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TH2F)
169  {
170  std::string histname=hists[i]->getName();
171  bool isproblem=false;
172  for (unsigned int j=0;j<problemnames_.size();++j)
173  {
174  if (problemnames_[j]==histname)
175  {
176  isproblem=true;
177  if (debug_>1) std::cout <<"<HcalBaseDQClient::htmlOutput> Found Problem Histogram '"<<histname<<"' in list of histograms"<<std::endl;
178  break;
179  }
180  }
181  if (isproblem) continue; // don't redraw problem histograms
182  ++counter;
183  if (counter%2==1)
184  htmlFile << "<tr align=\"center\">" << std::endl;
185  htmlAnyHisto(-1,(hists[i]->getTH2F()),"","", 92, htmlFile, htmlDir,debug_);
186  if (counter%2==2)
187  htmlFile <<"</tr>"<<std::endl;
188  }
189 
190  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TPROFILE)
191  {
192  ++counter;
193  if (counter%2==1)
194  htmlFile << "<tr align=\"center\">" << std::endl;
195  htmlAnyHisto(-1,(hists[i]->getTProfile()),"","", 92, htmlFile, htmlDir,debug_);
196  if (counter%2==2)
197  htmlFile <<"</tr>"<<std::endl;
198  }
199  }
200  htmlFile<<"</table>"<<std::endl;
201  htmlFile << "</body> " << std::endl;
202  htmlFile << "</html> " << std::endl;
203  htmlFile.close();
204  return;
205 }
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)
dictionary map
Definition: Association.py:205
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1672
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
virtual ~HcalBaseDQClient(void)
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:121
void showDirStructure(void) const
Definition: DQMStore.cc:2761
TH2F * getTH2F(void) const
DQMStore * dqmStore_