test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalBeamMonitor.cc
Go to the documentation of this file.
8 
9 #include <iomanip>
10 #include <cmath>
11 
12 // define sizes of ieta arrays for each subdetector
13 
14 #define PI 3.1415926535897932
15 #define HBETASIZE 34 // one more bin than needed, I think
16 #define HEETASIZE 60 // ""
17 #define HOETASIZE 32 // ""
18 #define HFETASIZE 84 // ""
19 
20 /* Task calculates various moments of Hcal recHits
21 
22  v1.0
23  16 August 2008
24  by Jeff Temple
25 
26 */
27 
28 // constructor
31  ETA_OFFSET_HB(16),
32  ETA_OFFSET_HE(29),
33  ETA_BOUND_HE(17),
34  ETA_OFFSET_HO(15),
35  ETA_OFFSET_HF(41),
36  ETA_BOUND_HF(29)
37 {
38  Online_ = ps.getUntrackedParameter<bool>("online",false);
39  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
40  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
41  debug_ = ps.getUntrackedParameter<int>("debug",0);
42  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
43  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
44  prefixME_.append("/");
45  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","BeamMonitor_Hcal");
46  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
47  subdir_.append("/");
48  subdir_=prefixME_+subdir_;
49  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
50  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
51  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
52  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
53 
54  // Beam Monitor-specific stuff
55 
56  // Collection type info
58  tok_hfdigi_ = consumes<HFDigiCollection>(digiLabel_);
59  hbheRechitLabel_ = ps.getUntrackedParameter<edm::InputTag>("hbheRechitLabel");
60 
61  tok_hbhe_ = consumes<HBHERecHitCollection>(hbheRechitLabel_);
62 
63  hoRechitLabel_ = ps.getUntrackedParameter<edm::InputTag>("hoRechitLabel");
64  tok_ho_ = consumes<HORecHitCollection>(hoRechitLabel_);
65 
66  hfRechitLabel_ = ps.getUntrackedParameter<edm::InputTag>("hfRechitLabel");
67  tok_hf_ = consumes<HFRecHitCollection>(hfRechitLabel_);
68 
69  // minimum events required in lumi block for tests to be processed
70  minEvents_ = ps.getUntrackedParameter<int>("minEvents",500);
71  lumiqualitydir_ = ps.getUntrackedParameter<std::string>("lumiqualitydir","");
72  if (lumiqualitydir_.size()>0 && lumiqualitydir_.substr(lumiqualitydir_.size()-1,lumiqualitydir_.size())!="/")
73  lumiqualitydir_.append("/");
74  occThresh_ = ps.getUntrackedParameter<double>("occupancyThresh",0.0625); // energy required to be counted by dead/hot checks
75  hotrate_ = ps.getUntrackedParameter<double>("hotrate",0.25);
76  minBadCells_ = ps.getUntrackedParameter<int>("minBadCells",10);
77  Overwrite_ = ps.getUntrackedParameter<bool>("Overwrite",false);
78  setupDone_ = false;
79 }
80 
81 
82 
84 
86 {
90 
99 
100  Etsum_eta_L->Reset();
101  Etsum_eta_S->Reset();
102  Etsum_phi_L->Reset();
103  Etsum_phi_S->Reset();
104  Etsum_ratio_p->Reset();
105  Etsum_ratio_m->Reset();
106  Etsum_map_L->Reset();
107  Etsum_map_S->Reset();
109  Etsum_rphi_L->Reset();
110  Etsum_rphi_S->Reset();
111  Energy_Occ->Reset();
112 
113  Occ_rphi_L->Reset();
114  Occ_rphi_S->Reset();
115  Occ_eta_L->Reset();
116  Occ_eta_S->Reset();
117  Occ_phi_L->Reset();
118  Occ_phi_S->Reset();
119  Occ_map_L->Reset();
120  Occ_map_S->Reset();
121 
129 
136 
137  HFlumi_occ_LS->Reset();
142 
143 
146 }
147 
148 
150 {
151  if (setupDone_)
152  return;
153  setupDone_ = true;
154  if (debug_>0) std::cout <<"<HcalBeamMonitor::setup> Setup in progress..."<<std::endl;
156 
157  //jason's
159  CenterOfEnergyRadius = ib.book1D("CenterOfEnergyRadius",
160  "Center Of Energy radius",
161  200,0,1);
162 
163  CenterOfEnergyRadius->setAxisTitle("(normalized) radius",1);
164 
165  CenterOfEnergy = ib.book2D("CenterOfEnergy",
166  "Center of Energy;normalized x coordinate;normalize y coordinate",
167  40,-1,1,
168  40,-1,1);
169 
170  COEradiusVSeta = ib.bookProfile("COEradiusVSeta",
171  "Center of Energy radius vs i#eta",
172  172,-43,43,
173  20,0,1);
174  COEradiusVSeta->setAxisTitle("i#eta",1);
175  COEradiusVSeta->setAxisTitle("(normalized) radius",2);
176 
177  std::stringstream histname;
178  std::stringstream histtitle;
179  ib.setCurrentFolder(subdir_+"HB");
180  HBCenterOfEnergyRadius = ib.book1D("HBCenterOfEnergyRadius",
181  "HB Center Of Energy radius",
182  200,0,1);
183  HBCenterOfEnergy = ib.book2D("HBCenterOfEnergy",
184  "HB Center of Energy",
185  40,-1,1,
186  40,-1,1);
187  if (makeDiagnostics_)
188  {
189  for (int i=-16;i<=16;++i)
190  {
191  if (i==0) continue;
192  histname.str("");
193  histtitle.str("");
194  histname<<"HB_CenterOfEnergyRadius_ieta"<<i;
195  histtitle<<"HB Center Of Energy ieta = "<<i;
196  HB_CenterOfEnergyRadius[i+ETA_OFFSET_HB]=ib.book1D(histname.str().c_str(),
197  histtitle.str().c_str(),
198  200,0,1);
199  } // end of HB loop
200  }
201  ib.setCurrentFolder(subdir_+"HE");
202  HECenterOfEnergyRadius = ib.book1D("HECenterOfEnergyRadius",
203  "HE Center Of Energy radius",
204  200,0,1);
205  HECenterOfEnergy = ib.book2D("HECenterOfEnergy",
206  "HE Center of Energy",
207  40,-1,1,
208  40,-1,1);
209 
210  if (makeDiagnostics_)
211  {
212  for (int i=-29;i<=29;++i)
213  {
214  if (abs(i)<ETA_BOUND_HE) continue;
215  histname.str("");
216  histtitle.str("");
217  histname<<"HE_CenterOfEnergyRadius_ieta"<<i;
218  histtitle<<"HE Center Of Energy ieta = "<<i;
219  HE_CenterOfEnergyRadius[i+ETA_OFFSET_HE]=ib.book1D(histname.str().c_str(),
220  histtitle.str().c_str(),
221  200,0,1);
222  } // end of HE loop
223  }
224  ib.setCurrentFolder(subdir_+"HO");
225  HOCenterOfEnergyRadius = ib.book1D("HOCenterOfEnergyRadius",
226  "HO Center Of Energy radius",
227  200,0,1);
228  HOCenterOfEnergy = ib.book2D("HOCenterOfEnergy",
229  "HO Center of Energy",
230  40,-1,1,
231  40,-1,1);
232  if (makeDiagnostics_)
233  {
234  for (int i=-15;i<=15;++i)
235  {
236  if (i==0) continue;
237  histname.str("");
238  histtitle.str("");
239  histname<<"HO_CenterOfEnergyRadius_ieta"<<i;
240  histtitle<<"HO Center Of Energy radius ieta = "<<i;
241  HO_CenterOfEnergyRadius[i+ETA_OFFSET_HO]=ib.book1D(histname.str().c_str(),
242  histtitle.str().c_str(),
243  200,0,1);
244  } // end of HO loop
245  }
246  ib.setCurrentFolder(subdir_+"HF");
247  HFCenterOfEnergyRadius = ib.book1D("HFCenterOfEnergyRadius",
248  "HF Center Of Energy radius",
249  200,0,1);
250  HFCenterOfEnergy = ib.book2D("HFCenterOfEnergy",
251  "HF Center of Energy",
252  40,-1,1,
253  40,-1,1);
254  if (makeDiagnostics_)
255  {
256  for (int i=-41;i<=41;++i)
257  {
258  if (abs(i)<ETA_BOUND_HF) continue;
259  histname.str("");
260  histtitle.str("");
261  histname<<"HF_CenterOfEnergyRadius_ieta"<<i;
262  histtitle<<"HF Center Of Energy radius ieta = "<<i;
263  HF_CenterOfEnergyRadius[i+ETA_OFFSET_HF]=ib.book1D(histname.str().c_str(),
264  histtitle.str().c_str(),
265  200,0,1);
266  } // end of HF loop
267  }
268 
269  ib.setCurrentFolder(subdir_+"Lumi");
270  // Wenhan's
271  // reducing bins from ",200,0,2000" to ",40,0,800"
272 
273  float radiusbins[13]={169,201,240,286,340,406,483,576,686,818,975,1162,1300};
274  float phibins[71]={-3.5,-3.4,-3.3,-3.2,-3.1,
275  -3.0,-2.9,-2.8,-2.7,-2.6,-2.5,-2.4,-2.3,-2.2,-2.1,
276  -2.0,-1.9,-1.8,-1.7,-1.6,-1.5,-1.4,-1.3,-1.2,-1.1,
277  -1.0,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,
278  0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,
279  1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9,
280  2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9,
281  3.0, 3.1, 3.2, 3.3, 3.4, 3.5};
282  Etsum_eta_L=ib.bookProfile("Et Sum vs Eta Long Fiber","Et Sum per Area vs Eta Long Fiber",27,0,27,100,0,100);
283  Etsum_eta_S=ib.bookProfile("Et Sum vs Eta Short Fiber","Et Sum per Area vs Eta Short Fiber",27,0,27,100,0,100);
284  Etsum_phi_L=ib.bookProfile("Et Sum vs Phi Long Fiber","Et Sum per Area vs Phi Long Fiber",36,0.5,72.5,100,0,100);
285  Etsum_phi_S=ib.bookProfile("Et Sum vs Phi Short Fiber","Et Sum per Area crossing vs Phi Short Fiber",36,0.5,72.5,100,0,100);
286 
287  Etsum_ratio_p=ib.book1D("Occ vs PMT events HF+","Energy difference of Long and Short Fiber HF+ in PMT events",105,0.,1.05);
288  Energy_Occ=ib.book1D("Occ vs Energy","Occupancy vs Energy",200,0,2000);
289  Etsum_ratio_m=ib.book1D("Occ vs PMT events HF-","Energy difference of Long and Short Fiber HF- in PMT events",105,0.,1.05);
290  Etsum_map_L=ib.book2D("EtSum 2D phi and eta Long Fiber","Et Sum 2D phi and eta Long Fiber",27,0,27,36,0.5,72.5);
291  Etsum_map_S=ib.book2D("EtSum 2D phi and eta Short Fiber","Et Sum 2D phi and eta Short Fiber",27,0,27,36,0.5,72.5);
292 
293  Etsum_rphi_S=ib.book2D("EtSum 2D phi and radius Short Fiber","Et Sum 2D phi and radius Short Fiber",12, radiusbins, 70, phibins);
294  Etsum_rphi_L=ib.book2D("EtSum 2D phi and radius Long Fiber","Et Sum 2D phi and radius Long Fiber",12, radiusbins, 70, phibins);
295 
296  Etsum_ratio_map=ib.book2D("Abnormal PMT events","Abnormal PMT events",
297  8,0,8,36, 0.5,72.5);
299 
300  HFlumi_occ_LS = ib.book2D("HFlumi_occ_LS","HFlumi occupancy for current LS",
301  8,0,8,36, 0.5,72.5);
303 
304  HFlumi_total_deadcells = ib.book2D("HFlumi_total_deadcells","Number of dead lumi channels for LS with at least 10 bad channels",
305  8,0,8,36,0.5,72.5);
307  HFlumi_total_hotcells = ib.book2D("HFlumi_total_hotcells","Number of hot lumi channels for LS with at least 10 bad channels",
308  8,0,8,36,0.5,72.5);
310 
311  HFlumi_diag_deadcells = ib.book2D("HFlumi_diag_deadcells","Channels that had no hit for at least one LS",
312  8,0,8,36,0.5,72.5);
314  HFlumi_diag_hotcells = ib.book2D("HFlumi_diag_hotcells","Channels that appeared hot for at least one LS",
315  8,0,8,36,0.5,72.5);
317 
318 
319 
320  Occ_rphi_S=ib.book2D("Occ 2D phi and radius Short Fiber","Occupancy 2D phi and radius Short Fiber",12, radiusbins, 70, phibins);
321  Occ_rphi_L=ib.book2D("Occ 2D phi and radius Long Fiber","Occupancy 2D phi and radius Long Fiber",12, radiusbins, 70, phibins);
322  Occ_eta_S=ib.bookProfile("Occ vs iEta Short Fiber","Occ per Bunch crossing vs iEta Short Fiber",27,0,27,40,0,800);
323  Occ_eta_L=ib.bookProfile("Occ vs iEta Long Fiber","Occ per Bunch crossing vs iEta Long Fiber",27,0,27,40,0,800);
324 
325  Occ_phi_L=ib.bookProfile("Occ vs iPhi Long Fiber","Occ per Bunch crossing vs iPhi Long Fiber",36,0.5,72.5,40,0,800);
326 
327  Occ_phi_S=ib.bookProfile("Occ vs iPhi Short Fiber","Occ per Bunch crossing vs iPhi Short Fiber",36,0.5,72.5,40,0,800);
328 
329  Occ_map_L=ib.book2D("Occ_map Long Fiber","Occ Map long Fiber (above threshold)",27,0,27,36,0.5,72.5);
330  Occ_map_S=ib.book2D("Occ_map Short Fiber","Occ Map Short Fiber (above threshold)",27,0,27,36,0.5,72.5);
331 
332  std::stringstream binlabel;
333  for (int zz=0;zz<27;++zz)
334  {
335  if (zz<13)
336  binlabel<<zz-41;
337  else if (zz==13)
338  binlabel<<"NULL";
339  else
340  binlabel<<zz+15;
341  Occ_eta_S->setBinLabel(zz+1,binlabel.str().c_str());
342  Occ_eta_L->setBinLabel(zz+1,binlabel.str().c_str());
343  Occ_map_S->setBinLabel(zz+1,binlabel.str().c_str());
344  Occ_map_L->setBinLabel(zz+1,binlabel.str().c_str());
345  Etsum_eta_S->setBinLabel(zz+1,binlabel.str().c_str());
346  Etsum_eta_L->setBinLabel(zz+1,binlabel.str().c_str());
347  Etsum_map_S->setBinLabel(zz+1,binlabel.str().c_str());
348  Etsum_map_L->setBinLabel(zz+1,binlabel.str().c_str());
349  binlabel.str("");
350  }
351 
352  //HFlumi plots
353  HFlumi_ETsum_perwedge = ib.book1D("HF lumi ET-sum per wedge","HF lumi ET-sum per wedge;wedge",36,1,37);
354  HFlumi_ETsum_perwedge->getTH1F()->SetMinimum(0);
355 
356  HFlumi_Occupancy_above_thr_r1 = ib.book1D("HF lumi Occupancy above threshold ring1","HF lumi Occupancy above threshold ring1;wedge",36,1,37);
357  HFlumi_Occupancy_between_thrs_r1 = ib.book1D("HF lumi Occupancy between thresholds ring1","HF lumi Occupancy between thresholds ring1;wedge",36,1,37);
358  HFlumi_Occupancy_below_thr_r1 = ib.book1D("HF lumi Occupancy below threshold ring1","HF lumi Occupancy below threshold ring1;wedge",36,1,37);
359  HFlumi_Occupancy_above_thr_r2 = ib.book1D("HF lumi Occupancy above threshold ring2","HF lumi Occupancy above threshold ring2;wedge",36,1,37);
360  HFlumi_Occupancy_between_thrs_r2 = ib.book1D("HF lumi Occupancy between thresholds ring2","HF lumi Occupancy between thresholds ring2;wedge",36,1,37);
361  HFlumi_Occupancy_below_thr_r2 = ib.book1D("HF lumi Occupancy below threshold ring2","HF lumi Occupancy below threshold ring2;wedge",36,1,37);
362 
363  HFlumi_Occupancy_above_thr_r1->getTH1F()->SetMinimum(0);
364  HFlumi_Occupancy_between_thrs_r1->getTH1F()->SetMinimum(0);
365  HFlumi_Occupancy_below_thr_r1->getTH1F()->SetMinimum(0);
366  HFlumi_Occupancy_above_thr_r2->getTH1F()->SetMinimum(0);
367  HFlumi_Occupancy_between_thrs_r2->getTH1F()->SetMinimum(0);
368  HFlumi_Occupancy_below_thr_r2->getTH1F()->SetMinimum(0);
369 
370  HFlumi_Occupancy_per_channel_vs_lumiblock_RING1 = ib.bookProfile("HFlumiRing1OccupancyPerChannelVsLB",
371  "HFlumi Occupancy per channel vs lumi-block (RING 1);LS; -ln(empty fraction)",
372  NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
373  HFlumi_Occupancy_per_channel_vs_lumiblock_RING2 = ib.bookProfile("HFlumiRing2OccupancyPerChannelVsLB","HFlumi Occupancy per channel vs lumi-block (RING 2);LS; -ln(empty fraction)",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
374 
375  HFlumi_Occupancy_per_channel_vs_BX_RING1 = ib.bookProfile("HFlumi Occupancy per channel vs BX (RING 1)","HFlumi Occupancy per channel vs BX (RING 1);BX; -ln(empty fraction)",4000,0,4000,100,0,10000);
376  HFlumi_Occupancy_per_channel_vs_BX_RING2 = ib.bookProfile("HFlumi Occupancy per channel vs BX (RING 2)","HFlumi Occupancy per channel vs BX (RING 2);BX; -ln(empty fraction)",4000,0,4000,100,0,10000);
377  HFlumi_ETsum_vs_BX = ib.bookProfile("HFlumi_ETsum_vs_BX","HFlumi ETsum vs BX; BX; ETsum",4000,0,4000,100,0,10000);
378 
379  HFlumi_Et_per_channel_vs_lumiblock = ib.bookProfile("HFlumi Et per channel vs lumi-block","HFlumi Et per channel vs lumi-block;LS;ET",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
380 
383  HFlumi_Et_per_channel_vs_lumiblock->getTProfile()->SetMarkerStyle(20);
384 
385  HFlumi_Ring1Status_vs_LS = ib.bookProfile("HFlumi_Ring1Status_vs_LS","Fraction of good Ring 1 channels vs LS;LS; Fraction of Good Channels",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
386  HFlumi_Ring2Status_vs_LS = ib.bookProfile("HFlumi_Ring2Status_vs_LS","Fraction of good Ring 2 channels vs LS;LS; Fraction of Good Channels",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
387  HFlumi_Ring1Status_vs_LS->getTProfile()->SetMarkerStyle(20);
388  HFlumi_Ring2Status_vs_LS->getTProfile()->SetMarkerStyle(20);
389 
390  return;
391 }
392 
394 {
396 
397  if (debug_>1) std::cout <<"HcalBeamMonitor::bookHistograms"<<std::endl;
399 
401  runNumber_=run.id().run();
402  if (lumiqualitydir_.size()>0 && Online_==true)
403  {
404  if (Overwrite_==false)
405  outfile_ <<lumiqualitydir_<<"HcalHFLumistatus_"<<runNumber_<<".txt";
406  else
407  outfile_ <<lumiqualitydir_<<"HcalHFLumistatus.txt";
408  std::ofstream outStream(outfile_.str().c_str()); // recreate the file, rather than appending to it
409  outStream<<"## Run "<<runNumber_<<std::endl;
410  outStream<<"## LumiBlock\tRing1Status\t\tRing2Status\t\tGlobalStatus\tNentries"<<std::endl;
411  outStream.close();
412  }
413 
414  // Get expected good channels in run according to channel quality database
415  // Get channel quality status info for each run
416 
417  // Default number of expected good channels in the run
420  BadCells_.clear(); // remove any old maps
421  // Get Channel quality info for the run
422  // Exclude bad channels from overall calculation
424  c.get<HcalChannelQualityRcd>().get("withTopo",p);
425  const HcalChannelQuality* chanquality = p.product();
426  std::vector<DetId> mydetids = chanquality->getAllChannels();
427 
428  for (unsigned int i=0;i<mydetids.size();++i)
429  {
430  if (mydetids[i].det()!=DetId::Hcal) continue;
431  HcalDetId id=mydetids[i];
432 
433  if (id.subdet()!=HcalForward) continue;
434  if ((id.depth()==1 && (abs(id.ieta())==33 || abs(id.ieta())==34)) ||
435  (id.depth()==2 && (abs(id.ieta())==35 || abs(id.ieta())==36))) {
436  const HcalChannelStatus* origstatus=chanquality->getValues(id);
437  HcalChannelStatus mystatus(origstatus->rawId(),origstatus->getValue());
438  if (mystatus.isBitSet(HcalChannelStatus::HcalCellHot))
440 
441  else if (mystatus.isBitSet(HcalChannelStatus::HcalCellDead))
443 
444  if (mystatus.isBitSet(HcalChannelStatus::HcalCellHot) ||
445  mystatus.isBitSet(HcalChannelStatus::HcalCellDead)) {
446  if (id.depth()==1) --ring1totalchannels_;
447  else if (id.depth()==2) --ring2totalchannels_;
448  }
449  } // if ((id.depth()==1) ...
450  } // for (unsigned int i=0;...)
451 
452  if (tevt_==0) this->setup(ib); // create all histograms; not necessary if merging runs together
453  if (mergeRuns_==false) this->reset(); // call reset at start of all runs
454 
455  return;
456 
457 } // void HcalBeamMonitor::bookHistograms(const edm::Run& run, const edm::EventSetup& c)
458 
459 
461 {
463  if (!IsAllowedCalibType()) return;
464  if (LumiInOrder(e.luminosityBlock())==false) return;
465 
466  // try to get rechits and digis
468 
472 
473  if (!(e.getByToken(tok_hfdigi_,hf_digi)))
474  {
475  edm::LogWarning("HcalBeamMonitor")<< digiLabel_<<" hf_digi not available";
476  return;
477  }
478 
479  if (!(e.getByToken(tok_hbhe_,hbhe_rechit)))
480  {
481  edm::LogWarning("HcalBeamMonitor")<< hbheRechitLabel_<<" hbhe_rechit not available";
482  return;
483  }
484 
485  if (!(e.getByToken(tok_hf_,hf_rechit)))
486  {
487  edm::LogWarning("HcalBeamMonitor")<< hfRechitLabel_<<" hf_rechit not available";
488  return;
489  }
490  if (!(e.getByToken(tok_ho_,ho_rechit)))
491  {
492  edm::LogWarning("HcalBeamMonitor")<< hoRechitLabel_<<" ho_rechit not available";
493  return;
494  }
495 
496  //good event; increment counters and process
498  c.get<HcalRecNumberingRecord>().get(topo);
499  // HcalBaseDQMonitor::analyze(e,c);
500  processEvent(*hbhe_rechit, *ho_rechit, *hf_rechit, *hf_digi, e.bunchCrossing(),*topo);
501 
502 } //void HcalBeamMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
503 
504 
506  const HORecHitCollection& hoHits,
507  const HFRecHitCollection& hfHits,
508  const HFDigiCollection& hf,
509  int bunchCrossing,
510  const HcalTopology& topology) {
511  //processEvent loop
515 
516  double totalX=0;
517  double totalY=0;
518  double totalE=0;
519 
520  double HBtotalX=0;
521  double HBtotalY=0;
522  double HBtotalE=0;
523  double HEtotalX=0;
524  double HEtotalY=0;
525  double HEtotalE=0;
526  double HOtotalX=0;
527  double HOtotalY=0;
528  double HOtotalE=0;
529  double HFtotalX=0;
530  double HFtotalY=0;
531  double HFtotalE=0;
532 
533  float hitsp[13][36][2];
534  float hitsm[13][36][2];
535  float hitsp_Et[13][36][2];
536  float hitsm_Et[13][36][2];
537 
538  for(int m=0;m<13;m++){
539  for(int n=0;n<36;n++){
540  hitsp[m][n][0]=0;
541  hitsp[m][n][1]=0;
542  hitsm[m][n][0]=0;
543  hitsm[m][n][1]=0;
544 
545  hitsp_Et[m][n][0]=0;
546  hitsp_Et[m][n][1]=0;
547  hitsm_Et[m][n][0]=0;
548  hitsm_Et[m][n][1]=0;
549  }
550  }
551 
552  if(hbheHits.size()>0)
553  {
554  double HB_weightedX[HBETASIZE]={0.};
555  double HB_weightedY[HBETASIZE]={0.};
556  double HB_energy[HBETASIZE]={0.};
557 
558  double HE_weightedX[HEETASIZE]={0.};
559  double HE_weightedY[HEETASIZE]={0.};
560  double HE_energy[HEETASIZE]={0.};
561 
562  int ieta, iphi;
563 
564  for (HBHEiter=hbheHits.begin();
565  HBHEiter!=hbheHits.end();
566  ++HBHEiter)
567  {
568 
569  // loop over all hits
570  if (HBHEiter->energy()<0) continue; // don't consider negative-energy cells
571  HcalDetId id(HBHEiter->detid().rawId());
572  ieta=id.ieta();
573  iphi=id.iphi();
574 
575  int index=-1;
576  if ((HcalSubdetector)(id.subdet())==HcalBarrel)
577  {
578  HBtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
579  HBtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
580  HBtotalE+=HBHEiter->energy();
581 
582  index=ieta+ETA_OFFSET_HB;
583  if (index<0 || index>= HBETASIZE) continue;
584  HB_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
585  HB_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
586  HB_energy[index]+=HBHEiter->energy();
587  } // if id.subdet()==HcalBarrel
588 
589  else
590  {
591  HEtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
592  HEtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
593  HEtotalE+=HBHEiter->energy();
594 
595  index=ieta+ETA_OFFSET_HE;
596  if (index<0 || index>= HEETASIZE) continue;
597  HE_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
598  HE_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
599  HE_energy[index]+=HBHEiter->energy();
600  }
601  } // for (HBHEiter=hbheHits.begin()...
602  // Fill each histogram
603 
604  int hbeta=ETA_OFFSET_HB;
605  for (int i=-1*hbeta;i<=hbeta;++i)
606  {
607  if (i==0) continue;
608  int index = i+ETA_OFFSET_HB;
609  if (index<0 || index>= HBETASIZE) continue;
610  if (HB_energy[index]==0) continue;
611  double moment=pow(HB_weightedX[index],2)+pow(HB_weightedY[index],2);
612  moment=pow(moment,0.5);
613  moment/=HB_energy[index];
614  if (moment!=0)
615  {
616  if (makeDiagnostics_) HB_CenterOfEnergyRadius[index]->Fill(moment);
617  COEradiusVSeta->Fill(i,moment);
618  }
619  } // for (int i=-1*hbeta;i<=hbeta;++i)
620 
621  int heeta=ETA_OFFSET_HE;
622  for (int i=-1*heeta;i<=heeta;++i)
623  {
624  if (i==0) continue;
625  if (i>-1*ETA_BOUND_HE && i <ETA_BOUND_HE) continue;
626  int index = i + ETA_OFFSET_HE;
627  if (index<0 || index>= HEETASIZE) continue;
628  if (HE_energy[index]==0) continue;
629  double moment=pow(HE_weightedX[index],2)+pow(HE_weightedY[index],2);
630  moment=pow(moment,0.5);
631  moment/=HE_energy[index];
632  if (moment!=0)
633  {
634  if (makeDiagnostics_) HE_CenterOfEnergyRadius[index]->Fill(moment);
635  COEradiusVSeta->Fill(i,moment);
636  }
637  } // for (int i=-1*heeta;i<=heeta;++i)
638 
639  } // if (hbheHits.size()>0)
640 
641 
642  // HO loop
643  if(hoHits.size()>0)
644  {
645  double HO_weightedX[HOETASIZE]={0.};
646  double HO_weightedY[HOETASIZE]={0.};
647  double HO_energy[HOETASIZE]={0.};
648  double offset;
649 
650  int ieta, iphi;
651  for (HOiter=hoHits.begin();
652  HOiter!=hoHits.end();
653  ++HOiter)
654  {
655  // loop over all cells
656  if (HOiter->energy()<0) continue; // don't include negative-energy cells?
657  HcalDetId id(HOiter->detid().rawId());
658  ieta=id.ieta();
659  iphi=id.iphi();
660 
661  HOtotalX+=HOiter->energy()*cos(PI*iphi/36.);
662  HOtotalY+=HOiter->energy()*sin(PI*iphi/36.);
663  HOtotalE+=HOiter->energy();
664 
665  int index=ieta+ETA_OFFSET_HO;
666  if (index<0 || index>= HOETASIZE) continue;
667  HO_weightedX[index]+=HOiter->energy()*cos(PI*iphi/36.);
668  HO_weightedY[index]+=HOiter->energy()*sin(PI*iphi/36.);
669  HO_energy[index]+=HOiter->energy();
670  } // for (HOiter=hoHits.begin();...)
671 
672  for (int i=-1*ETA_OFFSET_HO;i<=ETA_OFFSET_HO;++i)
673  {
674  if (i==0) continue;
675  int index = i + ETA_OFFSET_HO;
676  if (index < 0 || index>= HOETASIZE) continue;
677  if (HO_energy[index]==0) continue;
678  double moment=pow(HO_weightedX[index],2)+pow(HO_weightedY[index],2);
679  moment=pow(moment,0.5);
680  moment/=HO_energy[index];
681  // Shift HO values by 0.5 units in eta relative to HB
682  offset = (i>0 ? 0.5: -0.5);
683  if (moment!=0)
684  {
685  if (makeDiagnostics_) HO_CenterOfEnergyRadius[index]->Fill(moment);
686  COEradiusVSeta->Fill(i+offset,moment);
687  }
688  } // for (int i=-1*hoeta;i<=hoeta;++i)
689  } // if (hoHits.size()>0)
690 
692  // HF loop
693 
694  Etsum_ratio_map->Fill(-1,-1,1); // fill underflow bin with number of events
695  {
696  if(hfHits.size()>0)
697  {
698  double HF_weightedX[HFETASIZE]={0.};
699  double HF_weightedY[HFETASIZE]={0.};
700  double HF_energy[HFETASIZE]={0.};
701  double offset;
702 
703  // Assume ZS until shown otherwise
704  double emptytowersRing1 = ring1totalchannels_;
705  double emptytowersRing2 = ring2totalchannels_;
706  double ZStowersRing1 = ring1totalchannels_;
707  double ZStowersRing2 = ring2totalchannels_;
708 
709  int ieta, iphi;
710  float et,eta,phi,r;
711 
712  HFlumi_occ_LS->Fill(-1,-1,1 ); // event counter in occupancy histogram underflow bin
713  // set maximum to HFlumi_occ_LS->getBinContent(0,0)?
714  // that won't work -- offline will add multiple histograms, and maximum will get screwed up?
715  // No, we can add it here, but we also need a call to setMaximum in the client as well.
716  HFlumi_occ_LS->getTH2F()->SetMaximum(HFlumi_occ_LS->getBinContent(0,0));
717 
718  double etx=0, ety=0;
719 
720  for (HFiter=hfHits.begin();
721  HFiter!=hfHits.end();
722  ++HFiter)
723  { // loop on hfHits
724  // If hit present, don't count it as ZS any more
725  ieta = HFiter->id().ieta();
726  iphi = HFiter->id().iphi();
727 
728  int binieta=ieta;
729  if (ieta<0) binieta+=41;
730  else if (ieta>0) binieta-=15;
731 
732  // Count that hit was found in one of the rings used for luminosity calculation.
733  // If so, decrease the number of empty channels per ring by 1
734  if (abs(ieta)>=33 && abs(ieta)<=36) // luminosity ring check
735  {
736  // don't subtract away cells that have already been removed as bad
737  if (BadCells_.find(HFiter->id())==BadCells_.end()) // bad cell not found
738  {
739  if ((abs(ieta)<35) && HFiter->id().depth()==1) --ZStowersRing1;
740  else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- ZStowersRing2;
741  }
742  }
743 
744  if (HFiter->energy()<0) continue; // don't include negative-energy cells?
745 
746  std::pair<double,double> etas = topology.etaRange(HcalForward,abs(ieta));
747  eta=fabs(0.5*(etas.first+etas.second));
748 // eta=theHFEtaBounds[abs(ieta)-29];
749  et=HFiter->energy()/cosh(eta)/area[abs(ieta)-29];
750  if (abs(ieta)>=33 && abs(ieta)<=36) // Luminosity ring check
751  {
752  // don't count cells that are below threshold, or that have been marked bad in Chan Stat DB
753  if (et>=occThresh_ && BadCells_.find(HFiter->id())==BadCells_.end() ) // minimum ET threshold
754  {
755  if ((abs(ieta)<35) && HFiter->id().depth()==1) --emptytowersRing1;
756  else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- emptytowersRing2;
757  }
758  }
759  r=radius[abs(ieta)-29];
760  if(HFiter->id().iphi()<37)
761  phi=HFiter->id().iphi()*0.087266;
762  else phi=(HFiter->id().iphi()-72)*0.087266;
763 
764 
765  if (HFiter->id().depth()==1)
766  {
767  Etsum_eta_L->Fill(binieta,et);
768  Etsum_phi_L->Fill(iphi,et);
769  Etsum_map_L->Fill(binieta,iphi,et);
770  Etsum_rphi_L->Fill(r,phi,et);
771 
772  if(ieta>0) {
773  hitsp[ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
774  hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
775  }
776  else if(ieta<0) {
777  hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
778  hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
779  }
780  } // if (HFiter->id().depth()==1)
781 
782  //Fill 3 histos for Short Fibers :
783  if (HFiter->id().depth()==2)
784  {
785  Etsum_eta_S->Fill(binieta,et);
786  Etsum_phi_S->Fill(iphi,et);
787  Etsum_rphi_S->Fill(r,phi,et);
788  Etsum_map_S->Fill(binieta,iphi,et);
789  if(ieta>0)
790  {
791  hitsp[ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
792  hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
793  }
794  else if(ieta<0) {
795  hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
796  hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
797  }
798 
799  } // depth()==2
800  Energy_Occ->Fill(HFiter->energy());
801 
802  //HF: no non-threshold occupancy map is filled?
803 
804  if ((abs(ieta) == 33 || abs(ieta) == 34) && HFiter->id().depth() == 1)
805  {
806  etx+=et*cos(PI*iphi/36.);
807  ety+=et*sin(PI*iphi/36.);
808 
810  if (et>occThresh_)
811  {
812  int etabin=0;
813  if (ieta<0)
814  etabin=36+ieta; // bins 0-3 correspond to ieta = -36, -35, -34, -33
815  else
816  etabin=ieta-29; // bins 4-7 correspond to ieta = 33, 34, 35, 36
817  HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
818  }
819  }
820 
821  else if ((abs(ieta) == 35 || abs(ieta) == 36) && HFiter->id().depth() == 2)
822  {
823  etx+=et*cos(PI*iphi/36.);
824  ety+=et*sin(PI*iphi/36.);
825 
827  if (et>occThresh_)
828  {
829  int etabin=0;
830  if (ieta<0)
831  etabin=36+ieta; // bins 0-3 correspond to ieta = -36, -35, -34, -33
832  else
833  etabin=ieta-29; // bins 4-7 correspond to ieta = 33, 34, 35, 36
834  HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
835  }
836  }
837 
838  // Fill occupancy plots.
839 
840  int value=0;
841  if(et>occThresh_) value=1;
842 
843  if (HFiter->id().depth()==1)
844  {
845  Occ_eta_L->Fill(binieta,value);
846  Occ_phi_L->Fill(iphi,value);
847  Occ_map_L->Fill(binieta,iphi,value);
848  Occ_rphi_L->Fill(r,phi,value);
849  }
850 
851  else if (HFiter->id().depth()==2)
852  {
853  Occ_eta_S->Fill(binieta,value);
854  Occ_phi_S->Fill(iphi,value);
855  Occ_map_S->Fill(binieta,iphi,value);
856  Occ_rphi_S->Fill(r,phi,value);
857  }
858  HcalDetId id(HFiter->detid().rawId());
859 
860  HFtotalX+=HFiter->energy()*cos(PI*iphi/36.);
861  HFtotalY+=HFiter->energy()*sin(PI*iphi/36.);
862  HFtotalE+=HFiter->energy();
863 
864  int index=ieta+ETA_OFFSET_HF;
865  if (index<0 || index>= HFETASIZE) continue;
866  HF_weightedX[index]+=HFiter->energy()*cos(PI*iphi/36.);
867  HF_weightedY[index]+=HFiter->energy()*sin(PI*iphi/36.);
868  HF_energy[index]+=HFiter->energy();
869 
870  } // for (HFiter=hfHits.begin();...)
871 
872  // looped on all HF hits; calculate empty fraction
873  // empty towers = # of cells with ET < 0.0625 GeV, or cells missing because of ZS
874  // Calculated as : 144 - (# of cells with ET >= 0.0625 GeV)
875  // At some point, allow for calculations when channels are masked (and less than 144 channels expected)
876 
877  // Check Ring 1
878  double logvalue=-1;
879  if (ring1totalchannels_>0)
880  {
881  if (emptytowersRing1>0)
882  logvalue=-1.*log(emptytowersRing1/ring1totalchannels_);
884  HFlumi_Occupancy_per_channel_vs_BX_RING1->Fill(bunchCrossing,logvalue);
885  }
886  // Check Ring 2
887  logvalue=-1;
888  if (ring2totalchannels_>0)
889  {
890  if (emptytowersRing2>0)
891  logvalue=-1.*log(emptytowersRing2/ring2totalchannels_);
893  HFlumi_Occupancy_per_channel_vs_BX_RING2->Fill(bunchCrossing,logvalue);
894  }
895 
896  HFlumi_ETsum_vs_BX->Fill(bunchCrossing,pow(etx*etx+ety*ety,0.5));
897  int hfeta=ETA_OFFSET_HF;
898  for (int i=-1*hfeta;i<=hfeta;++i)
899  {
900  if (i==0) continue;
901  if (i>-1*ETA_BOUND_HF && i <ETA_BOUND_HF) continue;
902  int index = i + ETA_OFFSET_HF;
903  if (index<0 || index>= HFETASIZE) continue;
904  if (HF_energy[index]==0) continue;
905  double moment=pow(HF_weightedX[index],2)+pow(HF_weightedY[index],2);
906  moment=pow(moment,0.5);
907  moment/=HF_energy[index];
908  offset = (i>0 ? 0.5: -0.5);
909  if (moment!=0)
910  {
911  if (makeDiagnostics_) HF_CenterOfEnergyRadius[index]->Fill(moment);
912  COEradiusVSeta->Fill(i+offset,moment);
913  }
914  } // for (int i=-1*hfeta;i<=hfeta;++i)
915  float ratiom,ratiop;
916 
917  for(int i=0;i<13;i++){
918  for(int j=0;j<36;j++){
919 
920  if(hitsp[i][j][0]==hitsp[i][j][1]) continue;
921 
922  if (hitsp[i][j][0] < 1.2 && hitsp[i][j][1] < 1.8) continue;
923  //use only lumi rings
924  if (((i+29) < 33) || ((i+29) > 36)) continue;
925  ratiop=fabs((fabs(hitsp[i][j][0])-fabs(hitsp[i][j][1]))/(fabs(hitsp[i][j][0])+fabs(hitsp[i][j][1])));
926  //cout<<ratiop<<std::endl;
927  if ((hitsp_Et[i][j][0] > 5. && hitsp[i][j][1] < 1.8) || (hitsp_Et[i][j][1] > 5. && hitsp[i][j][0] < 1.2)){
928  Etsum_ratio_p->Fill(ratiop);
929  if(abs(ratiop>0.95)) Etsum_ratio_map->Fill(i,2*j+1); // i=4,5,6,7 for HFlumi rings
930  }
931  }
932  }
933 
934  for(int p=0;p<13;p++){
935  for(int q=0;q<36;q++){
936 
937  if(hitsm[p][q][0]==hitsm[p][q][1]) continue;
938 
939  if (hitsm[p][q][0] < 1.2 && hitsm[p][q][1] < 1.8) continue;
940  //use only lumi rings
941  if (((p+29) < 33) || ((p+29) > 36)) continue;
942  ratiom=fabs((fabs(hitsm[p][q][0])-fabs(hitsm[p][q][1]))/(fabs(hitsm[p][q][0])+fabs(hitsm[p][q][1])));
943  if ((hitsm_Et[p][q][0] > 5. && hitsm[p][q][1] < 1.8) || (hitsm_Et[p][q][1] > 5. && hitsm[p][q][0] < 1.2)){
944  Etsum_ratio_m->Fill(ratiom);
945  if(abs(ratiom>0.95)) Etsum_ratio_map->Fill(7-p,2*q+1); // p=4,5,6,7 for HFlumi rings
946  //p=7: ieta=-36; p=4: ieta=-33
947  }
948  }
949  }
950  } // if (hfHits.size()>0)
951 
952  totalX=HBtotalX+HEtotalX+HOtotalX+HFtotalX;
953  totalY=HBtotalY+HEtotalY+HOtotalY+HFtotalY;
954  totalE=HBtotalE+HEtotalE+HOtotalE+HFtotalE;
955 
956  double moment;
957  if (HBtotalE>0)
958  {
959  moment=pow(HBtotalX*HBtotalX+HBtotalY*HBtotalY,0.5)/HBtotalE;
960  HBCenterOfEnergyRadius->Fill(moment);
961  HBCenterOfEnergy->Fill(HBtotalX/HBtotalE, HBtotalY/HBtotalE);
962  }
963  if (HEtotalE>0)
964  {
965  moment=pow(HEtotalX*HEtotalX+HEtotalY*HEtotalY,0.5)/HEtotalE;
966  HECenterOfEnergyRadius->Fill(moment);
967  HECenterOfEnergy->Fill(HEtotalX/HEtotalE, HEtotalY/HEtotalE);
968  }
969  if (HOtotalE>0)
970  {
971  moment=pow(HOtotalX*HOtotalX+HOtotalY*HOtotalY,0.5)/HOtotalE;
972  HOCenterOfEnergyRadius->Fill(moment);
973  HOCenterOfEnergy->Fill(HOtotalX/HOtotalE, HOtotalY/HOtotalE);
974  }
975  if (HFtotalE>0)
976  {
977  moment=pow(HFtotalX*HFtotalX+HFtotalY*HFtotalY,0.5)/HFtotalE;
978  HFCenterOfEnergyRadius->Fill(moment);
979  HFCenterOfEnergy->Fill(HFtotalX/HFtotalE, HFtotalY/HFtotalE);
980  }
981  if (totalE>0)
982  {
983  moment = pow(totalX*totalX+totalY*totalY,0.5)/totalE;
984  CenterOfEnergyRadius->Fill(moment);
985  CenterOfEnergy->Fill(totalX/totalE, totalY/totalE);
986  }
987 
988 
989 
990  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); j++){
991  const HFDataFrame digi = (const HFDataFrame)(*j);
992  // calibs_= cond.getHcalCalibrations(digi.id()); // Old method was made private.
993  // float en=0;
994  // float ts =0; float bs=0;
995  // int maxi=0; float maxa=0;
996  // for(int i=sigS0_; i<=sigS1_; i++){
997  // if(digi.sample(i).adc()>maxa){maxa=digi.sample(i).adc(); maxi=i;}
998  // }
999  // for(int i=sigS0_; i<=sigS1_; i++){
1000  // float tmp1 =0;
1001  // int j1=digi.sample(i).adc();
1002  // tmp1 = (LedMonAdc2fc[j1]+0.5);
1003  // en += tmp1-calibs_.pedestal(digi.sample(i).capid());
1004  // if(i>=(maxi-1) && i<=maxi+1){
1005  // ts += i*(tmp1-calibs_.pedestal(digi.sample(i).capid()));
1006  // bs += tmp1-calibs_.pedestal(digi.sample(i).capid());
1007  // }
1008  // }
1009 
1010  //---HFlumiplots
1011  int theTStobeused = 6;
1012  // will have masking later:
1013  int mask=1;
1014  if(mask!=1) continue;
1015  //if we want to sum the 10 TS instead of just taking one:
1016  for (int i=0; i<digi.size(); i++) {
1017  if (i==theTStobeused) {
1018  float tmpET =0;
1019  int jadc=digi.sample(i).adc();
1020  //NOW LUT used in HLX are only identy LUTs, so Et filled
1021  //with unlinearised adc, ie tmpET = jadc
1022  // tmpET = (adc2fc[jadc]+0.5);
1023  tmpET = jadc;
1024 
1025  //-find which wedge we are in
1026  // ETsum and Occupancy will be summed for both L and S
1027  if(digi.id().ieta()>28){
1028  if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
1029  HFlumi_ETsum_perwedge->Fill(1,tmpET);
1030  if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
1031  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(1,1);
1032  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(1,1);
1033  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(1,1);
1034  }
1035  else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
1036  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(1,1);
1037  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(1,1);
1038  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(1,1);
1039  }
1040  }
1041  else {
1042  for (int iwedge=2; iwedge<19; iwedge++) {
1043  int itmp=4*(iwedge-1);
1044  if( (digi.id().iphi()==(itmp+1)) || (digi.id().iphi()==(itmp-1))) {
1045  HFlumi_ETsum_perwedge->Fill(iwedge,tmpET);
1046  if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
1047  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iwedge,1);
1048  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iwedge,1);
1049  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iwedge,1);
1050  }
1051  else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
1052  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iwedge,1);
1053  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iwedge,1);
1054  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iwedge,1);
1055  }
1056  iwedge=99;
1057  }
1058  }
1059  }
1060  } //--endif ieta in HF+
1061  else if(digi.id().ieta()<-28){
1062  if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
1063  HFlumi_ETsum_perwedge->Fill(19,tmpET);
1064  if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
1065  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(19,1);
1066  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(19,1);
1067  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(19,1);
1068  }
1069  else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
1070  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(19,1);
1071  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(19,1);
1072  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(19,1);
1073  }
1074  }
1075  else {
1076  for (int iw=2; iw<19; iw++) {
1077  int itemp=4*(iw-1);
1078  if( (digi.id().iphi()==(itemp+1)) || (digi.id().iphi()==(itemp-1))) {
1079  HFlumi_ETsum_perwedge->Fill(iw+18,tmpET);
1080  if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
1081  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iw+18,1);
1082  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iw+18,1);
1083  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iw+18,1);
1084  }
1085  else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
1086  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iw+18,1);
1087  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iw+18,1);
1088  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iw+18,1);
1089  }
1090  iw=99;
1091  }
1092  }
1093  }
1094  }//---endif ieta inHF-
1095  }//---endif TS=nr6
1096  }
1097  }//------end loop over TS for lumi
1098  return;
1099  }
1100 }
1101  // void HcalBeamMonitor::processEvent(const HBHERecHit Collection&hbheHits; ...)
1102 
1103 
1105  const edm::EventSetup& c)
1106 
1107 {
1108  // reset histograms that get updated each luminosity section
1109 
1110  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
1112 
1113  if (lumiSeg.luminosityBlock()==lastProcessedLS_) return; // we're seeing more events from current lumi section (after some break) -- should not reset histogram
1115  HFlumi_occ_LS->Reset();
1116  std::stringstream title;
1117  title <<"HFlumi occupancy for LS # " <<currentLS;
1118  HFlumi_occ_LS->getTH2F()->SetTitle(title.str().c_str());
1119  return;
1120 } // void HcalBeamMonitor::beginLuminosityBlock()
1121 
1123  const edm::EventSetup& c)
1124 {
1125  if (debug_>1) std::cout <<"<HcalBeamMonitor::endLuminosityBlock>"<<std::endl;
1126  if (LumiInOrder(lumiSeg.luminosityBlock())==false)
1127  {
1128  if (debug_>1)
1129  std::cout <<"<HcalBeamMonitor::endLuminosityBlock> Failed LumiInOrder test!"<<std::endl;
1130  return;
1131  }
1133  float Nentries=HFlumi_occ_LS->getBinContent(-1,-1);
1134  if (debug_>3)
1135  std::cout <<"Number of entries in this LB = "<<Nentries<<std::endl;
1136 
1137  if (Nentries<minEvents_)
1138  {
1139  // not enough entries to determine status; fill everything with -1 and return
1142  if (Online_==false)
1143  return;
1144  // write to output file if required (Online running)
1145  if (lumiqualitydir_.size()==0)
1146  return;
1147  // dump out lumi quality file
1148  std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
1149  outStream<<currentLS<<"\t\t-1\t\t\t-1\t\t\t-1\t\t"<<Nentries<<std::endl;
1150  outStream.close();
1151  return;
1152  }
1153  if (Nentries==0) return;
1154 
1155 
1156  HFlumi_total_deadcells->Fill(-1,-1,1); // counts good lumi sections in underflow bin
1157  HFlumi_total_hotcells->Fill(-1,-1,1);
1158  HFlumi_diag_deadcells->Fill(-1,-1,1); // counts good lumi sections in underflow bin
1159  HFlumi_diag_hotcells->Fill(-1,-1,1);
1160 
1161  // ADD IETA MAP
1162  int ietamap[8]={-36,-35,-34,-33,33,34,35,36};
1163  int ieta=-1, iphi = -1, depth=-1;
1164  int badring1=0;
1165  int badring2=0;
1166  int ndeadcells=0;
1167  int nhotcells=0;
1168 
1169  // Loop over cells once to count hot & dead chanels
1170  for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
1171  {
1172  for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
1173  {
1174 
1175  // Skip over channels that are flagged as bad
1176  if (x<=8)
1177  ieta=ietamap[x-1];
1178  else
1179  ieta=-1;
1180  iphi=2*y-1;
1181  if (abs(ieta)==33 || abs(ieta)==34) depth=1;
1182  else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
1183  else depth = -1;
1184  if (depth !=-1 && ieta!=1)
1185  {
1186  HcalDetId thisID(HcalForward, ieta, iphi, depth);
1187  if (BadCells_.find(thisID)!=BadCells_.end())
1188  continue;
1189  }
1190  double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
1191  if (Ncellhits==0)
1192  {
1193  ++ndeadcells;
1194  HFlumi_diag_deadcells->Fill(x-1,2*y-1,1);
1195  }
1196  // hot if present in more than 25% of events in the LS
1197  if (Ncellhits>hotrate_*Nentries)
1198  {
1199  ++nhotcells;
1200  HFlumi_diag_hotcells->Fill(x-1,2*y-1,1);
1201  }
1202  if (Ncellhits==0 || Ncellhits>hotrate_*Nentries) // cell was either hot or dead
1203  {
1204  if (depth==1) badring1++;
1205  else if (depth==2) badring2++;
1206  }
1207  } // loop over y
1208  } // loop over x
1209 
1210  // Fill problem histogram underflow bind with number of events
1211  ProblemsCurrentLB->Fill(-1,-1,levt_);
1212  if (ndeadcells+nhotcells>=minBadCells_)
1213  {
1214  // Fill with number of error channels * events (assume bad for all events in LS)
1215  ProblemsCurrentLB->Fill(6,0,(ndeadcells+nhotcells)*levt_);
1216  for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
1217  {
1218  for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
1219  {
1220  if (x<=8)
1221  ieta=ietamap[x-1];
1222  else
1223  ieta=-1;
1224  iphi=2*y-1;
1225  if (abs(ieta)==33 || abs(ieta)==34) depth=1;
1226  else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
1227  else depth = -1;
1228  if (depth !=-1 && ieta!=1)
1229  {
1230  // skip over channels that are flagged as bad
1231  HcalDetId thisID(HcalForward, ieta, iphi, depth);
1232  if (BadCells_.find(thisID)!=BadCells_.end())
1233  continue;
1234  }
1235  double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
1236  if (Ncellhits==0)
1237  {
1238  // One new luminosity section found with no entries for the cell in question
1239  HFlumi_total_deadcells->Fill(x-1,2*y-1,1);
1240  } // dead cell check
1241 
1242  // hot if present in more than 25% of events in the LS
1243  if (Ncellhits>hotrate_*Nentries)
1244  {
1245  HFlumi_total_hotcells->Fill(x-1,2*y-1,1);
1246  } // hot cell check
1247  } // loop over y
1248  } // loop over x
1249  } // if (ndeadcells+nhotcells>=minBadCells_)
1250 
1251  // Fill fraction of bad channels found in this LS
1252  double ring1status=0;
1253  double ring2status=0;
1254  if (ring1totalchannels_==0)
1255  ring1status=0;
1256  else
1257  ring1status=1-1.*badring1/ring1totalchannels_;
1258  HFlumi_Ring1Status_vs_LS->Fill(currentLS,ring1status);
1259  if (ring2totalchannels_==0)
1260  ring2status=0;
1261  else
1262  ring2status=1-1.*badring2/ring2totalchannels_;
1263  HFlumi_Ring2Status_vs_LS->Fill(currentLS,ring2status);
1264 
1265  // Good status: ring1 and ring2 status both > 90%
1266  int totalstatus=0;
1267  if (ring1status>0.9 && ring2status>0.9)
1268  totalstatus=1;
1269  else
1270  {
1271  if (ring1status<=0.9)
1272  totalstatus-=2;
1273  if (ring2status<=0.9)
1274  totalstatus-=4;
1275  }
1276 
1277  if (lumiqualitydir_.size()==0)
1278  return;
1279  // dump out lumi quality file
1280  std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
1281  outStream.precision(6);
1282  outStream<<currentLS<<"\t\t"<<ring1status<<"\t\t"<<ring2status<<"\t\t"<<totalstatus<<"\t\t"<<Nentries<<std::endl;
1283  outStream.close();
1284  return;
1285 }
1286 
1287 const float HcalBeamMonitor::area[]={0.111,0.175,0.175,0.175,0.175,0.175,0.174,0.178,0.172,0.175,0.178,0.346,0.604};
1288 const float HcalBeamMonitor::radius[]={1300,1162,975,818,686,576,483,406,340,286,240,201,169};
1289 
1291 {
1292  h->getTH2F()->GetXaxis()->SetBinLabel(1,"-36S");
1293  h->getTH2F()->GetXaxis()->SetBinLabel(2,"-35S");
1294  h->getTH2F()->GetXaxis()->SetBinLabel(3,"-34L");
1295  h->getTH2F()->GetXaxis()->SetBinLabel(4,"-33L");
1296  h->getTH2F()->GetXaxis()->SetBinLabel(5,"33L");
1297  h->getTH2F()->GetXaxis()->SetBinLabel(6,"34L");
1298  h->getTH2F()->GetXaxis()->SetBinLabel(7,"35S");
1299  h->getTH2F()->GetXaxis()->SetBinLabel(8,"36S");
1300  return;
1301 }
1302 
1304 
MonitorElement * HFCenterOfEnergyRadius
MonitorElement * Etsum_map_S
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * HBCenterOfEnergy
int i
Definition: DBlmapReader.cc:9
bool LumiInOrder(int lumisec)
MonitorElement * Etsum_eta_L
MonitorElement * Occ_rphi_L
MonitorElement * HOCenterOfEnergy
void setup(DQMStore::IBooker &)
MonitorElement * HFlumi_Occupancy_above_thr_r1
MonitorElement * ProblemsCurrentLB
RunID const & id() const
Definition: RunBase.h:39
int ib
Definition: cuy.py:660
MonitorElement * Occ_rphi_S
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
edm::EDGetTokenT< HFDigiCollection > tok_hfdigi_
RunNumber_t run() const
Definition: RunID.h:39
#define PI
void bookHistograms(DQMStore::IBooker &ib, const edm::Run &run, const edm::EventSetup &c)
CaloTopology const * topology(0)
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
MonitorElement * HFlumi_Occupancy_below_thr_r2
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define HBETASIZE
MonitorElement * Etsum_eta_S
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int adc() const
get the ADC sample
Definition: HcalQIESample.h:22
std::vector< int > AllowedCalibTypes_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
MonitorElement * Etsum_phi_S
MonitorElement * HFlumi_Occupancy_between_thrs_r2
MonitorElement * Occ_map_L
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
MonitorElement * Etsum_map_L
std::vector< HBHERecHit >::const_iterator const_iterator
int bunchCrossing() const
Definition: EventBase.h:65
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:62
MonitorElement * HFlumi_Occupancy_per_channel_vs_lumiblock_RING2
const Item * getValues(DetId fId, bool throwOnFail=true) const
MonitorElement * COEradiusVSeta
MonitorElement * Occ_phi_S
edm::InputTag hbheRechitLabel_
const int ETA_OFFSET_HF
MonitorElement * HFlumi_ETsum_perwedge
MonitorElement * HFlumi_Ring2Status_vs_LS
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
uint32_t rawId() const
void Fill(long long x)
LuminosityBlockNumber_t luminosityBlock() const
#define HOETASIZE
MonitorElement * Occ_phi_L
MonitorElement * HFlumi_ETsum_vs_BX
edm::InputTag hoRechitLabel_
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
static const float area[]
const int ETA_BOUND_HF
std::map< int, MonitorElement * > HB_CenterOfEnergyRadius
MonitorElement * HFlumi_Occupancy_per_channel_vs_BX_RING1
MonitorElement * HFCenterOfEnergy
MonitorElement * HFlumi_diag_deadcells
std::map< HcalDetId, int > BadCells_
std::vector< DetId > getAllChannels() const
MonitorElement * Etsum_ratio_map
MonitorElement * HECenterOfEnergyRadius
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
#define HFETASIZE
HcalSubdetector
Definition: HcalAssistant.h:31
const HcalQIESample & sample(int i) const
access a sample
Definition: HFDataFrame.h:39
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
MonitorElement * HFlumi_occ_LS
MonitorElement * CenterOfEnergyRadius
void processEvent(const HBHERecHitCollection &hbHits, const HORecHitCollection &hoHits, const HFRecHitCollection &hfHits, const HFDigiCollection &hf, int bunchCrossing, const HcalTopology &topology)
edm::EDGetTokenT< HORecHitCollection > tok_ho_
MonitorElement * CenterOfEnergy
MonitorElement * HFlumi_Occupancy_below_thr_r1
std::map< int, MonitorElement * > HE_CenterOfEnergyRadius
std::ostringstream outfile_
MonitorElement * HFlumi_Occupancy_per_channel_vs_BX_RING2
MonitorElement * Energy_Occ
MonitorElement * HFlumi_Ring1Status_vs_LS
MonitorElement * HFlumi_Occupancy_per_channel_vs_lumiblock_RING1
static const float radius[]
const_iterator end() const
std::map< int, MonitorElement * > HO_CenterOfEnergyRadius
void SetEtaLabels(MonitorElement *h)
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
MonitorElement * Occ_eta_L
void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * HFlumi_Occupancy_between_thrs_r1
#define HEETASIZE
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
HcalBeamMonitor(const edm::ParameterSet &ps)
MonitorElement * HECenterOfEnergy
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * HOCenterOfEnergyRadius
MonitorElement * Etsum_ratio_m
const T & get() const
Definition: EventSetup.h:56
MonitorElement * HFlumi_Et_per_channel_vs_lumiblock
MonitorElement * HBCenterOfEnergyRadius
T const * product() const
Definition: ESHandle.h:86
TH1F * getTH1F(void) const
MonitorElement * Etsum_rphi_S
double getBinContent(int binx) const
get content of bin (1-D)
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
MonitorElement * HFlumi_Occupancy_above_thr_r2
size_type size() const
TProfile * getTProfile(void) const
std::string lumiqualitydir_
unsigned int lastProcessedLS_
tuple cout
Definition: gather_cfg.py:145
MonitorElement * HFlumi_diag_hotcells
const int ETA_OFFSET_HO
const HcalDetId & id() const
Definition: HFDataFrame.h:22
MonitorElement * Etsum_ratio_p
uint32_t getValue() const
TH2F * getTH2F(void) const
const int ETA_OFFSET_HB
MonitorElement * Etsum_phi_L
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
virtual void setup(DQMStore::IBooker &)
MonitorElement * Etsum_rphi_L
edm::InputTag hfRechitLabel_
MonitorElement * Occ_map_S
edm::InputTag digiLabel_
std::map< int, MonitorElement * > HF_CenterOfEnergyRadius
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
MonitorElement * HFlumi_total_deadcells
const int ETA_BOUND_HE
MonitorElement * HFlumi_total_hotcells
const_iterator begin() const
Definition: Run.h:43
MonitorElement * Occ_eta_S
const int ETA_OFFSET_HE