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 {
107  if (!IsAllowedCalibType()) return;
108  if (LumiInOrder(e.luminosityBlock())==false) return;
109 
110 
111  // try to get digis
116 
117  if (!(e.getByToken(tok_hbhe_,hbhe_digi)))
118  {
119  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hbhe_digi not available";
120  return;
121  }
122 
123  if (!(e.getByToken(tok_hf_,hf_digi)))
124  {
125  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" hf_digi not available";
126  return;
127  }
128  if (!(e.getByToken(tok_ho_,ho_digi)))
129  {
130  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" ho_digi not available";
131  return;
132  }
133  if (!(e.getByToken(tok_report_,report)))
134  {
135  edm::LogWarning("HcalCoarsePedestalMonitor")<< digiLabel_<<" unpacker report not available";
136  return;
137  }
138 
139  // all objects grabbed; event is good
140  if (debug_>1) std::cout <<"\t<HcalCoarsePedestalMonitor::analyze> Processing good event! event # = "<<ievt_<<std::endl;
141 
142 // HcalBaseDQMonitor::analyze(e,s); // base class increments ievt_, etc. counters
143 
144  // Digi collection was grabbed successfully; process the Event
145  processEvent(*hbhe_digi, *ho_digi, *hf_digi, *report);
146 
147 } //void HcalCoarsePedestalMonitor::analyze(...)
148 
149 
151  const HODigiCollection& ho,
152  const HFDigiCollection& hf,
153  const HcalUnpackerReport& report)
154 {
155  // Skip events in which minimal good digis found -- still getting some strange (calib?) events through DQM
156 
157  unsigned int allgooddigis= hbhe.size()+ho.size()+hf.size();
158  // bad threshold: ignore events in which bad outnumber good by more than 100:1
159  // (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)
160  if ((allgooddigis==0) ||
161  (1.*report.badQualityDigis()>100*allgooddigis))
162  {
163  return;
164  }
165 
167 
168  unsigned int digisize=0;
169  int depth=0, iphi=0, ieta=0, binEta=-9999;
170 
171  double value=0;
172 
173  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); ++j)
174  {
175  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
176  if (digi.id().subdet()==HcalBarrel)
177  {if (!HBpresent_) continue;}
178  else if (digi.id().subdet()==HcalEndcap)
179  {if (!HEpresent_) continue;}
180  else continue;
181  digisize=digi.size();
182  if (digisize<8)
183  continue;
184 
185  depth=digi.id().depth();
186  iphi=digi.id().iphi();
187  ieta=digi.id().ieta();
188 
189  digi.id().subdet()==HcalBarrel ?
190  binEta=CalcEtaBin(HcalBarrel, ieta, depth) :
191  binEta=CalcEtaBin(HcalEndcap, ieta, depth);
192 
193  // 'value' is the average pedestal over the 8 time slices.
194  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
195  // in order to calculate average pedestals.
196  value=0;
197  for (unsigned int i=0;i<8;++i)
198  value+=digi.sample(i).adc()/8.;
199  pedestalsum_[binEta][iphi-1][depth-1]+=value;
200  ++pedestalocc_[binEta][iphi-1][depth-1];
201  }
202 
203 
205  if (HOpresent_)
206  {
207  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); ++j)
208  {
209  const HODataFrame digi = (const HODataFrame)(*j);
210  digisize=digi.size();
211  if (digisize<8)
212  continue;
213 
214  depth=digi.id().depth();
215  iphi=digi.id().iphi();
216  ieta=digi.id().ieta();
217  binEta=CalcEtaBin(HcalOuter, ieta, depth);
218 
219  // Don't fill cells that are part of HO ring 2 if an exclusion is applied
220  if (excludeHORing2_==true && abs(ieta)>10 && isSiPM(ieta,iphi,4)==false)
221  continue;
222 
223  // 'value' is the average pedestal over the 8 time slices.
224  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
225  // in order to calculate average pedestals.
226  value=0;
227  for (unsigned int i=0;i<8;++i)
228  value+=digi.sample(i).adc()/8.;
229  pedestalsum_[binEta][iphi-1][depth-1]+=value;
230  ++pedestalocc_[binEta][iphi-1][depth-1];
231  } // for (HODigiCollection)
232  }
233 
235  if (HFpresent_)
236  {
237  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); ++j)
238  {
239  const HFDataFrame digi = (const HFDataFrame)(*j);
240  digisize=digi.size();
241  if (digisize<8)
242  continue;
243  digisize=digi.size();
244  if (digisize<8)
245  continue;
246 
247  depth=digi.id().depth();
248  iphi=digi.id().iphi();
249  ieta=digi.id().ieta();
250  binEta=CalcEtaBin(HcalForward, ieta, depth);
251  // 'value' is the average pedestal over the 8 time slices.
252  // In the CoarsePedestal client, we will divide the summed value by Nevents (in underflow bin)
253  // in order to calculate average pedestals.
254  value=0;
255  for (unsigned int i=0;i<8;++i)
256  value+=digi.sample(i).adc()/8.;
257  pedestalsum_[binEta][iphi-1][depth-1]+=value;
258  ++pedestalocc_[binEta][iphi-1][depth-1];
259  } // for (HFDigiCollection)
260  } // if (HFpresent_)
261 
262  return;
263 } // void HcalCoarsePedestalMonitor::processEvent(...)
264 
265 
267  const edm::EventSetup& c)
268 {
271 }
272 
274  const edm::EventSetup& c)
275 {
276  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
277  fill_Nevents();
278  return;
279 }
281 {
282 
283  // require minimum number of events before processing
284  if (ievt_<minEvents_)
285  return;
286 
287 
288  // Set underflow bin to the number of pedestal events processed
289  // (Assume that number of ped events is the same for all channels/subdetectors)
290  for (unsigned int i=0;i<CoarsePedestalsSumByDepth.depth.size();++i)
291  CoarsePedestalsSumByDepth.depth[i]->setBinContent(0,0,ievt_);
292  for (unsigned int i=0;i<CoarsePedestalsOccByDepth.depth.size();++i)
293  CoarsePedestalsOccByDepth.depth[i]->setBinContent(0,0,ievt_);
294 
295 
296  int iphi=-1, ieta=-99, idepth=0, calcEta=-99;
297  // Loop over all depths, eta, phi
298  for (int d=0;d<4;++d)
299  {
300  idepth=d+1;
301  for (int phi=0;phi<72;++phi)
302  {
303  iphi=phi+1; // actual iphi value
304  for (int eta=0;eta<83;++eta)
305  {
306  ieta=eta-41; // actual ieta value;
307  if (validDetId(HcalBarrel, ieta, iphi, idepth))
308  {
309  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
310  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
311  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
312  }
313  if (validDetId(HcalEndcap, ieta, iphi, idepth))
314  {
315  calcEta = CalcEtaBin(HcalEndcap,ieta,idepth);
316  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
317  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
318  }
319  if (validDetId(HcalOuter, ieta, iphi, idepth))
320  {
321  calcEta = CalcEtaBin(HcalOuter,ieta,idepth);
322  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta,iphi,pedestalsum_[calcEta][phi][d]);
323  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta,iphi,pedestalocc_[calcEta][phi][d]);
324  }
325  if (validDetId(HcalForward, ieta, iphi, idepth))
326  {
327  calcEta = CalcEtaBin(HcalBarrel,ieta,idepth);
328  int zside=ieta/abs(ieta);
329  CoarsePedestalsSumByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalsum_[calcEta][phi][d]);
330  CoarsePedestalsOccByDepth.depth[d]->Fill(ieta+zside,iphi,pedestalocc_[calcEta][phi][d]);
331  }
332  }
333  }
334  }
335  // Fill unphysical bins
338 
339  return;
340 } // void HcalCoarsePedestalMonitor::fill_Nevents()
341 
342 
344 {
345  // then reset the MonitorElements
346  zeroCounters();
349  return;
350 }
351 
353 {
354  for (int i=0;i<85;++i)
355  for (int j=0;j<72;++j)
356  for (int k=0;k<4;++k)
357  {
358  pedestalsum_[i][j][k]=0;
359  pedestalocc_[i][j][k]=0;
360  }
361 }
363 
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