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