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