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