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