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  tok_hbhe_ = consumes<HBHEDigiCollection>(digiLabel_);
37  tok_ho_ = consumes<HODigiCollection>(digiLabel_);
38  tok_hf_ = consumes<HFDigiCollection>(digiLabel_);
39  tok_report_ = consumes<HcalUnpackerReport>(digiLabel_);
40 
41 }
42 
43 
44 // destructor
46 
47 
48 
50 {
51  // Need to add code to clear out subfolders as well?
52  if (debug_>0) std::cout <<"HcalCoarsePedestalMonitor::cleanup()"<<std::endl;
53  if (!enableCleanup_) return;
54  if (dbe_)
55  {
56  // removeContents doesn't remove subdirectories
59  dbe_->setCurrentFolder(subdir_+"CoarsePedestal_parameters");
61  dbe_->setCurrentFolder(subdir_+"LSvalues");
63  } // if(dbe_)
64 
65 } // void HcalCoarsePedestalMonitor::cleanup();
66 
67 
69 {
70  // Anything to do here?
71 }
72 
74 {
75  if (debug_>0) std::cout <<"HcalCoarsePedestalMonitor::endJob()"<<std::endl;
76  if (enableCleanup_) cleanup(); // when do we force cleanup?
77 }
78 
79 
81 {
82  // Call base class setup
84  if (!dbe_) return;
85 
86  /******* Set up all histograms ********/
87  if (debug_>1)
88  std::cout <<"<HcalCoarsePedestalMonitor::beginRun> Setting up histograms"<<std::endl;
89 
90  std::ostringstream name;
91  dbe_->setCurrentFolder(subdir_ +"CoarsePedestalSumPlots");
92  SetupEtaPhiHists(CoarsePedestalsSumByDepth,"Coarse Pedestal Summed Map","");
93  SetupEtaPhiHists(CoarsePedestalsOccByDepth,"Coarse Pedestal Occupancy Map","");
94  for (unsigned int i=0;i<CoarsePedestalsSumByDepth.depth.size();++i)
95  (CoarsePedestalsSumByDepth.depth[i]->getTH2F())->SetOption("colz");
96  for (unsigned int i=0;i<CoarsePedestalsOccByDepth.depth.size();++i)
97  (CoarsePedestalsOccByDepth.depth[i]->getTH2F())->SetOption("colz");
98 
99 
100  dbe_->setCurrentFolder(subdir_+"CoarsePedestal_parameters");
101  MonitorElement* ADCDiffThresh = dbe_->bookFloat("ADCdiff_Problem_Threshold");
102  ADCDiffThresh->Fill(ADCDiffThresh_);
103  MonitorElement* minevents = dbe_->bookInt("minEventsNeededForPedestalCalculation");
104  minevents->Fill(minEvents_);
105  MonitorElement* excludeHORing2 = dbe_->bookInt("excludeHORing2");
106  if (excludeHORing2_==true)
107  excludeHORing2->Fill(1);
108  else
109  excludeHORing2->Fill(0);
110 
111  this->reset();
112  return;
113 } // void HcalCoarsePedestalMonitor::setup()
114 
116 {
118  if (mergeRuns_ && tevt_>0) return; // don't reset counters if merging runs
119 
120  if (tevt_==0) this->setup(); // create all histograms; not necessary if merging runs together
121  if (mergeRuns_==false) this->reset(); // call reset at start of all runs
122 } // void HcalCoarsePedestalMonitor::beginRun()
123 
124 
126 {
127  if (!IsAllowedCalibType()) return;
128  if (LumiInOrder(e.luminosityBlock())==false) return;
129 
130 
131  // try to get digis
136 
137  if (!(e.getByToken(tok_hbhe_,hbhe_digi)))
138  {
139  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hbhe_digi not available";
140  return;
141  }
142 
143  if (!(e.getByToken(tok_hf_,hf_digi)))
144  {
145  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hf_digi not available";
146  return;
147  }
148  if (!(e.getByToken(tok_ho_,ho_digi)))
149  {
150  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" ho_digi not available";
151  return;
152  }
153  if (!(e.getByToken(tok_report_,report)))
154  {
155  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" unpacker report not available";
156  return;
157  }
158 
159  // all objects grabbed; event is good
160  if (debug_>1) std::cout <<"\t<HcalCoarsePedestalMonitor::analyze> Processing good event! event # = "<<ievt_<<std::endl;
161 
162  HcalBaseDQMonitor::analyze(e,s); // base class increments ievt_, etc. counters
163 
164  // Digi collection was grabbed successfully; process the Event
165  processEvent(*hbhe_digi, *ho_digi, *hf_digi, *report);
166 
167 } //void HcalCoarsePedestalMonitor::analyze(...)
168 
169 
171  const HODigiCollection& ho,
172  const HFDigiCollection& hf,
173  const HcalUnpackerReport& report)
174 {
175  if(!dbe_)
176  {
177  if(debug_)
178  std::cout <<"HcalCoarsePedestalMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
179  return;
180  }
181 
182  // Skip events in which minimal good digis found -- still getting some strange (calib?) events through DQM
183 
184  unsigned int allgooddigis= hbhe.size()+ho.size()+hf.size();
185  // bad threshold: ignore events in which bad outnumber good by more than 100:1
186  // (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)
187  if ((allgooddigis==0) ||
188  (1.*report.badQualityDigis()>100*allgooddigis))
189  {
190  return;
191  }
192 
194 
195  unsigned int digisize=0;
196  int depth=0, iphi=0, ieta=0, binEta=-9999;
197 
198  double value=0;
199 
200  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); ++j)
201  {
202  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
203  if (digi.id().subdet()==HcalBarrel)
204  {if (!HBpresent_) continue;}
205  else if (digi.id().subdet()==HcalEndcap)
206  {if (!HEpresent_) continue;}
207  else continue;
208  digisize=digi.size();
209  if (digisize<8)
210  continue;
211 
212  depth=digi.id().depth();
213  iphi=digi.id().iphi();
214  ieta=digi.id().ieta();
215 
216  digi.id().subdet()==HcalBarrel ?
217  binEta=CalcEtaBin(HcalBarrel, ieta, depth) :
218  binEta=CalcEtaBin(HcalEndcap, ieta, depth);
219 
220  // 'value' is the average pedestal over the 8 time slices.
221  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
222  // in order to calculate average pedestals.
223  value=0;
224  for (unsigned int i=0;i<8;++i)
225  value+=digi.sample(i).adc()/8.;
226  pedestalsum_[binEta][iphi-1][depth-1]+=value;
227  ++pedestalocc_[binEta][iphi-1][depth-1];
228  }
229 
230 
232  if (HOpresent_)
233  {
234  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); ++j)
235  {
236  const HODataFrame digi = (const HODataFrame)(*j);
237  digisize=digi.size();
238  if (digisize<8)
239  continue;
240 
241  depth=digi.id().depth();
242  iphi=digi.id().iphi();
243  ieta=digi.id().ieta();
244  binEta=CalcEtaBin(HcalOuter, ieta, depth);
245 
246  // Don't fill cells that are part of HO ring 2 if an exclusion is applied
247  if (excludeHORing2_==true && abs(ieta)>10 && isSiPM(ieta,iphi,4)==false)
248  continue;
249 
250  // 'value' is the average pedestal over the 8 time slices.
251  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
252  // in order to calculate average pedestals.
253  value=0;
254  for (unsigned int i=0;i<8;++i)
255  value+=digi.sample(i).adc()/8.;
256  pedestalsum_[binEta][iphi-1][depth-1]+=value;
257  ++pedestalocc_[binEta][iphi-1][depth-1];
258  } // for (HODigiCollection)
259  }
260 
262  if (HFpresent_)
263  {
264  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); ++j)
265  {
266  const HFDataFrame digi = (const HFDataFrame)(*j);
267  digisize=digi.size();
268  if (digisize<8)
269  continue;
270  digisize=digi.size();
271  if (digisize<8)
272  continue;
273 
274  depth=digi.id().depth();
275  iphi=digi.id().iphi();
276  ieta=digi.id().ieta();
277  binEta=CalcEtaBin(HcalForward, ieta, depth);
278  // 'value' is the average pedestal over the 8 time slices.
279  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
280  // in order to calculate average pedestals.
281  value=0;
282  for (unsigned int i=0;i<8;++i)
283  value+=digi.sample(i).adc()/8.;
284  pedestalsum_[binEta][iphi-1][depth-1]+=value;
285  ++pedestalocc_[binEta][iphi-1][depth-1];
286  } // for (HFDigiCollection)
287  } // if (HFpresent_)
288 
289  return;
290 } // void HcalCoarsePedestalMonitor::processEvent(...)
291 
292 
294  const edm::EventSetup& c)
295 {
298 }
299 
301  const edm::EventSetup& c)
302 {
303  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
304  fill_Nevents();
305  return;
306 }
308 {
309 
310  // require minimum number of events before processing
311  if (ievt_<minEvents_)
312  return;
313 
314 
315  // Set underflow bin to the number of pedestal events processed
316  // (Assume that number of ped events is the same for all channels/subdetectors)
317  for (unsigned int i=0;i<CoarsePedestalsSumByDepth.depth.size();++i)
318  CoarsePedestalsSumByDepth.depth[i]->setBinContent(0,0,ievt_);
319  for (unsigned int i=0;i<CoarsePedestalsOccByDepth.depth.size();++i)
320  CoarsePedestalsOccByDepth.depth[i]->setBinContent(0,0,ievt_);
321 
322 
323  int iphi=-1, ieta=-99, idepth=0, calcEta=-99;
324  // Loop over all depths, eta, phi
325  for (int d=0;d<4;++d)
326  {
327  idepth=d+1;
328  for (int phi=0;phi<72;++phi)
329  {
330  iphi=phi+1; // actual iphi value
331  for (int eta=0;eta<83;++eta)
332  {
333  ieta=eta-41; // actual ieta value;
334  if (validDetId(HcalBarrel, ieta, iphi, idepth))
335  {
336  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
337  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
338  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
339  }
340  if (validDetId(HcalEndcap, ieta, iphi, idepth))
341  {
342  calcEta = CalcEtaBin(HcalEndcap,ieta,idepth);
343  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
344  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
345  }
346  if (validDetId(HcalOuter, ieta, iphi, idepth))
347  {
348  calcEta = CalcEtaBin(HcalOuter,ieta,idepth);
349  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
350  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
351  }
352  if (validDetId(HcalForward, ieta, iphi, idepth))
353  {
354  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
355  int zside=ieta/abs(ieta);
356  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalsum_[calcEta][phi][d]);
357  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalocc_[calcEta][phi][d]);
358  }
359  }
360  }
361  }
362  // Fill unphysical bins
365 
366  return;
367 } // void HcalCoarsePedestalMonitor::fill_Nevents()
368 
369 
371 {
372  // then reset the MonitorElements
373  zeroCounters();
376  return;
377 }
378 
380 {
381  for (int i=0;i<85;++i)
382  for (int j=0;j<72;++j)
383  for (int k=0;k<4;++k)
384  {
385  pedestalsum_[i][j][k]=0;
386  pedestalocc_[i][j][k]=0;
387  }
388 }
390 
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:30
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int adc() const
get the ADC sample
Definition: HcalQIESample.h:22
std::vector< int > AllowedCalibTypes_
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
void Reset(void)
std::vector< HBHEDataFrame >::const_iterator const_iterator
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
edm::EDGetTokenT< HFDigiCollection > tok_hf_
int zside(DetId const &)
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:879
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:40
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:3085
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:36
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
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:849
virtual void setup(void)
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
void Reset(void)
reset ME (ie. contents, errors, etc)
edm::EDGetTokenT< HcalUnpackerReport > tok_report_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
const_iterator begin() const
Definition: Run.h:41
bool validDetId(HcalSubdetector sd, int ies, int ip, int dp)
edm::EDGetTokenT< HODigiCollection > tok_ho_
Definition: DDAxes.h:10