Belle II Software  release-08-01-10
DQMHistAnalysisTRG.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 //+
9 // File : DQMHistAnalysisTRGModule.cc
10 // Description : Module for TRG
11 //-
12 
13 
14 #include <dqm/analysis/modules/DQMHistAnalysisTRG.h>
15 #include <TROOT.h>
16 #include <iostream>
17 
18 using namespace std;
19 using namespace Belle2;
20 
21 //-----------------------------------------------------------------
22 // Register the Module
23 //-----------------------------------------------------------------
24 REG_MODULE(DQMHistAnalysisTRG);
25 
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29 
30 DQMHistAnalysisTRGModule::DQMHistAnalysisTRGModule()
32 {
33  // This module CAN NOT be run in parallel!
34 
35  // Parameter definition
36  addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("TRG:"));
37  B2DEBUG(1, "DQMHistAnalysisTRGModule: Constructor done.");
38 
39 }
40 
42 {
43  // destructor not needed
44  // EPICS singleton deletion not urgent -> can be done by framework
45 }
46 
48 {
49  B2DEBUG(1, "DQMHistAnalysisTRGModule: initialized.");
50 
51  gROOT->cd();
52  m_canvas = new TCanvas("TRG/c_Test");
53  //comL1-GDLL1
54  addDeltaPar("TRGGDL", "hGDL_gdlL1TocomL1_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
55  registerEpicsPV(m_pvPrefix + "comL1_GDLL1_mean", "comL1_GDLL1_mean");
56 
57  //ECLTRG timing
58  addDeltaPar("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_ECLTRG", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
59  registerEpicsPV(m_pvPrefix + "ECLTRG_timing_mean", "ECLTRG_timing_mean");
60 
61  //CDCTRG event timing
62  addDeltaPar("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_CDCTRG", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
63  registerEpicsPV(m_pvPrefix + "CDCTRG_timing_mean", "CDCTRG_timing_mean");
64 
65  //TOPTRG event timing
66  addDeltaPar("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_TOPTRG", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
67  registerEpicsPV(m_pvPrefix + "TOPTRG_timing_mean", "TOPTRG_timing_mean");
68 
69  //ECLTRG_peak
70  addDeltaPar("TRGGRL", "h_ECLL1", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
71  registerEpicsPV(m_pvPrefix + "ECLTRG_peak", "ECLTRG_peak");
72 
73 
74  //CDCTRG_2D_peak
75  addDeltaPar("TRGGRL", "h_CDCL1", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
76  registerEpicsPV(m_pvPrefix + "CDCTRG_2D_peak", "CDCTRG_2D_peak");
77 
78 
79  //NN_peak
80  addDeltaPar("TRGGRL", "h_CDCNNL1", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
81  registerEpicsPV(m_pvPrefix + "NN_peak", "NN_peak");
82 
83  //CDCTRG_TSF_peak
84  addDeltaPar("TRGGRL", "h_TSFL1", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
85  registerEpicsPV(m_pvPrefix + "CDCTRG_TSF_peak", "CDCTRG_TSF_peak");
86 
87  //KLMTRG_peak
88  addDeltaPar("TRGGRL", "h_KLML1", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
89  registerEpicsPV(m_pvPrefix + "KLMTRG_peak", "KLMTRG_peak");
90 
91  //TOPTRG_peak
92  addDeltaPar("TRGGRL", "h_TOPL1", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
93  registerEpicsPV(m_pvPrefix + "TOPTRG_peak", "TOPTRG_peak");
94 
95  //CDCTRG nTSFHits total
96  addDeltaPar("TRGGRL", "h_wirecnt_sum", HistDelta::c_Entries, 1000, 1);
97  registerEpicsPV(m_pvPrefix + "CDCTRG_meanTSFHits_total", "CDCTRG_meanTSFHits_total");
98 
99  //CDCTRG nTSFHits Injection BG Clean region
100  addDeltaPar("TRGGRL", "h_wirecnt_sum_clean", HistDelta::c_Entries, 1000, 1);
101  registerEpicsPV(m_pvPrefix + "CDCTRG_meanTSFHits_clean", "CDCTRG_meanTSFHits_clean"); // Mean value for the distribution of N(TSF)
102  registerEpicsPV(m_pvPrefix + "CDCTRG_tailTSFHits_clean",
103  "CDCTRG_tailTSFHits_clean"); // Tail position for the distribution of N(TSF)
104 
105  //CDCTRG nTSFHits HER Injection region
106  addDeltaPar("TRGGRL", "h_wirecnt_sum_injHER", HistDelta::c_Entries, 1000, 1);
107  registerEpicsPV(m_pvPrefix + "CDCTRG_meanTSFHits_injHER", "CDCTRG_meanTSFHits_injHER");
108 
109  //CDCTRG nTSFHits LER Injection region
110  addDeltaPar("TRGGRL", "h_wirecnt_sum_injLER", HistDelta::c_Entries, 1000, 1);
111  registerEpicsPV(m_pvPrefix + "CDCTRG_meanTSFHits_injLER", "CDCTRG_meanTSFHits_injLER");
112 
113  //ecl timing –cdc timing
114  addDeltaPar("TRGGDL", "hGDL_ns_cdcToecl_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
115  registerEpicsPV(m_pvPrefix + "ecltiming_cdctiming", "ecltiming_cdctiming");
116 
117  //top timing – ecl timing
118  addDeltaPar("TRGGDL", "hGDL_ns_topToecl_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
119  registerEpicsPV(m_pvPrefix + "toptiming_ecltiming", "toptiming_ecltiming");
120 
121  // top timing – cdc timing
122  addDeltaPar("TRGGDL", "hGDL_ns_topTocdc_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
123  registerEpicsPV(m_pvPrefix + "toptiming_cdctiming", "toptiming_cdctiming");
124 
125  // gdll1-ecl timing
126  addDeltaPar("TRGGDL", "hGDL_eclTogdlL1_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
127  registerEpicsPV(m_pvPrefix + "gdll1_ecltiming", "gdll1_ecltiming");
128 
129  //gdll1-cdctiming
130  addDeltaPar("TRGGDL", "hGDL_cdcTogdlL1_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
131  registerEpicsPV(m_pvPrefix + "gdll1_cdctiming", "gdll1_cdctiming");
132 
133  //gdll1-toptiming
134  addDeltaPar("TRGGDL", "hGDL_topTogdlL1_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
135  registerEpicsPV(m_pvPrefix + "gdll1_toptiming", "gdll1_toptiming");
136 
137  //barrel klm latency
138  addDeltaPar("TRGGDL", "hGDL_itd_klm_hit_rise_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
139  registerEpicsPV(m_pvPrefix + "barrel_klm_latency", "barrel_klm_latency");
140 
141  //endcap klm latency
142  addDeltaPar("TRGGDL", "hGDL_itd_eklm_hit_rise_all", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
143  registerEpicsPV(m_pvPrefix + "endcap_klm_latency", "endcap_klm_latency");
144 
145  //hadronb2_over_bhabha_all
146  addDeltaPar("softwaretrigger", "skim", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
147  registerEpicsPV(m_pvPrefix + "hadronb2_over_bhabha_all", "hadronb2_over_bhabha_all");
148 
149  //mumu2trk_over_bhabha_all
150  addDeltaPar("softwaretrigger", "skim", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
151  registerEpicsPV(m_pvPrefix + "mumu2trk_over_bhabha_all", "mumu2trk_over_bhabha_all");
152 
153  //hadronb2_over_mumu2trk
154  addDeltaPar("softwaretrigger", "skim", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
155  registerEpicsPV(m_pvPrefix + "hadronb2_over_mumu2trk", "hadronb2_over_mumu2trk");
156 
157  //ECLTRG_deadch
158 // m_canvas_ECLTRG_deadch = new TCanvas("ECLTRG_deadch");
159  addDeltaPar("TRG", "h_TCId", HistDelta::c_Entries, 1000, 1); // update each 1000 entries
160  registerEpicsPV(m_pvPrefix + "ECLTRG_deadch", "ECLTRG_deadch");
161 
162  //ECLTRG N(TC) total
163  addDeltaPar("TRG", "h_n_TChit_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
164  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_total", "ECLTRG_meanTC_total");
165 
166  //ECLTRG N(TC) clean
167  addDeltaPar("TRG", "h_n_TChit_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
168  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_clean", "ECLTRG_meanTC_clean"); // Mean value for the distribution of N(TC)
169  registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_clean", "ECLTRG_tailTC_clean"); // Tail position for the distribution of N(TC)
170 
171  //ECLTRG N(TC) HER Injection region
172  addDeltaPar("TRG", "h_n_TChit_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
173  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_injHER", "ECLTRG_meanTC_injHER");
174 
175  //ECLTRG N(TC) LER Injection region
176  addDeltaPar("TRG", "h_n_TChit_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
177  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_injLER", "ECLTRG_meanTC_injLER");
178 
179  //ECLTRG N(TC) total from the forward endcap
180  addDeltaPar("TRG", "h_n_TChit_FWD_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
181  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_total", "ECLTRG_meanTC_FWD_total");
182 
183  //ECLTRG N(TC) clean from the forward endcap
184  addDeltaPar("TRG", "h_n_TChit_FWD_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
185  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_clean",
186  "ECLTRG_meanTC_FWD_clean"); // Mean value for the distribution of N(TC) from the forward
187  registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_FWD_clean",
188  "ECLTRG_tailTC_FWD_clean"); // Tail position for the distribution of N(TC) from the forward
189 
190  //ECLTRG N(TC) HER Injection region from the forward endcap
191  addDeltaPar("TRG", "h_n_TChit_FWD_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
192  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_injHER", "ECLTRG_meanTC_FWD_injHER");
193 
194  //ECLTRG N(TC) LER Injection region from the forward endcap
195  addDeltaPar("TRG", "h_n_TChit_FWD_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
196  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_injLER", "ECLTRG_meanTC_FWD_injLER");
197 
198  //ECLTRG N(TC) total from the barrel
199  addDeltaPar("TRG", "h_n_TChit_BRL_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
200  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_total", "ECLTRG_meanTC_BRL_total");
201 
202  //ECLTRG N(TC) clean from the barrel
203  addDeltaPar("TRG", "h_n_TChit_BRL_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
204  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_clean",
205  "ECLTRG_meanTC_BRL_clean"); // Mean value for the distribution of N(TC) from the barrel
206  registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_BRL_clean",
207  "ECLTRG_tailTC_BRL_clean"); // Tail position for the distribution of N(TC) from the barrel
208 
209  //ECLTRG N(TC) HER Injection region from the barrel
210  addDeltaPar("TRG", "h_n_TChit_BRL_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
211  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_injHER", "ECLTRG_meanTC_BRL_injHER");
212 
213  //ECLTRG N(TC) LER Injection region from the barrel
214  addDeltaPar("TRG", "h_n_TChit_BRL_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
215  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_injLER", "ECLTRG_meanTC_BRL_injLER");
216 
217  //ECLTRG N(TC) total from the backward endcap
218  addDeltaPar("TRG", "h_n_TChit_BWD_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
219  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_total", "ECLTRG_meanTC_BWD_total");
220 
221  //ECLTRG N(TC) clean from the backward endcap
222  addDeltaPar("TRG", "h_n_TChit_BWD_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
223  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_clean",
224  "ECLTRG_meanTC_BWD_clean"); // Mean value for the distribution of N(TC) from the backward
225  registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_BWD_clean",
226  "ECLTRG_tailTC_BWD_clean"); // Tail position for the distribution of N(TC) from the backward
227 
228  //ECLTRG N(TC) HER Injection region from the backward endcap
229  addDeltaPar("TRG", "h_n_TChit_BWD_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
230  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_injHER", "ECLTRG_meanTC_BWD_injHER");
231 
232  //ECLTRG N(TC) LER Injection region from the backward endcap
233  addDeltaPar("TRG", "h_n_TChit_BWD_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
234  registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_injLER", "ECLTRG_meanTC_BWD_injLER");
235 
236  //CDCTRG_deadch
237 // m_canvas_CDCTRG_deadch = new TCanvas("CDCTRG_deadch");
238  addDeltaPar("TRGCDCTNN", "NeuroHWInTSID", HistDelta::c_Entries, 159778, 1); // update each 2000 entries
239  registerEpicsPV(m_pvPrefix + "CDCTRG_deadch", "CDCTRG_deadch");
240 
241  //update PV
242 // updateEpicsPVs(
243 // 5.0); // -> now trigger update. this may be optional, framework can take care unless we want to now the result immediately
244 }
245 
247 {
248  B2DEBUG(1, "DQMHistAnalysisTRGModule: beginRun called.");
249 }
250 
252 {
253  B2DEBUG(1, "DQMHistAnalysisTRGModule: endRun called.");
254 }
255 
257 {
258  B2DEBUG(1, "DQMHistAnalysisTRGModule: event called.");
259  doHistAnalysis();
260 }
261 
263 {
264  m_canvas->Clear();
265  m_canvas->cd(0);
266  //update comL1-GDLL1
267  auto hist_comL1_GDLL1 = getDelta("TRGGDL", "hGDL_gdlL1TocomL1_all", 0, true);// only if updated
268  if (hist_comL1_GDLL1) {
269  double comL1_GDLL1_mean = 0.0;
270  hist_comL1_GDLL1->Draw();
271  comL1_GDLL1_mean = hist_comL1_GDLL1->GetMean();
272  B2DEBUG(1, "comL1_GDLL1_mean:" << comL1_GDLL1_mean);
273  setEpicsPV("comL1_GDLL1_mean", comL1_GDLL1_mean);
274 // updateEpicsPVs(
275 // 5.0); // -> now trigger update. this may be optional, framework can take care unless we want to now the result immediately
276  }
277 
278  //update ECLTRG timing
279  auto hist = getDelta("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_ECLTRG", 0, true);// only if updated
280  if (hist) {
281  double ECLTRG_timing_mean = 0.0;
282  hist->Draw();
283  ECLTRG_timing_mean = hist->GetMean();
284  B2DEBUG(1, "ECLTRG_timing_mean:" << ECLTRG_timing_mean);
285  setEpicsPV("ECLTRG_timing_mean", ECLTRG_timing_mean);
286  }
287 
288 
289  //update CDCTRG timing
290  auto histCDCTRG = getDelta("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_CDCTRG", 0, true);// only if updated
291  if (histCDCTRG) {
292  double CDCTRG_timing_mean = 0.0;
293  histCDCTRG->Draw();
294  CDCTRG_timing_mean = histCDCTRG->GetMean();
295  B2DEBUG(1, "CDCTRG_timing_mean:" << CDCTRG_timing_mean);
296  setEpicsPV("CDCTRG_timing_mean", CDCTRG_timing_mean);
297  }
298 
299  //update TOPTRG timing
300  auto histTOPTRG = getDelta("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_TOPTRG", 0, true);// only if updated
301  if (histTOPTRG) {
302  double TOPTRG_timing_mean = 0.0;
303  histTOPTRG->Draw();
304  TOPTRG_timing_mean = histTOPTRG->GetMean();
305  B2DEBUG(1, "TOPTRG_timing_mean:" << TOPTRG_timing_mean);
306  setEpicsPV("TOPTRG_timing_mean", TOPTRG_timing_mean);
307  }
308 
309 // update ECLTRG peak
310  auto hist_ECLTRG_peak = getDelta("TRGGRL", "h_ECLL1", 0, true);// only if updated
311  if (hist_ECLTRG_peak) {
312  double ECLTRG_peak = 0.0;
313  hist_ECLTRG_peak->Draw();
314  int bin_ECLTRG_peak = hist_ECLTRG_peak->GetMaximumBin();
315  ECLTRG_peak = hist_ECLTRG_peak->GetXaxis()->GetBinCenter(bin_ECLTRG_peak);
316  B2DEBUG(1, "ECLTRG_peak:" << ECLTRG_peak);
317  setEpicsPV("ECLTRG_peak", ECLTRG_peak);
318 
319  }
320 
321 // update ECLTRG deadch
322  auto hist_ECLTRG_deadch = getDelta("TRG", "h_TCId", 0, true);// only if updated
323  if (hist_ECLTRG_deadch) {
324  hist_ECLTRG_deadch->Draw();
325  int numberOfBins = hist_ECLTRG_deadch->GetNbinsX();
326 // int YMax = hist_ECLTRG_deadch->GetBinContent(hist_ECLTRG_deadch->GetMaximumBin());
327  int ECLTRG_deadch = 0;
328  for (int i = 2; i <= numberOfBins; i++) {
329  if (hist_ECLTRG_deadch->GetBinContent(i) <= 0) { ECLTRG_deadch += 1; }
330  }
331  B2DEBUG(1, "ECLTRG_deadch:" << ECLTRG_deadch);
332  setEpicsPV("ECLTRG_deadch", ECLTRG_deadch);
333  }
334 // m_canvas_CDCTRG_2D_peak->Clear();
335 // m_canvas_CDCTRG_2D_peak->cd(0);
336 // update CDCTRG 2D peak
337  auto hist_CDCTRG_2D_peak = getDelta("TRGGRL", "h_CDCL1", 0, true);// only if updated
338  if (hist_CDCTRG_2D_peak) {
339  double CDCTRG_2D_peak = 0.0;
340  hist_CDCTRG_2D_peak->Draw();
341  int bin_CDCTRG_2D_peak = hist_CDCTRG_2D_peak->GetMaximumBin();
342  CDCTRG_2D_peak = hist_CDCTRG_2D_peak->GetXaxis()->GetBinCenter(bin_CDCTRG_2D_peak);
343  B2DEBUG(1, "CDCTRG_2D_peak:" << CDCTRG_2D_peak);
344  setEpicsPV("CDCTRG_2D_peak", CDCTRG_2D_peak);
345 
346  }
347 
348 // update CDCTRG NN peak
349  auto hist_NN_peak = getDelta("TRGGRL", "h_CDCNNL1", 0, true);// only if updated
350  if (hist_NN_peak) {
351  double NN_peak = 0.0;
352  hist_NN_peak->Draw();
353  int bin_NN_peak = hist_NN_peak->GetMaximumBin();
354  NN_peak = hist_NN_peak->GetXaxis()->GetBinCenter(bin_NN_peak);
355  B2DEBUG(1, "NN_peak:" << NN_peak);
356  setEpicsPV("NN_peak", NN_peak);
357 
358  }
359 
360 // update CDCTRG TSF
361  auto hist_CDCTRG_TSF_peak = getDelta("TRGGRL", "h_TSFL1", 0, true);// only if updated
362  if (hist_CDCTRG_TSF_peak) {
363  double CDCTRG_TSF_peak = 0.0;
364  hist_CDCTRG_TSF_peak->Draw();
365  int bin_CDCTRG_TSF_peak = hist_CDCTRG_TSF_peak->GetMaximumBin();
366  CDCTRG_TSF_peak = hist_CDCTRG_TSF_peak->GetXaxis()->GetBinCenter(bin_CDCTRG_TSF_peak);
367  B2DEBUG(1, "CDCTRG_TSF_peak:" << CDCTRG_TSF_peak);
368  setEpicsPV("CDCTRG_TSF_peak", CDCTRG_TSF_peak);
369 
370  }
371 
372 // update CDCTRG deadch
373  auto hist_CDCTRG_deadch = getDelta("TRGCDCTNN", "NeuroHWInTSID", 0, true);// only if updated
374  if (hist_CDCTRG_deadch) {
375  hist_CDCTRG_deadch->Draw();
376  int numberOfBins = hist_CDCTRG_deadch->GetNbinsX();
377 // int YMax = hist_CDCTRG_deadch->GetBinContent(hist_CDCTRG_deadch->GetMaximumBin());
378  int CDCTRG_deadch = 0;
379  for (int i = 3; i <= numberOfBins; i++) {
380  if (hist_CDCTRG_deadch->GetBinContent(i) <= 0) {CDCTRG_deadch += 1; }
381  }
382  B2DEBUG(1, "CDCTRG_deadch:" << CDCTRG_deadch);
383  setEpicsPV("CDCTRG_deadch", CDCTRG_deadch);
384  }
385 
386 // update KLMTRG
387  auto hist_KLMTRG_peak = getDelta("TRGGRL", "h_KLML1", 0, true);// only if updated
388  if (hist_KLMTRG_peak) {
389  double KLMTRG_peak = 0.0;
390  hist_KLMTRG_peak->Draw();
391  int bin_KLMTRG_peak = hist_KLMTRG_peak->GetMaximumBin();
392  KLMTRG_peak = hist_KLMTRG_peak->GetXaxis()->GetBinCenter(bin_KLMTRG_peak);
393  B2DEBUG(1, "KLMTRG_peak:" << KLMTRG_peak);
394  setEpicsPV("KLMTRG_peak", KLMTRG_peak);
395 
396  }
397 
398 // update TOPTRG
399  auto hist_TOPTRG_peak = getDelta("TRGGRL", "h_TOPL1", 0, true);// only if updated
400  if (hist_TOPTRG_peak) {
401  double TOPTRG_peak = 0.0;
402  hist_TOPTRG_peak->Draw();
403  int bin_TOPTRG_peak = hist_TOPTRG_peak->GetMaximumBin();
404  TOPTRG_peak = hist_TOPTRG_peak->GetXaxis()->GetBinCenter(bin_TOPTRG_peak);
405  B2DEBUG(1, "TOPTRG_peak:" << TOPTRG_peak);
406  setEpicsPV("TOPTRG_peak", TOPTRG_peak);
407 
408  }
409 
410 // update ecltiming_cdctiming
411  auto hist_ecltiming_cdctiming = getDelta("TRGGDL", "hGDL_ns_cdcToecl_all", 0, true);// only if updated
412  if (hist_ecltiming_cdctiming) {
413  double ecltiming_cdctiming = 0.0;
414  hist_ecltiming_cdctiming->Draw();
415  int bin_ecltiming_cdctiming = hist_ecltiming_cdctiming->GetMaximumBin();
416  ecltiming_cdctiming = hist_ecltiming_cdctiming->GetXaxis()->GetBinCenter(bin_ecltiming_cdctiming);
417  B2DEBUG(1, "ecltiming_cdctiming:" << ecltiming_cdctiming);
418  setEpicsPV("ecltiming_cdctiming", ecltiming_cdctiming);//Peak
419  }
420 
421 // update toptiming_ecltiming
422  auto hist_toptiming_ecltiming = getDelta("TRGGDL", "hGDL_ns_topToecl_all", 0, true);// only if updated
423  if (hist_toptiming_ecltiming) {
424  double toptiming_ecltiming = 0.0;
425  hist_toptiming_ecltiming->Draw();
426  int bin_toptiming_ecltiming = hist_toptiming_ecltiming->GetMaximumBin();
427  toptiming_ecltiming = hist_toptiming_ecltiming->GetXaxis()->GetBinCenter(bin_toptiming_ecltiming);
428  B2DEBUG(1, "toptiming_ecltiming:" << toptiming_ecltiming);
429  setEpicsPV("toptiming_ecltiming", toptiming_ecltiming);//Peak
430  }
431 
432 // update toptiming_cdctiming
433  auto hist_toptiming_cdctiming = getDelta("TRGGDL", "hGDL_ns_topTocdc_all", 0, true);// only if updated
434  if (hist_toptiming_cdctiming) {
435  double toptiming_cdctiming = 0.0;
436  hist_toptiming_cdctiming->Draw();
437  int bin_toptiming_cdctiming = hist_toptiming_cdctiming->GetMaximumBin();
438  toptiming_cdctiming = hist_toptiming_cdctiming->GetXaxis()->GetBinCenter(bin_toptiming_cdctiming);
439  B2DEBUG(1, "toptiming_cdctiming:" << toptiming_cdctiming);
440  setEpicsPV("toptiming_cdctiming", toptiming_cdctiming);//Peak
441  }
442 
443 // update gdll1_ecltiming
444  auto hist_gdll1_ecltiming = getDelta("TRGGDL", "hGDL_eclTogdlL1_all", 0, true);// only if updated
445  if (hist_gdll1_ecltiming) {
446  double gdll1_ecltiming = 0.0;
447  hist_gdll1_ecltiming->Draw();
448  int bin_gdll1_ecltiming = hist_gdll1_ecltiming->GetMaximumBin();
449  gdll1_ecltiming = hist_gdll1_ecltiming->GetXaxis()->GetBinCenter(bin_gdll1_ecltiming);
450  B2DEBUG(1, "gdll1_ecltiming:" << gdll1_ecltiming);
451  setEpicsPV("gdll1_ecltiming", gdll1_ecltiming);//Peak
452  }
453 
454 // update gdll1_cdctiming
455  auto hist_gdll1_cdctiming = getDelta("TRGGDL", "hGDL_cdcTogdlL1_all", 0, true);// only if updated
456  if (hist_gdll1_cdctiming) {
457  double gdll1_cdctiming = 0.0;
458  hist_gdll1_cdctiming->Draw();
459  int bin_gdll1_cdctiming = hist_gdll1_cdctiming->GetMaximumBin();
460  gdll1_cdctiming = hist_gdll1_cdctiming->GetXaxis()->GetBinCenter(bin_gdll1_cdctiming);
461  B2DEBUG(1, "gdll1_cdctiming:" << gdll1_cdctiming);
462  setEpicsPV("gdll1_cdctiming", gdll1_cdctiming);//Peak
463  }
464 
465 // update gdll1_toptiming
466  auto hist_gdll1_toptiming = getDelta("TRGGDL", "hGDL_topTogdlL1_all", 0, true);// only if updated
467  if (hist_gdll1_toptiming) {
468  double gdll1_toptiming = 0.0;
469  hist_gdll1_toptiming->Draw();
470  int bin_gdll1_toptiming = hist_gdll1_toptiming->GetMaximumBin();
471  gdll1_toptiming = hist_gdll1_toptiming->GetXaxis()->GetBinCenter(bin_gdll1_toptiming);
472  B2DEBUG(1, "gdll1_toptiming:" << gdll1_toptiming);
473  setEpicsPV("gdll1_toptiming", gdll1_toptiming);//Peak
474  }
475 
476 // update barrel_klm_latency
477  auto hist_barrel_klm_latency = getDelta("TRGGDL", "hGDL_itd_klm_hit_rise_all", 0, true);// only if updated
478  if (hist_barrel_klm_latency) {
479  double barrel_klm_latency = 0.0;
480  hist_barrel_klm_latency->Draw();
481  int bin_barrel_klm_latency = hist_barrel_klm_latency->GetMaximumBin();
482  barrel_klm_latency = hist_barrel_klm_latency->GetXaxis()->GetBinCenter(bin_barrel_klm_latency);
483  B2DEBUG(1, "barrel_klm_latency:" << barrel_klm_latency);
484  setEpicsPV("barrel_klm_latency", barrel_klm_latency);//Peak
485  }
486 
487 // update endcap_klm_latency
488  auto hist_endcap_klm_latency = getDelta("TRGGDL", "hGDL_itd_eklm_hit_rise_all", 0, true);// only if updated
489  if (hist_endcap_klm_latency) {
490  double endcap_klm_latency = 0.0;
491  hist_endcap_klm_latency->Draw();
492  int bin_endcap_klm_latency = hist_endcap_klm_latency->GetMaximumBin();
493  endcap_klm_latency = hist_endcap_klm_latency->GetXaxis()->GetBinCenter(bin_endcap_klm_latency);
494  B2DEBUG(1, "endcap_klm_latency:" << endcap_klm_latency);
495  setEpicsPV("endcap_klm_latency", endcap_klm_latency);//Peak
496  }
497 
498 // update #hadronb2/#bhabha_all
499  auto hist_hadronb2_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
500  if (hist_hadronb2_over_bhabha_all) {
501  hist_hadronb2_over_bhabha_all->Draw();
502  if (hist_hadronb2_over_bhabha_all->GetBinContent(hist_hadronb2_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
503  double hadronb2_over_bhabha_all = 0.0;
504  hadronb2_over_bhabha_all = hist_hadronb2_over_bhabha_all->GetBinContent(
505  hist_hadronb2_over_bhabha_all->GetXaxis()->FindBin("accept_hadronb2")) / hist_hadronb2_over_bhabha_all->GetBinContent(
506  hist_hadronb2_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
507 
508  B2DEBUG(1, "hadronb2_over_bhabha_all:" << hadronb2_over_bhabha_all);
509  setEpicsPV("hadronb2_over_bhabha_all", hadronb2_over_bhabha_all);
510  }
511  }
512 
513 // update #mumu2trk/#bhabha_all
514  auto hist_mumu2trk_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
515  if (hist_mumu2trk_over_bhabha_all) {
516  hist_mumu2trk_over_bhabha_all->Draw();
517  if (hist_mumu2trk_over_bhabha_all->GetBinContent(hist_mumu2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
518  double mumu2trk_over_bhabha_all = 0.0;
519  mumu2trk_over_bhabha_all = hist_mumu2trk_over_bhabha_all->GetBinContent(
520  hist_mumu2trk_over_bhabha_all->GetXaxis()->FindBin("accept_mumu_2trk")) / hist_mumu2trk_over_bhabha_all->GetBinContent(
521  hist_mumu2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
522  B2DEBUG(1, "mumu2trk_over_bhabha_all:" << mumu2trk_over_bhabha_all);
523  setEpicsPV("mumu2trk_over_bhabha_all", mumu2trk_over_bhabha_all);
524  }
525 
526  }
527 
528 // update #hadronb2/#mumu2trk
529  auto hist_hadronb2_over_mumu2trk = getDelta("softwaretrigger", "skim", 0, true);// only if updated
530  if (hist_hadronb2_over_mumu2trk) {
531  hist_hadronb2_over_mumu2trk->Draw();
532  if (hist_hadronb2_over_mumu2trk->GetBinContent(
533  hist_hadronb2_over_mumu2trk->GetXaxis()->FindBin("accept_mumu_2trk")) != 0) {
534  double hadronb2_over_mumu2trk = 0.0;
535  hadronb2_over_mumu2trk = hist_hadronb2_over_mumu2trk->GetBinContent(
536  hist_hadronb2_over_mumu2trk->GetXaxis()->FindBin("accept_hadronb2")) / hist_hadronb2_over_mumu2trk->GetBinContent(
537  hist_hadronb2_over_mumu2trk->GetXaxis()->FindBin("accept_mumu_2trk"));
538  B2DEBUG(1, "hadronb2_over_mumu2trk:" << hadronb2_over_mumu2trk);
539  setEpicsPV("hadronb2_over_mumu2trk", hadronb2_over_mumu2trk);
540  }
541 
542  }
543 
544 
545 
546 // update #mumu_tight/#bhabha_all
547  auto hist_mumu_tight_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
548  if (hist_mumu_tight_over_bhabha_all) {
549  hist_mumu_tight_over_bhabha_all->Draw();
550  if (hist_mumu_tight_over_bhabha_all->GetBinContent(
551  hist_mumu_tight_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
552  double mumu_tight_over_bhabha_all = 0.0;
553  mumu_tight_over_bhabha_all = hist_mumu_tight_over_bhabha_all->GetBinContent(
554  hist_mumu_tight_over_bhabha_all->GetXaxis()->FindBin("accept_mumutight")) / hist_mumu_tight_over_bhabha_all->GetBinContent(
555  hist_mumu_tight_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
556  B2DEBUG(1, "mumu_tight_over_bhabha_all:" << mumu_tight_over_bhabha_all);
557  setEpicsPV("mumu_tight_over_bhabha_all", mumu_tight_over_bhabha_all);
558  }
559 
560  }
561 
562 // update #gammagamma/#bhabha_all
563  auto hist_gammagamma_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
564  if (hist_gammagamma_over_bhabha_all) {
565  hist_gammagamma_over_bhabha_all->Draw();
566  if (hist_gammagamma_over_bhabha_all->GetBinContent(
567  hist_gammagamma_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
568  double gammagamma_over_bhabha_all = 0.0;
569  gammagamma_over_bhabha_all = hist_gammagamma_over_bhabha_all->GetBinContent(
570  hist_gammagamma_over_bhabha_all->GetXaxis()->FindBin("accept_gamma_gamma")) / hist_gammagamma_over_bhabha_all->GetBinContent(
571  hist_gammagamma_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
572  B2DEBUG(1, "gammagamma_over_bhabha_all:" << gammagamma_over_bhabha_all);
573  setEpicsPV("gammagamma_over_bhabha_all", gammagamma_over_bhabha_all);
574  }
575 
576  }
577 
578 // update #tautau2trk/#bhabha_all
579  auto hist_tautau2trk_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
580  if (hist_tautau2trk_over_bhabha_all) {
581  hist_tautau2trk_over_bhabha_all->Draw();
582  if (hist_tautau2trk_over_bhabha_all->GetBinContent(
583  hist_tautau2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
584  double tautau2trk_over_bhabha_all = 0.0;
585  tautau2trk_over_bhabha_all = hist_tautau2trk_over_bhabha_all->GetBinContent(
586  hist_tautau2trk_over_bhabha_all->GetXaxis()->FindBin("accept_tau_2trk")) / hist_tautau2trk_over_bhabha_all->GetBinContent(
587  hist_tautau2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
588  B2DEBUG(1, "tautau2trk_over_bhabha_all:" << tautau2trk_over_bhabha_all);
589  setEpicsPV("tautau2trk_over_bhabha_all", tautau2trk_over_bhabha_all);
590  }
591 
592  }
593 
594 // update #hadron/#bhabha_all
595  auto hist_hadron_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
596  if (hist_hadron_over_bhabha_all) {
597  hist_hadron_over_bhabha_all->Draw();
598  if (hist_hadron_over_bhabha_all->GetBinContent(
599  hist_hadron_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
600  double hadron_over_bhabha_all = 0.0;
601  hadron_over_bhabha_all = hist_hadron_over_bhabha_all->GetBinContent(
602  hist_hadron_over_bhabha_all->GetXaxis()->FindBin("accept_hadron")) / hist_hadron_over_bhabha_all->GetBinContent(
603  hist_hadron_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
604  B2DEBUG(1, "hadron_over_bhabha_all:" << hadron_over_bhabha_all);
605  setEpicsPV("hadron_over_bhabha_all", hadron_over_bhabha_all);
606  }
607 
608  }
609 
610  auto hist_nTSFHits_total = getDelta("TRGGRL", "h_wirecnt_sum", 0, true);
611  if (hist_nTSFHits_total) {
612  double mean = hist_nTSFHits_total->GetMean();
613  B2DEBUG(1, "CDCTRG_meanTSFHits_total:" << mean);
614  setEpicsPV("CDCTRG_meanTSFHits_total", mean);
615  }
616 
617  auto hist_nTSFHits_clean = getDelta("TRGGRL", "h_wirecnt_sum_clean", 0, true);
618  if (hist_nTSFHits_clean) {
619  double mean = hist_nTSFHits_clean->GetMean();
620  B2DEBUG(1, "CDCTRG_meanTSFHits_clean:" << mean);
621  setEpicsPV("CDCTRG_meanTSFHits_clean", mean);
622 
623  double tail = getThreshold(hist_nTSFHits_clean, 0.5, 0.02);
624  B2DEBUG(1, "CDCTRG_tailTSFHits_clean:" << tail);
625  setEpicsPV("CDCTRG_tailTSFHits_clean", tail);
626  }
627 
628  auto hist_nTSFHits_injHER = getDelta("TRGGRL", "h_wirecnt_sum_injHER", 0, true);
629  if (hist_nTSFHits_injHER) {
630  double mean = hist_nTSFHits_injHER->GetMean();
631  B2DEBUG(1, "CDCTRG_meanTSFHits_injHER:" << mean);
632  setEpicsPV("CDCTRG_meanTSFHits_injHER", mean);
633  }
634 
635  auto hist_nTSFHits_injLER = getDelta("TRGGRL", "h_wirecnt_sum_injLER", 0, true);
636  if (hist_nTSFHits_injLER) {
637  double mean = hist_nTSFHits_injLER->GetMean();
638  B2DEBUG(1, "CDCTRG_meanTSFHits_injLER:" << mean);
639  setEpicsPV("CDCTRG_meanTSFHits_injLER", mean);
640  }
641 
642  auto hist_nTC_total = getDelta("TRG", "h_n_TChit_event_clkgrp", 0, true);
643  if (hist_nTC_total) {
644  double mean = hist_nTC_total->GetMean();
645  B2DEBUG(1, "ECLTRG_meanTC_total:" << mean);
646  setEpicsPV("ECLTRG_meanTC_total", mean);
647  }
648 
649  auto hist_nTC_clean = getDelta("TRG", "h_n_TChit_clean_clkgrp", 0, true);
650  if (hist_nTC_clean) {
651  double mean = hist_nTC_clean->GetMean();
652  B2DEBUG(1, "ECLTRG_meanTC_clean:" << mean);
653  setEpicsPV("ECLTRG_meanTC_clean", mean);
654 
655  double tail = getThreshold(hist_nTC_clean, 0.5);
656  B2DEBUG(1, "ECLTRG_tailTC_clean:" << tail);
657  setEpicsPV("ECLTRG_tailTC_clean", tail);
658  }
659 
660  auto hist_nTC_injHER = getDelta("TRG", "h_n_TChit_injHER_clkgrp", 0, true);
661  if (hist_nTC_injHER) {
662  double mean = hist_nTC_injHER->GetMean();
663  B2DEBUG(1, "ECLTRG_meanTC_injHER:" << mean);
664  setEpicsPV("ECLTRG_meanTC_injHER", mean);
665  }
666 
667  auto hist_nTC_injLER = getDelta("TRG", "h_n_TChit_injLER_clkgrp", 0, true);
668  if (hist_nTC_injLER) {
669  double mean = hist_nTC_injLER->GetMean();
670  B2DEBUG(1, "ECLTRG_meanTC_injLER:" << mean);
671  setEpicsPV("ECLTRG_meanTC_injLER", mean);
672  }
673 
674  auto hist_nTC_FWD_total = getDelta("TRG", "h_n_TChit_FWD_event_clkgrp", 0, true);
675  if (hist_nTC_FWD_total) {
676  double mean = hist_nTC_FWD_total->GetMean();
677  B2DEBUG(1, "ECLTRG_meanTC_FWD_total:" << mean);
678  setEpicsPV("ECLTRG_meanTC_FWD_total", mean);
679  }
680 
681  auto hist_nTC_FWD_clean = getDelta("TRG", "h_n_TChit_FWD_clean_clkgrp", 0, true);
682  if (hist_nTC_FWD_clean) {
683  double mean = hist_nTC_FWD_clean->GetMean();
684  B2DEBUG(1, "ECLTRG_meanTC_FWD_clean:" << mean);
685  setEpicsPV("ECLTRG_meanTC_FWD_clean", mean);
686 
687  double tail = getThreshold(hist_nTC_FWD_clean, 0.5);
688  B2DEBUG(1, "ECLTRG_tailTC_FWD_clean:" << tail);
689  setEpicsPV("ECLTRG_tailTC_FWD_clean", tail);
690  }
691 
692  auto hist_nTC_FWD_injHER = getDelta("TRG", "h_n_TChit_FWD_injHER_clkgrp", 0, true);
693  if (hist_nTC_FWD_injHER) {
694  double mean = hist_nTC_FWD_injHER->GetMean();
695  B2DEBUG(1, "ECLTRG_meanTC_FWD_injHER:" << mean);
696  setEpicsPV("ECLTRG_meanTC_FWD_injHER", mean);
697  }
698 
699  auto hist_nTC_FWD_injLER = getDelta("TRG", "h_n_TChit_FWD_injLER_clkgrp", 0, true);
700  if (hist_nTC_FWD_injLER) {
701  double mean = hist_nTC_FWD_injLER->GetMean();
702  B2DEBUG(1, "ECLTRG_meanTC_FWD_injLER:" << mean);
703  setEpicsPV("ECLTRG_meanTC_FWD_injLER", mean);
704  }
705 
706  auto hist_nTC_BRL_total = getDelta("TRG", "h_n_TChit_BRL_event_clkgrp", 0, true);
707  if (hist_nTC_BRL_total) {
708  double mean = hist_nTC_BRL_total->GetMean();
709  B2DEBUG(1, "ECLTRG_meanTC_BRL_total:" << mean);
710  setEpicsPV("ECLTRG_meanTC_BRL_total", mean);
711  }
712 
713  auto hist_nTC_BRL_clean = getDelta("TRG", "h_n_TChit_BRL_clean_clkgrp", 0, true);
714  if (hist_nTC_BRL_clean) {
715  double mean = hist_nTC_BRL_clean->GetMean();
716  B2DEBUG(1, "ECLTRG_meanTC_BRL_clean:" << mean);
717  setEpicsPV("ECLTRG_meanTC_BRL_clean", mean);
718 
719  double tail = getThreshold(hist_nTC_BRL_clean, 0.5);
720  B2DEBUG(1, "ECLTRG_tailTC_BRL_clean:" << tail);
721  setEpicsPV("ECLTRG_tailTC_BRL_clean", tail);
722  }
723 
724  auto hist_nTC_BRL_injHER = getDelta("TRG", "h_n_TChit_BRL_injHER_clkgrp", 0, true);
725  if (hist_nTC_BRL_injHER) {
726  double mean = hist_nTC_BRL_injHER->GetMean();
727  B2DEBUG(1, "ECLTRG_meanTC_BRL_injHER:" << mean);
728  setEpicsPV("ECLTRG_meanTC_BRL_injHER", mean);
729  }
730 
731  auto hist_nTC_BRL_injLER = getDelta("TRG", "h_n_TChit_BRL_injLER_clkgrp", 0, true);
732  if (hist_nTC_BRL_injLER) {
733  double mean = hist_nTC_BRL_injLER->GetMean();
734  B2DEBUG(1, "ECLTRG_meanTC_BRL_injLER:" << mean);
735  setEpicsPV("ECLTRG_meanTC_BRL_injLER", mean);
736  }
737 
738  auto hist_nTC_BWD_total = getDelta("TRG", "h_n_TChit_BWD_event_clkgrp", 0, true);
739  if (hist_nTC_BWD_total) {
740  double mean = hist_nTC_BWD_total->GetMean();
741  B2DEBUG(1, "ECLTRG_meanTC_BWD_total:" << mean);
742  setEpicsPV("ECLTRG_meanTC_BWD_total", mean);
743  }
744 
745  auto hist_nTC_BWD_clean = getDelta("TRG", "h_n_TChit_BWD_clean_clkgrp", 0, true);
746  if (hist_nTC_BWD_clean) {
747  double mean = hist_nTC_BWD_clean->GetMean();
748  B2DEBUG(1, "ECLTRG_meanTC_BWD_clean:" << mean);
749  setEpicsPV("ECLTRG_meanTC_BWD_clean", mean);
750 
751  double tail = getThreshold(hist_nTC_BWD_clean, 0.5);
752  B2DEBUG(1, "ECLTRG_tailTC_BWD_clean:" << tail);
753  setEpicsPV("ECLTRG_tailTC_BWD_clean", tail);
754  }
755 
756  auto hist_nTC_BWD_injHER = getDelta("TRG", "h_n_TChit_BWD_injHER_clkgrp", 0, true);
757  if (hist_nTC_BWD_injHER) {
758  double mean = hist_nTC_BWD_injHER->GetMean();
759  B2DEBUG(1, "ECLTRG_meanTC_BWD_injHER:" << mean);
760  setEpicsPV("ECLTRG_meanTC_BWD_injHER", mean);
761  }
762 
763  auto hist_nTC_BWD_injLER = getDelta("TRG", "h_n_TChit_BWD_injLER_clkgrp", 0, true);
764  if (hist_nTC_BWD_injLER) {
765  double mean = hist_nTC_BWD_injLER->GetMean();
766  B2DEBUG(1, "ECLTRG_meanTC_BWD_injLER:" << mean);
767  setEpicsPV("ECLTRG_meanTC_BWD_injLER", mean);
768  }
769 
770 
771  // Tag canvas as updated ONLY if things have changed.
772  UpdateCanvas(m_canvas->GetName(), hist != nullptr);
773 
774  // this if left over from jsroot, may not be needed anymore (to check)
775  m_canvas->Update();
776 
777 }
778 
780 {
781  B2DEBUG(1, "DQMHistAnalysisTRGModule: terminate called");
782 }
783 
784 
785 double DQMHistAnalysisTRGModule::getThreshold(const TH1* hist, const double lower_bound, const double widthFraction)
786 {
787  if (hist == nullptr) return 0.;
788 
789  double movsum = 0;
790  int nbins = hist->GetNbinsX();
791  int width = nbins * widthFraction;
792  int num = 0;
793 
794  if (width <= 1) width = 2;
795 
796  int meanbin = hist->GetXaxis()->FindBin(hist->GetMean());
797 
798  for (int i = meanbin - 1; 1 <= i && i <= meanbin - width; i--) {
799  num++;
800  movsum += hist->GetBinContent(i);
801  }
802 
803  for (int i = meanbin; i < nbins; i++) {
804  int binIdx = i + 1;
805 
806  if (num < width) {
807  movsum += hist->GetBinContent(binIdx);
808  num++;
809  } else {
810  movsum += hist->GetBinContent(binIdx);
811  movsum -= hist->GetBinContent(binIdx - width);
812  }
813 
814  if (movsum / num < lower_bound) {
815  return hist->GetBinCenter(binIdx);
816  }
817  }
818  return hist->GetXaxis()->GetBinCenter(nbins);
819 }
The base class for the histogram analysis module.
int registerEpicsPV(std::string pvname, std::string keyname="", bool update_pvs=true)
EPICS related Functions.
void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
TH1 * getDelta(const std::string &fullname, int n=0, bool onlyIfUpdated=true)
Get Delta histogram.
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
void UpdateCanvas(std::string name, bool updated=true)
Mark canvas as updated (or not)
void terminate(void) override final
This method is called at the end of the event processing.
static double getThreshold(const TH1 *hist, const double lower_bound, const double widthFraction=0.01)
A utility function to find the location of the tail of histograms.
void initialize(void) override final
Initializer.
void endRun(void) override final
Called when run ends.
std::string m_pvPrefix
prefix for EPICS PVs
void doHistAnalysis()
Do the actual processing.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.