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.
3 
4 #include <iostream>
5 #include <vector>
6 
7 /*
8  * \file HcalBaseDQMonitor.cc
9  *
10  * $Date: 2012/06/21 13:40:22 $
11  * $Revision: 1.7 $
12  * \author J Temple
13  *
14  * Base class for all Hcal DQM analyzers
15  *
16 
17 */
18 
19 // constructor
20 
22 {
23  Online_ = ps.getUntrackedParameter<bool>("online",false);
24  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
25  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
26  debug_ = ps.getUntrackedParameter<int>("debug",0);
27  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
28  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
29  prefixME_.append("/");
30  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","Test/");
31  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
32  subdir_.append("/");
33  subdir_=prefixME_+subdir_;
34  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
35  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
36  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
37  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
38 
39  meIevt_=0;
40  meLevt_=0;
41  meTevtHist_=0;
42  ProblemsVsLB=0;
49 } //HcalBaseDQMonitor::HcalBaseDQMonitor(const ParameterSet& ps)
50 
51 
52 // destructor
53 
55 {
56 
57 }
58 
60 {
61 
62  if (debug_>0) std::cout <<"HcalBaseDQMonitor::beginJob(): task = '"<<subdir_<<"'"<<std::endl;
64 
65  ievt_=0;
66  levt_=0;
67  tevt_=0;
68  currenttype_=-1;
69  HBpresent_=false;
70  HEpresent_=false;
71  HOpresent_=false;
72  HFpresent_=false;
73 
74 
75 } // beginJob()
76 
78 {
79  if (enableCleanup_)
80  cleanup();
81 } // endJob()
82 
84 {
85  if (debug_>0) std::cout <<"HcalBaseDQMonitor::beginRun(): task = '"<<subdir_<<"'"<<std::endl;
86  if (! mergeRuns_)
87  {
88  this->setup();
89  this->reset();
90  }
91  else if (tevt_ == 0)
92  {
93  this->setup();
94  this->reset();
95  }
96 } // beginRun(const edm::Run& run, const edm::EventSetup& c)
97 
99 {
100  if (debug_>0) std::cout <<"HcalBaseDQMonitor::endRun: task = "<<subdir_<<std::endl;
101 } //endRun(...)
102 
104 {
105  if (debug_>0) std::cout <<"HcalBaseDQMonitor::reset(): task = "<<subdir_<<std::endl;
106  if (meIevt_) meIevt_->Fill(-1);
107  ievt_=0;
108  if (meLevt_) meLevt_->Fill(-1);
109  levt_=0;
110  if (meTevt_) meTevt_->Fill(-1);
111  tevt_=0;
112  if (meTevtHist_) meTevtHist_->Reset();
114  HBpresent_=false;
115  HEpresent_=false;
116  HOpresent_=false;
117  HFpresent_=false;
118  currentLS=0;
119  currenttype_=-1;
120 } //reset()
121 
123 {
124 
125 } //cleanup()
126 
128 {
129  if (debug_>3) std::cout <<"<HcalBaseDQMonitor> setup in progress"<<std::endl;
131  meIevt_ = dbe_->bookInt("EventsProcessed");
132  if (meIevt_) meIevt_->Fill(-1);
133  meLevt_ = dbe_->bookInt("EventsProcessed_currentLS");
134  if (meLevt_) meLevt_->Fill(-1);
135  meTevt_ = dbe_->bookInt("EventsProcessed_Total");
136  if (meTevt_) meTevt_->Fill(-1);
137  meTevtHist_=dbe_->book1D("Events_Processed_Task_Histogram","Counter of Events Processed By This Task",1,0.5,1.5);
138  if (meTevtHist_) meTevtHist_->Reset();
139  dbe_->setCurrentFolder(subdir_+"LSvalues");
140  ProblemsCurrentLB=dbe_->book2D("ProblemsThisLS","Problem Channels in current Lumi Section",
141  7,0,7,1,0,1);
142  if (ProblemsCurrentLB)
143  {
144  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
145  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
146  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
147  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
148  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
149  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
150  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(7,"HFlumi");
151  (ProblemsCurrentLB->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
153  }
154 } // setup()
155 
156 
158  const edm::EventSetup& c)
159 {
160  if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
161  currentLS=lumiSeg.luminosityBlock();
162  levt_=0;
163  if (meLevt_!=0) meLevt_->Fill(-1);
164  if (ProblemsCurrentLB)
166 }
167 
169  const edm::EventSetup& c)
170 {
171  if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
172  // Inherited classes do end-of-lumi functions here
173 }
174 
175 
177 {
178  if (skipOutOfOrderLS_==false) return true; // don't skip out-of-order lumi sections
179  // check that latest lumi section is >= last processed
180  if (Online_ && lumisec<currentLS)
181  return false;
182  return true;
183 }
184 
186 {
187  if (debug_>9) std::cout <<"<HcalBaseDQMonitor::IsAllowedCalibType>"<<std::endl;
188  if (AllowedCalibTypes_.size()==0)
189  {
190  if (debug_>9) std::cout <<"\tNo calib types specified by user; All events allowed"<<std::endl;
191  return true;
192  }
193  MonitorElement* me = dbe_->get((prefixME_+"HcalInfo/CURRENT_EVENT_TYPE").c_str());
194  if (me) currenttype_=me->getIntValue();
195  else
196  {
197  if (debug_>9) std::cout <<"\tCalib Type cannot be determined from HcalMonitorModule"<<std::endl;
198  return true; // is current type can't be determined, assume event is allowed
199  }
200  if (debug_>9) std::cout <<"\tHcalBaseDQMonitor::IsAllowedCalibType checking if calibration type = "<<currenttype_<<" is allowed...";
202  {
203  if (AllowedCalibTypes_[i]==currenttype_)
204  {
205  if (debug_>9) std::cout <<"\t Type allowed!"<<std::endl;
206  return true;
207  }
208  }
209  if (debug_>9) std::cout <<"\t Type not allowed!"<<std::endl;
210  return false;
211 } // bool HcalBaseDQMonitor::IsAllowedCalibType()
212 
214 {
215  if (debug_>5) std::cout <<"\t<HcalBaseDQMonitor::analyze> event = "<<ievt_<<std::endl;
216  eventAllowed_=true; // assume event is allowed
217 
218  // fill with total events seen (this differs from ievent, which is total # of good events)
219  ++tevt_;
220  if (meTevt_) meTevt_->Fill(tevt_);
221  if (meTevtHist_) meTevtHist_->Fill(1);
222  // skip out of order lumi events
223  if (this->LumiInOrder(e.luminosityBlock())==false)
224  {
225  eventAllowed_=false;
226  return;
227  }
228  // skip events of wrong calibration type
230  if (!eventAllowed_) return;
231 
232  // Event is good; count it
233  ++ievt_;
234  ++levt_;
235  if (meIevt_) meIevt_->Fill(ievt_);
236  if (meLevt_) meLevt_->Fill(levt_);
237 
238 
239  MonitorElement* me;
240  if (HBpresent_==false)
241  {
242  me = dbe_->get((prefixME_+"HcalInfo/HBpresent"));
243  if (me==0 || me->getIntValue()>0) HBpresent_=true;
244  }
245  if (HEpresent_==false)
246  {
247  me = dbe_->get((prefixME_+"HcalInfo/HEpresent"));
248  if (me==0 || me->getIntValue()>0) HEpresent_=true;
249  }
250  if (HOpresent_==false)
251  {
252  me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
253  if (me==0 || me->getIntValue()>0) HOpresent_=true;
254  }
255  if (HFpresent_==false)
256  {
257  me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
258  if (me ==0 || me->getIntValue()>0) HFpresent_=true;
259  }
260 
261 
262 } // void HcalBaseDQMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
263 
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:717
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)
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
MonitorElement * ProblemsVsLB_HB
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:1468
int64_t getIntValue(void) const
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:624
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:845
virtual void setup(void)
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * meLevt_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33