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  if ( logicalMap_ ) delete logicalMap_;
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 
71 {
72 
73  if (debug_>2) std::cout <<"\t<HcalBaseDQClient::htmlOutput> Preparing html for task: "<<name_<<std::endl;
74  int pcol_error[105];
75  for( int i=0; i<105; ++i )
76  {
77 
78  TColor* color = gROOT->GetColor( 901+i );
79  if( ! color ) color = new TColor( 901+i, 0, 0, 0, "" );
80  if (i<5)
81  color->SetRGB(i/5.,1.,0);
82  else if (i>100)
83  color->SetRGB(0,0,0);
84  else
85  color->SetRGB(1,1-0.01*i,0);
86  pcol_error[i]=901+i;
87  } // for (int i=0;i<105;++i)
88 
89  std::ofstream htmlFile;
90  std::string outfile=htmlDir+name_+".html";
91  htmlFile.open(outfile.c_str());
92 
93  // html page header
94  htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
95  htmlFile << "<html> " << std::endl;
96  htmlFile << "<head> " << std::endl;
97  htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
98  htmlFile << " http-equiv=\"content-type\"> " << std::endl;
99  htmlFile << " <title>Monitor: Hcal "<<name_<<" output</title> " << std::endl;
100  htmlFile << "</head> " << std::endl;
101  htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
102  htmlFile << "<body> " << std::endl;
103  htmlFile << "<br> " << std::endl;
104  htmlFile << "<hr>" << std::endl;
105 
106  gStyle->SetPalette(105,pcol_error);
107  gStyle->SetNumberContours(105);
108  gROOT->ForceStyle();
109 
110  if (debug_>0) std::cout <<"<HcalBaseDQClient::htmlOutput> Writing html output for client "<<this->name()<<std::endl;
111  if (ProblemCells!=0)
112  {
113  (ProblemCells->getTH2F())->SetMaximum(1.05);
114  (ProblemCells->getTH2F())->SetMinimum(0.);
115  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
116  htmlFile << "cellpadding=\"10\"> " << std::endl;
117  htmlFile<<"<tr align=\"center\">"<<std::endl;
118  htmlAnyHisto(-1,ProblemCells->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
119  htmlFile<<"</tr>"<<std::endl;
120  htmlFile<<"</table>"<<std::endl;
121  }
122  if (ProblemCellsByDepth!=0)
123  {
124  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
125  htmlFile << "cellpadding=\"10\"> " << std::endl;
126  for (unsigned int i=0;i<ProblemCellsByDepth->depth.size()/2;++i)
127  {
128  if (ProblemCellsByDepth->depth[2*i]==0) continue;
129  if (ProblemCellsByDepth->depth[2*i+1]==0) continue;
130  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMaximum(1.05);
131  (ProblemCellsByDepth->depth[2*i]->getTH2F())->SetMinimum(0.);
132  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMaximum(1.05);
133  (ProblemCellsByDepth->depth[2*i+1]->getTH2F())->SetMinimum(0.);
134  htmlFile<<"<tr align=\"center\">"<<std::endl;
135  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
136  htmlAnyHisto(-1,ProblemCellsByDepth->depth[2*i+1]->getTH2F(),"ieta","iphi",92, htmlFile,htmlDir,debug_);
137 
138  htmlFile<<"</tr>"<<std::endl;
139  }
140  htmlFile<<"</table>"<<std::endl;
141  }
142 
143  htmlFile << "<table align=\"center\" border=\"1\" cellspacing=\"0\" " << std::endl;
144  htmlFile << "cellpadding=\"10\"> " << std::endl;
145 
146 
147  std::vector<MonitorElement*> hists = ig.getAllContents(subdir_);
148  gStyle->SetPalette(1);
149 
150  int counter=0;
151  for (unsigned int i=0;i<hists.size();++i)
152  {
153  if (hists[i]->kind()==MonitorElement::DQM_KIND_TH1F)
154  {
155  ++counter;
156  if (counter%2==1)
157  htmlFile << "<tr align=\"center\">" << std::endl;
158  htmlAnyHisto(-1,(hists[i]->getTH1F()),"","", 92, htmlFile, htmlDir,debug_);
159  if (counter%2==2)
160  htmlFile <<"</tr>"<<std::endl;
161  }
162 
163  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TH2F)
164  {
165  std::string histname=hists[i]->getName();
166  bool isproblem=false;
167  for (unsigned int j=0;j<problemnames_.size();++j)
168  {
169  if (problemnames_[j]==histname)
170  {
171  isproblem=true;
172  if (debug_>1) std::cout <<"<HcalBaseDQClient::htmlOutput> Found Problem Histogram '"<<histname<<"' in list of histograms"<<std::endl;
173  break;
174  }
175  }
176  if (isproblem) continue; // don't redraw problem histograms
177  ++counter;
178  if (counter%2==1)
179  htmlFile << "<tr align=\"center\">" << std::endl;
180  htmlAnyHisto(-1,(hists[i]->getTH2F()),"","", 92, htmlFile, htmlDir,debug_);
181  if (counter%2==2)
182  htmlFile <<"</tr>"<<std::endl;
183  }
184 
185  else if (hists[i]->kind()==MonitorElement::DQM_KIND_TPROFILE)
186  {
187  ++counter;
188  if (counter%2==1)
189  htmlFile << "<tr align=\"center\">" << std::endl;
190  htmlAnyHisto(-1,(hists[i]->getTProfile()),"","", 92, htmlFile, htmlDir,debug_);
191  if (counter%2==2)
192  htmlFile <<"</tr>"<<std::endl;
193  }
194  }
195  htmlFile<<"</table>"<<std::endl;
196  htmlFile << "</body> " << std::endl;
197  htmlFile << "</html> " << std::endl;
198  htmlFile.close();
199 
200  return;
201 }
203  if (needLogicalMap_ && logicalMap_==0) {
205  c.get<HcalRecNumberingRecord>().get(pT);
207  logicalMap_=new HcalLogicalMap(gen.createMap(&(*pT)));
208  }
209 }
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)
int ib
Definition: cuy.py:660
void htmlAnyHisto(int runNo, myHist *hist, const char *xlab, const char *ylab, int width, std::ofstream &htmlFile, std::string htmlDir, int debug=0)
virtual void htmlOutput(DQMStore::IBooker &, DQMStore::IGetter &, std::string htmlDir)
virtual bool validHtmlOutput(DQMStore::IBooker &, DQMStore::IGetter &)
def gen
run2 Cosmic #### Run 256259 @ 0T 2015C### Run 272133 @ 3.8T 2016B###
std::vector< MonitorElement * > depth
std::vector< std::string > problemnames_
EtaPhiHists * ProblemCellsByDepth
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:56
virtual void setStatusMap(std::map< HcalDetId, unsigned int > &map)
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0)
Definition: DQMStore.cc:298
std::string subdir_
std::map< HcalDetId, unsigned int > badstatusmap
virtual ~HcalBaseDQClient(void)
std::string prefixME_
HcalLogicalMap * logicalMap_
static std::atomic< unsigned int > counter
TH2F * getTH2F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
tuple cout
Definition: gather_cfg.py:145
TH2F * getTH2F(void) const
void getLogicalMap(const edm::EventSetup &es)