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