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: 2010/07/20 02:58:25 $
11  * $Revision: 1.5 $
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_ && tevt_>0) return;
87  this->setup();
88  this->reset();
89 } // beginRun(const edm::Run& run, const edm::EventSetup& c)
90 
92 {
93  if (debug_>0) std::cout <<"HcalBaseDQMonitor::endRun: task = "<<subdir_<<std::endl;
94 } //endRun(...)
95 
97 {
98  if (debug_>0) std::cout <<"HcalBaseDQMonitor::reset(): task = "<<subdir_<<std::endl;
99  if (meIevt_) meIevt_->Fill(-1);
100  ievt_=0;
101  if (meLevt_) meLevt_->Fill(-1);
102  levt_=0;
103  if (meTevt_) meTevt_->Fill(-1);
104  tevt_=0;
105  if (meTevtHist_) meTevtHist_->Reset();
107  HBpresent_=false;
108  HEpresent_=false;
109  HOpresent_=false;
110  HFpresent_=false;
111  currentLS=0;
112  currenttype_=-1;
113 } //reset()
114 
116 {
117 
118 } //cleanup()
119 
121 {
122  if (debug_>3) std::cout <<"<HcalBaseDQMonitor> setup in progress"<<std::endl;
124  meIevt_ = dbe_->bookInt("EventsProcessed");
125  if (meIevt_) meIevt_->Fill(-1);
126  meLevt_ = dbe_->bookInt("EventsProcessed_currentLS");
127  if (meLevt_) meLevt_->Fill(-1);
128  meTevt_ = dbe_->bookInt("EventsProcessed_Total");
129  if (meTevt_) meTevt_->Fill(-1);
130  meTevtHist_=dbe_->book1D("Events_Processed_Task_Histogram","Counter of Events Processed By This Task",1,0.5,1.5);
131  if (meTevtHist_) meTevtHist_->Reset();
132  dbe_->setCurrentFolder(subdir_+"LSvalues");
133  ProblemsCurrentLB=dbe_->book2D("ProblemsThisLS","Problem Channels in current Lumi Section",
134  7,0,7,1,0,1);
135  if (ProblemsCurrentLB)
136  {
137  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
138  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
139  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
140  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
141  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
142  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
143  (ProblemsCurrentLB->getTH2F())->GetXaxis()->SetBinLabel(7,"HFlumi");
144  (ProblemsCurrentLB->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
146  }
147 } // setup()
148 
149 
151  const edm::EventSetup& c)
152 {
153  if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
154  currentLS=lumiSeg.luminosityBlock();
155  levt_=0;
156  if (meLevt_!=0) meLevt_->Fill(-1);
157  if (ProblemsCurrentLB)
159 }
160 
162  const edm::EventSetup& c)
163 {
164  if (this->LumiInOrder(lumiSeg.luminosityBlock())==false) return;
165  // Inherited classes do end-of-lumi functions here
166 }
167 
168 
170 {
171  if (skipOutOfOrderLS_==false) return true; // don't skip out-of-order lumi sections
172  // check that latest lumi section is >= last processed
173  if (Online_ && lumisec<currentLS)
174  return false;
175  return true;
176 }
177 
179 {
180  if (debug_>9) std::cout <<"<HcalBaseDQMonitor::IsAllowedCalibType>"<<std::endl;
181  if (AllowedCalibTypes_.size()==0)
182  {
183  if (debug_>9) std::cout <<"\tNo calib types specified by user; All events allowed"<<std::endl;
184  return true;
185  }
186  MonitorElement* me = dbe_->get((prefixME_+"HcalInfo/CURRENT_EVENT_TYPE").c_str());
187  if (me) currenttype_=me->getIntValue();
188  else
189  {
190  if (debug_>9) std::cout <<"\tCalib Type cannot be determined from HcalMonitorModule"<<std::endl;
191  return true; // is current type can't be determined, assume event is allowed
192  }
193  if (debug_>9) std::cout <<"\tHcalBaseDQMonitor::IsAllowedCalibType checking if calibration type = "<<currenttype_<<" is allowed...";
195  {
196  if (AllowedCalibTypes_[i]==currenttype_)
197  {
198  if (debug_>9) std::cout <<"\t Type allowed!"<<std::endl;
199  return true;
200  }
201  }
202  if (debug_>9) std::cout <<"\t Type not allowed!"<<std::endl;
203  return false;
204 } // bool HcalBaseDQMonitor::IsAllowedCalibType()
205 
207 {
208  if (debug_>5) std::cout <<"\t<HcalBaseDQMonitor::analyze> event = "<<ievt_<<std::endl;
209  eventAllowed_=true; // assume event is allowed
210 
211  // fill with total events seen (this differs from ievent, which is total # of good events)
212  ++tevt_;
213  if (meTevt_) meTevt_->Fill(tevt_);
214  if (meTevtHist_) meTevtHist_->Fill(1);
215  // skip out of order lumi events
216  if (this->LumiInOrder(e.luminosityBlock())==false)
217  {
218  eventAllowed_=false;
219  return;
220  }
221  // skip events of wrong calibration type
223  if (!eventAllowed_) return;
224 
225  // Event is good; count it
226  ++ievt_;
227  ++levt_;
228  if (meIevt_) meIevt_->Fill(ievt_);
229  if (meLevt_) meLevt_->Fill(levt_);
230 
231 
232  MonitorElement* me;
233  if (HBpresent_==false)
234  {
235  me = dbe_->get((prefixME_+"HcalInfo/HBpresent"));
236  if (me==0 || me->getIntValue()>0) HBpresent_=true;
237  }
238  if (HEpresent_==false)
239  {
240  me = dbe_->get((prefixME_+"HcalInfo/HEpresent"));
241  if (me==0 || me->getIntValue()>0) HEpresent_=true;
242  }
243  if (HOpresent_==false)
244  {
245  me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
246  if (me==0 || me->getIntValue()>0) HOpresent_=true;
247  }
248  if (HFpresent_==false)
249  {
250  me = dbe_->get((prefixME_+"HcalInfo/HOpresent"));
251  if (me ==0 || me->getIntValue()>0) HFpresent_=true;
252  }
253 
254 
255 } // void HcalBaseDQMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
256 
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:514
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:1265
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:41
MonitorElement * ProblemsVsLB_HO
MonitorElement * ProblemsVsLB
TH2F * getTH2F(void) const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:421
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:642
virtual void setup(void)
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * meLevt_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
Definition: Run.h:32