CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalCoarsePedestalMonitor.cc
Go to the documentation of this file.
3 #include <cmath>
4 
12 
13 // constructor
15 {
16  Online_ = ps.getUntrackedParameter<bool>("online",false);
17  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
18  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
19  debug_ = ps.getUntrackedParameter<int>("debug",0);
20  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
21  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
22  prefixME_.append("/");
23  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","CoarsePedestalMonitor_Hcal");
24  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
25  subdir_.append("/");
26  subdir_=prefixME_+subdir_;
27  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
28  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
29  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
30  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
32  ADCDiffThresh_ = ps.getUntrackedParameter<double>("ADCDiffThresh",1.);
33  minEvents_ = ps.getUntrackedParameter<int>("minEvents",100); // minimum number of events needed before histograms are filled
34  excludeHORing2_ = ps.getUntrackedParameter<bool>("excludeHORing2",false);
35 
36 }
37 
38 
39 // destructor
41 
42 
43 
45 {
46  // Need to add code to clear out subfolders as well?
47  if (debug_>0) std::cout <<"HcalCoarsePedestalMonitor::cleanup()"<<std::endl;
48  if (!enableCleanup_) return;
49  if (dbe_)
50  {
51  // removeContents doesn't remove subdirectories
54  dbe_->setCurrentFolder(subdir_+"CoarsePedestal_parameters");
56  dbe_->setCurrentFolder(subdir_+"LSvalues");
58  } // if(dbe_)
59 
60 } // void HcalCoarsePedestalMonitor::cleanup();
61 
62 
64 {
65  // Anything to do here?
66 }
67 
69 {
70  if (debug_>0) std::cout <<"HcalCoarsePedestalMonitor::endJob()"<<std::endl;
71  if (enableCleanup_) cleanup(); // when do we force cleanup?
72 }
73 
74 
76 {
77  // Call base class setup
79  if (!dbe_) return;
80 
81  /******* Set up all histograms ********/
82  if (debug_>1)
83  std::cout <<"<HcalCoarsePedestalMonitor::beginRun> Setting up histograms"<<std::endl;
84 
85  std::ostringstream name;
86  dbe_->setCurrentFolder(subdir_ +"CoarsePedestalSumPlots");
87  SetupEtaPhiHists(CoarsePedestalsSumByDepth,"Coarse Pedestal Summed Map","");
88  SetupEtaPhiHists(CoarsePedestalsOccByDepth,"Coarse Pedestal Occupancy Map","");
89  for (unsigned int i=0;i<CoarsePedestalsSumByDepth.depth.size();++i)
90  (CoarsePedestalsSumByDepth.depth[i]->getTH2F())->SetOption("colz");
91  for (unsigned int i=0;i<CoarsePedestalsOccByDepth.depth.size();++i)
92  (CoarsePedestalsOccByDepth.depth[i]->getTH2F())->SetOption("colz");
93 
94 
95  dbe_->setCurrentFolder(subdir_+"CoarsePedestal_parameters");
96  MonitorElement* ADCDiffThresh = dbe_->bookFloat("ADCdiff_Problem_Threshold");
97  ADCDiffThresh->Fill(ADCDiffThresh_);
98  MonitorElement* minevents = dbe_->bookInt("minEventsNeededForPedestalCalculation");
99  minevents->Fill(minEvents_);
100  MonitorElement* excludeHORing2 = dbe_->bookInt("excludeHORing2");
101  if (excludeHORing2_==true)
102  excludeHORing2->Fill(1);
103  else
104  excludeHORing2->Fill(0);
105 
106  this->reset();
107  return;
108 } // void HcalCoarsePedestalMonitor::setup()
109 
111 {
113  if (mergeRuns_ && tevt_>0) return; // don't reset counters if merging runs
114 
115  if (tevt_==0) this->setup(); // create all histograms; not necessary if merging runs together
116  if (mergeRuns_==false) this->reset(); // call reset at start of all runs
117 } // void HcalCoarsePedestalMonitor::beginRun()
118 
119 
121 {
122  if (!IsAllowedCalibType()) return;
123  if (LumiInOrder(e.luminosityBlock())==false) return;
124 
125 
126  // try to get digis
131 
132  if (!(e.getByLabel(digiLabel_,hbhe_digi)))
133  {
134  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hbhe_digi not available";
135  return;
136  }
137 
138  if (!(e.getByLabel(digiLabel_,hf_digi)))
139  {
140  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hf_digi not available";
141  return;
142  }
143  if (!(e.getByLabel(digiLabel_,ho_digi)))
144  {
145  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" ho_digi not available";
146  return;
147  }
148  if (!(e.getByLabel(digiLabel_,report)))
149  {
150  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" unpacker report not available";
151  return;
152  }
153 
154  // all objects grabbed; event is good
155  if (debug_>1) std::cout <<"\t<HcalCoarsePedestalMonitor::analyze> Processing good event! event # = "<<ievt_<<std::endl;
156 
157  HcalBaseDQMonitor::analyze(e,s); // base class increments ievt_, etc. counters
158 
159  // Digi collection was grabbed successfully; process the Event
160  processEvent(*hbhe_digi, *ho_digi, *hf_digi, *report);
161 
162 } //void HcalCoarsePedestalMonitor::analyze(...)
163 
164 
166  const HODigiCollection& ho,
167  const HFDigiCollection& hf,
168  const HcalUnpackerReport& report)
169 {
170  if(!dbe_)
171  {
172  if(debug_)
173  std::cout <<"HcalCoarsePedestalMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
174  return;
175  }
176 
177  // Skip events in which minimal good digis found -- still getting some strange (calib?) events through DQM
178 
179  unsigned int allgooddigis= hbhe.size()+ho.size()+hf.size();
180  // bad threshold: ignore events in which bad outnumber good by more than 100:1
181  // (one RBX in HBHE seems to send valid data occasionally even on QIE resets, which is why we can't just require allgooddigis==0 when looking for events to skip)
182  if ((allgooddigis==0) ||
183  (1.*report.badQualityDigis()>100*allgooddigis))
184  {
185  return;
186  }
187 
189 
190  unsigned int digisize=0;
191  int depth=0, iphi=0, ieta=0, binEta=-9999;
192 
193  double value=0;
194 
195  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); ++j)
196  {
197  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
198  if (digi.id().subdet()==HcalBarrel)
199  {if (!HBpresent_) continue;}
200  else if (digi.id().subdet()==HcalEndcap)
201  {if (!HEpresent_) continue;}
202  else continue;
203  digisize=digi.size();
204  if (digisize<8)
205  continue;
206 
207  depth=digi.id().depth();
208  iphi=digi.id().iphi();
209  ieta=digi.id().ieta();
210 
211  digi.id().subdet()==HcalBarrel ?
212  binEta=CalcEtaBin(HcalBarrel, ieta, depth) :
213  binEta=CalcEtaBin(HcalEndcap, ieta, depth);
214 
215  // 'value' is the average pedestal over the 8 time slices.
216  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
217  // in order to calculate average pedestals.
218  value=0;
219  for (unsigned int i=0;i<8;++i)
220  value+=digi.sample(i).adc()/8.;
221  pedestalsum_[binEta][iphi-1][depth-1]+=value;
222  ++pedestalocc_[binEta][iphi-1][depth-1];
223  }
224 
225 
227  if (HOpresent_)
228  {
229  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); ++j)
230  {
231  const HODataFrame digi = (const HODataFrame)(*j);
232  digisize=digi.size();
233  if (digisize<8)
234  continue;
235 
236  depth=digi.id().depth();
237  iphi=digi.id().iphi();
238  ieta=digi.id().ieta();
239  binEta=CalcEtaBin(HcalOuter, ieta, depth);
240 
241  // Don't fill cells that are part of HO ring 2 if an exclusion is applied
242  if (excludeHORing2_==true && abs(ieta)>10 && isSiPM(ieta,iphi,4)==false)
243  continue;
244 
245  // 'value' is the average pedestal over the 8 time slices.
246  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
247  // in order to calculate average pedestals.
248  value=0;
249  for (unsigned int i=0;i<8;++i)
250  value+=digi.sample(i).adc()/8.;
251  pedestalsum_[binEta][iphi-1][depth-1]+=value;
252  ++pedestalocc_[binEta][iphi-1][depth-1];
253  } // for (HODigiCollection)
254  }
255 
257  if (HFpresent_)
258  {
259  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); ++j)
260  {
261  const HFDataFrame digi = (const HFDataFrame)(*j);
262  digisize=digi.size();
263  if (digisize<8)
264  continue;
265  digisize=digi.size();
266  if (digisize<8)
267  continue;
268 
269  depth=digi.id().depth();
270  iphi=digi.id().iphi();
271  ieta=digi.id().ieta();
272  binEta=CalcEtaBin(HcalForward, ieta, depth);
273  // 'value' is the average pedestal over the 8 time slices.
274  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
275  // in order to calculate average pedestals.
276  value=0;
277  for (unsigned int i=0;i<8;++i)
278  value+=digi.sample(i).adc()/8.;
279  pedestalsum_[binEta][iphi-1][depth-1]+=value;
280  ++pedestalocc_[binEta][iphi-1][depth-1];
281  } // for (HFDigiCollection)
282  } // if (HFpresent_)
283 
284  return;
285 } // void HcalCoarsePedestalMonitor::processEvent(...)
286 
287 
289  const edm::EventSetup& c)
290 {
293 }
294 
296  const edm::EventSetup& c)
297 {
298  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
299  fill_Nevents();
300  return;
301 }
303 {
304 
305  // require minimum number of events before processing
306  if (ievt_<minEvents_)
307  return;
308 
309 
310  // Set underflow bin to the number of pedestal events processed
311  // (Assume that number of ped events is the same for all channels/subdetectors)
312  for (unsigned int i=0;i<CoarsePedestalsSumByDepth.depth.size();++i)
313  CoarsePedestalsSumByDepth.depth[i]->setBinContent(0,0,ievt_);
314  for (unsigned int i=0;i<CoarsePedestalsOccByDepth.depth.size();++i)
315  CoarsePedestalsOccByDepth.depth[i]->setBinContent(0,0,ievt_);
316 
317 
318  int iphi=-1, ieta=-99, idepth=0, calcEta=-99;
319  // Loop over all depths, eta, phi
320  for (int d=0;d<4;++d)
321  {
322  idepth=d+1;
323  for (int phi=0;phi<72;++phi)
324  {
325  iphi=phi+1; // actual iphi value
326  for (int eta=0;eta<83;++eta)
327  {
328  ieta=eta-41; // actual ieta value;
329  if (validDetId(HcalBarrel, ieta, iphi, idepth))
330  {
331  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
332  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
333  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
334  }
335  if (validDetId(HcalEndcap, ieta, iphi, idepth))
336  {
337  calcEta = CalcEtaBin(HcalEndcap,ieta,idepth);
338  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
339  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
340  }
341  if (validDetId(HcalOuter, ieta, iphi, idepth))
342  {
343  calcEta = CalcEtaBin(HcalOuter,ieta,idepth);
344  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
345  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
346  }
347  if (validDetId(HcalForward, ieta, iphi, idepth))
348  {
349  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
350  int zside=ieta/abs(ieta);
351  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalsum_[calcEta][phi][d]);
352  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalocc_[calcEta][phi][d]);
353  }
354  }
355  }
356  }
357  // Fill unphysical bins
360 
361  return;
362 } // void HcalCoarsePedestalMonitor::fill_Nevents()
363 
364 
366 {
367  // then reset the MonitorElements
368  zeroCounters();
371  return;
372 }
373 
375 {
376  for (int i=0;i<85;++i)
377  for (int j=0;j<72;++j)
378  for (int k=0;k<4;++k)
379  {
380  pedestalsum_[i][j][k]=0;
381  pedestalocc_[i][j][k]=0;
382  }
383 }
385 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool LumiInOrder(int lumisec)
MonitorElement * ProblemsCurrentLB
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int adc() const
get the ADC sample
Definition: HcalQIESample.h:24
std::vector< int > AllowedCalibTypes_
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
void Reset(void)
std::vector< T >::const_iterator const_iterator
#define abs(x)
Definition: mlp_lapack.h:159
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
T eta() const
const HcalQIESample & sample(int i) const
access a sample
Definition: HODataFrame.h:40
void processEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalUnpackerReport &report)
const HcalDetId & id() const
Definition: HODataFrame.h:23
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
void Fill(long long x)
LuminosityBlockNumber_t luminosityBlock() const
tuple report
Definition: zeeHLT_cff.py:9
bool isSiPM(int ieta, int iphi, int depth)
int depth() const
get the tower depth
Definition: HcalDetId.h:42
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
std::vector< MonitorElement * > depth
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2569
void endRun(const edm::Run &run, const edm::EventSetup &c)
void analyze(const edm::Event &e, const edm::EventSetup &c)
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
const HcalQIESample & sample(int i) const
access a sample
Definition: HFDataFrame.h:39
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
int k[5][pyjets_maxn]
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
const HcalQIESample & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:39
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
int CalcEtaBin(int subdet, int ieta, int depth)
HcalCoarsePedestalMonitor(const edm::ParameterSet &ps)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void SetupEtaPhiHists(EtaPhiHists &hh, std::string Name, std::string Units)
int badQualityDigis() const
size_type size() const
void fill_Nevents()
Methods, variables accessible only within class code.
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
tuple cout
Definition: gather_cfg.py:121
const HcalDetId & id() const
Definition: HFDataFrame.h:22
void beginRun(const edm::Run &run, const edm::EventSetup &c)
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:629
virtual void setup(void)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
const_iterator begin() const
Definition: Run.h:36
bool validDetId(HcalSubdetector sd, int ies, int ip, int dp)
Definition: DDAxes.h:10