Go to the documentation of this file.00001 #include <DQM/HcalMonitorTasks/interface/HcalBaseDQMonitor.h>
00002 #include "FWCore/Framework/interface/LuminosityBlock.h"
00003 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
00004 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00005 #include "CalibCalorimetry/HcalAlgos/interface/HcalLogicalMapGenerator.h"
00006
00007 #include <iostream>
00008 #include <vector>
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 HcalBaseDQMonitor::HcalBaseDQMonitor(const edm::ParameterSet& ps)
00025 {
00026 Online_ = ps.getUntrackedParameter<bool>("online",false);
00027 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
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>("TaskFolder","Test/");
00034 if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00035 subdir_.append("/");
00036 subdir_=prefixME_+subdir_;
00037 AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00038 skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
00039 NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00040 makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00041
00042 setupDone_ = false;
00043 logicalMap_= 0;
00044 needLogicalMap_=false;
00045 meIevt_=0;
00046 meLevt_=0;
00047 meTevtHist_=0;
00048 ProblemsVsLB=0;
00049 ProblemsVsLB_HB=0;
00050 ProblemsVsLB_HE=0;
00051 ProblemsVsLB_HF=0;
00052 ProblemsVsLB_HBHEHF=0;
00053 ProblemsVsLB_HO=0;
00054 ProblemsCurrentLB=0;
00055 }
00056
00057
00058
00059
00060 HcalBaseDQMonitor::~HcalBaseDQMonitor()
00061 {
00062 if (logicalMap_) delete logicalMap_;
00063 }
00064
00065 void HcalBaseDQMonitor::beginJob(void)
00066 {
00067
00068 if (debug_>0) std::cout <<"HcalBaseDQMonitor::beginJob(): task = '"<<subdir_<<"'"<<std::endl;
00069 dbe_ = edm::Service<DQMStore>().operator->();
00070
00071 ievt_=0;
00072 levt_=0;
00073 tevt_=0;
00074 currenttype_=-1;
00075 HBpresent_=false;
00076 HEpresent_=false;
00077 HOpresent_=false;
00078 HFpresent_=false;
00079
00080
00081 }
00082
00083 void HcalBaseDQMonitor::endJob(void)
00084 {
00085 if (enableCleanup_)
00086 cleanup();
00087 }
00088
00089 void HcalBaseDQMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
00090 {
00091 if (debug_>0) std::cout <<"HcalBaseDQMonitor::beginRun(): task = '"<<subdir_<<"'"<<std::endl;
00092 if (! mergeRuns_)
00093 {
00094 this->setup();
00095 this->reset();
00096 }
00097 else if (tevt_ == 0)
00098 {
00099 this->setup();
00100 this->reset();
00101 }
00102 }
00103
00104 void HcalBaseDQMonitor::endRun(const edm::Run& run, const edm::EventSetup& c)
00105 {
00106 if (debug_>0) std::cout <<"HcalBaseDQMonitor::endRun: task = "<<subdir_<<std::endl;
00107 }
00108
00109 void HcalBaseDQMonitor::reset(void)
00110 {
00111 if (debug_>0) std::cout <<"HcalBaseDQMonitor::reset(): task = "<<subdir_<<std::endl;
00112 if (meIevt_) meIevt_->Fill(-1);
00113 ievt_=0;
00114 if (meLevt_) meLevt_->Fill(-1);
00115 levt_=0;
00116 if (meTevt_) meTevt_->Fill(-1);
00117 tevt_=0;
00118 if (meTevtHist_) meTevtHist_->Reset();
00119 if (ProblemsCurrentLB) ProblemsCurrentLB->Reset();
00120 HBpresent_=false;
00121 HEpresent_=false;
00122 HOpresent_=false;
00123 HFpresent_=false;
00124 currentLS=0;
00125 currenttype_=-1;
00126 }
00127
00128 void HcalBaseDQMonitor::cleanup(void)
00129 {
00130
00131 }
00132
00133 void HcalBaseDQMonitor::setup(void)
00134 {
00135 if (setupDone_)
00136 return;
00137 setupDone_ = true;
00138 if (debug_>3) std::cout <<"<HcalBaseDQMonitor> setup in progress"<<std::endl;
00139 dbe_->setCurrentFolder(subdir_);
00140 meIevt_ = dbe_->bookInt("EventsProcessed");
00141 if (meIevt_) meIevt_->Fill(-1);
00142 meLevt_ = dbe_->bookInt("EventsProcessed_currentLS");
00143 if (meLevt_) meLevt_->Fill(-1);
00144 meTevt_ = dbe_->bookInt("EventsProcessed_Total");
00145 if (meTevt_) meTevt_->Fill(-1);
00146 meTevtHist_=dbe_->book1D("Events_Processed_Task_Histogram","Counter of Events Processed By This Task",1,0.5,1.5);
00147 if (meTevtHist_) meTevtHist_->Reset();
00148 dbe_->setCurrentFolder(subdir_+"LSvalues");
00149 ProblemsCurrentLB=dbe_->book2D("ProblemsThisLS","Problem Channels in current Lumi Section",
00150 7,0,7,1,0,1);
00151 if (ProblemsCurrentLB)
00152 {
00153 (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
00154 (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
00155 (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
00156 (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
00157 (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
00158 (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
00159 (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(7,"HFlumi");
00160 (ProblemsCurrentLB->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
00161 ProblemsCurrentLB->Reset();
00162 }
00163 }
00164
00165
00166 void HcalBaseDQMonitor::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00167 const edm::EventSetup& c)
00168 {
00169 if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
00170 currentLS=lumiSeg.luminosityBlock();
00171 levt_=0;
00172 if (meLevt_!=0) meLevt_->Fill(-1);
00173 if (ProblemsCurrentLB)
00174 ProblemsCurrentLB->Reset();
00175 }
00176
00177 void HcalBaseDQMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00178 const edm::EventSetup& c)
00179 {
00180 if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
00181
00182 }
00183
00184
00185 bool HcalBaseDQMonitor::LumiInOrder(int lumisec)
00186 {
00187 if (skipOutOfOrderLS_==false) return true;
00188
00189 if (Online_ && lumisec<currentLS)
00190 return false;
00191 return true;
00192 }
00193
00194 bool HcalBaseDQMonitor::IsAllowedCalibType()
00195 {
00196 if (debug_>9) std::cout <<"<HcalBaseDQMonitor::IsAllowedCalibType>"<<std::endl;
00197 if (AllowedCalibTypes_.size()==0)
00198 {
00199 if (debug_>9) std::cout <<"\tNo calib types specified by user; All events allowed"<<std::endl;
00200 return true;
00201 }
00202 MonitorElement* me = dbe_->get((prefixME_+"HcalInfo/CURRENT_EVENT_TYPE").c_str());
00203 if (me) currenttype_=me->getIntValue();
00204 else
00205 {
00206 if (debug_>9) std::cout <<"\tCalib Type cannot be determined from HcalMonitorModule"<<std::endl;
00207 return true;
00208 }
00209 if (debug_>9) std::cout <<"\tHcalBaseDQMonitor::IsAllowedCalibType checking if calibration type = "<<currenttype_<<" is allowed...";
00210 for (std::vector<int>::size_type i=0;i<AllowedCalibTypes_.size();++i)
00211 {
00212 if (AllowedCalibTypes_[i]==currenttype_)
00213 {
00214 if (debug_>9) std::cout <<"\t Type allowed!"<<std::endl;
00215 return true;
00216 }
00217 }
00218 if (debug_>9) std::cout <<"\t Type not allowed!"<<std::endl;
00219 return false;
00220 }
00221
00222 void HcalBaseDQMonitor::getLogicalMap(const edm::EventSetup& c) {
00223 if (needLogicalMap_ && logicalMap_==0) {
00224 edm::ESHandle<HcalTopology> pT;
00225 c.get<IdealGeometryRecord>().get(pT);
00226 HcalLogicalMapGenerator gen;
00227 logicalMap_=new HcalLogicalMap(gen.createMap(&(*pT)));
00228 }
00229 }
00230
00231 void HcalBaseDQMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
00232 {
00233 getLogicalMap(c);
00234
00235 if (debug_>5) std::cout <<"\t<HcalBaseDQMonitor::analyze> event = "<<ievt_<<std::endl;
00236 eventAllowed_=true;
00237
00238
00239 ++tevt_;
00240 if (meTevt_) meTevt_->Fill(tevt_);
00241 if (meTevtHist_) meTevtHist_->Fill(1);
00242
00243 if (this->LumiInOrder(e.luminosityBlock())==false)
00244 {
00245 eventAllowed_=false;
00246 return;
00247 }
00248
00249 eventAllowed_&=(this->IsAllowedCalibType());
00250 if (!eventAllowed_) return;
00251
00252
00253 ++ievt_;
00254 ++levt_;
00255 if (meIevt_) meIevt_->Fill(ievt_);
00256 if (meLevt_) meLevt_->Fill(levt_);
00257
00258
00259 MonitorElement* me;
00260 if (HBpresent_==false)
00261 {
00262 me = dbe_->get((prefixME_+"HcalInfo/HBpresent"));
00263 if (me==0 || me->getIntValue()>0) HBpresent_=true;
00264 }
00265 if (HEpresent_==false)
00266 {
00267 me = dbe_->get((prefixME_+"HcalInfo/HEpresent"));
00268 if (me==0 || me->getIntValue()>0) HEpresent_=true;
00269 }
00270 if (HOpresent_==false)
00271 {
00272 me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
00273 if (me==0 || me->getIntValue()>0) HOpresent_=true;
00274 }
00275 if (HFpresent_==false)
00276 {
00277 me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
00278 if (me ==0 || me->getIntValue()>0) HFpresent_=true;
00279 }
00280
00281
00282 }
00283
00284 DEFINE_FWK_MODULE(HcalBaseDQMonitor);