00001 #include "DQM/HcalMonitorClient/interface/HcalDetDiagNoiseMonitorClient.h"
00002 #include "DQM/HcalMonitorClient/interface/HcalClientUtils.h"
00003 #include "DQM/HcalMonitorClient/interface/HcalHistoUtils.h"
00004
00005 #include "CondFormats/HcalObjects/interface/HcalChannelStatus.h"
00006 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00007 #include "CondFormats/HcalObjects/interface/HcalCondObjectContainer.h"
00008
00009 #include <iostream>
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 HcalDetDiagNoiseMonitorClient::HcalDetDiagNoiseMonitorClient(std::string myname)
00021 {
00022 name_=myname;
00023 }
00024
00025 HcalDetDiagNoiseMonitorClient::HcalDetDiagNoiseMonitorClient(std::string myname, const edm::ParameterSet& ps)
00026 {
00027 name_=myname;
00028 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
00029 debug_ = ps.getUntrackedParameter<int>("debug",0);
00030 prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00031 if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00032 prefixME_.append("/");
00033 subdir_ = ps.getUntrackedParameter<std::string>("DetDiagNoiseMonitorFolder","DetDiagNoiseMonitor_Hcal/");
00034 if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00035 subdir_.append("/");
00036 subdir_=prefixME_+subdir_;
00037
00038 validHtmlOutput_ = ps.getUntrackedParameter<bool>("DetDiagNoiseMonitor_validHtmlOutput",true);
00039 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00040 badChannelStatusMask_ = ps.getUntrackedParameter<int>("DetDiagNoiseMonitor_BadChannelStatusMask",
00041 ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
00042
00043 minerrorrate_ = ps.getUntrackedParameter<double>("DetDiagNoiseMonitor_minerrorrate",
00044 ps.getUntrackedParameter<double>("minerrorrate",0.05));
00045 minevents_ = ps.getUntrackedParameter<int>("DetDiagNoiseMonitor_minevents",
00046 ps.getUntrackedParameter<int>("minevents",1));
00047 ProblemCells=0;
00048 ProblemCellsByDepth=0;
00049 }
00050
00051 void HcalDetDiagNoiseMonitorClient::analyze()
00052 {
00053 if (debug_>2) std::cout <<"\tHcalDetDiagNoiseMonitorClient::analyze()"<<std::endl;
00054 calculateProblems();
00055 }
00056
00057 void HcalDetDiagNoiseMonitorClient::calculateProblems()
00058 {
00059 if (debug_>2) std::cout <<"\t\tHcalDetDiagNoiseMonitorClient::calculateProblems()"<<std::endl;
00060 if(!dqmStore_) return;
00061 double totalevents=0;
00062 int etabins=0, phibins=0, zside=0;
00063 double problemvalue=0;
00064
00065
00066 if (ProblemCells!=0)
00067 {
00068 ProblemCells->Reset();
00069 (ProblemCells->getTH2F())->SetMaximum(1.05);
00070 (ProblemCells->getTH2F())->SetMinimum(0.);
00071 }
00072 for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
00073 {
00074 if (ProblemCellsByDepth->depth[d]!=0)
00075 {
00076 ProblemCellsByDepth->depth[d]->Reset();
00077 (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
00078 (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
00079 }
00080 }
00081 enoughevents_=true;
00082
00083
00084
00085 std::vector<std::string> name = HcalEtaPhiHistNames();
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
00109 {
00110 if (ProblemCellsByDepth->depth[d]==0) continue;
00111
00112
00113 totalevents=0;
00114
00115
00116
00117
00118
00119
00120
00121 totalevents=1;
00122
00123 etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
00124 phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
00125 for (int eta=0;eta<etabins;++eta)
00126 {
00127 int ieta=CalcIeta(eta,d+1);
00128 if (ieta==-9999) continue;
00129 for (int phi=0;phi<phibins;++phi)
00130 {
00131 problemvalue=0;
00132
00133
00134
00135
00136 if (problemvalue==0) continue;
00137
00138 problemvalue = std::min(1.,problemvalue);
00139
00140 zside=0;
00141 if (isHF(eta,d+1))
00142 ieta<0 ? zside = -1 : zside = 1;
00143
00144
00145
00146 if (problemvalue>minerrorrate_)
00147 {
00148 HcalSubdetector subdet=HcalEmpty;
00149 if (isHB(eta,d+1))subdet=HcalBarrel;
00150 else if (isHE(eta,d+1)) subdet=HcalEndcap;
00151 else if (isHF(eta,d+1)) subdet=HcalForward;
00152 else if (isHO(eta,d+1)) subdet=HcalOuter;
00153 HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
00154 if (badstatusmap.find(hcalid)!=badstatusmap.end())
00155 problemvalue=999;
00156 }
00157
00158 ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
00159 if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
00160 }
00161 }
00162 }
00163
00164 if (ProblemCells==0)
00165 {
00166 if (debug_>0) std::cout <<"<HcalDetDiagNoiseMonitorClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
00167 return;
00168 }
00169
00170
00171 etabins=(ProblemCells->getTH2F())->GetNbinsX();
00172 phibins=(ProblemCells->getTH2F())->GetNbinsY();
00173 for (int eta=0;eta<etabins;++eta)
00174 {
00175 for (int phi=0;phi<phibins;++phi)
00176 {
00177 if (ProblemCells->getBinContent(eta+1,phi+1)>1. && ProblemCells->getBinContent(eta+1,phi+1)<999)
00178 ProblemCells->setBinContent(eta+1,phi+1,1.);
00179 }
00180 }
00181
00182 FillUnphysicalHEHFBins(*ProblemCellsByDepth);
00183 FillUnphysicalHEHFBins(ProblemCells);
00184 return;
00185 }
00186
00187 void HcalDetDiagNoiseMonitorClient::beginJob()
00188 {
00189 dqmStore_ = edm::Service<DQMStore>().operator->();
00190 if (debug_>0)
00191 {
00192 std::cout <<"<HcalDetDiagNoiseMonitorClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
00193 dqmStore_->showDirStructure();
00194 }
00195 }
00196 void HcalDetDiagNoiseMonitorClient::endJob(){}
00197
00198 void HcalDetDiagNoiseMonitorClient::beginRun(void)
00199 {
00200 enoughevents_=false;
00201 if (!dqmStore_)
00202 {
00203 if (debug_>0) std::cout <<"<HcalDetDiagNoiseMonitorClient::beginRun> dqmStore does not exist!"<<std::endl;
00204 return;
00205 }
00206 dqmStore_->setCurrentFolder(subdir_);
00207 problemnames_.clear();
00208
00209
00210 ProblemCells=dqmStore_->book2D(" ProblemDetDiagNoiseMonitor",
00211 " Problem DetDiagNoiseMonitor Rate for all HCAL;ieta;iphi",
00212 85,-42.5,42.5,
00213 72,0.5,72.5);
00214 problemnames_.push_back(ProblemCells->getName());
00215 if (debug_>1)
00216 std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
00217 dqmStore_->setCurrentFolder(subdir_+"problem_DetDiagNoiseMonitor");
00218 ProblemCellsByDepth = new EtaPhiHists();
00219 ProblemCellsByDepth->setup(dqmStore_," Problem DetDiagNoiseMonitor Rate");
00220 for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
00221 problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
00222 nevts_=0;
00223 }
00224
00225 void HcalDetDiagNoiseMonitorClient::endRun(void){analyze();}
00226
00227 void HcalDetDiagNoiseMonitorClient::setup(void){}
00228 void HcalDetDiagNoiseMonitorClient::cleanup(void){}
00229
00230 bool HcalDetDiagNoiseMonitorClient::hasErrors_Temp(void)
00231 {
00232 if (!ProblemCells)
00233 {
00234 if (debug_>1) std::cout <<"<HcalDetDiagNoiseMonitorClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
00235 return false;
00236 }
00237 int problemcount=0;
00238 int ieta=-9999;
00239
00240 for (int depth=0;depth<4; ++depth)
00241 {
00242 int etabins = (ProblemCells->getTH2F())->GetNbinsX();
00243 int phibins = (ProblemCells->getTH2F())->GetNbinsY();
00244 for (int hist_eta=0;hist_eta<etabins;++hist_eta)
00245 {
00246 for (int hist_phi=0; hist_phi<phibins;++hist_phi)
00247 {
00248 ieta=CalcIeta(hist_eta,depth+1);
00249 if (ieta==-9999) continue;
00250 if (ProblemCellsByDepth->depth[depth]==0)
00251 continue;
00252 if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
00253 ++problemcount;
00254
00255 }
00256 }
00257 }
00258
00259 if (problemcount>0) return true;
00260 return false;
00261 }
00262
00263 bool HcalDetDiagNoiseMonitorClient::hasWarnings_Temp(void){return false;}
00264 bool HcalDetDiagNoiseMonitorClient::hasOther_Temp(void){return false;}
00265 bool HcalDetDiagNoiseMonitorClient::test_enabled(void){return true;}
00266
00267
00268 void HcalDetDiagNoiseMonitorClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
00269 {
00270
00271
00272
00273
00274 }
00275
00276