CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalBaseDQMonitor.cc
Go to the documentation of this file.
6 
7 #include <iostream>
8 #include <vector>
9 
10 /*
11  * \file HcalBaseDQMonitor.cc
12  *
13  * \author J Temple
14  *
15  * Base class for all Hcal DQM analyzers
16  *
17 
18 */
19 
20 // constructor
21 
23 {
24  Online_ = ps.getUntrackedParameter<bool>("online",false);
25  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
26  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
27  debug_ = ps.getUntrackedParameter<int>("debug",0);
28  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
29  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
30  prefixME_.append("/");
31  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","Test/");
32  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
33  subdir_.append("/");
34  subdir_=prefixME_+subdir_;
35  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
36  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
37  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
38  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
39 
40  setupDone_ = false;
41  logicalMap_= 0;
42  needLogicalMap_=false;
43  meIevt_=0;
44  meLevt_=0;
45  meTevtHist_=0;
46  ProblemsVsLB=0;
53 } //HcalBaseDQMonitor::HcalBaseDQMonitor(const ParameterSet& ps)
54 
55 
56 // destructor
57 
59 {
60  if (logicalMap_) delete logicalMap_;
61 }
62 
64 {
65 
66  if (debug_>0) std::cout <<"HcalBaseDQMonitor::beginJob(): task = '"<<subdir_<<"'"<<std::endl;
68 
69  ievt_=0;
70  levt_=0;
71  tevt_=0;
72  currenttype_=-1;
73  HBpresent_=false;
74  HEpresent_=false;
75  HOpresent_=false;
76  HFpresent_=false;
77 
78 
79 } // beginJob()
80 
82 {
83  if (enableCleanup_)
84  cleanup();
85 } // endJob()
86 
88 {
89  if (debug_>0) std::cout <<"HcalBaseDQMonitor::beginRun(): task = '"<<subdir_<<"'"<<std::endl;
90  if (! mergeRuns_)
91  {
92  this->setup();
93  this->reset();
94  }
95  else if (tevt_ == 0)
96  {
97  this->setup();
98  this->reset();
99  }
100 } // beginRun(const edm::Run& run, const edm::EventSetup& c)
101 
103 {
104  if (debug_>0) std::cout <<"HcalBaseDQMonitor::endRun: task = "<<subdir_<<std::endl;
105 } //endRun(...)
106 
108 {
109  if (debug_>0) std::cout <<"HcalBaseDQMonitor::reset(): task = "<<subdir_<<std::endl;
110  if (meIevt_) meIevt_->Fill(-1);
111  ievt_=0;
112  if (meLevt_) meLevt_->Fill(-1);
113  levt_=0;
114  if (meTevt_) meTevt_->Fill(-1);
115  tevt_=0;
116  if (meTevtHist_) meTevtHist_->Reset();
118  HBpresent_=false;
119  HEpresent_=false;
120  HOpresent_=false;
121  HFpresent_=false;
122  currentLS=0;
123  currenttype_=-1;
124 } //reset()
125 
127 {
128 
129 } //cleanup()
130 
132 {
133  if (setupDone_)
134  return;
135  setupDone_ = true;
136  if (debug_>3) std::cout <<"<HcalBaseDQMonitor> setup in progress"<<std::endl;
138  meIevt_ = dbe_->bookInt("EventsProcessed");
139  if (meIevt_) meIevt_->Fill(-1);
140  meLevt_ = dbe_->bookInt("EventsProcessed_currentLS");
141  if (meLevt_) meLevt_->Fill(-1);
142  meTevt_ = dbe_->bookInt("EventsProcessed_Total");
143  if (meTevt_) meTevt_->Fill(-1);
144  meTevtHist_=dbe_->book1D("Events_Processed_Task_Histogram","Counter of Events Processed By This Task",1,0.5,1.5);
145  if (meTevtHist_) meTevtHist_->Reset();
146  dbe_->setCurrentFolder(subdir_+"LSvalues");
147  ProblemsCurrentLB=dbe_->book2D("ProblemsThisLS","Problem Channels in current Lumi Section",
148  7,0,7,1,0,1);
149  if (ProblemsCurrentLB)
150  {
151  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
152  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
153  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
154  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
155  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
156  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
157  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(7,"HFlumi");
158  (ProblemsCurrentLB->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
160  }
161 } // setup()
162 
163 
165  const edm::EventSetup& c)
166 {
167  if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
168  currentLS=lumiSeg.luminosityBlock();
169  levt_=0;
170  if (meLevt_!=0) meLevt_->Fill(-1);
171  if (ProblemsCurrentLB)
173 }
174 
176  const edm::EventSetup& c)
177 {
178  if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
179  // Inherited classes do end-of-lumi functions here
180 }
181 
182 
184 {
185  if (skipOutOfOrderLS_==false) return true; // don't skip out-of-order lumi sections
186  // check that latest lumi section is >= last processed
187  if (Online_ && lumisec<currentLS)
188  return false;
189  return true;
190 }
191 
193 {
194  if (debug_>9) std::cout <<"<HcalBaseDQMonitor::IsAllowedCalibType>"<<std::endl;
195  if (AllowedCalibTypes_.size()==0)
196  {
197  if (debug_>9) std::cout <<"\tNo calib types specified by user; All events allowed"<<std::endl;
198  return true;
199  }
200  MonitorElement* me = dbe_->get((prefixME_+"HcalInfo/CURRENT_EVENT_TYPE").c_str());
201  if (me) currenttype_=me->getIntValue();
202  else
203  {
204  if (debug_>9) std::cout <<"\tCalib Type cannot be determined from HcalMonitorModule"<<std::endl;
205  return true; // is current type can't be determined, assume event is allowed
206  }
207  if (debug_>9) std::cout <<"\tHcalBaseDQMonitor::IsAllowedCalibType checking if calibration type = "<<currenttype_<<" is allowed...";
209  {
210  if (AllowedCalibTypes_[i]==currenttype_)
211  {
212  if (debug_>9) std::cout <<"\t Type allowed!"<<std::endl;
213  return true;
214  }
215  }
216  if (debug_>9) std::cout <<"\t Type not allowed!"<<std::endl;
217  return false;
218 } // bool HcalBaseDQMonitor::IsAllowedCalibType()
219 
221  if (needLogicalMap_ && logicalMap_==0) {
223  c.get<IdealGeometryRecord>().get(pT);
225  logicalMap_=new HcalLogicalMap(gen.createMap(&(*pT)));
226  }
227 }
228 
230 {
231  getLogicalMap(c);
232 
233  if (debug_>5) std::cout <<"\t<HcalBaseDQMonitor::analyze> event = "<<ievt_<<std::endl;
234  eventAllowed_=true; // assume event is allowed
235 
236  // fill with total events seen (this differs from ievent, which is total # of good events)
237  ++tevt_;
238  if (meTevt_) meTevt_->Fill(tevt_);
239  if (meTevtHist_) meTevtHist_->Fill(1);
240  // skip out of order lumi events
241  if (this->LumiInOrder(e.luminosityBlock())==false)
242  {
243  eventAllowed_=false;
244  return;
245  }
246  // skip events of wrong calibration type
248  if (!eventAllowed_) return;
249 
250  // Event is good; count it
251  ++ievt_;
252  ++levt_;
253  if (meIevt_) meIevt_->Fill(ievt_);
254  if (meLevt_) meLevt_->Fill(levt_);
255 
256 
257  MonitorElement* me;
258  if (HBpresent_==false)
259  {
260  me = dbe_->get((prefixME_+"HcalInfo/HBpresent"));
261  if (me==0 || me->getIntValue()>0) HBpresent_=true;
262  }
263  if (HEpresent_==false)
264  {
265  me = dbe_->get((prefixME_+"HcalInfo/HEpresent"));
266  if (me==0 || me->getIntValue()>0) HEpresent_=true;
267  }
268  if (HOpresent_==false)
269  {
270  me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
271  if (me==0 || me->getIntValue()>0) HOpresent_=true;
272  }
273  if (HFpresent_==false)
274  {
275  me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
276  if (me ==0 || me->getIntValue()>0) HFpresent_=true;
277  }
278 
279 
280 } // void HcalBaseDQMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
281 
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool LumiInOrder(int lumisec)
MonitorElement * ProblemsCurrentLB
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:942
MonitorElement * ProblemsVsLB_HF
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< int > AllowedCalibTypes_
virtual void cleanup(void)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
virtual void endJob(void)
void getLogicalMap(const edm::EventSetup &c)
MonitorElement * meTevt_
uint16_t size_type
void Fill(long long x)
LuminosityBlockNumber_t luminosityBlock() const
virtual void beginJob()
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
MonitorElement * meTevtHist_
MonitorElement * ProblemsVsLB_HBHEHF
virtual ~HcalBaseDQMonitor()
MonitorElement * ProblemsVsLB_HB
HcalLogicalMap * logicalMap_
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * meIevt_
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1696
HcalLogicalMap createMap(const HcalTopology *topo, unsigned int mapIOV=4)
int64_t getIntValue(void) const
const T & get() const
Definition: EventSetup.h:55
virtual void reset(void)
MonitorElement * ProblemsVsLB_HE
virtual void endRun(const edm::Run &run, const edm::EventSetup &c)
tuple cout
Definition: gather_cfg.py:121
MonitorElement * ProblemsVsLB_HO
MonitorElement * ProblemsVsLB
TH2F * getTH2F(void) const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:849
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1070
virtual void setup(void)
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * meLevt_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41