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 
49 {
50  // Anything to do here?
51 }
52 
54 {
55  if (debug_>0) std::cout <<"HcalCoarsePedestalMonitor::endJob()"<<std::endl;
56  if (enableCleanup_) cleanup(); // when do we force cleanup?
57 }
58 
59 
61 {
62  // Call base class setup
64 
65  /******* Set up all histograms ********/
66  if (debug_>1)
67  std::cout <<"<HcalCoarsePedestalMonitor::setup> Setting up histograms"<<std::endl;
68 
69  std::ostringstream name;
70  ib.setCurrentFolder(subdir_ +"CoarsePedestalSumPlots");
71  SetupEtaPhiHists(ib,CoarsePedestalsSumByDepth,"Coarse Pedestal Summed Map","");
72  SetupEtaPhiHists(ib,CoarsePedestalsOccByDepth,"Coarse Pedestal Occupancy Map","");
73  for (unsigned int i=0;i<CoarsePedestalsSumByDepth.depth.size();++i)
74  (CoarsePedestalsSumByDepth.depth[i]->getTH2F())->SetOption("colz");
75  for (unsigned int i=0;i<CoarsePedestalsOccByDepth.depth.size();++i)
76  (CoarsePedestalsOccByDepth.depth[i]->getTH2F())->SetOption("colz");
77 
78 
79  ib.setCurrentFolder(subdir_+"CoarsePedestal_parameters");
80  MonitorElement* ADCDiffThresh = ib.bookFloat("ADCdiff_Problem_Threshold");
81  ADCDiffThresh->Fill(ADCDiffThresh_);
82  MonitorElement* minevents = ib.bookInt("minEventsNeededForPedestalCalculation");
83  minevents->Fill(minEvents_);
84  MonitorElement* excludeHORing2 = ib.bookInt("excludeHORing2");
85  if (excludeHORing2_==true)
86  excludeHORing2->Fill(1);
87  else
88  excludeHORing2->Fill(0);
89 
90  this->reset();
91  return;
92 } // void HcalCoarsePedestalMonitor::setup()
93 
95 {
97  if (mergeRuns_ && tevt_>0) return; // don't reset counters if merging runs
98 
99  if (tevt_==0) this->setup(ib); // create all histograms; not necessary if merging runs together
100  if (mergeRuns_==false) this->reset(); // call reset at start of all runs
101 } // void HcalCoarsePedestalMonitor::bookHistograms()
102 
103 
105 {
106  if (!IsAllowedCalibType()) return;
107  if (LumiInOrder(e.luminosityBlock())==false) return;
108 
109 
110  // try to get digis
115 
116  if (!(e.getByToken(tok_hbhe_,hbhe_digi)))
117  {
118  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hbhe_digi not available";
119  return;
120  }
121 
122  if (!(e.getByToken(tok_hf_,hf_digi)))
123  {
124  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hf_digi not available";
125  return;
126  }
127  if (!(e.getByToken(tok_ho_,ho_digi)))
128  {
129  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" ho_digi not available";
130  return;
131  }
132  if (!(e.getByToken(tok_report_,report)))
133  {
134  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" unpacker report not available";
135  return;
136  }
137 
138  // all objects grabbed; event is good
139  if (debug_>1) std::cout <<"\t<HcalCoarsePedestalMonitor::analyze> Processing good event! event # = "<<ievt_<<std::endl;
140 
141  HcalBaseDQMonitor::analyze(e,s); // base class increments ievt_, etc. counters
142 
143  // Digi collection was grabbed successfully; process the Event
144  processEvent(*hbhe_digi, *ho_digi, *hf_digi, *report);
145 
146 } //void HcalCoarsePedestalMonitor::analyze(...)
147 
148 
150  const HODigiCollection& ho,
151  const HFDigiCollection& hf,
152  const HcalUnpackerReport& report)
153 {
154  // Skip events in which minimal good digis found -- still getting some strange (calib?) events through DQM
155 
156  unsigned int allgooddigis= hbhe.size()+ho.size()+hf.size();
157  // bad threshold: ignore events in which bad outnumber good by more than 100:1
158  // (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)
159  if ((allgooddigis==0) ||
160  (1.*report.badQualityDigis()>100*allgooddigis))
161  {
162  return;
163  }
164 
166 
167  unsigned int digisize=0;
168  int depth=0, iphi=0, ieta=0, binEta=-9999;
169 
170  double value=0;
171 
172  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); ++j)
173  {
174  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
175  if (digi.id().subdet()==HcalBarrel)
176  {if (!HBpresent_) continue;}
177  else if (digi.id().subdet()==HcalEndcap)
178  {if (!HEpresent_) continue;}
179  else continue;
180  digisize=digi.size();
181  if (digisize<8)
182  continue;
183 
184  depth=digi.id().depth();
185  iphi=digi.id().iphi();
186  ieta=digi.id().ieta();
187 
188  digi.id().subdet()==HcalBarrel ?
189  binEta=CalcEtaBin(HcalBarrel, ieta, depth) :
190  binEta=CalcEtaBin(HcalEndcap, ieta, depth);
191 
192  // 'value' is the average pedestal over the 8 time slices.
193  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
194  // in order to calculate average pedestals.
195  value=0;
196  for (unsigned int i=0;i<8;++i)
197  value+=digi.sample(i).adc()/8.;
198  pedestalsum_[binEta][iphi-1][depth-1]+=value;
199  ++pedestalocc_[binEta][iphi-1][depth-1];
200  }
201 
202 
204  if (HOpresent_)
205  {
206  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); ++j)
207  {
208  const HODataFrame digi = (const HODataFrame)(*j);
209  digisize=digi.size();
210  if (digisize<8)
211  continue;
212 
213  depth=digi.id().depth();
214  iphi=digi.id().iphi();
215  ieta=digi.id().ieta();
216  binEta=CalcEtaBin(HcalOuter, ieta, depth);
217 
218  // Don't fill cells that are part of HO ring 2 if an exclusion is applied
219  if (excludeHORing2_==true && abs(ieta)>10 && isSiPM(ieta,iphi,4)==false)
220  continue;
221 
222  // 'value' is the average pedestal over the 8 time slices.
223  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
224  // in order to calculate average pedestals.
225  value=0;
226  for (unsigned int i=0;i<8;++i)
227  value+=digi.sample(i).adc()/8.;
228  pedestalsum_[binEta][iphi-1][depth-1]+=value;
229  ++pedestalocc_[binEta][iphi-1][depth-1];
230  } // for (HODigiCollection)
231  }
232 
234  if (HFpresent_)
235  {
236  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); ++j)
237  {
238  const HFDataFrame digi = (const HFDataFrame)(*j);
239  digisize=digi.size();
240  if (digisize<8)
241  continue;
242  digisize=digi.size();
243  if (digisize<8)
244  continue;
245 
246  depth=digi.id().depth();
247  iphi=digi.id().iphi();
248  ieta=digi.id().ieta();
249  binEta=CalcEtaBin(HcalForward, ieta, depth);
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 (HFDigiCollection)
259  } // if (HFpresent_)
260 
261  return;
262 } // void HcalCoarsePedestalMonitor::processEvent(...)
263 
264 
266  const edm::EventSetup& c)
267 {
270 }
271 
273  const edm::EventSetup& c)
274 {
275  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
276  fill_Nevents();
277  return;
278 }
280 {
281 
282  // require minimum number of events before processing
283  if (ievt_<minEvents_)
284  return;
285 
286 
287  // Set underflow bin to the number of pedestal events processed
288  // (Assume that number of ped events is the same for all channels/subdetectors)
289  for (unsigned int i=0;i<CoarsePedestalsSumByDepth.depth.size();++i)
290  CoarsePedestalsSumByDepth.depth[i]->setBinContent(0,0,ievt_);
291  for (unsigned int i=0;i<CoarsePedestalsOccByDepth.depth.size();++i)
292  CoarsePedestalsOccByDepth.depth[i]->setBinContent(0,0,ievt_);
293 
294 
295  int iphi=-1, ieta=-99, idepth=0, calcEta=-99;
296  // Loop over all depths, eta, phi
297  for (int d=0;d<4;++d)
298  {
299  idepth=d+1;
300  for (int phi=0;phi<72;++phi)
301  {
302  iphi=phi+1; // actual iphi value
303  for (int eta=0;eta<83;++eta)
304  {
305  ieta=eta-41; // actual ieta value;
306  if (validDetId(HcalBarrel, ieta, iphi, idepth))
307  {
308  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
309  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
310  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
311  }
312  if (validDetId(HcalEndcap, ieta, iphi, idepth))
313  {
314  calcEta = CalcEtaBin(HcalEndcap,ieta,idepth);
315  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
316  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
317  }
318  if (validDetId(HcalOuter, ieta, iphi, idepth))
319  {
320  calcEta = CalcEtaBin(HcalOuter,ieta,idepth);
321  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
322  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
323  }
324  if (validDetId(HcalForward, ieta, iphi, idepth))
325  {
326  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
327  int zside=ieta/abs(ieta);
328  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalsum_[calcEta][phi][d]);
329  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalocc_[calcEta][phi][d]);
330  }
331  }
332  }
333  }
334  // Fill unphysical bins
337 
338  return;
339 } // void HcalCoarsePedestalMonitor::fill_Nevents()
340 
341 
343 {
344  // then reset the MonitorElements
345  zeroCounters();
348  return;
349 }
350 
352 {
353  for (int i=0;i<85;++i)
354  for (int j=0;j<72;++j)
355  for (int k=0;k<4;++k)
356  {
357  pedestalsum_[i][j][k]=0;
358  pedestalocc_[i][j][k]=0;
359  }
360 }
362 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool LumiInOrder(int lumisec)
MonitorElement * ProblemsCurrentLB
int ib
Definition: cuy.py:660
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:446
void bookHistograms(DQMStore::IBooker &ib, const edm::Run &run, const edm::EventSetup &c)
#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)
virtual void cleanup(void)
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
MonitorElement * bookInt(Args &&...args)
Definition: DQMStore.h:103
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
void Fill(long long x)
LuminosityBlockNumber_t luminosityBlock() const
tuple report
Definition: zeeHLT_cff.py:9
void SetupEtaPhiHists(DQMStore::IBooker &ib, EtaPhiHists &hh, std::string Name, std::string Units)
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
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
void setup(DQMStore::IBooker &)
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
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)
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
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109
const HcalDetId & id() const
Definition: HFDataFrame.h:22
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
void Reset(void)
reset ME (ie. contents, errors, etc)
virtual void setup(DQMStore::IBooker &)
edm::EDGetTokenT< HcalUnpackerReport > tok_report_
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