00001 #include "DQM/HcalMonitorClient/interface/HcalNZSClient.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 HcalNZSClient::HcalNZSClient(std::string myname)
00021 {
00022 name_=myname;
00023 }
00024
00025 HcalNZSClient::HcalNZSClient(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>("NZSFolder","NZSMonitor_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>("NZS_validHtmlOutput",true);
00039 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00040 badChannelStatusMask_ = ps.getUntrackedParameter<int>("NZS_BadChannelStatusMask",
00041 ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
00042
00043 minerrorrate_ = ps.getUntrackedParameter<double>("NZS_minerrorrate",
00044 ps.getUntrackedParameter<double>("minerrorrate",0.01));
00045 minevents_ = ps.getUntrackedParameter<int>("NZS_minevents",
00046 ps.getUntrackedParameter<int>("minevents",1));
00047 ProblemCells=0;
00048 ProblemCellsByDepth=0;
00049 }
00050
00051 void HcalNZSClient::analyze()
00052 {
00053 if (debug_>2) std::cout <<"\tHcalNZSClient::analyze()"<<std::endl;
00054 calculateProblems();
00055 }
00056
00057 void HcalNZSClient::calculateProblems()
00058 {
00059 if (debug_>2) std::cout <<"\t\tHcalNZSClient::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 for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
00104 {
00105 if (ProblemCellsByDepth->depth[d]==0) continue;
00106
00107
00108 totalevents=0;
00109 if (totalevents==0 || totalevents<minevents_) continue;
00110 etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
00111 phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
00112 problemvalue=0;
00113 for (int eta=0;eta<etabins;++eta)
00114 {
00115 int ieta=CalcIeta(eta,d+1);
00116 if (ieta==-9999) continue;
00117 for (int phi=0;phi<phibins;++phi)
00118 {
00119 problemvalue=0;
00120
00121 if (problemvalue==0) continue;
00122 problemvalue/=totalevents;
00123 problemvalue = std::min(1.,problemvalue);
00124
00125 zside=0;
00126 if (isHF(eta,d+1))
00127 ieta<0 ? zside = -1 : zside = 1;
00128
00129
00130
00131 if (problemvalue>minerrorrate_)
00132 {
00133 HcalSubdetector subdet=HcalEmpty;
00134 if (isHB(eta,d+1))subdet=HcalBarrel;
00135 else if (isHE(eta,d+1)) subdet=HcalEndcap;
00136 else if (isHF(eta,d+1)) subdet=HcalForward;
00137 else if (isHO(eta,d+1)) subdet=HcalOuter;
00138 HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
00139 if (badstatusmap.find(hcalid)!=badstatusmap.end())
00140 problemvalue=999;
00141 }
00142
00143 ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
00144 if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
00145 }
00146 }
00147 }
00148
00149 if (ProblemCells==0)
00150 {
00151 if (debug_>0) std::cout <<"<HcalNZSClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
00152 return;
00153 }
00154
00155
00156 etabins=(ProblemCells->getTH2F())->GetNbinsX();
00157 phibins=(ProblemCells->getTH2F())->GetNbinsY();
00158 for (int eta=0;eta<etabins;++eta)
00159 {
00160 for (int phi=0;phi<phibins;++phi)
00161 {
00162 if (ProblemCells->getBinContent(eta+1,phi+1)>1. && ProblemCells->getBinContent(eta+1,phi+1)<999)
00163 ProblemCells->setBinContent(eta+1,phi+1,1.);
00164 }
00165 }
00166
00167 FillUnphysicalHEHFBins(*ProblemCellsByDepth);
00168 FillUnphysicalHEHFBins(ProblemCells);
00169 return;
00170 }
00171
00172 void HcalNZSClient::beginJob()
00173 {
00174 dqmStore_ = edm::Service<DQMStore>().operator->();
00175 if (debug_>0)
00176 {
00177 std::cout <<"<HcalNZSClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
00178 dqmStore_->showDirStructure();
00179 }
00180 }
00181 void HcalNZSClient::endJob(){}
00182
00183 void HcalNZSClient::beginRun(void)
00184 {
00185 enoughevents_=false;
00186 if (!dqmStore_)
00187 {
00188 if (debug_>0) std::cout <<"<HcalNZSClient::beginRun> dqmStore does not exist!"<<std::endl;
00189 return;
00190 }
00191 dqmStore_->setCurrentFolder(subdir_);
00192 problemnames_.clear();
00193
00194
00195 ProblemCells=dqmStore_->book2D(" ProblemNZS",
00196 " Problem NZS Rate for all HCAL;ieta;iphi",
00197 85,-42.5,42.5,
00198 72,0.5,72.5);
00199 problemnames_.push_back(ProblemCells->getName());
00200 if (debug_>1)
00201 std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
00202 dqmStore_->setCurrentFolder(subdir_+"problem_NZS");
00203 ProblemCellsByDepth = new EtaPhiHists();
00204 ProblemCellsByDepth->setup(dqmStore_," Problem NZS Rate");
00205 for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
00206 problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
00207 nevts_=0;
00208 }
00209
00210 void HcalNZSClient::endRun(void){analyze();}
00211
00212 void HcalNZSClient::setup(void){}
00213 void HcalNZSClient::cleanup(void){}
00214
00215 bool HcalNZSClient::hasErrors_Temp(void)
00216 {
00217 if (!ProblemCells)
00218 {
00219 if (debug_>1) std::cout <<"<HcalNZSClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
00220 return false;
00221 }
00222 int problemcount=0;
00223 int ieta=-9999;
00224
00225 for (int depth=0;depth<4; ++depth)
00226 {
00227 int etabins = (ProblemCells->getTH2F())->GetNbinsX();
00228 int phibins = (ProblemCells->getTH2F())->GetNbinsY();
00229 for (int hist_eta=0;hist_eta<etabins;++hist_eta)
00230 {
00231 for (int hist_phi=0; hist_phi<phibins;++hist_phi)
00232 {
00233 ieta=CalcIeta(hist_eta,depth+1);
00234 if (ieta==-9999) continue;
00235 if (ProblemCellsByDepth->depth[depth]==0)
00236 continue;
00237 if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
00238 ++problemcount;
00239
00240 }
00241 }
00242 }
00243
00244 if (problemcount>0) return true;
00245 return false;
00246 }
00247
00248 bool HcalNZSClient::hasWarnings_Temp(void){return false;}
00249 bool HcalNZSClient::hasOther_Temp(void){return false;}
00250 bool HcalNZSClient::test_enabled(void){return true;}
00251
00252
00253 void HcalNZSClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
00254 {
00255
00256
00257
00258
00259 }
00260
00261 HcalNZSClient::~HcalNZSClient()
00262 {}