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  } // if ((id.depth()==1) ...
452  } // for (unsigned int i=0;...)
453 
454  if (tevt_==0) this->setup(); // create all histograms; not necessary if merging runs together
455  if (mergeRuns_==false) this->reset(); // call reset at start of all runs
456 
457  return;
458 
459 } // void HcalBeamMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
460 
461 
463 {
464  if (!IsAllowedCalibType()) return;
465  if (LumiInOrder(e.luminosityBlock())==false) return;
466 
467  // try to get rechits and digis
469 
473 
474  if (!(e.getByLabel(digiLabel_,hf_digi)))
475  {
476  edm::LogWarning("HcalBeamMonitor")<< digiLabel_<<" hf_digi not available";
477  return;
478  }
479 
480  if (!(e.getByLabel(hbheRechitLabel_,hbhe_rechit)))
481  {
482  edm::LogWarning("HcalBeamMonitor")<< hbheRechitLabel_<<" hbhe_rechit not available";
483  return;
484  }
485 
486  if (!(e.getByLabel(hfRechitLabel_,hf_rechit)))
487  {
488  edm::LogWarning("HcalBeamMonitor")<< hfRechitLabel_<<" hf_rechit not available";
489  return;
490  }
491  if (!(e.getByLabel(hoRechitLabel_,ho_rechit)))
492  {
493  edm::LogWarning("HcalBeamMonitor")<< hoRechitLabel_<<" ho_rechit not available";
494  return;
495  }
496 
497  //good event; increment counters and process
499  processEvent(*hbhe_rechit, *ho_rechit, *hf_rechit, *hf_digi, e.bunchCrossing());
500 
501 } //void HcalBeamMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
502 
503 
505  const HORecHitCollection& hoHits,
506  const HFRecHitCollection& hfHits,
507  const HFDigiCollection& hf,
508  int bunchCrossing
509  )
510 
511 {
512  //processEvent loop
513  if (!dbe_)
514  {
515  if (debug_>0) std::cout <<"HcalBeamMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
516  return;
517  }
518 
522 
523  double totalX=0;
524  double totalY=0;
525  double totalE=0;
526 
527  double HBtotalX=0;
528  double HBtotalY=0;
529  double HBtotalE=0;
530  double HEtotalX=0;
531  double HEtotalY=0;
532  double HEtotalE=0;
533  double HOtotalX=0;
534  double HOtotalY=0;
535  double HOtotalE=0;
536  double HFtotalX=0;
537  double HFtotalY=0;
538  double HFtotalE=0;
539 
540  float hitsp[13][36][2];
541  float hitsm[13][36][2];
542  float hitsp_Et[13][36][2];
543  float hitsm_Et[13][36][2];
544 
545  for(int m=0;m<13;m++){
546  for(int n=0;n<36;n++){
547  hitsp[m][n][0]=0;
548  hitsp[m][n][1]=0;
549  hitsm[m][n][0]=0;
550  hitsm[m][n][1]=0;
551 
552  hitsp_Et[m][n][0]=0;
553  hitsp_Et[m][n][1]=0;
554  hitsm_Et[m][n][0]=0;
555  hitsm_Et[m][n][1]=0;
556  }
557  }
558 
559  if(hbheHits.size()>0)
560  {
561  double HB_weightedX[HBETASIZE]={0.};
562  double HB_weightedY[HBETASIZE]={0.};
563  double HB_energy[HBETASIZE]={0.};
564 
565  double HE_weightedX[HEETASIZE]={0.};
566  double HE_weightedY[HEETASIZE]={0.};
567  double HE_energy[HEETASIZE]={0.};
568 
569  int ieta, iphi;
570 
571  for (HBHEiter=hbheHits.begin();
572  HBHEiter!=hbheHits.end();
573  ++HBHEiter)
574  {
575 
576  // loop over all hits
577  if (HBHEiter->energy()<0) continue; // don't consider negative-energy cells
578  HcalDetId id(HBHEiter->detid().rawId());
579  ieta=id.ieta();
580  iphi=id.iphi();
581 
582  int index=-1;
583  if ((HcalSubdetector)(id.subdet())==HcalBarrel)
584  {
585  HBtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
586  HBtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
587  HBtotalE+=HBHEiter->energy();
588 
589  index=ieta+ETA_OFFSET_HB;
590  if (index<0 || index> HBETASIZE) continue;
591  HB_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
592  HB_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
593  HB_energy[index]+=HBHEiter->energy();
594  } // if id.subdet()==HcalBarrel
595 
596  else
597  {
598  HEtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
599  HEtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
600  HEtotalE+=HBHEiter->energy();
601 
602  index=ieta+ETA_OFFSET_HE;
603  if (index<0 || index> HEETASIZE) continue;
604  HE_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
605  HE_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
606  HE_energy[index]+=HBHEiter->energy();
607  }
608  } // for (HBHEiter=hbheHits.begin()...
609  // Fill each histogram
610 
611  int hbeta=ETA_OFFSET_HB;
612  for (int i=-1*hbeta;i<=hbeta;++i)
613  {
614  if (i==0) continue;
615  int index = i+ETA_OFFSET_HB;
616  if (index<0 || index> HBETASIZE) continue;
617  if (HB_energy[index]==0) continue;
618  double moment=pow(HB_weightedX[index],2)+pow(HB_weightedY[index],2);
619  moment=pow(moment,0.5);
620  moment/=HB_energy[index];
621  if (moment!=0)
622  {
623  if (makeDiagnostics_) HB_CenterOfEnergyRadius[index]->Fill(moment);
624  COEradiusVSeta->Fill(i,moment);
625  }
626  } // for (int i=-1*hbeta;i<=hbeta;++i)
627 
628  int heeta=ETA_OFFSET_HE;
629  for (int i=-1*heeta;i<=heeta;++i)
630  {
631  if (i==0) continue;
632  if (i>-1*ETA_BOUND_HE && i <ETA_BOUND_HE) continue;
633  int index = i + ETA_OFFSET_HE;
634  if (index<0 || index> HEETASIZE) continue;
635  if (HE_energy[index]==0) continue;
636  double moment=pow(HE_weightedX[index],2)+pow(HE_weightedY[index],2);
637  moment=pow(moment,0.5);
638  moment/=HE_energy[index];
639  if (moment!=0)
640  {
641  if (makeDiagnostics_) HE_CenterOfEnergyRadius[index]->Fill(moment);
642  COEradiusVSeta->Fill(i,moment);
643  }
644  } // for (int i=-1*heeta;i<=heeta;++i)
645 
646  } // if (hbheHits.size()>0)
647 
648 
649  // HO loop
650  if(hoHits.size()>0)
651  {
652  double HO_weightedX[HOETASIZE]={0.};
653  double HO_weightedY[HOETASIZE]={0.};
654  double HO_energy[HOETASIZE]={0.};
655  double offset;
656 
657  int ieta, iphi;
658  for (HOiter=hoHits.begin();
659  HOiter!=hoHits.end();
660  ++HOiter)
661  {
662  // loop over all cells
663  if (HOiter->energy()<0) continue; // don't include negative-energy cells?
664  HcalDetId id(HOiter->detid().rawId());
665  ieta=id.ieta();
666  iphi=id.iphi();
667 
668  HOtotalX+=HOiter->energy()*cos(PI*iphi/36.);
669  HOtotalY+=HOiter->energy()*sin(PI*iphi/36.);
670  HOtotalE+=HOiter->energy();
671 
672  int index=ieta+ETA_OFFSET_HO;
673  if (index<0 || index>HOETASIZE) continue;
674  HO_weightedX[index]+=HOiter->energy()*cos(PI*iphi/36.);
675  HO_weightedY[index]+=HOiter->energy()*sin(PI*iphi/36.);
676  HO_energy[index]+=HOiter->energy();
677  } // for (HOiter=hoHits.begin();...)
678 
679  for (int i=-1*ETA_OFFSET_HO;i<=ETA_OFFSET_HO;++i)
680  {
681  if (i==0) continue;
682  int index = i + ETA_OFFSET_HO;
683  if (index < 0 || index> HOETASIZE) continue;
684  if (HO_energy[index]==0) continue;
685  double moment=pow(HO_weightedX[index],2)+pow(HO_weightedY[index],2);
686  moment=pow(moment,0.5);
687  moment/=HO_energy[index];
688  // Shift HO values by 0.5 units in eta relative to HB
689  offset = (i>0 ? 0.5: -0.5);
690  if (moment!=0)
691  {
692  if (makeDiagnostics_) HO_CenterOfEnergyRadius[index]->Fill(moment);
693  COEradiusVSeta->Fill(i+offset,moment);
694  }
695  } // for (int i=-1*hoeta;i<=hoeta;++i)
696  } // if (hoHits.size()>0)
697 
699  // HF loop
700 
701  Etsum_ratio_map->Fill(-1,-1,1); // fill underflow bin with number of events
702  {
703  if(hfHits.size()>0)
704  {
705  double HF_weightedX[HFETASIZE]={0.};
706  double HF_weightedY[HFETASIZE]={0.};
707  double HF_energy[HFETASIZE]={0.};
708  double offset;
709 
710  // Assume ZS until shown otherwise
711  double emptytowersRing1 = ring1totalchannels_;
712  double emptytowersRing2 = ring2totalchannels_;
713  double ZStowersRing1 = ring1totalchannels_;
714  double ZStowersRing2 = ring2totalchannels_;
715 
716  int ieta, iphi;
717  float et,eta,phi,r;
718 
719  HFlumi_occ_LS->Fill(-1,-1,1 ); // event counter in occupancy histogram underflow bin
720  // set maximum to HFlumi_occ_LS->getBinContent(0,0)?
721  // that won't work -- offline will add multiple histograms, and maximum will get screwed up?
722  // No, we can add it here, but we also need a call to setMaximum in the client as well.
723  HFlumi_occ_LS->getTH2F()->SetMaximum(HFlumi_occ_LS->getBinContent(0,0));
724 
725  double etx=0, ety=0;
726 
727  for (HFiter=hfHits.begin();
728  HFiter!=hfHits.end();
729  ++HFiter)
730  { // loop on hfHits
731  // If hit present, don't count it as ZS any more
732  ieta = HFiter->id().ieta();
733  iphi = HFiter->id().iphi();
734 
735  int binieta=ieta;
736  if (ieta<0) binieta+=41;
737  else if (ieta>0) binieta-=15;
738 
739  // Count that hit was found in one of the rings used for luminosity calculation.
740  // If so, decrease the number of empty channels per ring by 1
741  if (abs(ieta)>=33 && abs(ieta)<=36) // luminosity ring check
742  {
743  // don't subtract away cells that have already been removed as bad
744  if (BadCells_.find(HFiter->id())==BadCells_.end()) // bad cell not found
745  {
746  if ((abs(ieta)<35) && HFiter->id().depth()==1) --ZStowersRing1;
747  else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- ZStowersRing2;
748  }
749  }
750 
751  if (HFiter->energy()<0) continue; // don't include negative-energy cells?
752 
753  eta=theHFEtaBounds[abs(ieta)-29];
754  et=HFiter->energy()/cosh(eta)/area[abs(ieta)-29];
755  if (abs(ieta)>=33 && abs(ieta)<=36) // Luminosity ring check
756  {
757  // don't count cells that are below threshold, or that have been marked bad in Chan Stat DB
758  if (et>=occThresh_ && BadCells_.find(HFiter->id())==BadCells_.end() ) // minimum ET threshold
759  {
760  if ((abs(ieta)<35) && HFiter->id().depth()==1) --emptytowersRing1;
761  else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- emptytowersRing2;
762  }
763  }
764  r=radius[abs(ieta)-29];
765  if(HFiter->id().iphi()<37)
766  phi=HFiter->id().iphi()*0.087266;
767  else phi=(HFiter->id().iphi()-72)*0.087266;
768 
769 
770  if (HFiter->id().depth()==1)
771  {
772  Etsum_eta_L->Fill(binieta,et);
773  Etsum_phi_L->Fill(iphi,et);
774  Etsum_map_L->Fill(binieta,iphi,et);
775  Etsum_rphi_L->Fill(r,phi,et);
776 
777  if(ieta>0) {
778  hitsp[ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
779  hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
780  }
781  else if(ieta<0) {
782  hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
783  hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
784  }
785  } // if (HFiter->id().depth()==1)
786 
787  //Fill 3 histos for Short Fibers :
788  if (HFiter->id().depth()==2)
789  {
790  Etsum_eta_S->Fill(binieta,et);
791  Etsum_phi_S->Fill(iphi,et);
792  Etsum_rphi_S->Fill(r,phi,et);
793  Etsum_map_S->Fill(binieta,iphi,et);
794  if(ieta>0)
795  {
796  hitsp[ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
797  hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
798  }
799  else if(ieta<0) {
800  hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
801  hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
802  }
803 
804  } // depth()==2
805  Energy_Occ->Fill(HFiter->energy());
806 
807  //HF: no non-threshold occupancy map is filled?
808 
809  if ((abs(ieta) == 33 || abs(ieta) == 34) && HFiter->id().depth() == 1)
810  {
811  etx+=et*cos(PI*iphi/36.);
812  ety+=et*sin(PI*iphi/36.);
813 
815  if (et>occThresh_)
816  {
817  int etabin=0;
818  if (ieta<0)
819  etabin=36+ieta; // bins 0-3 correspond to ieta = -36, -35, -34, -33
820  else
821  etabin=ieta-29; // bins 4-7 correspond to ieta = 33, 34, 35, 36
822  HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
823  }
824  }
825 
826  else if ((abs(ieta) == 35 || abs(ieta) == 36) && HFiter->id().depth() == 2)
827  {
828  etx+=et*cos(PI*iphi/36.);
829  ety+=et*sin(PI*iphi/36.);
830 
832  if (et>occThresh_)
833  {
834  int etabin=0;
835  if (ieta<0)
836  etabin=36+ieta; // bins 0-3 correspond to ieta = -36, -35, -34, -33
837  else
838  etabin=ieta-29; // bins 4-7 correspond to ieta = 33, 34, 35, 36
839  HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
840  }
841  }
842 
843  // Fill occupancy plots.
844 
845  int value=0;
846  if(et>occThresh_) value=1;
847 
848  if (HFiter->id().depth()==1)
849  {
850  Occ_eta_L->Fill(binieta,value);
851  Occ_phi_L->Fill(iphi,value);
852  Occ_map_L->Fill(binieta,iphi,value);
853  Occ_rphi_L->Fill(r,phi,value);
854  }
855 
856  else if (HFiter->id().depth()==2)
857  {
858  Occ_eta_S->Fill(binieta,value);
859  Occ_phi_S->Fill(iphi,value);
860  Occ_map_S->Fill(binieta,iphi,value);
861  Occ_rphi_S->Fill(r,phi,value);
862  }
863  HcalDetId id(HFiter->detid().rawId());
864 
865  HFtotalX+=HFiter->energy()*cos(PI*iphi/36.);
866  HFtotalY+=HFiter->energy()*sin(PI*iphi/36.);
867  HFtotalE+=HFiter->energy();
868 
869  int index=ieta+ETA_OFFSET_HF;
870  if (index<0 || index>HFETASIZE) continue;
871  HF_weightedX[index]+=HFiter->energy()*cos(PI*iphi/36.);
872  HF_weightedY[index]+=HFiter->energy()*sin(PI*iphi/36.);
873  HF_energy[index]+=HFiter->energy();
874 
875  } // for (HFiter=hfHits.begin();...)
876 
877  // looped on all HF hits; calculate empty fraction
878  // empty towers = # of cells with ET < 0.0625 GeV, or cells missing because of ZS
879  // Calculated as : 144 - (# of cells with ET >= 0.0625 GeV)
880  // At some point, allow for calculations when channels are masked (and less than 144 channels expected)
881 
882  // Check Ring 1
883  double logvalue=-1;
884  if (ring1totalchannels_>0)
885  {
886  if (emptytowersRing1>0)
887  logvalue=-1.*log(emptytowersRing1/ring1totalchannels_);
889  HFlumi_Occupancy_per_channel_vs_BX_RING1->Fill(bunchCrossing,logvalue);
890  }
891  // Check Ring 2
892  logvalue=-1;
893  if (ring2totalchannels_>0)
894  {
895  if (emptytowersRing2>0)
896  logvalue=-1.*log(emptytowersRing2/ring2totalchannels_);
898  HFlumi_Occupancy_per_channel_vs_BX_RING2->Fill(bunchCrossing,logvalue);
899  }
900 
901  HFlumi_ETsum_vs_BX->Fill(bunchCrossing,pow(etx*etx+ety*ety,0.5));
902  int hfeta=ETA_OFFSET_HF;
903  for (int i=-1*hfeta;i<=hfeta;++i)
904  {
905  if (i==0) continue;
906  if (i>-1*ETA_BOUND_HF && i <ETA_BOUND_HF) continue;
907  int index = i + ETA_OFFSET_HF;
908  if (index<0 || index>HFETASIZE) continue;
909  if (HF_energy[index]==0) continue;
910  double moment=pow(HF_weightedX[index],2)+pow(HF_weightedY[index],2);
911  moment=pow(moment,0.5);
912  moment/=HF_energy[index];
913  offset = (i>0 ? 0.5: -0.5);
914  if (moment!=0)
915  {
916  if (makeDiagnostics_) HF_CenterOfEnergyRadius[index]->Fill(moment);
917  COEradiusVSeta->Fill(i+offset,moment);
918  }
919  } // for (int i=-1*hfeta;i<=hfeta;++i)
920  float ratiom,ratiop;
921 
922  for(int i=0;i<13;i++){
923  for(int j=0;j<36;j++){
924 
925  if(hitsp[i][j][0]==hitsp[i][j][1]) continue;
926 
927  if (hitsp[i][j][0] < 1.2 && hitsp[i][j][1] < 1.8) continue;
928  //use only lumi rings
929  if (((i+29) < 33) || ((i+29) > 36)) continue;
930  ratiop=fabs((fabs(hitsp[i][j][0])-fabs(hitsp[i][j][1]))/(fabs(hitsp[i][j][0])+fabs(hitsp[i][j][1])));
931  //cout<<ratiop<<std::endl;
932  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)){
933  Etsum_ratio_p->Fill(ratiop);
934  if(abs(ratiop>0.95)) Etsum_ratio_map->Fill(i,2*j+1); // i=4,5,6,7 for HFlumi rings
935  }
936  }
937  }
938 
939  for(int p=0;p<13;p++){
940  for(int q=0;q<36;q++){
941 
942  if(hitsm[p][q][0]==hitsm[p][q][1]) continue;
943 
944  if (hitsm[p][q][0] < 1.2 && hitsm[p][q][1] < 1.8) continue;
945  //use only lumi rings
946  if (((p+29) < 33) || ((p+29) > 36)) continue;
947  ratiom=fabs((fabs(hitsm[p][q][0])-fabs(hitsm[p][q][1]))/(fabs(hitsm[p][q][0])+fabs(hitsm[p][q][1])));
948  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)){
949  Etsum_ratio_m->Fill(ratiom);
950  if(abs(ratiom>0.95)) Etsum_ratio_map->Fill(7-p,2*q+1); // p=4,5,6,7 for HFlumi rings
951  //p=7: ieta=-36; p=4: ieta=-33
952  }
953  }
954  }
955  } // if (hfHits.size()>0)
956 
957  totalX=HBtotalX+HEtotalX+HOtotalX+HFtotalX;
958  totalY=HBtotalY+HEtotalY+HOtotalY+HFtotalY;
959  totalE=HBtotalE+HEtotalE+HOtotalE+HFtotalE;
960 
961  double moment;
962  if (HBtotalE>0)
963  {
964  moment=pow(HBtotalX*HBtotalX+HBtotalY*HBtotalY,0.5)/HBtotalE;
965  HBCenterOfEnergyRadius->Fill(moment);
966  HBCenterOfEnergy->Fill(HBtotalX/HBtotalE, HBtotalY/HBtotalE);
967  }
968  if (HEtotalE>0)
969  {
970  moment=pow(HEtotalX*HEtotalX+HEtotalY*HEtotalY,0.5)/HEtotalE;
971  HECenterOfEnergyRadius->Fill(moment);
972  HECenterOfEnergy->Fill(HEtotalX/HEtotalE, HEtotalY/HEtotalE);
973  }
974  if (HOtotalE>0)
975  {
976  moment=pow(HOtotalX*HOtotalX+HOtotalY*HOtotalY,0.5)/HOtotalE;
977  HOCenterOfEnergyRadius->Fill(moment);
978  HOCenterOfEnergy->Fill(HOtotalX/HOtotalE, HOtotalY/HOtotalE);
979  }
980  if (HFtotalE>0)
981  {
982  moment=pow(HFtotalX*HFtotalX+HFtotalY*HFtotalY,0.5)/HFtotalE;
983  HFCenterOfEnergyRadius->Fill(moment);
984  HFCenterOfEnergy->Fill(HFtotalX/HFtotalE, HFtotalY/HFtotalE);
985  }
986  if (totalE>0)
987  {
988  moment = pow(totalX*totalX+totalY*totalY,0.5)/totalE;
989  CenterOfEnergyRadius->Fill(moment);
990  CenterOfEnergy->Fill(totalX/totalE, totalY/totalE);
991  }
992 
993 
994 
995  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); j++){
996  const HFDataFrame digi = (const HFDataFrame)(*j);
997  // calibs_= cond.getHcalCalibrations(digi.id()); // Old method was made private.
998  // float en=0;
999  // float ts =0; float bs=0;
1000  // int maxi=0; float maxa=0;
1001  // for(int i=sigS0_; i<=sigS1_; i++){
1002  // if(digi.sample(i).adc()>maxa){maxa=digi.sample(i).adc(); maxi=i;}
1003  // }
1004  // for(int i=sigS0_; i<=sigS1_; i++){
1005  // float tmp1 =0;
1006  // int j1=digi.sample(i).adc();
1007  // tmp1 = (LedMonAdc2fc[j1]+0.5);
1008  // en += tmp1-calibs_.pedestal(digi.sample(i).capid());
1009  // if(i>=(maxi-1) && i<=maxi+1){
1010  // ts += i*(tmp1-calibs_.pedestal(digi.sample(i).capid()));
1011  // bs += tmp1-calibs_.pedestal(digi.sample(i).capid());
1012  // }
1013  // }
1014 
1015  //---HFlumiplots
1016  int theTStobeused = 6;
1017  // will have masking later:
1018  int mask=1;
1019  if(mask!=1) continue;
1020  //if we want to sum the 10 TS instead of just taking one:
1021  for (int i=0; i<digi.size(); i++) {
1022  if (i==theTStobeused) {
1023  float tmpET =0;
1024  int jadc=digi.sample(i).adc();
1025  //NOW LUT used in HLX are only identy LUTs, so Et filled
1026  //with unlinearised adc, ie tmpET = jadc
1027  // tmpET = (adc2fc[jadc]+0.5);
1028  tmpET = jadc;
1029 
1030  //-find which wedge we are in
1031  // ETsum and Occupancy will be summed for both L and S
1032  if(digi.id().ieta()>28){
1033  if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
1034  HFlumi_ETsum_perwedge->Fill(1,tmpET);
1035  if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
1036  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(1,1);
1037  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(1,1);
1038  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(1,1);
1039  }
1040  else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
1041  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(1,1);
1042  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(1,1);
1043  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(1,1);
1044  }
1045  }
1046  else {
1047  for (int iwedge=2; iwedge<19; iwedge++) {
1048  int itmp=4*(iwedge-1);
1049  if( (digi.id().iphi()==(itmp+1)) || (digi.id().iphi()==(itmp-1))) {
1050  HFlumi_ETsum_perwedge->Fill(iwedge,tmpET);
1051  if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
1052  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iwedge,1);
1053  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iwedge,1);
1054  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iwedge,1);
1055  }
1056  else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
1057  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iwedge,1);
1058  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iwedge,1);
1059  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iwedge,1);
1060  }
1061  iwedge=99;
1062  }
1063  }
1064  }
1065  } //--endif ieta in HF+
1066  else if(digi.id().ieta()<-28){
1067  if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
1068  HFlumi_ETsum_perwedge->Fill(19,tmpET);
1069  if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
1070  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(19,1);
1071  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(19,1);
1072  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(19,1);
1073  }
1074  else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
1075  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(19,1);
1076  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(19,1);
1077  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(19,1);
1078  }
1079  }
1080  else {
1081  for (int iw=2; iw<19; iw++) {
1082  int itemp=4*(iw-1);
1083  if( (digi.id().iphi()==(itemp+1)) || (digi.id().iphi()==(itemp-1))) {
1084  HFlumi_ETsum_perwedge->Fill(iw+18,tmpET);
1085  if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
1086  if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iw+18,1);
1087  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iw+18,1);
1088  if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iw+18,1);
1089  }
1090  else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
1091  if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iw+18,1);
1092  if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iw+18,1);
1093  if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iw+18,1);
1094  }
1095  iw=99;
1096  }
1097  }
1098  }
1099  }//---endif ieta inHF-
1100  }//---endif TS=nr6
1101  }
1102  }//------end loop over TS for lumi
1103  return;
1104  }
1105 }
1106  // void HcalBeamMonitor::processEvent(const HBHERecHit Collection&hbheHits; ...)
1107 
1108 
1110  const edm::EventSetup& c)
1111 
1112 {
1113  // reset histograms that get updated each luminosity section
1114 
1115  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
1117 
1118  if (lumiSeg.luminosityBlock()==lastProcessedLS_) return; // we're seeing more events from current lumi section (after some break) -- should not reset histogram
1120  HFlumi_occ_LS->Reset();
1121  std::stringstream title;
1122  title <<"HFlumi occupancy for LS # " <<currentLS;
1123  HFlumi_occ_LS->getTH2F()->SetTitle(title.str().c_str());
1124  return;
1125 } // void HcalBeamMonitor::beginLuminosityBlock()
1126 
1128  const edm::EventSetup& c)
1129 {
1130  if (debug_>1) std::cout <<"<HcalBeamMonitor::endLuminosityBlock>"<<std::endl;
1131  if (LumiInOrder(lumiSeg.luminosityBlock())==false)
1132  {
1133  if (debug_>1)
1134  std::cout <<"<HcalBeamMonitor::endLuminosityBlock> Failed LumiInOrder test!"<<std::endl;
1135  return;
1136  }
1138  float Nentries=HFlumi_occ_LS->getBinContent(-1,-1);
1139  if (debug_>3)
1140  std::cout <<"Number of entries in this LB = "<<Nentries<<std::endl;
1141 
1142  if (Nentries<minEvents_)
1143  {
1144  // not enough entries to determine status; fill everything with -1 and return
1147  if (Online_==false)
1148  return;
1149  // write to output file if required (Online running)
1150  if (lumiqualitydir_.size()==0)
1151  return;
1152  // dump out lumi quality file
1153  std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
1154  outStream<<currentLS<<"\t\t-1\t\t\t-1\t\t\t-1\t\t"<<Nentries<<std::endl;
1155  outStream.close();
1156  return;
1157  }
1158  if (Nentries==0) return;
1159 
1160 
1161  HFlumi_total_deadcells->Fill(-1,-1,1); // counts good lumi sections in underflow bin
1162  HFlumi_total_hotcells->Fill(-1,-1,1);
1163  HFlumi_diag_deadcells->Fill(-1,-1,1); // counts good lumi sections in underflow bin
1164  HFlumi_diag_hotcells->Fill(-1,-1,1);
1165 
1166  // ADD IETA MAP
1167  int ietamap[8]={-36,-35,-34,-33,33,34,35,36};
1168  int ieta=-1, iphi = -1, depth=-1;
1169  int badring1=0;
1170  int badring2=0;
1171  int ndeadcells=0;
1172  int nhotcells=0;
1173 
1174  // Loop over cells once to count hot & dead chanels
1175  for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
1176  {
1177  for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
1178  {
1179 
1180  // Skip over channels that are flagged as bad
1181  if (x<=8)
1182  ieta=ietamap[x-1];
1183  else
1184  ieta=-1;
1185  iphi=2*y-1;
1186  if (abs(ieta)==33 || abs(ieta)==34) depth=1;
1187  else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
1188  else depth = -1;
1189  if (depth !=-1 && ieta!=1)
1190  {
1191  HcalDetId thisID(HcalForward, ieta, iphi, depth);
1192  if (BadCells_.find(thisID)!=BadCells_.end())
1193  continue;
1194  }
1195  double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
1196  if (Ncellhits==0)
1197  {
1198  ++ndeadcells;
1199  HFlumi_diag_deadcells->Fill(x-1,2*y-1,1);
1200  }
1201  // hot if present in more than 25% of events in the LS
1202  if (Ncellhits>hotrate_*Nentries)
1203  {
1204  ++nhotcells;
1205  HFlumi_diag_hotcells->Fill(x-1,2*y-1,1);
1206  }
1207  if (Ncellhits==0 || Ncellhits>hotrate_*Nentries) // cell was either hot or dead
1208  {
1209  if (depth==1) badring1++;
1210  else if (depth==2) badring2++;
1211  }
1212  } // loop over y
1213  } // loop over x
1214 
1215  // Fill problem histogram underflow bind with number of events
1216  ProblemsCurrentLB->Fill(-1,-1,levt_);
1217  if (ndeadcells+nhotcells>=minBadCells_)
1218  {
1219  // Fill with number of error channels * events (assume bad for all events in LS)
1220  ProblemsCurrentLB->Fill(6,0,(ndeadcells+nhotcells)*levt_);
1221  for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
1222  {
1223  for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
1224  {
1225  if (x<=8)
1226  ieta=ietamap[x-1];
1227  else
1228  ieta=-1;
1229  iphi=2*y-1;
1230  if (abs(ieta)==33 || abs(ieta)==34) depth=1;
1231  else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
1232  else depth = -1;
1233  if (depth !=-1 && ieta!=1)
1234  {
1235  // skip over channels that are flagged as bad
1236  HcalDetId thisID(HcalForward, ieta, iphi, depth);
1237  if (BadCells_.find(thisID)!=BadCells_.end())
1238  continue;
1239  }
1240  double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
1241  if (Ncellhits==0)
1242  {
1243  // One new luminosity section found with no entries for the cell in question
1244  HFlumi_total_deadcells->Fill(x-1,2*y-1,1);
1245  } // dead cell check
1246 
1247  // hot if present in more than 25% of events in the LS
1248  if (Ncellhits>hotrate_*Nentries)
1249  {
1250  HFlumi_total_hotcells->Fill(x-1,2*y-1,1);
1251  } // hot cell check
1252  } // loop over y
1253  } // loop over x
1254  } // if (ndeadcells+nhotcells>=minBadCells_)
1255 
1256  // Fill fraction of bad channels found in this LS
1257  double ring1status=0;
1258  double ring2status=0;
1259  if (ring1totalchannels_==0)
1260  ring1status=0;
1261  else
1262  ring1status=1-1.*badring1/ring1totalchannels_;
1263  HFlumi_Ring1Status_vs_LS->Fill(currentLS,ring1status);
1264  if (ring2totalchannels_==0)
1265  ring2status=0;
1266  else
1267  ring2status=1-1.*badring2/ring2totalchannels_;
1268  HFlumi_Ring2Status_vs_LS->Fill(currentLS,ring2status);
1269 
1270  // Good status: ring1 and ring2 status both > 90%
1271  int totalstatus=0;
1272  if (ring1status>0.9 && ring2status>0.9)
1273  totalstatus=1;
1274  else
1275  {
1276  if (ring1status<=0.9)
1277  totalstatus-=2;
1278  if (ring2status<=0.9)
1279  totalstatus-=4;
1280  }
1281 
1282  if (lumiqualitydir_.size()==0)
1283  return;
1284  // dump out lumi quality file
1285  std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
1286  outStream.precision(6);
1287  outStream<<currentLS<<"\t\t"<<ring1status<<"\t\t"<<ring2status<<"\t\t"<<totalstatus<<"\t\t"<<Nentries<<std::endl;
1288  outStream.close();
1289  return;
1290 }
1291 
1292 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};
1293 const float HcalBeamMonitor::radius[]={1300,1162,975,818,686,576,483,406,340,286,240,201,169};
1294 
1296 {
1297  h->getTH2F()->GetXaxis()->SetBinLabel(1,"-36S");
1298  h->getTH2F()->GetXaxis()->SetBinLabel(2,"-35S");
1299  h->getTH2F()->GetXaxis()->SetBinLabel(3,"-34L");
1300  h->getTH2F()->GetXaxis()->SetBinLabel(4,"-33L");
1301  h->getTH2F()->GetXaxis()->SetBinLabel(5,"33L");
1302  h->getTH2F()->GetXaxis()->SetBinLabel(6,"34L");
1303  h->getTH2F()->GetXaxis()->SetBinLabel(7,"35S");
1304  h->getTH2F()->GetXaxis()->SetBinLabel(8,"36S");
1305  return;
1306 }
1307 
1309 
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:519
#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
MonitorElement * Occ_phi_S
edm::InputTag hbheRechitLabel_
const int ETA_OFFSET_HF
MonitorElement * HFlumi_ETsum_perwedge
T eta() const
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:2330
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:833
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:359
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
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:647
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:237
const int ETA_BOUND_HE
MonitorElement * HFlumi_total_hotcells
const_iterator begin() const
Definition: Run.h:31
MonitorElement * Occ_eta_S
Definition: DDAxes.h:10
const int ETA_OFFSET_HE