CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDigiMonitor.cc
Go to the documentation of this file.
3 #include <cmath>
4 
10 
11 // constructor
13  Online_ = ps.getUntrackedParameter<bool>("online",false);
14  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
15  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
16  debug_ = ps.getUntrackedParameter<int>("debug",0);
17  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
18  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
19  prefixME_.append("/");
20  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","DigiMonitor_Hcal");
21  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
22  subdir_.append("/");
23  subdir_=prefixME_+subdir_;
24  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
25  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
26  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
27  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
29  FEDRawDataCollection_ = ps.getUntrackedParameter<edm::InputTag>("FEDRawDataCollection");
30  shapeThresh_ = ps.getUntrackedParameter<int>("shapeThresh",20);
31  //shapeThresh_ is used for plotting pulse shapes for all digis with pedestal-subtracted ADC sum > shapeThresh_;
32  shapeThreshHB_ = ps.getUntrackedParameter<int>("shapeThreshHB",shapeThresh_);
33  shapeThreshHE_ = ps.getUntrackedParameter<int>("shapeThreshHE",shapeThresh_);
34  shapeThreshHF_ = ps.getUntrackedParameter<int>("shapeThreshHF",shapeThresh_);
35  shapeThreshHO_ = ps.getUntrackedParameter<int>("shapeThreshHO",shapeThresh_);
36 
37  hltresultsLabel_ = ps.getUntrackedParameter<edm::InputTag>("HLTResultsLabel");
38  MinBiasHLTBits_ = ps.getUntrackedParameter<std::vector<std::string> >("MinBiasHLTBits");
39  excludeHORing2_ = ps.getUntrackedParameter<bool>("excludeHORing2",false);
40  excludeHO1P02_ = ps.getUntrackedParameter<bool>("excludeHO1P02",false);
41  excludeBadQPLLs_ = ps.getUntrackedParameter<bool>("excludeBadQPLL",false);
42 
43  if (debug_>0)
44  std::cout <<"<HcalDigiMonitor> Digi shape ADC threshold set to: >" << shapeThresh_ <<" counts above nominal pedestal (3*10)"<< std::endl;
45 
46  // Specify which tests to run when looking for problem digis
47  digi_checkoccupancy_ = ps.getUntrackedParameter<bool>("checkForMissingDigis",false); // off by default -- checked by dead cell monitor
48  digi_checkcapid_ = ps.getUntrackedParameter<bool>("checkCapID",true);
49  digi_checkdigisize_ = ps.getUntrackedParameter<bool>("checkDigiSize",true);
50  digi_checkadcsum_ = ps.getUntrackedParameter<bool>("checkADCsum",true);
51  digi_checkdverr_ = ps.getUntrackedParameter<bool>("checkDVerr",true);
52  mindigisizeHBHE_ = ps.getUntrackedParameter<int>("minDigiSizeHBHE",1);
53  maxdigisizeHBHE_ = ps.getUntrackedParameter<int>("maxDigiSizeHBHE",10);
54  mindigisizeHO_ = ps.getUntrackedParameter<int>("minDigiSizeHO",1);
55  maxdigisizeHO_ = ps.getUntrackedParameter<int>("maxDigiSizeHO",10);
56  mindigisizeHF_ = ps.getUntrackedParameter<int>("minDigiSizeHF",1);
57  maxdigisizeHF_ = ps.getUntrackedParameter<int>("maxDigiSizeHF",10);
58 
59 
60  badChannelStatusMask_ = ps.getUntrackedParameter<int>("BadChannelStatusMask",
61  ps.getUntrackedParameter<int>("BadChannelStatusMask",
62  (1<<HcalChannelStatus::HcalCellDead))); // identify channel status values to mask
63  if (debug_>1)
64  {
65  std::cout <<"<HcalDigiMonitor> Checking for the following problems:"<<std::endl;
66  if (digi_checkcapid_) std::cout <<"\tChecking that cap ID rotation is correct;"<<std::endl;
67  if (digi_checkdigisize_)
68  {
69  std::cout <<"\tChecking that HBHE digi size is between ["<<mindigisizeHBHE_<<" - "<<maxdigisizeHBHE_<<"];"<<std::endl;
70  std::cout <<"\tChecking that HO digi size is between ["<<mindigisizeHO_<<" - "<<maxdigisizeHO_<<"];"<<std::endl;
71  std::cout <<"\tChecking that HF digi size is between ["<<mindigisizeHF_<<" - "<<maxdigisizeHF_<<"];"<<std::endl;
72  }
73  if (digi_checkadcsum_) std::cout <<"\tChecking that ADC sum of digi is greater than 0;"<<std::endl;
74  if (digi_checkdverr_) std::cout <<"\tChecking that data valid bit is true and digi error bit is false;\n"<<std::endl;
75  }
76 
77  shutOffOrbitTest_ = ps.getUntrackedParameter<bool>("shutOffOrbitTest",false);
78  DigiMonitor_ExpectedOrbitMessageTime_=ps.getUntrackedParameter<int>("ExpectedOrbitMessageTime",3559); // -1 means that orbit mismatches won't be checked
79 
83  HFP_shape=0;
84  HFM_shape=0;
85  setupDone_=false;
86 
87  // register for data access
88  tok_raw_ = consumes<FEDRawDataCollection>(FEDRawDataCollection_);
89  tok_hbhe_ = consumes<HBHEDigiCollection>(digiLabel_);
90  tok_ho_ = consumes<HODigiCollection>(digiLabel_);
91  tok_hf_ = consumes<HFDigiCollection>(digiLabel_);
92  tok_unpack_ = consumes<HcalUnpackerReport>(digiLabel_);
93  tok_trigger_ = consumes<edm::TriggerResults>(hltresultsLabel_);
94  tok_hfrec_ = consumes<HFRecHitCollection>(ps.getUntrackedParameter<edm::InputTag>("hfRechitLabel"));
95 
96  //set Token(-s)
97  dcsStatusToken_ = consumes<DcsStatusCollection>(std::string("scalersRawToDigi"));
98  FEDRawDataCollectionToken_ = consumes<FEDRawDataCollection>(FEDRawDataCollection_);
99 }
100 
101 // destructor
103 
104 // Checks capid rotation; returns false if no problems with rotation
105 static bool bitUpset(int last, int now){
106  if(last ==-1) return false;
107  int v = last+1;
108  if(v==4) v=0;
109  if(v==now) return false;
110  return true;
111 } // static bool bitUpset(...)
112 
113 /*void HcalDigiMonitor::cleanup()
114 {
115  // Need to add code to clear out subfolders as well?
116  if (debug_>0) std::cout <<"HcalDigiMonitor::cleanup()"<<std::endl;
117  if (!enableCleanup_) return;
118  if (dbe_)
119  {
120  // removeContents doesn't remove subdirectories
121  dbe_->setCurrentFolder(subdir_);
122  dbe_->removeContents();
123  dbe_->setCurrentFolder(subdir_+"digi_parameters"); dbe_->removeContents();
124  dbe_->setCurrentFolder(subdir_+"bad_digis/bad_digi_occupancy"); dbe_->removeContents();
125  dbe_->setCurrentFolder(subdir_+"bad_digis/1D_digi_plots"); dbe_->removeContents();
126  dbe_->setCurrentFolder(subdir_+"bad_digis/badcapID"); dbe_->removeContents();
127  dbe_->setCurrentFolder(subdir_+"bad_digis/data_invalid_error"); dbe_->removeContents();
128  dbe_->setCurrentFolder(subdir_+"bad_digis/bad_reportUnpackerErrors"); dbe_->removeContents();
129  dbe_->setCurrentFolder(subdir_+"bad_digis/baddigisize"); dbe_->removeContents();
130  dbe_->setCurrentFolder(subdir_+"digi_info"); dbe_->removeContents();
131  dbe_->setCurrentFolder(subdir_+"bad_digis/badfibBCNoff"); dbe_->removeContents();
132  dbe_->setCurrentFolder(subdir_+"good_digis/1D_digi_plots"); dbe_->removeContents();
133  dbe_->setCurrentFolder(subdir_+"good_digis/digi_occupancy"); dbe_->removeContents();
134  dbe_->setCurrentFolder(subdir_+"bad_digis/bad_digi_occupancy"); dbe_->removeContents();
135  dbe_->setCurrentFolder(subdir_+"bad_digis"); dbe_->removeContents();
136  dbe_->setCurrentFolder(subdir_+"good_digis/"); dbe_->removeContents();
137  dbe_->setCurrentFolder(subdir_+"digi_info/HB"); dbe_->removeContents();
138  dbe_->setCurrentFolder(subdir_+"digi_info/HE"); dbe_->removeContents();
139  dbe_->setCurrentFolder(subdir_+"digi_info/HO"); dbe_->removeContents();
140  dbe_->setCurrentFolder(subdir_+"digi_info/HF"); dbe_->removeContents();
141  dbe_->setCurrentFolder(subdir_+"LSvalues");
142  dbe_->removeContents();
143  } // if(dbe_)
144 
145 }*/ // void HcalDigiMonitor::cleanup();
146 
147 
149 {
150  // Anything to do here?
151 }
152 
154 {
155  if (debug_>0) std::cout <<"HcalDigiMonitor::endJob()"<<std::endl;
156  if (enableCleanup_) cleanup(); // when do we force cleanup?
157 }
158 
159 
161 {
162  if (setupDone_)
163  return;
164  setupDone_=true;
165  // Call base class setup
167 
168  /******* Set up all histograms ********/
169  if (debug_>1)
170  std::cout <<"<HcalDigiMonitor::setup> Setting up histograms"<<std::endl;
171 
172  std::ostringstream name;
174 
175  ib.setCurrentFolder(subdir_+"digi_parameters");
176  MonitorElement* ExpectedOrbit = ib.bookInt("ExpectedOrbitMessageTime");
178 
179  MonitorElement* shapeT = ib.bookInt("DigiShapeThresh");
180  shapeT->Fill(shapeThresh_);
181  MonitorElement* shapeTHB = ib.bookInt("DigiShapeThreshHB");
182  shapeTHB->Fill(shapeThreshHB_);
183  MonitorElement* shapeTHE = ib.bookInt("DigiShapeThreshHE");
184  shapeTHE->Fill(shapeThreshHE_);
185  MonitorElement* shapeTHO = ib.bookInt("DigiShapeThreshHO");
186  shapeTHO->Fill(shapeThreshHO_);
187  MonitorElement* shapeTHF = ib.bookInt("DigiShapeThreshHF");
188  shapeTHF->Fill(shapeThreshHF_);
189 
190  ib.setCurrentFolder(subdir_+"bad_digis/bad_digi_occupancy");
191  SetupEtaPhiHists(ib,DigiErrorsByDepth,"Bad Digi Map","");
192  ib.setCurrentFolder(subdir_+"bad_digis/1D_digi_plots");
193  ProblemsVsLB=ib.bookProfile("BadDigisVsLB","Number Bad Digis vs Luminosity block;Lumi block;# of Bad digis",
194  NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
195  ProblemsVsLB_HB=ib.bookProfile("HB Bad Quality Digis vs LB","HB Bad Quality Digis vs Luminosity Block",
196  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
197  100,0,10000);
198  ProblemsVsLB_HE=ib.bookProfile("HE Bad Quality Digis vs LB","HE Bad Quality Digis vs Luminosity Block",
199  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
200  100,0,10000);
201  ProblemsVsLB_HO=ib.bookProfile("HO Bad Quality Digis vs LB","HO Bad Quality Digis vs Luminosity Block",
202  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
203  100,0,10000);
204  ProblemsVsLB_HF=ib.bookProfile("HF Bad Quality Digis vs LB","HF Bad Quality Digis vs Luminosity Block",
205  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
206  100,0,10000);
207  ProblemsVsLB_HBHEHF=ib.bookProfile("HBHEHF Bad Quality Digis vs LB","HBHEHF Bad Quality Digis vs Luminosity Block",
208  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
209  100,0,10000);
210 
211  ProblemDigisInLastNLB_HBHEHF_alarm=ib.book1D("ProblemDigisInLastNLB_HBHEHF_alarm",
212  "Total Number of ProblemDigis HBHEHF in last 10 LS. Last bin contains OverFlow",
213  100,0,100);
214 
215 
216  if (makeDiagnostics_)
217  {
218  // by default, unpacked digis won't have these errors
219  ib.setCurrentFolder(subdir_+"diagnostics/bad_digis/badcapID");
220  SetupEtaPhiHists(ib,DigiErrorsBadCapID," Digis with Bad Cap ID Rotation", "");
221  ib.setCurrentFolder(subdir_+"diagnostics/bad_digis/data_invalid_error");
222  SetupEtaPhiHists(ib,DigiErrorsDVErr," Digis with Data Invalid or Error Bit Set", "");
223  }
224 
225  if (Online_)
226  {
227  // Special histograms for Pawel's timing study
228  ib.setCurrentFolder(subdir_+"HFTimingStudy");
229  HFtiming_etaProfile=ib.bookProfile("HFTiming_etaProfile","HFTiming Eta Profile;ieta;average time (time slice)",83,-41.5,41.5,200,0,10);
230  HFP_shape=ib.book1D("HFP_signal_shape","HFP signal shape",10,-0.5,9.5);
231  HFM_shape=ib.book1D("HFM_signal_shape","HFM signal shape",10,-0.5,9.5);
232  ib.setCurrentFolder(subdir_+"HFTimingStudy/sumplots");
233  HFtiming_totaltime2D=ib.book2D("HFTiming_Total_Time","HFTiming Total Time",83,-41.5,41.5,72,0.5,72.5);
234  HFtiming_occupancy2D=ib.book2D("HFTiming_Occupancy","HFTiming Occupancy",83,-41.5,41.5,72,0.5,72.5);
235  }
236 
237  ib.setCurrentFolder(subdir_+"bad_digis/bad_reportUnpackerErrors");
238  SetupEtaPhiHists(ib,DigiErrorsUnpacker," Bad Unpacker Digis", "");
239 
240  ib.setCurrentFolder(subdir_+"bad_digis/baddigisize");
241  SetupEtaPhiHists(ib,DigiErrorsBadDigiSize," Digis with Bad Size", "");
242 
243  ib.setCurrentFolder(subdir_+"digi_info");
244 
245  h_valid_digis=ib.book1D("ValidEvents","Events with minimum number of valid digis",2,-0.5,1.5);
246  h_valid_digis->setBinLabel(1,"Valid");
247  h_valid_digis->setBinLabel(2,"Invalid");
248 
249  h_invalid_orbitnumMod103=ib.book1D("InvalidDigiEvents_ORN","Orbit Number (mod 103) for Events with Many Unpacker Errors",103,-0.5,102.5);
250  h_invalid_bcn=ib.book1D("InvalidDigiEvents_BCN","Bunch Crossing Number fo Events with Many Unpacker Errors",3464,-0.5,3563.5);
251 
252  DigiSize = ib.book2D("Digi Size", "Digi Size",4,0,4,20,-0.5,19.5);
253  DigiSize->setBinLabel(1,"HB",1);
254  DigiSize->setBinLabel(2,"HE",1);
255  DigiSize->setBinLabel(3,"HO",1);
256  DigiSize->setBinLabel(4,"HF",1);
257  DigiSize->setAxisTitle("Subdetector",1);
258  DigiSize->setAxisTitle("Digi Size",2);
259 
260  DigiExpectedSize = ib.book2D("Digi Expected Size", "Digi Expected Size",3,0,3,20,-0.5,19.5);
261  DigiExpectedSize->setBinLabel(1,"HBHE",1);
262  DigiExpectedSize->setBinLabel(2,"HO",1);
263  DigiExpectedSize->setBinLabel(3,"HF",1);
264  DigiExpectedSize->setAxisTitle("Subdetector",1);
265  DigiExpectedSize->setAxisTitle("Digi Expected Size from HTR",2);
266 
267  ib.setCurrentFolder(subdir_+"bad_digis/badfibBCNoff");
268  SetupEtaPhiHists(ib,DigiErrorsBadFibBCNOff," Digis with non-zero Fiber Orbit Msg Idle BCN Offsets", "");
269 
270  ib.setCurrentFolder(subdir_+"good_digis/1D_digi_plots");
271  HBocc_vs_LB=ib.bookProfile("HBoccVsLB","HB digi occupancy vs Luminosity Block;Lumi block;# of Good digis",
272  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
273  0,2600);
274  HEocc_vs_LB=ib.bookProfile("HEoccVsLB","HE digi occupancy vs Luminosity Block;Lumi block;# of Good digis",
275  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
276  0,2600);
277  HOocc_vs_LB=ib.bookProfile("HOoccVsLB","HO digi occupancy vs Luminosity Block;Lumi block;# of Good digis",
278  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
279  0,2200);
280  HFocc_vs_LB=ib.bookProfile("HFoccVsLB","HF digi occupancy vs Luminosity Block;Lumi block;# of Good digis",
281  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
282  0,1800);
283 
284  ib.setCurrentFolder(subdir_+"good_digis/digi_occupancy");
285  SetupEtaPhiHists(ib,DigiOccupancyByDepth," Digi Eta-Phi Occupancy Map","");
286  DigiOccupancyPhi= ib.book1D("Digi Phi Occupancy Map",
287  "Digi Phi Occupancy Map;i#phi;# of Events",
288  72,0.5,72.5);
289  DigiOccupancyEta= ib.book1D("Digi Eta Occupancy Map",
290  "Digi Eta Occupancy Map;i#eta;# of Events",
291  83,-41.5,41.5);
292  DigiOccupancyVME = ib.book2D("Digi VME Occupancy Map",
293  "Digi VME Occupancy Map;HTR Slot;VME Crate Id",
294  40,-0.25,19.75,36,-0.5,35.5);
295 
296  DigiOccupancySpigot = ib.book2D("Digi Spigot Occupancy Map",
297  "Digi Spigot Occupancy Map;Spigot;DCC Id",
299  36,-0.5,35.5);
300 
301  ib.setCurrentFolder(subdir_+"bad_digis/bad_digi_occupancy");
302  DigiErrorVME = ib.book2D("Digi VME Error Map",
303  "Digi VME Error Map;HTR Slot;VME Crate Id",
304  40,-0.25,19.75,18,-0.5,17.5);
305 
306  DigiErrorSpigot = ib.book2D("Digi Spigot Error Map",
307  "Digi Spigot Error Map;Spigot;DCC Id",
309  36,-0.5,35.5);
310 
311  ib.setCurrentFolder(subdir_+"bad_digis");
312  int nbins = sizeof(bins_cellcount_new)/sizeof(float)-1;
313 
314  DigiBQ = ib.book1D("NumBadQualDigis","Number Bad Qual Digis within Digi Collection",nbins, bins_cellcount_new);
315 
316  nbins=sizeof(bins_fraccount_new)/sizeof(float)-1;
317 
318  DigiBQFrac = ib.book1D("Bad Digi Fraction","Bad Digi Fraction;Bad Quality Digi Fraction for digis in collection; # of Events",
319  nbins, bins_fraccount_new);
320 
321  nbins = sizeof(bins_cellcount_new)/sizeof(float)-1;
322  DigiUnpackerErrorCount = ib.book1D("Unpacker Error Count", "Number of Bad Digis from Unpacker; Bad Unpacker Digis; # of Events",nbins, bins_cellcount_new);
323 
324  nbins=sizeof(bins_fraccount_new)/sizeof(float)-1;
325  DigiUnpackerErrorFrac = ib.book1D("Unpacker Bad Digi Fraction",
326  "Bad Digis From Unpacker/ (Bad Digis From Unpacker + Good Digis); Bad Unpacker Fraction; # of Events",
327  nbins,bins_fraccount_new);
328 
329  ib.setCurrentFolder(subdir_+"good_digis/");
330  DigiNum = ib.book1D("NumGoodDigis","Number of Digis;# of Good Digis;# of Events",DIGI_NUM+1,-0.5,DIGI_NUM+1-0.5);
331 
332  setupSubdetHists(ib,hbHists,"HB");
333  setupSubdetHists(ib,heHists,"HE");
334  setupSubdetHists(ib,hoHists,"HO");
335  setupSubdetHists(ib,hfHists,"HF");
336 
337  this->reset();
338  return;
339 } // void HcalDigiMonitor::setup()
340 
342 {
344  if (mergeRuns_ && tevt_>0) return; // don't reset counters if merging runs
345 
346  if (debug_>1) std::cout <<"\t<HcalDigiMonitor::bookHistograms> Getting conditions from DB!"<<std::endl;
347  c.get<HcalDbRecord>().get(conditions_);
348 
349  // Get all pedestals by Cap ID
351  c.get<HcalChannelQualityRcd>().get("withTopo",p);
352  const HcalChannelQuality *chanquality= p.product();
353  std::vector<DetId> mydetids = chanquality->getAllChannels();
354  PedestalsByCapId_.clear();
355 
356  for (std::vector<DetId>::const_iterator chan = mydetids.begin();chan!=mydetids.end();++chan)
357  {
358  if (chan->det()!=DetId::Hcal) continue; // not hcal
359  std::vector <double> peds; // could be ints, right?
360  peds.clear();
361  HcalCalibrations calibs=conditions_->getHcalCalibrations(*chan);
362  const HcalQIECoder* channelCoder = conditions_->getHcalCoder(*chan);
363  const HcalQIEShape* shape = conditions_->getHcalShape(channelCoder);
364  //double total=0; // use this is we want to calculate average pedestal value
365  for (int capid=0;capid<4;++capid)
366  {
367  // temp_ADC should be an int, right?
368  double temp_ADC=channelCoder->adc(*shape,(float)calibs.pedestal(capid),capid);
369  peds.push_back(temp_ADC);
370  //total=total+temp_ADC;
371  }
372  //for (int capid=0;capid<4;++capid) peds.push_back(total/4.); // use this if we just want to use average value
373  PedestalsByCapId_[*chan]=peds;
374  } // loop on DetIds
375 
376  if (tevt_==0) this->setup(ib); // create all histograms; not necessary if merging runs together
377  if (mergeRuns_==false) this->reset(); // call reset at start of all runs
378 
379  // Get known dead cells for this run
380  KnownBadCells_.clear();
381  if (badChannelStatusMask_>0)
382  {
384  c.get<HcalChannelQualityRcd>().get("withTopo",p);
385  const HcalChannelQuality* chanquality= p.product();
386  std::vector<DetId> mydetids = chanquality->getAllChannels();
387  for (std::vector<DetId>::const_iterator i = mydetids.begin();
388  i!=mydetids.end();
389  ++i)
390  {
391  if (i->det()!=DetId::Hcal) continue; // not an hcal cell
392  HcalDetId id=HcalDetId(*i);
393  int status=(chanquality->getValues(id))->getValue();
394  if ((status & badChannelStatusMask_))
395  {
396  KnownBadCells_[id.rawId()]=status;
397  }
398  }
399  } // if (badChannelStatusMask_>0)
400 
401 } // void HcalDigiMonitor::bookHistograms()
402 
403 
405 {
406  std::stringstream name;
407  int nChan=0;
408  if (subdet=="HB" || subdet=="HE") nChan=2592;
409  else if (subdet == "HO") nChan=2160;
410  else if (subdet == "HF") nChan=1728;
411 
412  ib.setCurrentFolder(subdir_+"digi_info/"+subdet);
413  hist.shape = ib.book1D(subdet+" Digi Shape",subdet+" Digi Shape;Time Slice",10,-0.5,9.5);
414  hist.shapeThresh = ib.book1D(subdet+" Digi Shape - over thresh",
415  subdet+" Digi Shape - over thresh passing trigger and HF HT cuts;Time slice",
416  10,-0.5,9.5);
417  hist.ThreshCount = ib.book1D(subdet+" Total Digis Over Threshold",
418  subdet+" Total Digis Over Threshold",
419  1,-0.5,0.5);
420  // Create plots of sums of adjacent time slices
421  for (int ts=0;ts<9;++ts)
422  {
423  name<<subdet<<" Plus Time Slices "<<ts<<" and "<<ts+1;
424  hist.TS_sum_plus.push_back(ib.book1D(name.str().c_str(),name.str().c_str(),50, 0., 50.));
425  name.str("");
426  name<<subdet<<" Minus Time Slices "<<ts<<" and "<<ts+1;
427  hist.TS_sum_minus.push_back(ib.book1D(name.str().c_str(),name.str().c_str(),50, 0., 50.));
428  name.str("");
429  }
430  hist.presample= ib.book1D(subdet+" Digi Presamples",subdet+" Digi Presamples",50,-0.5,49.5);
431  hist.BQ = ib.book1D(subdet+" Bad Quality Digis",subdet+" Bad Quality Digis",nChan+1,-0.5,nChan+0.5);
432  //(hist.BQ->getTH1F())->LabelsOption("v");
433  hist.BQFrac = ib.book1D(subdet+" Bad Quality Digi Fraction",subdet+" Bad Quality Digi Fraction",DIGI_BQ_FRAC_NBINS,(0-0.5/(DIGI_BQ_FRAC_NBINS-1)),1+0.5/(DIGI_BQ_FRAC_NBINS-1));
434  hist.DigiFirstCapID = ib.book1D(subdet+" Capid 1st Time Slice",subdet+" Capid for 1st Time Slice;CapId (T0)- 1st CapId (T0);# of Events",7,-3.5,3.5);
435 
436  hist.DVerr = ib.book1D(subdet+" Data Valid Err Bits",subdet+" QIE Data Valid Err Bits",4,-0.5,3.5);
437  hist.DVerr ->setBinLabel(1,"Err=0, DV=0",1);
438  hist.DVerr ->setBinLabel(2,"Err=0, DV=1",1);
439  hist.DVerr ->setBinLabel(3,"Err=1, DV=0",1);
440  hist.DVerr ->setBinLabel(4,"Err=1, DV=1",1);
441  hist.CapID = ib.book1D(subdet+" CapID",subdet+" CapID",4,-0.5,3.5);
442  hist.ADC = ib.book1D(subdet+" ADC count per time slice",subdet+" ADC count per time slice",200,-0.5,199.5);
443  hist.ADCsum = ib.book1D(subdet+" ADC sum", subdet+" ADC sum",200,-0.5,199.5);
444  hist.fibBCNOff = ib.book1D(subdet+" Fiber Orbit Message Idle BCN Offset", subdet+" Fiber Orbit Message Idle BCN Offset;Offset from Expected",
445  15, -7.5, 7.5);
446 }
447 
449 {
451 
452  if (!IsAllowedCalibType()) return;
453  if (LumiInOrder(e.luminosityBlock())==false) return;
454 
455  // Get HLT trigger information for HF timing study
456  passedMinBiasHLT_=false;
457 
459  // check if detectors whether they were ON
461  e.getByToken(dcsStatusToken_, dcsStatus);
462 
463  if (dcsStatus.isValid() && dcsStatus->size() != 0) {
464  if ((*dcsStatus)[0].ready(DcsStatus::HBHEa) &&
465  (*dcsStatus)[0].ready(DcsStatus::HBHEb) &&
466  (*dcsStatus)[0].ready(DcsStatus::HBHEc)) {
467  hbhedcsON = true;
468  if (debug_) std::cout << "hbhe on" << std::endl;
469  }
470  else hbhedcsON = false;
471 
472  if ((*dcsStatus)[0].ready(DcsStatus::HF)) {
473  hfdcsON = true;
474  if (debug_) std::cout << "hf on" << std::endl;
475  }
476  else hfdcsON = false;
477  }
479 
481  if (!(e.getByToken(tok_trigger_,hltRes))) {
482  if (debug_>0) edm::LogWarning("HcalDigiMonitor")<<" Could not get HLT results with tag "<<hltresultsLabel_<<std::endl;
483  } else {
484  const edm::TriggerNames & triggerNames = e.triggerNames(*hltRes);
485  const unsigned int nTrig(triggerNames.size());
486  for (unsigned int i=0;i<nTrig;++i){
487  // repeat for minbias triggers
488  for (unsigned int k=0;k<MinBiasHLTBits_.size();++k) {
489  // if (triggerNames.triggerName(i)==MinBiasHLTBits_[k] && hltRes->accept(i))
490  if (triggerNames.triggerName(i).find(MinBiasHLTBits_[k])!=std::string::npos && hltRes->accept(i)) {
491  passedMinBiasHLT_=true;
492  break;
493  }
494  }
495  }
496  } //else
497 
499  s.get<HcalRecNumberingRecord>().get(topo);
500 
501  // Now get collections we need
502  HT_HFP_=0;
503  HT_HFM_=0;
504  // bool rechitsFound=false;
506  if (e.getByToken(tok_hfrec_,hf_rechit)) {
507  // rechitsFound=true;
508  for (HFRecHitCollection::const_iterator HF=hf_rechit->begin();HF!=hf_rechit->end();++HF) {
509  float en=HF->energy();
510  int ieta=HF->id().ieta();
511  // ieta for HF starts at 29, so subtract away 29 when computing fEta
512  std::pair<double,double> etas = topo->etaRange(HF->id().subdet(),abs(ieta));
513  double fEta=fabs(0.5*(etas.first+etas.second));
514  ieta>0 ? HT_HFP_+=en/cosh(fEta) : HT_HFM_+=en/cosh(fEta);
515  }
516  } else {
517  // if no rechits found, form above-threshold plots based only on digi comparison to ADC threshold
518  HT_HFP_=999;
519  HT_HFM_=999;
520  }
521 
522  // try to get digis
526 
527  if (!(e.getByToken(tok_hbhe_,hbhe_digi))) {
528  edm::LogWarning("HcalDigiMonitor")<< digiLabel_<<" hbhe_digi not available";
529  return;
530  }
531 
532  if (!(e.getByToken(tok_hf_,hf_digi))) {
533  edm::LogWarning("HcalDigiMonitor")<< digiLabel_<<" hf_digi not available";
534  return;
535  }
536  if (!(e.getByToken(tok_ho_,ho_digi))) {
537  edm::LogWarning("HcalDigiMonitor")<< digiLabel_<<" ho_digi not available";
538  return;
539  }
541  if (!(e.getByToken(tok_unpack_,report))) {
542  edm::LogWarning("HcalDigiMonitor")<< digiLabel_<<" unpacker report not available";
543  return;
544  }
545  // try to get Raw Data
547  if ( !(e.getByToken(FEDRawDataCollectionToken_, rawraw))) {
548  edm::LogWarning("HcalRawDataMonitor")<<" raw data with label "<<FEDRawDataCollection_<<" not available";
549  return;
550  }
551 
552  // get the DCC header & trailer (or bail out)
553  // this needs to be done better, for now basically getting only one number per HBHE/HO/HF
554  // will create a map (dccid, spigot) -> DetID to be used in process_Digi later
555  for (int i=FEDNumbering::MINHCALFEDID;
557  // Skipping uHBHE FEDs
558  if (i>FEDNumbering::MAXHCALFEDID && i<1118)
559  continue;
560  const FEDRawData& fed = rawraw->FEDData(i);
561  if (fed.size()<12) continue; //At least the size of headers and trailers of a DCC.
562 
563  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fed.data());
564  if(!dccHeader) return;
565  if (debug_>0) std::cout << "### Processing FED: " << i << std::endl;
566 
567  // For uTCA spigos are useless => by default we have digisize = 4
568  // As of 20.05.2015
569  // HF = 2
570  if ((i>=1118 && i<=1122) ||
571  (i>=718 && i<=723)) {
572  mindigisizeHF_ = 4;
573  maxdigisizeHF_ = 4;
574  DigiExpectedSize->Fill(2, 4);
575  continue;
576  }
577 
578  // VME readout contains Number of Time Samples per Digi
579  // uTCA doesn't!
580  HcalHTRData htr;
581  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
582  if (!dccHeader->getSpigotPresent(spigot)) continue;
583 
584  // Load the given decoder with the pointer and length from this spigot.
585  // i.e. initialize htr, within dcc raw data size.
586  dccHeader->getSpigotData(spigot, htr, fed.size());
587 
588  int NTS = htr.getNDD(); //number time slices, in precision channels
589  if (debug_>0)
590  std::cout << "### Number of TS=" << NTS << std::endl;
591  if (NTS==0) continue; // no DAQ data in this HTR (fully zero-suppressed)
592  int dccid=dccHeader->getSourceId();
593 
594  if(dccid==720 && (spigot==12 || spigot==13)) continue; // calibration HTR
595  if(dccid==722 && (spigot==12 || spigot==13)) continue; // ZDC HTR
596 
597  int subdet = -1;
598 
599  if(dccid >= 700 && dccid<=717) { subdet = 0; mindigisizeHBHE_ = NTS; maxdigisizeHBHE_ = NTS; } // HBHE
600  if((dccid >= 1118 && dccid<=1122) ||
601  (dccid>=718 && dccid<=723))
602  { subdet = 2; mindigisizeHF_ = NTS; maxdigisizeHF_ = NTS; } // HF
603  if(dccid >= 724 && dccid<=731) { subdet = 1; mindigisizeHO_ = NTS; maxdigisizeHO_ = NTS; } // HO
604 
605  DigiExpectedSize->Fill(subdet,int(NTS),1);
606  }
607  }
608 
609  // all objects grabbed; event is good
610  if (debug_>1) std::cout <<"\t<HcalDigiMonitor::analyze> Processing good event! event # = "<<ievt_<<std::endl;
611 
612  // HcalBaseDQMonitor::analyze(e,s); // base class increments ievt_, etc. counters
613 
614  // Digi collection was grabbed successfully; process the Event
615  processEvent(*hbhe_digi, *ho_digi, *hf_digi, *conditions_,
616  *report, e.orbitNumber(),e.bunchCrossing());
617 
618 } //void HcalDigiMonitor::analyze(...)
619 
621  const HODigiCollection& ho,
622  const HFDigiCollection& hf,
623  const HcalDbService& cond,
624  const HcalUnpackerReport& report,
625  int orN, int bcN)
626 {
627 
628  // Skip events in which minimal good digis found -- still getting some strange (calib?) events through DQM
629 
631 
632  unsigned int allgooddigis= hbhe.size()+ho.size()+hf.size();
633 
634  // new data format in HCAL marks idle messages in the abort gap as bad capid.
635  // ignore this events. Also, sometimes there are many corrupted digis left
636  // from the QIE reset: ignore if in abort gap
637  if(bcN>=3446 && bcN<=3564)
638  if( (report.badQualityDigis()>100 && hbhe.size()==0) || (report.badQualityDigis()>1000) )
639  return;
640 
641  // bad threshold: ignore events in which bad outnumber good by more than 100:1
642  // (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)
643  if ((allgooddigis==0) ||
644  (1.*report.badQualityDigis()>100*allgooddigis))
645  {
646  h_valid_digis->Fill(1);
647  if (bcN>-1)
648  h_invalid_bcn->Fill(bcN);
649  if (orN>-1)
650  h_invalid_orbitnumMod103->Fill(orN%103);
651 
652  return;
653  }
654 
655  h_valid_digis->Fill(0);
656 
657  // hbHists.count_bad=0;
658  // hbHists.count_good=0;
659  // heHists.count_bad=0;
660  // heHists.count_good=0;
661  // hoHists.count_bad=0;
662  // hoHists.count_good=0;
663  // hfHists.count_bad=0;
664  // hfHists.count_good=0;
665 
666  // int HO0bad=0;
667  // int HO12bad=0;
668  // int HFlumibad=0;
669 
670  // Check unpacker report for bad digis
671 
672  typedef std::vector<DetId> DetIdVector;
673 
674  for ( DetIdVector::const_iterator baddigi_iter=report.bad_quality_begin();
675  baddigi_iter != report.bad_quality_end();
676  ++baddigi_iter)
677  {
678  HcalDetId id(baddigi_iter->rawId());
679  int rDepth = id.depth();
680  int rPhi = id.iphi();
681  int rEta = id.ieta();
682  int binEta = CalcEtaBin(id.subdet(), rEta, rDepth); // why is this here?
683 
684  if (binEta < 85 && binEta >= 0
685  && (rPhi-1) >= 0 && (rPhi-1)<72
686  && (rDepth-1) >= 0 && (rDepth-1)<4)
687  if(uniqcounter2[binEta][rPhi-1][rDepth-1]<1)
688  {
689  if (id.subdet()==HcalBarrel) ++hbHists.count_bad;
690  else if (id.subdet()==HcalEndcap) ++heHists.count_bad;
691  else if (id.subdet()==HcalForward)
692  {
693  ++hfHists.count_bad;
694  if (rDepth==1 && (abs(rEta)==33 || abs(rEta)==34)) ++HFlumibad;
695  else if (rDepth==2 && (abs(rEta)==35 || abs(rEta)==36)) ++HFlumibad;
696  }
697  else if (id.subdet()==HcalOuter)
698  {
699  // Mark HORing+/-2 channels as present, HO/YB+/-2 has HV off (at 100V).
700  if (excludeHORing2_==true && rDepth==4)
701  if (abs(rEta)>=11 && abs(rEta)<=15 && !isSiPM(rEta,rPhi,rDepth)) continue;
702 
703  if (excludeHO1P02_==true)
704  if( (rEta>4 && rEta<10) && (rPhi<=10 || rPhi>70) ) continue;
705 
706  if (KnownBadCells_.find(id)!=KnownBadCells_.end()) continue;
707 
708  ++hoHists.count_bad;
709  if (abs(rEta)<5) ++HO0bad;
710  else ++HO12bad;
711  }
712  else
713  continue; // skip anything that isn't HB, HE, HO, HF
714  // extra protection against nonsensical values -- prevents occasional crashes
715 
716  ++badunpackerreport[binEta][rPhi-1][rDepth-1];
717  ++baddigis[binEta][rPhi-1][rDepth-1];
718 
719  // QPLL unlocking channels, have to ignore unpacker errors (fix requires opening CMS)
720  bool HEM15A = true ? (id.subdet()==HcalEndcap && (rPhi>56 && rPhi<59 && rEta<0)) : false;
721  bool HEM15B = true ? (id.subdet()==HcalEndcap && (rPhi>54 && rPhi<57 && rEta<0)) : false;
722  bool HBP14A = true ? (id.subdet()==HcalBarrel && (rPhi>50 && rPhi<53 && rEta>0)) : false;
723 
724  if(excludeBadQPLLs_ && rDepth==1)
725  if( HEM15A || HEM15B || HBP14A )
726  ++knownbadQPLLs;
727 
728  uniqcounter2[binEta][rPhi-1][rDepth-1]++;
729  }
730  }
732 
733  int firsthbcap=-1;
734  int firsthecap=-1;
735  int firsthocap=-1;
736  int firsthfcap=-1;
737 
738  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); ++j)
739  {
740  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
741 
742  if (digi.id().subdet()==HcalBarrel)
743  {
744  if (!HBpresent_) continue;
745  if (KnownBadCells_.find(digi.id())!=KnownBadCells_.end()) continue;
746 
747  process_Digi(digi, hbHists, firsthbcap);
748 
749  }
750  else if (digi.id().subdet()==HcalEndcap)
751  {
752  if (!HEpresent_) continue;
753  process_Digi(digi, heHists,firsthecap);
754  }
755  }
756 
757  // // Fill good digis vs lumi block; also fill bad errors?
760 
761  // Calculate number of bad quality cells and bad quality fraction
763  {
765  if (counter<DIGI_SUBDET_NUM)
768  if (counter2<DIGI_SUBDET_NUM) ++hbHists.count_BQFrac[(int)counter2];
769  }
770 
772  {
774  if (counter<DIGI_SUBDET_NUM)
777  if (counter2<DIGI_SUBDET_NUM) ++heHists.count_BQFrac[int(counter2)];
778  }
779 
781  if (HOpresent_)
782  {
783  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); ++j)
784  {
785  const HODataFrame digi = (const HODataFrame)(*j);
786  // Mark HORing+/-2 channels as present, HO/YB+/-2 has HV off (at 100V).
787  if (excludeHORing2_==true && digi.id().depth()==4)
788  if (abs(digi.id().ieta())>=11 && abs(digi.id().ieta())<=15 &&
789  !isSiPM(digi.id().ieta(),digi.id().iphi(),digi.id().depth())) continue;
790 
791  if (excludeHO1P02_==true)
792  if( (digi.id().ieta()>4 && digi.id().ieta()<10)
793  && (digi.id().iphi()<=10 || digi.id().iphi()>70) ) continue;
794 
795  if (KnownBadCells_.find(digi.id())!=KnownBadCells_.end()) continue;
796 
797  process_Digi(digi, hoHists, firsthocap);
798  } // for (HODigiCollection)
799 
800  if (hoHists.count_bad>0 || hoHists.count_good>0)
801  {
803  if (counter<DIGI_SUBDET_NUM)
805 
807  if (counter2<DIGI_SUBDET_NUM) ++hoHists.count_BQFrac[int(counter2)];
808  }
810  } // if (HOpresent_)
811 
813  if (HFpresent_)
814  {
815  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); ++j)
816  {
817  const HFDataFrame digi = (const HFDataFrame)(*j);
818  process_Digi(digi, hfHists, firsthfcap);
819  } // for (HFDigiCollection)
820 
821  if (hfHists.count_bad>0 || hfHists.count_good>0)
822  {
824  if (counter<DIGI_SUBDET_NUM)
827  if (counter2<DIGI_SUBDET_NUM) ++hfHists.count_BQFrac[int(counter2)];
828  }
830  } // if (HFpresent_)
831 
832  // This only counts digis that are present but bad somehow; it does not count digis that are missing
835 
836  if (count_good<DIGI_NUM)
837  ++diginum[count_good];
838 
839  // Fill bad quality histograms
840  DigiUnpackerErrorFrac->Fill(1.*report.badQualityDigis()/(report.badQualityDigis()+count_good));
841  DigiBQ->Fill(count_bad);
842  if (count_bad>0 || count_good>0)
843  DigiBQFrac->Fill(1.*count_bad/(count_bad+count_good));
844 
845  // Call 'update' on all histograms so that they update in online DQM
850 
851  // Now update global (non-subdetector-specific) histograms
852  DigiNum->update();
853  DigiErrorVME->update();
855  DigiBQ->update();
856  DigiBQFrac->update();
859 
860  // Update eta-phi hists
861  for (unsigned int zz=0;zz<DigiErrorOccupancyByDepth.depth.size();++zz)
862  DigiErrorOccupancyByDepth.depth[zz]->update();
863  for (unsigned int zz=0;zz<DigiErrorsByDepth.depth.size();++zz)
864  DigiErrorsByDepth.depth[zz]->update();
865  for (unsigned int zz=0;zz<DigiErrorsBadCapID.depth.size();++zz)
866  DigiErrorsBadCapID.depth[zz]->update();
867  for (unsigned int zz=0;zz<DigiErrorsDVErr.depth.size();++zz)
868  DigiErrorsDVErr.depth[zz]->update();
869  for (unsigned int zz=0;zz<DigiErrorsBadDigiSize.depth.size();++zz)
870  DigiErrorsBadDigiSize.depth[zz]->update();
871  for (unsigned int zz=0;zz<DigiErrorsBadADCSum.depth.size();++zz)
872  DigiErrorsBadADCSum.depth[zz]->update();
873  for (unsigned int zz=0;zz<DigiErrorsUnpacker.depth.size();++zz)
874  DigiErrorsUnpacker.depth[zz]->update();
875  for (unsigned int zz=0;zz<DigiErrorsBadFibBCNOff.depth.size();++zz)
876  DigiErrorsBadFibBCNOff.depth[zz]->update();
877 
882  DigiSize->update();
884 
885  // // Fill problems vs. lumi block plots
886  // ProblemsVsLB->Fill(currentLS,count_bad);
887  // ProblemsVsLB_HB->Fill(currentLS,hbHists.count_bad);
888  // ProblemsVsLB_HE->Fill(currentLS,heHists.count_bad);
889  // ProblemsVsLB_HO->Fill(currentLS,hoHists.count_bad);
890  // ProblemsVsLB_HF->Fill(currentLS,hfHists.count_bad);
891  // ProblemsVsLB_HBHEHF->Fill(currentLS,hbHists.count_bad+heHists.count_bad+hfHists.count_bad);
892 
893  // // Fill the number of problem digis in each channel
894  // ProblemsCurrentLB->Fill(-1,-1,1); // event counter
895  // ProblemsCurrentLB->Fill(0,0,hbHists.count_bad);
896  // ProblemsCurrentLB->Fill(1,0,heHists.count_bad);
897  // ProblemsCurrentLB->Fill(2,0,hoHists.count_bad);
898  // ProblemsCurrentLB->Fill(3,0,hfHists.count_bad);
899  // ProblemsCurrentLB->Fill(4,0,HO0bad);
900  // ProblemsCurrentLB->Fill(5,0,HO12bad);
901  // ProblemsCurrentLB->Fill(6,0,HFlumibad);
902 
903  // Call fill method every checkNevents
904  //fill_Nevents();
905 
906  return;
907 } // void HcalDigiMonitor::processEvent(...)
908 
909 
910 
911 template <class DIGI>
912 int HcalDigiMonitor::process_Digi(DIGI& digi, DigiHists& h, int& firstcap)
913 {
914  int err=0x0;
915  bool bitUp = false;
916  int ADCcount=0;
917 
918  int shapeThresh=0;
919 
920  int mindigisize=1;
921  int maxdigisize=10;
922 
923  if (digi.id().subdet()==HcalBarrel)
924  {
925  shapeThresh=shapeThreshHB_;
926  mindigisize=mindigisizeHBHE_;
927  maxdigisize=maxdigisizeHBHE_;
928  }
929  else if (digi.id().subdet()==HcalEndcap)
930  {
931  shapeThresh=shapeThreshHE_;
932  mindigisize=mindigisizeHBHE_;
933  maxdigisize=maxdigisizeHBHE_;
934  }
935  else if (digi.id().subdet()==HcalOuter)
936  {
937  shapeThresh=shapeThreshHO_;
938  mindigisize=mindigisizeHO_;
939  maxdigisize=maxdigisizeHO_;
940  }
941  else if (digi.id().subdet()==HcalForward)
942  {
943  shapeThresh=shapeThreshHF_;
944  mindigisize=mindigisizeHF_;
945  maxdigisize=maxdigisizeHF_;
946  }
947  int iEta = digi.id().ieta();
948  int iPhi = digi.id().iphi();
949  int iDepth = digi.id().depth();
950  int calcEta = CalcEtaBin(digi.id().subdet(),iEta,iDepth);
951 
952  // Check that digi size is correct
953  if (digi.size()<mindigisize || digi.size()>maxdigisize)
954  {
955  if (digi_checkdigisize_) err|=0x1;
956  ++baddigisize[calcEta][iPhi-1][iDepth-1];
957  }
958  // Check digi size; if > 20, increment highest bin of digisize array
959  if (digi.size()<20)
960  ++digisize[static_cast<int>(digi.size())][digi.id().subdet()-1];
961  else
962  ++digisize[19][digi.id().subdet()-1];
963 
964  // loop over time slices of digi to check capID and errors
965  ++h.count_presample[digi.presamples()];
966 
967  // Check CapID rotation
968  if (firstcap==-1) firstcap = digi.sample(0).capid();
969  int capdif = digi.sample(0).capid() - firstcap;
970  //capdif = capdif%3 - capdif/3; // unnecessary?
971  // capdif should run from -3 to +3
972  if (capdif >-4 && capdif<4)
973  ++h.capIDdiff[capdif+3];
974  else
975  ++h.capIDdiff[7];
976 
977  int last=-1;
978 
979  int offset = digi.fiberIdleOffset();
980 
981  // Only count BCN offset errors if ExpectedOrbitMessage Time is >-1
982  // For offline (and thus cfg default), this won't be checked, since
983  // we can't keep up to date with changes.
984  if (offset != -1000 && DigiMonitor_ExpectedOrbitMessageTime_>-1)
985  {
986  // increment counters only for non-zero offsets?
987  ++h.fibbcnoff[offset + 7];
988  if (offset != 0)
989  {
990  ++badFibBCNOff[calcEta][iPhi-1][iDepth-1];
991  if (shutOffOrbitTest_ == false) err |= 0xF; // not an error if test turned off
992  }
993  }
994 
995  int tssum=0;
996 
997  bool digi_error=false;
998 
999  const int DigiSize=digi.size();
1000  for (int i=0;i<10;++i) pedSubtractedADC_[i]=0;
1001  const int pedSubADCsize=sizeof(pedSubtractedADC_)/sizeof(double);
1002 
1003  std::map<HcalDetId, std::vector<double> >::iterator foundID = PedestalsByCapId_.find(digi.id());
1004  for (int i=0;i<DigiSize;++i)
1005  {
1006  int thisCapid = digi.sample(i).capid();
1007  if (thisCapid>=0 && thisCapid<4) ++h.capid[thisCapid];
1008 
1009  if (makeDiagnostics_)
1010  {
1011  if(bitUpset(last,thisCapid)) bitUp=true; // checking capID rotation
1012  last = thisCapid;
1013  // Check for digi error bits
1014  if (digi_checkdverr_)
1015  {
1016  if(digi.sample(i).er()) err=(err|0x2);
1017  if(!digi.sample(i).dv()) err=(err|0x2);
1018  }
1019  if ((digi_error==false) && (digi.sample(i).er() || !digi.sample(i).dv()))
1020  {
1021  ++digierrorsdverr[calcEta][iPhi-1][iDepth-1];
1022  digi_error=true; // only count 1 error per digi in this plot
1023  }
1024  ++h.dverr[static_cast<int>(2*digi.sample(i).er()+digi.sample(i).dv())];
1025  } // if (makeDiagnostics_)
1026 
1027  h.count_shape[i]+=digi.sample(i).adc();
1028 
1029  // Calculate ADC sum of adjacent samples -- still necessary?
1030  if (i==digi.size()-1) continue;
1031  tssum= digi.sample(i).adc()+digi.sample(i+1).adc();
1032  if (tssum<50 && tssum>=0)
1033  {
1034  if (iEta>0)
1035  ++h.tssumplus[tssum][i];
1036  else
1037  ++h.tssumminus[tssum][i];
1038  }
1039 
1040  if (digi.sample(i).adc()<0) ++h.adc[0];
1041  else if (digi.sample(i).adc()<200) ++h.adc[digi.sample(i).adc()];
1042  else ++h.adc[199];
1043 
1044  if (i>=pedSubADCsize) continue; // don't exceed maximum array length when checking digis
1045 
1046  if (foundID!=PedestalsByCapId_.end())
1047  {
1048  pedSubtractedADC_[i]=digi.sample(i).adc()-(foundID->second)[thisCapid];
1049  ADCcount+=(int)(digi.sample(i).adc()-(foundID->second)[thisCapid]);
1050  }
1051  else
1052  {
1053  pedSubtractedADC_[i]=digi.sample(i).adc()-3;
1054  ADCcount+=digi.sample(i).adc()-3; // default pedestal subtraction of 3 ADC counts
1055  }
1056  } // for (int i=0;i<digi.size();++i)
1057 
1058  // capid error found
1059  if(bitUp)
1060  {
1061  if (digi_checkcapid_) err=(err|0x4);
1062  ++badcapID[calcEta][iPhi-1][iDepth-1];
1063  }
1064 
1065 
1066  // These plots generally don't get filled, unless we turn off the suppression of bad digis
1067  if (err>0)
1068  {
1069  if(uniqcounter[calcEta][iPhi-1][iDepth-1]<1)
1070  {
1071  ++h.count_bad;
1072  ++baddigis[calcEta][iPhi-1][iDepth-1];
1073  ++errorVME[static_cast<int>(2*(digi.elecId().htrSlot()+0.5*digi.elecId().htrTopBottom()))][static_cast<int>(digi.elecId().readoutVMECrateId())];
1074  ++errorSpigot[static_cast<int>(digi.elecId().spigot())][static_cast<int>(digi.elecId().dccid())];
1075  }
1076  uniqcounter[calcEta][iPhi-1][iDepth-1]++;
1077 
1078  return err;
1079  }
1080 
1081  if (ADCcount<0) ADCcount=0;
1082  if (ADCcount<199)
1083  ++h.adcsum[ADCcount];
1084  else
1085  ++h.adcsum[199]; // effective overflow bin
1086 
1087  // require larger threshold to look at pulse shapes
1088 
1089  if (ADCcount>shapeThresh && passedMinBiasHLT_ && HT_HFP_>1 && HT_HFM_>1)
1090  {
1091  h.ThreshCount->Fill(0,1);
1092  if (digi.id().subdet()!=HcalOuter || isSiPM(iEta,iPhi, iDepth)==false)
1093  {
1094  for (int i=0;i<pedSubADCsize;++i)
1096  }
1097  }
1098 
1099  // occupancy plots are only filled for good histograms
1100  ++h.count_good;
1101  ++occupancyEtaPhi[calcEta][iPhi-1][iDepth-1];
1102  ++occupancyEta[iEta+41];
1103  ++occupancyPhi[iPhi-1];
1104  // htr Slots run from 0-20, incremented by 0.5 for top/bottom
1105  ++occupancyVME[static_cast<int>(2*(digi.elecId().htrSlot()+0.5*digi.elecId().htrTopBottom()))][static_cast<int>(digi.elecId().readoutVMECrateId())];
1106  ++occupancySpigot[static_cast<int>(digi.elecId().spigot())][static_cast<int>(digi.elecId().dccid())];
1107 
1108  // Pawel's code for HF timing checks -- run only in online mode for non-calib events
1109  if (digi.id().subdet()==HcalForward
1110  && Online_ //only run online
1111  && currenttype_==0 // require non-calibration event
1112  && passedMinBiasHLT_ // require min bias trigger
1113  )
1114  {
1115  int maxtime=-1;
1116  double maxenergy=-1, fullenergy=0;
1117  int digisize=digi.size();
1118  for (int ff=0;ff<digisize;++ff)
1119  {
1120  fullenergy+=digi.sample(ff).nominal_fC()-2.5;
1121  if (digi.sample(ff).nominal_fC()-2.5>maxenergy)
1122  {
1123  maxenergy=digi.sample(ff).nominal_fC()-2.5;
1124  maxtime=ff;
1125  }
1126  }
1127 
1128  if (maxtime>=2 && maxtime<=5 && maxenergy>20 && maxenergy<100) // only look between time slices 2-5; anything else should be nonsense
1129  {
1130  for (int ff=0;ff<digisize;++ff){
1131  if(fullenergy>0){
1132  if(digi.id().ieta()>0)HFP_shape->Fill(ff,(digi.sample(ff).nominal_fC()-2.5)/fullenergy);
1133  if(digi.id().ieta()<0)HFM_shape->Fill(ff,(digi.sample(ff).nominal_fC()-2.5)/fullenergy);
1134  }
1135  }
1136 
1137  double time_den=0, time_num=0;
1138  // form weighted time sum
1139  int startslice=std::max(0,maxtime-1);
1140  int endslice=std::min(digisize-1,maxtime+1);
1141  for (int ss=startslice;ss<=endslice;++ss)
1142  {
1143  // subtract 'default' pedestal of 2.5 fC
1144  time_num+=ss*(digi.sample(ss).nominal_fC()-2.5);
1145  time_den+=digi.sample(ss).nominal_fC()-2.5;
1146  }
1147 
1148  int myiphi=iPhi;
1149  if (iDepth==2) ++myiphi;
1150  if (HFtiming_etaProfile!=0 && time_den!=0)
1151  HFtiming_etaProfile->Fill(iEta,time_num/time_den);
1152  if (HFtiming_totaltime2D!=0 && time_den!=0)
1153  HFtiming_totaltime2D->Fill(iEta,myiphi,time_num/time_den);
1154  if (HFtiming_occupancy2D!=0 && time_den!=0)
1155  HFtiming_occupancy2D->Fill(iEta,myiphi,1);
1156  } //maxtime>-1
1157  } // if HcalForward
1158 
1159  return err;
1160 } // template <class DIGI> int HcalDigiMonitor::process_Digi
1161 
1163  const edm::EventSetup& c) {
1166 }
1167 
1169  const edm::EventSetup& c)
1170 {
1171  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
1172 
1173  // Reset current LS histogram
1174  if (ProblemsCurrentLB)
1176 
1178 
1179  //increase the number of LS counting, for alarmer. Only make alarms for HBHE
1180  if(hbhedcsON == true && hfdcsON == true && HBpresent_ == 1 && HEpresent_ == 1 && HFpresent_ == 1)
1181  ++alarmer_counter_;
1182  else
1183  alarmer_counter_ = 0;
1184 
1186  c.get<HcalRecNumberingRecord>().get(topo);
1187 
1188  fill_Nevents(*topo);
1189 
1190  zeroCounters(); // reset counters of good/bad digis
1191 
1192  return;
1193 }
1194 
1196  if (debug_>0)
1197  std::cout <<"<HcalDigiMonitor> Calling fill_Nevents for event "<<tevt_<< " (processed events = "<<ievt_<<")"<<std::endl;
1198  int iPhi, iEta, iDepth;
1199  // bool valid=false;
1200 
1201  // Fill problems vs. lumi block plots
1208 
1210  alarmer_counter_ = 0;
1211 
1212  if( alarmer_counter_ >= 5 )
1214 
1215  // Fill the number of problem digis in each channel
1216  if (ProblemsCurrentLB)
1217  {
1218  ProblemsCurrentLB->Fill(-1,-1,1); // event counter
1226  }
1227 
1228  // Fill plots of sums of adjacent digi samples
1229  for (int i=0;i<10;++i)
1230  {
1231  for (int j=0;j<50;++j)
1232  {
1233  if (hbHists.tssumplus[j][i]>0) hbHists.TS_sum_plus[i]->Fill(j, hbHists.tssumplus[j][i]);
1234  if (hbHists.tssumminus[j][i]>0) hbHists.TS_sum_minus[i]->Fill(j, hbHists.tssumminus[j][i]);
1235  if (heHists.tssumplus[j][i]>0) heHists.TS_sum_plus[i]->Fill(j, heHists.tssumplus[j][i]);
1236  if (heHists.tssumminus[j][i]>0) heHists.TS_sum_minus[i]->Fill(j, heHists.tssumminus[j][i]);
1237  if (hoHists.tssumplus[j][i]>0) hoHists.TS_sum_plus[i]->Fill(j, hoHists.tssumplus[j][i]);
1238  if (hoHists.tssumminus[j][i]>0) hoHists.TS_sum_minus[i]->Fill(j, hoHists.tssumminus[j][i]);
1239  if (hfHists.tssumplus[j][i]>0) hfHists.TS_sum_plus[i]->Fill(j, hfHists.tssumplus[j][i]);
1240  if (hfHists.tssumminus[j][i]>0) hfHists.TS_sum_minus[i]->Fill(j, hfHists.tssumminus[j][i]);
1241  }
1242  } // for (int i=0;i<10;++i)
1243 
1244  for (int i=0;i<DIGI_NUM;++i)
1245  {
1246  if (diginum[i]>0) DigiNum->Fill(i, diginum[i]);
1247  if (i>=DIGI_SUBDET_NUM) continue;
1248 
1249  if (hbHists.count_BQ[i]>0) hbHists.BQ->Fill(i, hbHists.count_BQ[i]);
1250  if (heHists.count_BQ[i]>0) heHists.BQ->Fill(i, heHists.count_BQ[i]);
1251  if (hoHists.count_BQ[i]>0) hoHists.BQ->Fill(i, hoHists.count_BQ[i]);
1252  if (hfHists.count_BQ[i]>0) hfHists.BQ->Fill(i, hfHists.count_BQ[i]);
1253  }//for int i=0;i<DIGI_NUM;++i)
1254 
1255 
1256  // Fill data-valid/error plots and capid plots
1257  for (int i=0;i<4;++i)
1258  {
1259  if (hbHists.dverr[i]>0) hbHists.DVerr->Fill(i, hbHists.dverr[i]);
1260  if (heHists.dverr[i]>0) heHists.DVerr->Fill(i, heHists.dverr[i]);
1261  if (hoHists.dverr[i]>0) hoHists.DVerr->Fill(i, hoHists.dverr[i]);
1262  if (hfHists.dverr[i]>0) hfHists.DVerr->Fill(i, hfHists.dverr[i]);
1263 
1264  if (hbHists.capid[i]>0) hbHists.CapID->Fill(i, hbHists.capid[i]);
1265  if (heHists.capid[i]>0) heHists.CapID->Fill(i, heHists.capid[i]);
1266  if (hoHists.capid[i]>0) hoHists.CapID->Fill(i, hoHists.capid[i]);
1267  if (hfHists.capid[i]>0) hfHists.CapID->Fill(i, hfHists.capid[i]);
1268  }
1269 
1270  for (int i=0;i<200;++i)
1271  {
1272  if (hbHists.adc[i]>0) hbHists.ADC->Fill(i, hbHists.adc[i]);
1273 
1274  if (heHists.adc[i]>0) heHists.ADC->Fill(i, heHists.adc[i]);
1275  if (hoHists.adc[i]>0) hoHists.ADC->Fill(i, hoHists.adc[i]);
1276  if (hfHists.adc[i]>0) hfHists.ADC->Fill(i, hfHists.adc[i]);
1277 
1282  }
1283 
1284  for (int i = 0; i < 15; ++i)
1285  {
1286  if (hbHists.fibbcnoff[i]>0) hbHists.fibBCNOff->Fill(i-7,
1287  hbHists.fibbcnoff[i]);
1288  if (heHists.fibbcnoff[i]>0) heHists.fibBCNOff->Fill(i-7,
1289  heHists.fibbcnoff[i]);
1290  if (hfHists.fibbcnoff[i]>0) hfHists.fibBCNOff->Fill(i-7,
1291  hfHists.fibbcnoff[i]);
1292  if (hoHists.fibbcnoff[i]>0) hoHists.fibBCNOff->Fill(i-7,
1293  hoHists.fibbcnoff[i]);
1294  }
1295 
1296  // Fill plots of bad fraction of digis found
1297  for (int i=0;i<DIGI_BQ_FRAC_NBINS;++i)
1298  {
1299  if (DIGI_BQ_FRAC_NBINS==1) break;
1300  if (hbHists.count_BQFrac[i]>0) hbHists.BQFrac->Fill(1.*i/(DIGI_BQ_FRAC_NBINS-1), hbHists.count_BQFrac[i]);
1301  if (heHists.count_BQFrac[i]>0) heHists.BQFrac->Fill(1.*i/(DIGI_BQ_FRAC_NBINS-1), heHists.count_BQFrac[i]);
1302  if (hoHists.count_BQFrac[i]>0)
1303  {
1304  hoHists.BQFrac->Fill(1.*i/(DIGI_BQ_FRAC_NBINS), hoHists.count_BQFrac[i]);
1305  }
1306  if (hfHists.count_BQFrac[i]>0) hfHists.BQFrac->Fill(1.*i/(DIGI_BQ_FRAC_NBINS-1), hfHists.count_BQFrac[i]);
1307  }//for (int i=0;i<DIGI_BQ_FRAC_NBINS;++i)
1308 
1309  // Fill presample plots
1310  for (int i=0;i<50;++i)
1311  {
1316  } //for (int i=0;i<50;++i)
1317 
1318  // Fill shape plots
1319  for (int i=0;i<10;++i)
1320  {
1329  }// for (int i=0;i<10;++i)
1330 
1331  // Fill capID difference plots
1332  for (int i=0;i<8;++i)
1333  {
1338  }
1339 
1340  // Fill VME plots
1341  for (int i=0;i<40;++i)
1342  {
1343  for (int j=0;j<18;++j)
1344  {
1345  if (errorVME[i][j]>0) DigiErrorVME->Fill(i, j,errorVME[i][j]);
1346  if (occupancyVME[i][j]>0) DigiOccupancyVME->Fill(i, j,occupancyVME[i][j]);
1347  }
1348  } //for (int i=0;i<40;++i)
1349 
1350  // Fill SPIGOT plots
1351  for (int i=0;i<HcalDCCHeader::SPIGOT_COUNT;++i)
1352  {
1353  for (int j=0;j<36;++j)
1354  {
1355  if (errorSpigot[i][j]>0) DigiErrorSpigot->Fill(i, j,errorSpigot[i][j]);
1357  }
1358  } //for (int i=0;i<HcalDCCHeader::SPIGOT_COUNT;++i)
1359 
1360  // Loop over subdetectors
1361  for (int sub=0;sub<4;++sub)
1362  {
1363  for (int dsize=0;dsize<20;++dsize)
1364  {
1365  if (digisize[dsize][sub]>0)
1366  DigiSize->Fill(sub,dsize,digisize[dsize][sub]);
1367  }
1368  } // for (int sub=0;sub<4;++sub)
1369 
1370  // Loop over eta, phi, depth
1371  for (int d=0;d<4;++d) {
1372  iDepth=d+1;
1373  DigiErrorsByDepth.depth[d]->setBinContent(0,0,ievt_); // underflow bin contains event counter
1374  DigiOccupancyByDepth.depth[d]->setBinContent(0,0,ievt_);
1375  DigiErrorsBadDigiSize.depth[d]->setBinContent(0,0,ievt_);
1376  DigiErrorsUnpacker.depth[d]->setBinContent(0,0,ievt_);
1377  DigiErrorsBadFibBCNOff.depth[d]->setBinContent(0,0,ievt_);
1378 
1379  for (int phi=0;phi<72;++phi) {
1380  iPhi=phi+1;
1382  for (int eta=0;eta<83;++eta) {
1383  // DigiOccupanyEta uses 'true' ieta (included the overlap at +/- 29)
1384  iEta=eta-41;
1385  if (phi==0)
1387  // valid=false;
1388 
1389  // HB
1390  if (topology.validDetId(HcalBarrel, iEta, iPhi, iDepth)) {
1391  // valid=true;
1392  if (HBpresent_) {
1393  int calcEta = CalcEtaBin(HcalBarrel,iEta,iDepth);
1394 
1395  DigiOccupancyByDepth.depth[d]->Fill(iEta, iPhi,
1396  occupancyEtaPhi[calcEta][phi][d]);
1397 
1398  if (makeDiagnostics_) {
1399  DigiErrorsBadCapID.depth[d]->Fill(iEta, iPhi,
1400  badcapID[calcEta][phi][d]);
1401  DigiErrorsDVErr.depth[d]->Fill(iEta, iPhi,
1402  digierrorsdverr[calcEta][phi][d]);
1403  }
1404  DigiErrorsBadDigiSize.depth[d]->Fill(iEta, iPhi,
1405  baddigisize[calcEta][phi][d]);
1406  DigiErrorsBadFibBCNOff.depth[d]->Fill(iEta, iPhi,
1407  badFibBCNOff[calcEta][phi][d]);
1408  DigiErrorsUnpacker.depth[d]->Fill(iEta, iPhi,
1409  badunpackerreport[calcEta][phi][d]);
1410  DigiErrorsByDepth.depth[d]->Fill(iEta, iPhi,
1411  baddigis[calcEta][phi][d]);
1412  // Use this for testing purposes only
1413  //DigiErrorsByDepth[d]->Fill(iEta, iPhi, ievt_);
1414  } // if (HBpresent_)
1415  } // validDetId(HB)
1416  // HE
1417  if (topology.validDetId(HcalEndcap, iEta, iPhi, iDepth)) {
1418  // valid=true;
1419  if (HEpresent_) {
1420  int calcEta = CalcEtaBin(HcalEndcap,iEta,iDepth);
1421 
1422  DigiOccupancyByDepth.depth[d]->Fill(iEta, iPhi,
1423  occupancyEtaPhi[calcEta][phi][d]);
1424 
1425  if (makeDiagnostics_) {
1426  DigiErrorsBadCapID.depth[d]->Fill(iEta, iPhi,
1427  badcapID[calcEta][phi][d]);
1428  DigiErrorsDVErr.depth[d]->Fill(iEta, iPhi,
1429  digierrorsdverr[calcEta][phi][d]);
1430  }
1431  DigiErrorsBadDigiSize.depth[d]->Fill(iEta, iPhi,
1432  baddigisize[calcEta][phi][d]);
1433  DigiErrorsBadFibBCNOff.depth[d]->Fill(iEta, iPhi,
1434  badFibBCNOff[calcEta][phi][d]);
1435  DigiErrorsUnpacker.depth[d]->Fill(iEta, iPhi,
1436  badunpackerreport[calcEta][phi][d]);
1437  DigiErrorsByDepth.depth[d]->Fill(iEta, iPhi,
1438  baddigis[calcEta][phi][d]);
1439  } // if (HEpresent_)
1440  } // valid HE found
1441  // HO
1442  if (topology.validDetId(HcalOuter,iEta,iPhi,iDepth)) {
1443  // valid=true;
1444  if (HOpresent_) {
1445  int calcEta = CalcEtaBin(HcalOuter,iEta,iDepth);
1446  DigiOccupancyByDepth.depth[d]->Fill(iEta, iPhi,
1447  occupancyEtaPhi[calcEta][phi][d]);
1448  if (makeDiagnostics_) {
1449  DigiErrorsBadCapID.depth[d]->Fill(iEta, iPhi,
1450  badcapID[calcEta][phi][d]);
1451  DigiErrorsDVErr.depth[d]->Fill(iEta, iPhi,
1452  digierrorsdverr[calcEta][phi][d]);
1453  }
1454  DigiErrorsBadDigiSize.depth[d]->Fill(iEta, iPhi,
1455  baddigisize[calcEta][phi][d]);
1456  DigiErrorsBadFibBCNOff.depth[d]->Fill(iEta, iPhi,
1457  badFibBCNOff[calcEta][phi][d]);
1458  DigiErrorsUnpacker.depth[d]->Fill(iEta, iPhi,
1459  badunpackerreport[calcEta][phi][d]);
1460 
1461  DigiErrorsByDepth.depth[d]->Fill(iEta,iPhi,
1462  baddigis[calcEta][phi][d]);
1463  } // if (HOpresent_)
1464  }//validDetId(HO)
1465  // HF
1466  if (topology.validDetId(HcalForward,iEta,iPhi,iDepth)) {
1467  // valid=true;
1468  if (HFpresent_) {
1469  int calcEta = CalcEtaBin(HcalForward,iEta,iDepth);
1470  int zside = iEta/abs(iEta);
1471  DigiOccupancyByDepth.depth[d]->Fill(iEta+zside, iPhi,
1472  occupancyEtaPhi[calcEta][phi][d]);
1473 
1474  if (makeDiagnostics_) {
1475  DigiErrorsBadCapID.depth[d]->Fill(iEta+zside, iPhi,
1476  badcapID[calcEta][phi][d]);
1477  DigiErrorsDVErr.depth[d]->Fill(iEta+zside, iPhi,
1478  digierrorsdverr[calcEta][phi][d]);
1479  }
1480  DigiErrorsBadDigiSize.depth[d]->Fill(iEta+zside, iPhi,
1481  baddigisize[calcEta][phi][d]);
1482  DigiErrorsBadFibBCNOff.depth[d]->Fill(iEta+zside, iPhi,
1483  badFibBCNOff[calcEta][phi][d]);
1484  DigiErrorsUnpacker.depth[d]->Fill(iEta+zside, iPhi,
1485  badunpackerreport[calcEta][phi][d]);
1486  DigiErrorsByDepth.depth[d]->Fill(iEta+zside, iPhi,
1487  baddigis[calcEta][phi][d]);
1488 
1489  } // if (HFpresent_)
1490  }
1491  } // for (int eta=0;...)
1492  } // for (int phi=0;...)
1493  } // for (int d=0;...)
1494 
1495  // Now fill all the unphysical cell values
1497  if (makeDiagnostics_)
1498  {
1501  }
1506 
1507  // zeroCounters(); // reset counters of good/bad digis
1508 
1509  return;
1510 } // void HcalDigiMonitor::fill_Nevents(const HcalTopology&)
1511 
1512 
1514 {
1515  // Set all histogram counters back to 0
1516  // Call this after all every N evnets
1517 
1518  /******** Zero all counters *******/
1519  for (int d=0; d<DEPTHBINS; d++) {
1520  for (int eta=0; eta<ETABINS; eta++) {
1521  for (int phi=0; phi<PHIBINS; phi++){
1522  uniqcounter[eta][phi][d] = 0.0;
1523  uniqcounter2[eta][phi][d] = 0.0;
1524  }
1525  }
1526  }
1527 
1528  hbHists.count_bad=0;
1529  hbHists.count_good=0;
1530  heHists.count_bad=0;
1531  heHists.count_good=0;
1532  hoHists.count_bad=0;
1533  hoHists.count_good=0;
1534  hfHists.count_bad=0;
1535  hfHists.count_good=0;
1536 
1537  knownbadQPLLs = 0;
1538 
1539  HO0bad=0;
1540  HO12bad=0;
1541  HFlumibad=0;
1542 
1543  for (int i=0;i<85;++i)
1544  {
1545  occupancyEta[i]=0;
1546  if (i<72)
1547  occupancyPhi[i]=0;
1548  for (int j=0;j<72;++j)
1549  {
1550  for (int k=0;k<4;++k)
1551  {
1552  baddigis[i][j][k]=0;
1553  badcapID[i][j][k]=0;
1554  baddigisize[i][j][k]=0;
1555  occupancyEtaPhi[i][j][k]=0;
1556  digierrorsdverr[i][j][k]=0;
1557  badFibBCNOff[i][j][k]=0;
1558  badunpackerreport[i][j][k]=0;
1559  }
1560  } // for (int j=0;j<72;++i)
1561  } // for (int i=0;i<85;++i)
1562 
1563  for (int i=0;i<40;++i)
1564  {
1565  for (int j=0;j<18;++j)
1566  {
1567  occupancyVME[i][j]=0;
1568  errorVME[i][j]=0;
1569  }
1570  }
1571 
1572  for (int i=0;i<HcalDCCHeader::SPIGOT_COUNT;++i)
1573  {
1574  for (int j=0;j<36;++j)
1575  {
1576  occupancySpigot[i][j]=0;
1577  errorSpigot[i][j]=0;
1578  }
1579  }
1580 
1581 
1582  for (int i=0;i<20;++i)
1583  {
1584  for (int j=0;j<4;++j)
1585  digisize[i][j]=0;
1586  }
1587 
1588  for (int i=0;i<DIGI_NUM;++i)
1589  {
1590  diginum[i]=0;
1591 
1592  // set all DigiHists counters to 0
1593  if (i<4)
1594  {
1595  hbHists.dverr[i]=0;
1596  heHists.dverr[i]=0;
1597  hoHists.dverr[i]=0;
1598  hfHists.dverr[i]=0;
1599  hbHists.capid[i]=0;
1600  heHists.capid[i]=0;
1601  hoHists.capid[i]=0;
1602  hfHists.capid[i]=0;
1603  }
1604  if (i<8)
1605  {
1606  hbHists.capIDdiff[i]=0;
1607  heHists.capIDdiff[i]=0;
1608  hoHists.capIDdiff[i]=0;
1609  hfHists.capIDdiff[i]=0;
1610  }
1611 
1612  if (i<10)
1613  {
1614  hbHists.count_shape[i]=0;
1615  heHists.count_shape[i]=0;
1616  hoHists.count_shape[i]=0;
1617  hfHists.count_shape[i]=0;
1618 
1623  }
1624  if (i<50)
1625  {
1630  for (int j=0;j<10;++j)
1631  {
1632  hbHists.tssumplus[i][j]=0;
1633  heHists.tssumplus[i][j]=0;
1634  hoHists.tssumplus[i][j]=0;
1635  hfHists.tssumplus[i][j]=0;
1636  hbHists.tssumminus[i][j]=0;
1637  heHists.tssumminus[i][j]=0;
1638  hoHists.tssumminus[i][j]=0;
1639  hfHists.tssumminus[i][j]=0;
1640  }
1641  }
1642 
1643  if (i<15)
1644  {
1645  hbHists.fibbcnoff[i]=0;
1646  heHists.fibbcnoff[i]=0;
1647  hoHists.fibbcnoff[i]=0;
1648  hfHists.fibbcnoff[i]=0;
1649  }
1650 
1651  if (i<200)
1652  {
1653  hbHists.adc[i]=0;
1654  heHists.adc[i]=0;
1655  hoHists.adc[i]=0;
1656  hfHists.adc[i]=0;
1657  hbHists.adcsum[i]=0;
1658  heHists.adcsum[i]=0;
1659  hoHists.adcsum[i]=0;
1660  hfHists.adcsum[i]=0;
1661  }
1662  if (i<DIGI_SUBDET_NUM)
1663  {
1664  hbHists.count_BQ[i]=0;
1665  heHists.count_BQ[i]=0;
1666  hoHists.count_BQ[i]=0;
1667  hfHists.count_BQ[i]=0;
1668  }
1669  if (i<DIGI_BQ_FRAC_NBINS)
1670  {
1671  hbHists.count_BQFrac[i]=0;
1672  heHists.count_BQFrac[i]=0;
1673  hoHists.count_BQFrac[i]=0;
1674  hfHists.count_BQFrac[i]=0;
1675  }
1676  } // for (int i=0;i<DIGI_NUM;++i)
1677 
1678 
1679  return;
1680 }
1681 
1683 {
1684  // call update command for all histograms (should make them update when running in online DQM?)
1685  h.shape->update();
1686  h.shapeThresh->update();
1687  h.presample->update();
1688  h.BQ->update();
1689  h.BQFrac->update();
1690  h.DigiFirstCapID->update();
1691  h.DVerr->update();
1692  h.CapID->update();
1693  h.ADC->update();
1694  h.ADCsum->update();
1695  h.fibBCNOff->update();
1696 
1697  for (unsigned int i=0;i<h.TS_sum_plus.size();++i)
1698  h.TS_sum_plus[i]->update();
1699  for (unsigned int i=0;i<h.TS_sum_minus.size();++i)
1700  h.TS_sum_minus[i]->update();
1701 } //void HcalDigiMonitor::UpdateHists(DigiHists& h)
1702 
1703 
1705 {
1706  // reset the temporary histograms
1707  zeroCounters();
1708 
1709  // then reset the MonitorElements
1710 
1712  alarmer_counter_ = 0;
1713  knownbadQPLLs = 0;
1714 
1715  hbhedcsON = true; hfdcsON = true;
1716 
1726 
1731  DigiErrorVME->Reset();
1733 
1734  DigiBQ->Reset();
1735  DigiBQFrac->Reset();
1738 
1739  DigiNum->Reset();
1740 
1741  hbHists.shape->Reset();
1743  hbHists.presample->Reset();
1744  hbHists.BQ->Reset();
1745  hbHists.BQFrac->Reset();
1747  hbHists.DVerr->Reset();
1748  hbHists.CapID->Reset();
1749  hbHists.ADC->Reset();
1750  hbHists.ADCsum->Reset();
1751  hbHists.fibBCNOff->Reset();
1752  for (unsigned int i=0;i<hbHists.TS_sum_plus.size();++i)
1753  hbHists.TS_sum_plus[i]->Reset();
1754  for (unsigned int i=0;i<hbHists.TS_sum_minus.size();++i)
1755  hbHists.TS_sum_minus[i]->Reset();
1756 
1757  heHists.shape->Reset();
1759  heHists.presample->Reset();
1760  heHists.BQ->Reset();
1761  heHists.BQFrac->Reset();
1763  heHists.DVerr->Reset();
1764  heHists.CapID->Reset();
1765  heHists.ADC->Reset();
1766  heHists.ADCsum->Reset();
1767  heHists.fibBCNOff->Reset();
1768  for (unsigned int i=0;i<heHists.TS_sum_plus.size();++i)
1769  heHists.TS_sum_plus[i]->Reset();
1770  for (unsigned int i=0;i<heHists.TS_sum_minus.size();++i)
1771  heHists.TS_sum_minus[i]->Reset();
1772 
1773  hoHists.shape->Reset();
1775  hoHists.presample->Reset();
1776  hoHists.BQ->Reset();
1777  hoHists.BQFrac->Reset();
1779  hoHists.DVerr->Reset();
1780  hoHists.CapID->Reset();
1781  hoHists.ADC->Reset();
1782  hoHists.ADCsum->Reset();
1783  hoHists.fibBCNOff->Reset();
1784  for (unsigned int i=0;i<hoHists.TS_sum_plus.size();++i)
1785  hoHists.TS_sum_plus[i]->Reset();
1786  for (unsigned int i=0;i<hoHists.TS_sum_minus.size();++i)
1787  hoHists.TS_sum_minus[i]->Reset();
1788 
1789  hfHists.shape->Reset();
1791  hfHists.presample->Reset();
1792  hfHists.BQ->Reset();
1793  hfHists.BQFrac->Reset();
1795  hfHists.DVerr->Reset();
1796  hfHists.CapID->Reset();
1797  hfHists.ADC->Reset();
1798  hfHists.ADCsum->Reset();
1799  hfHists.fibBCNOff->Reset();
1800  for (unsigned int i=0;i<hfHists.TS_sum_plus.size();++i)
1801  hfHists.TS_sum_plus[i]->Reset();
1802  for (unsigned int i=0;i<hfHists.TS_sum_minus.size();++i)
1803  hfHists.TS_sum_minus[i]->Reset();
1804 
1805  return;
1806 }
1808 
MonitorElement * h_invalid_bcn
bool passedMinBiasHLT_
Methods, variables accessible only within class code.
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
int capid[4]
bool LumiInOrder(int lumisec)
int count_presample[50]
MonitorElement * DigiBQFrac
edm::EDGetTokenT< DcsStatusCollection > dcsStatusToken_
int getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
Definition: HcalHTRData.cc:388
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:220
MonitorElement * ProblemsCurrentLB
MonitorElement * HFtiming_occupancy2D
edm::InputTag digiLabel_
MonitorElement * ADC
std::vector< std::string > MinBiasHLTBits_
int ib
Definition: cuy.py:660
EtaPhiHists DigiErrorsDVErr
int occupancySpigot[40][36]
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:45
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
int tssumminus[50][10]
MonitorElement * shape
MonitorElement * DigiSize
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * HFP_shape
CaloTopology const * topology(0)
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
void bookHistograms(DQMStore::IBooker &ib, const edm::Run &run, const edm::EventSetup &c)
int occupancyVME[40][18]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
MonitorElement * BQ
MonitorElement * ProblemsVsLB_HF
int errorVME[40][18]
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool validDetId(HcalSubdetector subdet, int ieta, int iphi, int depth) const
std::map< unsigned int, int > KnownBadCells_
MonitorElement * HFtiming_totaltime2D
std::vector< int > AllowedCalibTypes_
MonitorElement * shapeThresh
MonitorElement * HFM_shape
void Reset(void)
int badcapID[85][72][4]
EtaPhiHists DigiErrorOccupancyByDepth
#define DIGI_BQ_FRAC_NBINS
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< HFRecHit >::const_iterator const_iterator
int bunchCrossing() const
Definition: EventBase.h:66
int fibbcnoff[15]
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
int count_BQ[2593]
HcalDigiMonitor(const edm::ParameterSet &ps)
double pedestal(int fCapId) const
get pedestal for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
Strings::size_type size() const
Definition: TriggerNames.cc:39
int zside(DetId const &)
void update(void)
Mark the object updated.
int badFibBCNOff[85][72][4]
MonitorElement * DigiOccupancyEta
MonitorElement * DigiErrorVME
MonitorElement * DigiOccupancyVME
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
int dverr[4]
MonitorElement * DigiNum
MonitorElement * HOocc_vs_LB
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const HcalDetId & id() const
Definition: HODataFrame.h:23
int baddigis[85][72][4]
MonitorElement * ThreshCount
void Fill(long long x)
int adcsum[200]
LuminosityBlockNumber_t luminosityBlock() const
std::map< HcalDetId, std::vector< double > > PedestalsByCapId_
MonitorElement * DigiErrorSpigot
#define DEPTHBINS
tuple report
Definition: zeeHLT_cff.py:9
tuple d
Definition: ztail.py:151
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
EtaPhiHists DigiErrorsBadFibBCNOff
void SetupEtaPhiHists(DQMStore::IBooker &ib, EtaPhiHists &hh, std::string Name, std::string Units)
void UpdateHists(DigiHists &h)
int adc[200]
bool isSiPM(int ieta, int iphi, int depth)
int depth() const
get the tower depth
Definition: HcalDetId.h:55
std::vector< MonitorElement * > depth
int DigiMonitor_ExpectedOrbitMessageTime_
MonitorElement * HBocc_vs_LB
int baddigisize[85][72][4]
#define DIGI_SUBDET_NUM
MonitorElement * ProblemsVsLB_HBHEHF
MonitorElement * ProblemsVsLB_HB
int digierrorsdverr[85][72][4]
uint64_t uniqcounter[85][72][4]
std::vector< DetId > getAllChannels() const
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
DetIdVector::const_iterator bad_quality_begin() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const float bins_cellcount_new[]
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
int orbitNumber() const
Definition: EventBase.h:67
std::vector< MonitorElement * > TS_sum_minus
T min(T a, T b)
Definition: MathUtil.h:58
MonitorElement * HFocc_vs_LB
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< HcalUnpackerReport > tok_unpack_
std::vector< MonitorElement * > TS_sum_plus
int process_Digi(T &digi, DigiHists &hist, int &firstcap)
uint64_t uniqcounter2[85][72][4]
const_iterator end() const
MonitorElement * DigiBQ
MonitorElement * DigiUnpackerErrorCount
int getSourceId() const
Definition: HcalDCCHeader.h:32
MonitorElement * HEocc_vs_LB
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
MonitorElement * ADCsum
EtaPhiHists DigiErrorsBadDigiSize
int errorSpigot[15][36]
MonitorElement * fibBCNOff
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
#define DIGI_NUM
static bool bitUpset(int last, int now)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * DigiOccupancySpigot
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
EtaPhiHists DigiErrorsBadADCSum
edm::InputTag hltresultsLabel_
const T & get() const
Definition: EventSetup.h:56
#define ETABINS
MonitorElement * HFtiming_etaProfile
T const * product() const
Definition: ESHandle.h:86
MonitorElement * ProblemsVsLB_HE
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
int CalcEtaBin(int subdet, int ieta, int depth)
void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * DVerr
edm::EDGetTokenT< HODigiCollection > tok_ho_
edm::InputTag FEDRawDataCollection_
MonitorElement * h_invalid_orbitnumMod103
int badQualityDigis() const
int occupancyEtaPhi[85][72][4]
void setup(DQMStore::IBooker &)
edm::EDGetTokenT< HFDigiCollection > tok_hf_
MonitorElement * CapID
int tssumplus[50][10]
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
edm::EDGetTokenT< FEDRawDataCollection > FEDRawDataCollectionToken_
size_type size() const
MonitorElement * h_valid_digis
static std::atomic< unsigned int > counter
double count_shapeThresh[10]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
edm::EDGetTokenT< edm::TriggerResults > tok_trigger_
void setupSubdetHists(DQMStore::IBooker &ib, DigiHists &hist, std::string subdet)
unsigned adc(const HcalQIEShape &fShape, float fCharge, unsigned fCapId) const
fC + capid [0..3] -&gt; ADC conversion
Definition: HcalQIECoder.cc:27
#define PHIBINS
int capIDdiff[8]
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
tuple cout
Definition: gather_cfg.py:121
MonitorElement * DigiUnpackerErrorFrac
void fill_Nevents(const HcalTopology &)
MonitorElement * DigiFirstCapID
EtaPhiHists DigiErrorsBadCapID
MonitorElement * ProblemsVsLB_HO
EtaPhiHists DigiOccupancyByDepth
MonitorElement * BQFrac
MonitorElement * ProblemsVsLB
tuple status
Definition: ntuplemaker.py:245
if(conf.exists("allCellsPositionCalc"))
int badunpackerreport[85][72][4]
MonitorElement * presample
int count_BQFrac[101]
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
MonitorElement * DigiExpectedSize
void processEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalDbService &cond, const HcalUnpackerReport &report, int orN, int bcN)
void Reset(void)
reset ME (ie. contents, errors, etc)
virtual void setup(DQMStore::IBooker &)
int count_shape[10]
edm::EDGetTokenT< HFRecHitCollection > tok_hfrec_
EtaPhiHists DigiErrorsByDepth
EtaPhiHists DigiErrorsUnpacker
int digisize[20][4]
edm::ESHandle< HcalDbService > conditions_
const float bins_fraccount_new[]
const_iterator begin() const
Definition: Run.h:43
DetIdVector::const_iterator bad_quality_end() const
MonitorElement * DigiOccupancyPhi
MonitorElement * ProblemDigisInLastNLB_HBHEHF_alarm
double pedSubtractedADC_[10]
void endRun(const edm::Run &run, const edm::EventSetup &c)
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_