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>
11 
12 
14 {
15  name_=s;
16  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
17  debug_ = ps.getUntrackedParameter<int>("debug",0);
18  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
19  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
20  prefixME_.append("/");
21 
22  validHtmlOutput_ = ps.getUntrackedParameter<bool>("validHtmlOutput",true);
23  Online_ = ps.getUntrackedParameter<bool>("online",false);
24 
25  subdir_="HcalInfo/";
26  subdir_=prefixME_+subdir_;
27 
28  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
30  enoughevents_=true;
31  minerrorrate_=0;
32  minevents_=0;
33 
34  ProblemCells=0;
36 
37  logicalMap_=0;
38  needLogicalMap_=false;
39 }
40 
42 {}
43 
45 {
47  if (debug_>0)
48  {
49  std::cout <<"<HcalBaseDQClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
51  }
52 }
53 
54 void HcalBaseDQClient::setStatusMap(std::map<HcalDetId, unsigned int>& map)
55  {
56  /* Get the list of all bad channels in the status map,
57  and combine it with the bad cell requirements for the particular task
58  to form a new map
59  */
60 
61  if (debug_>1) std::cout <<"<HcalBaseDQClient::setStatusMap> Input map size = "<<map.size()<<std::endl;
62  for (std::map<HcalDetId, unsigned int>::const_iterator iter = map.begin();
63  iter!=map.end();++iter)
64  {
65  if ((iter->second & badChannelStatusMask_) == 0 ) continue; // channel not marked as bad by this test
66  badstatusmap[iter->first]=iter->second;
67  }
68 
69  if (debug_>1) std::cout <<"<HcalBaseDQClient::setStatusMap> "<<name_<<" Output map size = "<<badstatusmap.size()<<std::endl;
70  } // void HcalBaseDQClient::getStatusMap
71 
72 
74 {
75  return validHtmlOutput_;
76 }
77 
79 {
80  if (dqmStore_==0)
81  {
82  if (debug_>0) std::cout <<"<HcalBaseDQClient::htmlOutput> dqmStore object does not exist!"<<std::endl;
83  return;
84  }
85 
86  if (debug_>2) std::cout <<"\t<HcalBaseDQClient::htmlOutput> Preparing html for task: "<<name_<<std::endl;
87  int pcol_error[105];
88  for( int i=0; i<105; ++i )
89  {
90 
91  TColor* color = gROOT->GetColor( 901+i );
92  if( ! color ) color = new TColor( 901+i, 0, 0, 0, "" );
93  if (i<5)
94  color->SetRGB(i/5.,1.,0);
95  else if (i>100)
96  color->SetRGB(0,0,0);
97  else
98  color->SetRGB(1,1-0.01*i,0);
99  pcol_error[i]=901+i;
100  } // for (int i=0;i<105;++i)
101 
102  ofstream htmlFile;
103  std::string outfile=htmlDir+name_+".html";
104  htmlFile.open(outfile.c_str());
105 
106  // html page header
107  htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
108  htmlFile << "<html> " << std::endl;
109  htmlFile << "<head> " << std::endl;
110  htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
111  htmlFile << " http-equiv=\"content-type\"> " << std::endl;
112  htmlFile << " <title>Monitor: Hcal "<<name_<<" output</title> " << std::endl;
113  htmlFile << "</head> " << std::endl;
114  htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
115  htmlFile << "<body> " << std::endl;
116  htmlFile << "<br> " << std::endl;
117  htmlFile << "<hr>" << std::endl;
118 
119  gStyle->SetPalette(105,pcol_error);
120  gStyle->SetNumberContours(105);
121  gROOT->ForceStyle();
122 
123  if (debug_>0) std::cout <<"<HcalBaseDQClient::htmlOutput> Writing html output for client "<<this->name()<<std::endl;
124  if (ProblemCells!=0)
125  {
126  (ProblemCells->getTH2F())->SetMaximum(1.05);
127  (ProblemCells->getTH2F())->SetMinimum(0.);
128  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
129  htmlFile << "cellpadding=\"10\"> " << std::endl;
130  htmlFile<<"<tr align=\"center\">"<<std::endl;
131  htmlAnyHisto(-1,ProblemCells->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
132  htmlFile<<"</tr>"<<std::endl;
133  htmlFile<<"</table>"<<std::endl;
134  }
135  if (ProblemCellsByDepth!=0)
136  {
137  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
138  htmlFile << "cellpadding=\"10\"> " << std::endl;
139  for (unsigned int i=0;i<ProblemCellsByDepth->depth.size()/2;++i)
140  {
141  if (ProblemCellsByDepth->depth[2*i]==0) continue;
142  if (ProblemCellsByDepth->depth[2*i+1]==0) continue;
143  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMaximum(1.05);
144  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMinimum(0.);
145  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMaximum(1.05);
146  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMinimum(0.);
147  htmlFile<<"<tr align=\"center\">"<<std::endl;
148  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
149  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i+1]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
150 
151  htmlFile<<"</tr>"<<std::endl;
152  }
153  htmlFile<<"</table>"<<std::endl;
154  }
155 
156  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
157  htmlFile << "cellpadding=\"10\"> " << std::endl;
158 
159 
160  std::vector<MonitorElement*> hists = dqmStore_->getAllContents(subdir_);
161  gStyle->SetPalette(1);
162 
163  int counter=0;
164  for (unsigned int i=0;i<hists.size();++i)
165  {
166  if (hists[i]->kind()==MonitorElement::DQM_KIND_TH1F)
167  {
168  ++counter;
169  if (counter%2==1)
170  htmlFile << "<tr align=\"center\">" << std::endl;
171  htmlAnyHisto(-1,(hists[i]->getTH1F()),"","", 92, htmlFile, htmlDir,debug_);
172  if (counter%2==2)
173  htmlFile <<"</tr>"<<std::endl;
174  }
175 
176  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TH2F)
177  {
178  std::string histname=hists[i]->getName();
179  bool isproblem=false;
180  for (unsigned int j=0;j<problemnames_.size();++j)
181  {
182  if (problemnames_[j]==histname)
183  {
184  isproblem=true;
185  if (debug_>1) std::cout <<"<HcalBaseDQClient::htmlOutput> Found Problem Histogram '"<<histname<<"' in list of histograms"<<std::endl;
186  break;
187  }
188  }
189  if (isproblem) continue; // don't redraw problem histograms
190  ++counter;
191  if (counter%2==1)
192  htmlFile << "<tr align=\"center\">" << std::endl;
193  htmlAnyHisto(-1,(hists[i]->getTH2F()),"","", 92, htmlFile, htmlDir,debug_);
194  if (counter%2==2)
195  htmlFile <<"</tr>"<<std::endl;
196  }
197 
198  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TPROFILE)
199  {
200  ++counter;
201  if (counter%2==1)
202  htmlFile << "<tr align=\"center\">" << std::endl;
203  htmlAnyHisto(-1,(hists[i]->getTProfile()),"","", 92, htmlFile, htmlDir,debug_);
204  if (counter%2==2)
205  htmlFile <<"</tr>"<<std::endl;
206  }
207  }
208  htmlFile<<"</table>"<<std::endl;
209  htmlFile << "</body> " << std::endl;
210  htmlFile << "</html> " << std::endl;
211  htmlFile.close();
212  return;
213 }
215  if (needLogicalMap_ && logicalMap_==0) {
217  c.get<IdealGeometryRecord>().get(pT);
219  logicalMap_=new HcalLogicalMap(gen.createMap(&(*pT)));
220  }
221 }
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:1677
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)
HcalLogicalMap createMap(const HcalTopology *topo, unsigned int mapIOV=4)
const T & get() const
Definition: EventSetup.h:55
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_
HcalLogicalMap * logicalMap_
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:2766
TH2F * getTH2F(void) const
DQMStore * dqmStore_
void getLogicalMap(const edm::EventSetup &es)