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