Belle II Software development
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
18using namespace std;
19using namespace Belle2;
20
21//-----------------------------------------------------------------
22// Register the Module
23//-----------------------------------------------------------------
24REG_MODULE(DQMHistAnalysisTRG);
25
26//-----------------------------------------------------------------
27// Implementation
28//-----------------------------------------------------------------
29
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, 1000000, 1); // update each 1000000 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, 1000000, 1); // update each 1000000 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, 1000000, 1); // update each 1000000 entries
155 registerEpicsPV(m_pvPrefix + "hadronb2_over_mumu2trk", "hadronb2_over_mumu2trk");
156
157 //ECLTRG_deadch
158 addDeltaPar("TRG", "h_TCId", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
159 registerEpicsPV(m_pvPrefix + "ECLTRG_deadch", "ECLTRG_deadch");
160
161 //ECLTRG N(TC) total
162 addDeltaPar("TRG", "h_n_TChit_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
163 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_total", "ECLTRG_meanTC_total");
164
165 //ECLTRG N(TC) clean
166 addDeltaPar("TRG", "h_n_TChit_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
167 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_clean", "ECLTRG_meanTC_clean"); // Mean value for the distribution of N(TC)
168 registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_clean", "ECLTRG_tailTC_clean"); // Tail position for the distribution of N(TC)
169
170 //ECLTRG N(TC) HER Injection region
171 addDeltaPar("TRG", "h_n_TChit_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
172 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_injHER", "ECLTRG_meanTC_injHER");
173
174 //ECLTRG N(TC) LER Injection region
175 addDeltaPar("TRG", "h_n_TChit_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
176 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_injLER", "ECLTRG_meanTC_injLER");
177
178 //ECLTRG N(TC) total from the forward endcap
179 addDeltaPar("TRG", "h_n_TChit_FWD_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
180 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_total", "ECLTRG_meanTC_FWD_total");
181
182 //ECLTRG N(TC) clean from the forward endcap
183 addDeltaPar("TRG", "h_n_TChit_FWD_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
184 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_clean",
185 "ECLTRG_meanTC_FWD_clean"); // Mean value for the distribution of N(TC) from the forward
186 registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_FWD_clean",
187 "ECLTRG_tailTC_FWD_clean"); // Tail position for the distribution of N(TC) from the forward
188
189 //ECLTRG N(TC) HER Injection region from the forward endcap
190 addDeltaPar("TRG", "h_n_TChit_FWD_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
191 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_injHER", "ECLTRG_meanTC_FWD_injHER");
192
193 //ECLTRG N(TC) LER Injection region from the forward endcap
194 addDeltaPar("TRG", "h_n_TChit_FWD_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
195 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_FWD_injLER", "ECLTRG_meanTC_FWD_injLER");
196
197 //ECLTRG N(TC) total from the barrel
198 addDeltaPar("TRG", "h_n_TChit_BRL_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
199 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_total", "ECLTRG_meanTC_BRL_total");
200
201 //ECLTRG N(TC) clean from the barrel
202 addDeltaPar("TRG", "h_n_TChit_BRL_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
203 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_clean",
204 "ECLTRG_meanTC_BRL_clean"); // Mean value for the distribution of N(TC) from the barrel
205 registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_BRL_clean",
206 "ECLTRG_tailTC_BRL_clean"); // Tail position for the distribution of N(TC) from the barrel
207
208 //ECLTRG N(TC) HER Injection region from the barrel
209 addDeltaPar("TRG", "h_n_TChit_BRL_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
210 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_injHER", "ECLTRG_meanTC_BRL_injHER");
211
212 //ECLTRG N(TC) LER Injection region from the barrel
213 addDeltaPar("TRG", "h_n_TChit_BRL_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
214 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BRL_injLER", "ECLTRG_meanTC_BRL_injLER");
215
216 //ECLTRG N(TC) total from the backward endcap
217 addDeltaPar("TRG", "h_n_TChit_BWD_event_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
218 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_total", "ECLTRG_meanTC_BWD_total");
219
220 //ECLTRG N(TC) clean from the backward endcap
221 addDeltaPar("TRG", "h_n_TChit_BWD_clean_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
222 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_clean",
223 "ECLTRG_meanTC_BWD_clean"); // Mean value for the distribution of N(TC) from the backward
224 registerEpicsPV(m_pvPrefix + "ECLTRG_tailTC_BWD_clean",
225 "ECLTRG_tailTC_BWD_clean"); // Tail position for the distribution of N(TC) from the backward
226
227 //ECLTRG N(TC) HER Injection region from the backward endcap
228 addDeltaPar("TRG", "h_n_TChit_BWD_injHER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
229 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_injHER", "ECLTRG_meanTC_BWD_injHER");
230
231 //ECLTRG N(TC) LER Injection region from the backward endcap
232 addDeltaPar("TRG", "h_n_TChit_BWD_injLER_clkgrp", HistDelta::c_Entries, 10000, 1); // update each 10000 entries
233 registerEpicsPV(m_pvPrefix + "ECLTRG_meanTC_BWD_injLER", "ECLTRG_meanTC_BWD_injLER");
234
235 //CDCTRG_deadch
236// m_canvas_CDCTRG_deadch = new TCanvas("CDCTRG_deadch");
237 addDeltaPar("TRGCDCTNN", "NeuroHWInTSID", HistDelta::c_Entries, 100000, 1); // update each 100000 entries
238 registerEpicsPV(m_pvPrefix + "CDCTRG_deadch", "CDCTRG_deadch");
239
240}
241
243{
244 B2DEBUG(1, "DQMHistAnalysisTRGModule: beginRun called.");
245}
246
248{
249 B2DEBUG(1, "DQMHistAnalysisTRGModule: endRun called.");
250}
251
253{
254 B2DEBUG(1, "DQMHistAnalysisTRGModule: event called.");
256}
257
259{
260 m_canvas->Clear();
261 m_canvas->cd(0);
262
263 bool m_IsPhysicsRun = (getRunType() == "physics") || (getRunType() == "cosmic") || (getRunType() == "debug");
264 if (m_IsPhysicsRun == true) {
265
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 }
275
276 //update ECLTRG timing
277 auto hist = getDelta("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_ECLTRG", 0, true);// only if updated
278 if (hist) {
279 double ECLTRG_timing_mean = 0.0;
280 hist->Draw();
281 ECLTRG_timing_mean = hist->GetMean();
282 B2DEBUG(1, "ECLTRG_timing_mean:" << ECLTRG_timing_mean);
283 setEpicsPV("ECLTRG_timing_mean", ECLTRG_timing_mean);
284 }
285
286
287 //update CDCTRG timing
288 auto histCDCTRG = getDelta("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_CDCTRG", 0, true);// only if updated
289 if (histCDCTRG) {
290 double CDCTRG_timing_mean = 0.0;
291 histCDCTRG->Draw();
292 CDCTRG_timing_mean = histCDCTRG->GetMean();
293 B2DEBUG(1, "CDCTRG_timing_mean:" << CDCTRG_timing_mean);
294 setEpicsPV("CDCTRG_timing_mean", CDCTRG_timing_mean);
295 }
296
297 //update TOPTRG timing
298 auto histTOPTRG = getDelta("EventT0DQMdir", "m_histEventT0_TOP_hadron_L1_TOPTRG", 0, true);// only if updated
299 if (histTOPTRG) {
300 double TOPTRG_timing_mean = 0.0;
301 histTOPTRG->Draw();
302 TOPTRG_timing_mean = histTOPTRG->GetMean();
303 B2DEBUG(1, "TOPTRG_timing_mean:" << TOPTRG_timing_mean);
304 setEpicsPV("TOPTRG_timing_mean", TOPTRG_timing_mean);
305 }
306
307// update ECLTRG peak
308 auto hist_ECLTRG_peak = getDelta("TRGGRL", "h_ECLL1", 0, true);// only if updated
309 if (hist_ECLTRG_peak) {
310// TH1F* hist_ECLTRG_clone = (TH1F*)hist_ECLTRG_peak->Clone();//Clone the histogram.
311 double ECLTRG_peak = 0.0;
312 hist_ECLTRG_peak->Draw();
313// int bin_ECLTRG_peak = hist_ECLTRG_peak->GetMaximumBin();
314// ECLTRG_peak = hist_ECLTRG_peak->GetXaxis()->GetBinCenter(bin_ECLTRG_peak);
315 ECLTRG_peak = hist_ECLTRG_peak->GetMean();
316
317 /*
318 while(ECLTRG_peak<-1310){
319 hist_ECLTRG_clone->SetBinContent(bin_ECLTRG_peak, 0);
320 bin_ECLTRG_peak = hist_ECLTRG_clone->GetMaximumBin();
321 ECLTRG_peak = hist_ECLTRG_clone->GetXaxis()->GetBinCenter(bin_ECLTRG_peak);
322 }
323 */
324
325 B2DEBUG(1, "ECLTRG_peak:" << ECLTRG_peak);
326 setEpicsPV("ECLTRG_peak", ECLTRG_peak);
327// delete hist_ECLTRG_clone;
328 }
329
330// update ECLTRG deadch
331 auto hist_ECLTRG_deadch = getDelta("TRG", "h_TCId", 0, true);// only if updated
332 if (hist_ECLTRG_deadch) {
333 hist_ECLTRG_deadch->Draw();
334 int numberOfBins = hist_ECLTRG_deadch->GetNbinsX();
335 double average = 0;
336 for (int i = 80; i < 512; i++) {
337 average += hist_ECLTRG_deadch->GetBinContent(i);
338 }
339 average = 1.0 * average / (512 - 80);
340 int ECLTRG_deadch = 0;
341// for (int i = 2; i <= numberOfBins - 1; i++) {
342// if (hist_ECLTRG_deadch->GetBinContent(i) <= 0.01 * hist_ECLTRG_deadch->GetMaximum()) { ECLTRG_deadch += 1; }
343// }
344 for (int i = 2; i <= numberOfBins - 1; i++) {
345 if (hist_ECLTRG_deadch->GetBinContent(i) <= 0.01 * average) { ECLTRG_deadch += 1; }
346 }
347 B2DEBUG(1, "ECLTRG_deadch:" << ECLTRG_deadch);
348 setEpicsPV("ECLTRG_deadch", ECLTRG_deadch);
349 }
350
351// update TOPTRG deadch
352 auto hist_TOPTRG_deadch = getDelta("TRGGRL", "h_slot_TOP", 0, true);// only if updated
353 if (hist_TOPTRG_deadch) {
354 hist_TOPTRG_deadch->Draw();
355 int numberOfBins = hist_TOPTRG_deadch->GetNbinsX();
356 int TOPTRG_deadch = 0;
357 for (int i = 2; i <= numberOfBins - 1; i++) {
358 if (hist_TOPTRG_deadch->GetBinContent(i) <= 0.01 * hist_TOPTRG_deadch->GetMaximum()) { TOPTRG_deadch += 1; }
359 }
360 B2DEBUG(1, "TOPTRG_deadch:" << TOPTRG_deadch);
361 setEpicsPV("TOPTRG_deadch", TOPTRG_deadch);
362 }
363
364// m_canvas_CDCTRG_2D_peak->Clear();
365// m_canvas_CDCTRG_2D_peak->cd(0);
366// update CDCTRG 2D peak
367 auto hist_CDCTRG_2D_peak = getDelta("TRGGRL", "h_CDCL1", 0, true);// only if updated
368 if (hist_CDCTRG_2D_peak) {
369 double CDCTRG_2D_peak = 0.0;
370 hist_CDCTRG_2D_peak->Draw();
371 int bin_CDCTRG_2D_peak = hist_CDCTRG_2D_peak->GetMaximumBin();
372 CDCTRG_2D_peak = hist_CDCTRG_2D_peak->GetXaxis()->GetBinCenter(bin_CDCTRG_2D_peak);
373 B2DEBUG(1, "CDCTRG_2D_peak:" << CDCTRG_2D_peak);
374 setEpicsPV("CDCTRG_2D_peak", CDCTRG_2D_peak);
375
376 }
377
378// update CDCTRG NN peak
379 auto hist_NN_peak = getDelta("TRGGRL", "h_CDCNNL1", 0, true);// only if updated
380 if (hist_NN_peak) {
381 double NN_peak = 0.0;
382 hist_NN_peak->Draw();
383 int bin_NN_peak = hist_NN_peak->GetMaximumBin();
384 NN_peak = hist_NN_peak->GetXaxis()->GetBinCenter(bin_NN_peak);
385 B2DEBUG(1, "NN_peak:" << NN_peak);
386 setEpicsPV("NN_peak", NN_peak);
387
388 }
389
390// update CDCTRG TSF
391 auto hist_CDCTRG_TSF_peak = getDelta("TRGGRL", "h_TSFL1", 0, true);// only if updated
392 if (hist_CDCTRG_TSF_peak) {
393 double CDCTRG_TSF_peak = 0.0;
394 hist_CDCTRG_TSF_peak->Draw();
395 int bin_CDCTRG_TSF_peak = hist_CDCTRG_TSF_peak->GetMaximumBin();
396 CDCTRG_TSF_peak = hist_CDCTRG_TSF_peak->GetXaxis()->GetBinCenter(bin_CDCTRG_TSF_peak);
397 B2DEBUG(1, "CDCTRG_TSF_peak:" << CDCTRG_TSF_peak);
398 setEpicsPV("CDCTRG_TSF_peak", CDCTRG_TSF_peak);
399
400 }
401
402// update CDCTRG deadch
403 auto hist_CDCTRG_deadch = getDelta("TRGCDCTNN", "NeuroHWInTSID", 0, true);// only if updated
404 if (hist_CDCTRG_deadch) {
405 hist_CDCTRG_deadch->Draw();
406 int numberOfBins = hist_CDCTRG_deadch->GetNbinsX();
407// int YMax = hist_CDCTRG_deadch->GetBinContent(hist_CDCTRG_deadch->GetMaximumBin());
408 int CDCTRG_deadch = 0;
409 for (int i = 3; i <= numberOfBins; i++) {
410 if (hist_CDCTRG_deadch->GetBinContent(i) <= 0.01 * hist_CDCTRG_deadch->GetMaximum()) {CDCTRG_deadch += 1;}
411// if (hist_CDCTRG_deadch->GetBinContent(i) <= 0) {CDCTRG_deadch += 1;}
412 }
413 B2DEBUG(1, "CDCTRG_deadch:" << CDCTRG_deadch);
414 setEpicsPV("CDCTRG_deadch", CDCTRG_deadch);
415 }
416
417// update KLMTRG
418 auto hist_KLMTRG_peak = getDelta("TRGGRL", "h_KLML1", 0, true);// only if updated
419 if (hist_KLMTRG_peak) {
420 double KLMTRG_peak = 0.0;
421 hist_KLMTRG_peak->Draw();
422 int bin_KLMTRG_peak = hist_KLMTRG_peak->GetMaximumBin();
423 KLMTRG_peak = hist_KLMTRG_peak->GetXaxis()->GetBinCenter(bin_KLMTRG_peak);
424 B2DEBUG(1, "KLMTRG_peak:" << KLMTRG_peak);
425 setEpicsPV("KLMTRG_peak", KLMTRG_peak);
426
427 }
428
429// update TOPTRG
430 auto hist_TOPTRG_peak = getDelta("TRGGRL", "h_TOPL1", 0, true);// only if updated
431 if (hist_TOPTRG_peak) {
432 double TOPTRG_peak = 0.0;
433 hist_TOPTRG_peak->Draw();
434 int bin_TOPTRG_peak = hist_TOPTRG_peak->GetMaximumBin();
435 TOPTRG_peak = hist_TOPTRG_peak->GetXaxis()->GetBinCenter(bin_TOPTRG_peak);
436 B2DEBUG(1, "TOPTRG_peak:" << TOPTRG_peak);
437 setEpicsPV("TOPTRG_peak", TOPTRG_peak);
438
439 }
440
441// update ecltiming_cdctiming
442 auto hist_ecltiming_cdctiming = getDelta("TRGGDL", "hGDL_ns_cdcToecl_all", 0, true);// only if updated
443 if (hist_ecltiming_cdctiming) {
444 double ecltiming_cdctiming = 0.0;
445 hist_ecltiming_cdctiming->Draw();
446 int bin_ecltiming_cdctiming = hist_ecltiming_cdctiming->GetMaximumBin();
447 ecltiming_cdctiming = hist_ecltiming_cdctiming->GetXaxis()->GetBinCenter(bin_ecltiming_cdctiming);
448 B2DEBUG(1, "ecltiming_cdctiming:" << ecltiming_cdctiming);
449 setEpicsPV("ecltiming_cdctiming", ecltiming_cdctiming);//Peak
450 }
451
452// update toptiming_ecltiming
453 auto hist_toptiming_ecltiming = getDelta("TRGGDL", "hGDL_ns_topToecl_all", 0, true);// only if updated
454 if (hist_toptiming_ecltiming) {
455 double toptiming_ecltiming = 0.0;
456 hist_toptiming_ecltiming->Draw();
457 int bin_toptiming_ecltiming = hist_toptiming_ecltiming->GetMaximumBin();
458 toptiming_ecltiming = hist_toptiming_ecltiming->GetXaxis()->GetBinCenter(bin_toptiming_ecltiming);
459 B2DEBUG(1, "toptiming_ecltiming:" << toptiming_ecltiming);
460 setEpicsPV("toptiming_ecltiming", toptiming_ecltiming);//Peak
461 }
462
463// update toptiming_cdctiming
464 auto hist_toptiming_cdctiming = getDelta("TRGGDL", "hGDL_ns_topTocdc_all", 0, true);// only if updated
465 if (hist_toptiming_cdctiming) {
466 double toptiming_cdctiming = 0.0;
467 hist_toptiming_cdctiming->Draw();
468 int bin_toptiming_cdctiming = hist_toptiming_cdctiming->GetMaximumBin();
469 toptiming_cdctiming = hist_toptiming_cdctiming->GetXaxis()->GetBinCenter(bin_toptiming_cdctiming);
470 B2DEBUG(1, "toptiming_cdctiming:" << toptiming_cdctiming);
471 setEpicsPV("toptiming_cdctiming", toptiming_cdctiming);//Peak
472 }
473
474// update gdll1_ecltiming
475 auto hist_gdll1_ecltiming = getDelta("TRGGDL", "hGDL_eclTogdlL1_all", 0, true);// only if updated
476 if (hist_gdll1_ecltiming) {
477 double gdll1_ecltiming = 0.0;
478 hist_gdll1_ecltiming->Draw();
479 int bin_gdll1_ecltiming = hist_gdll1_ecltiming->GetMaximumBin();
480 gdll1_ecltiming = hist_gdll1_ecltiming->GetXaxis()->GetBinCenter(bin_gdll1_ecltiming);
481 B2DEBUG(1, "gdll1_ecltiming:" << gdll1_ecltiming);
482 setEpicsPV("gdll1_ecltiming", gdll1_ecltiming);//Peak
483 }
484
485// update gdll1_cdctiming
486 auto hist_gdll1_cdctiming = getDelta("TRGGDL", "hGDL_cdcTogdlL1_all", 0, true);// only if updated
487 if (hist_gdll1_cdctiming) {
488 double gdll1_cdctiming = 0.0;
489 hist_gdll1_cdctiming->Draw();
490 int bin_gdll1_cdctiming = hist_gdll1_cdctiming->GetMaximumBin();
491 gdll1_cdctiming = hist_gdll1_cdctiming->GetXaxis()->GetBinCenter(bin_gdll1_cdctiming);
492 B2DEBUG(1, "gdll1_cdctiming:" << gdll1_cdctiming);
493 setEpicsPV("gdll1_cdctiming", gdll1_cdctiming);//Peak
494 }
495
496// update gdll1_toptiming
497 auto hist_gdll1_toptiming = getDelta("TRGGDL", "hGDL_topTogdlL1_all", 0, true);// only if updated
498 if (hist_gdll1_toptiming) {
499 double gdll1_toptiming = 0.0;
500 hist_gdll1_toptiming->Draw();
501 int bin_gdll1_toptiming = hist_gdll1_toptiming->GetMaximumBin();
502 gdll1_toptiming = hist_gdll1_toptiming->GetXaxis()->GetBinCenter(bin_gdll1_toptiming);
503 B2DEBUG(1, "gdll1_toptiming:" << gdll1_toptiming);
504 setEpicsPV("gdll1_toptiming", gdll1_toptiming);//Peak
505 }
506
507// update barrel_klm_latency
508 auto hist_barrel_klm_latency = getDelta("TRGGDL", "hGDL_itd_klm_hit_rise_all", 0, true);// only if updated
509 if (hist_barrel_klm_latency) {
510 double barrel_klm_latency = 0.0;
511 hist_barrel_klm_latency->Draw();
512 int bin_barrel_klm_latency = hist_barrel_klm_latency->GetMaximumBin();
513 barrel_klm_latency = hist_barrel_klm_latency->GetXaxis()->GetBinCenter(bin_barrel_klm_latency);
514 B2DEBUG(1, "barrel_klm_latency:" << barrel_klm_latency);
515 setEpicsPV("barrel_klm_latency", barrel_klm_latency);//Peak
516 }
517
518// update endcap_klm_latency
519 auto hist_endcap_klm_latency = getDelta("TRGGDL", "hGDL_itd_eklm_hit_rise_all", 0, true);// only if updated
520 if (hist_endcap_klm_latency) {
521 double endcap_klm_latency = 0.0;
522 hist_endcap_klm_latency->Draw();
523 int bin_endcap_klm_latency = hist_endcap_klm_latency->GetMaximumBin();
524 endcap_klm_latency = hist_endcap_klm_latency->GetXaxis()->GetBinCenter(bin_endcap_klm_latency);
525 B2DEBUG(1, "endcap_klm_latency:" << endcap_klm_latency);
526 setEpicsPV("endcap_klm_latency", endcap_klm_latency);//Peak
527 }
528
529 bool m_IsPhysicsRun_ratio = (getRunType() == "physics");
530 if (m_IsPhysicsRun_ratio == true) {
531
532
533// update #hadronb2/#bhabha_all
534 auto hist_hadronb2_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
535 if (hist_hadronb2_over_bhabha_all) {
536 hist_hadronb2_over_bhabha_all->Draw();
537 if (hist_hadronb2_over_bhabha_all->GetBinContent(hist_hadronb2_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
538 double hadronb2_over_bhabha_all = 0.0;
539 hadronb2_over_bhabha_all = hist_hadronb2_over_bhabha_all->GetBinContent(
540 hist_hadronb2_over_bhabha_all->GetXaxis()->FindBin("accept_hadronb2")) / hist_hadronb2_over_bhabha_all->GetBinContent(
541 hist_hadronb2_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
542
543 B2DEBUG(1, "hadronb2_over_bhabha_all:" << hadronb2_over_bhabha_all);
544 setEpicsPV("hadronb2_over_bhabha_all", hadronb2_over_bhabha_all);
545 }
546 }
547
548// update #mumu2trk/#bhabha_all
549 auto hist_mumu2trk_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
550 if (hist_mumu2trk_over_bhabha_all) {
551 hist_mumu2trk_over_bhabha_all->Draw();
552 if (hist_mumu2trk_over_bhabha_all->GetBinContent(hist_mumu2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
553 double mumu2trk_over_bhabha_all = 0.0;
554 mumu2trk_over_bhabha_all = hist_mumu2trk_over_bhabha_all->GetBinContent(
555 hist_mumu2trk_over_bhabha_all->GetXaxis()->FindBin("accept_mumu_2trk")) / hist_mumu2trk_over_bhabha_all->GetBinContent(
556 hist_mumu2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
557 B2DEBUG(1, "mumu2trk_over_bhabha_all:" << mumu2trk_over_bhabha_all);
558 setEpicsPV("mumu2trk_over_bhabha_all", mumu2trk_over_bhabha_all);
559 }
560
561 }
562
563// update #hadronb2/#mumu2trk
564 auto hist_hadronb2_over_mumu2trk = getDelta("softwaretrigger", "skim", 0, true);// only if updated
565 if (hist_hadronb2_over_mumu2trk) {
566 hist_hadronb2_over_mumu2trk->Draw();
567 if (hist_hadronb2_over_mumu2trk->GetBinContent(
568 hist_hadronb2_over_mumu2trk->GetXaxis()->FindBin("accept_mumu_2trk")) != 0) {
569 double hadronb2_over_mumu2trk = 0.0;
570 hadronb2_over_mumu2trk = hist_hadronb2_over_mumu2trk->GetBinContent(
571 hist_hadronb2_over_mumu2trk->GetXaxis()->FindBin("accept_hadronb2")) / hist_hadronb2_over_mumu2trk->GetBinContent(
572 hist_hadronb2_over_mumu2trk->GetXaxis()->FindBin("accept_mumu_2trk"));
573 B2DEBUG(1, "hadronb2_over_mumu2trk:" << hadronb2_over_mumu2trk);
574 setEpicsPV("hadronb2_over_mumu2trk", hadronb2_over_mumu2trk);
575 }
576
577 }
578
579
580
581// update #mumu_tight/#bhabha_all
582 auto hist_mumu_tight_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
583 if (hist_mumu_tight_over_bhabha_all) {
584 hist_mumu_tight_over_bhabha_all->Draw();
585 if (hist_mumu_tight_over_bhabha_all->GetBinContent(
586 hist_mumu_tight_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
587 double mumu_tight_over_bhabha_all = 0.0;
588 mumu_tight_over_bhabha_all = hist_mumu_tight_over_bhabha_all->GetBinContent(
589 hist_mumu_tight_over_bhabha_all->GetXaxis()->FindBin("accept_mumutight")) / hist_mumu_tight_over_bhabha_all->GetBinContent(
590 hist_mumu_tight_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
591 B2DEBUG(1, "mumu_tight_over_bhabha_all:" << mumu_tight_over_bhabha_all);
592 setEpicsPV("mumu_tight_over_bhabha_all", mumu_tight_over_bhabha_all);
593 }
594
595 }
596
597// update #gammagamma/#bhabha_all
598 auto hist_gammagamma_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
599 if (hist_gammagamma_over_bhabha_all) {
600 hist_gammagamma_over_bhabha_all->Draw();
601 if (hist_gammagamma_over_bhabha_all->GetBinContent(
602 hist_gammagamma_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
603 double gammagamma_over_bhabha_all = 0.0;
604 gammagamma_over_bhabha_all = hist_gammagamma_over_bhabha_all->GetBinContent(
605 hist_gammagamma_over_bhabha_all->GetXaxis()->FindBin("accept_gamma_gamma")) / hist_gammagamma_over_bhabha_all->GetBinContent(
606 hist_gammagamma_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
607 B2DEBUG(1, "gammagamma_over_bhabha_all:" << gammagamma_over_bhabha_all);
608 setEpicsPV("gammagamma_over_bhabha_all", gammagamma_over_bhabha_all);
609 }
610
611 }
612
613// update #tautau2trk/#bhabha_all
614 auto hist_tautau2trk_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
615 if (hist_tautau2trk_over_bhabha_all) {
616 hist_tautau2trk_over_bhabha_all->Draw();
617 if (hist_tautau2trk_over_bhabha_all->GetBinContent(
618 hist_tautau2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
619 double tautau2trk_over_bhabha_all = 0.0;
620 tautau2trk_over_bhabha_all = hist_tautau2trk_over_bhabha_all->GetBinContent(
621 hist_tautau2trk_over_bhabha_all->GetXaxis()->FindBin("accept_tau_2trk")) / hist_tautau2trk_over_bhabha_all->GetBinContent(
622 hist_tautau2trk_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
623 B2DEBUG(1, "tautau2trk_over_bhabha_all:" << tautau2trk_over_bhabha_all);
624 setEpicsPV("tautau2trk_over_bhabha_all", tautau2trk_over_bhabha_all);
625 }
626
627 }
628
629// update #hadron/#bhabha_all
630 auto hist_hadron_over_bhabha_all = getDelta("softwaretrigger", "skim", 0, true);// only if updated
631 if (hist_hadron_over_bhabha_all) {
632 hist_hadron_over_bhabha_all->Draw();
633 if (hist_hadron_over_bhabha_all->GetBinContent(
634 hist_hadron_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all")) != 0) {
635 double hadron_over_bhabha_all = 0.0;
636 hadron_over_bhabha_all = hist_hadron_over_bhabha_all->GetBinContent(
637 hist_hadron_over_bhabha_all->GetXaxis()->FindBin("accept_hadron")) / hist_hadron_over_bhabha_all->GetBinContent(
638 hist_hadron_over_bhabha_all->GetXaxis()->FindBin("accept_bhabha_all"));
639 B2DEBUG(1, "hadron_over_bhabha_all:" << hadron_over_bhabha_all);
640 setEpicsPV("hadron_over_bhabha_all", hadron_over_bhabha_all);
641 }
642
643 }
644
645 }
646
647 auto hist_nTSFHits_total = getDelta("TRGGRL", "h_wirecnt_sum", 0, true);
648 if (hist_nTSFHits_total) {
649 double mean = hist_nTSFHits_total->GetMean();
650 B2DEBUG(1, "CDCTRG_meanTSFHits_total:" << mean);
651 setEpicsPV("CDCTRG_meanTSFHits_total", mean);
652 }
653
654 auto hist_nTSFHits_clean = getDelta("TRGGRL", "h_wirecnt_sum_clean", 0, true);
655 if (hist_nTSFHits_clean) {
656 double mean = hist_nTSFHits_clean->GetMean();
657 B2DEBUG(1, "CDCTRG_meanTSFHits_clean:" << mean);
658 setEpicsPV("CDCTRG_meanTSFHits_clean", mean);
659
660 double tail = getThreshold(hist_nTSFHits_clean, 0.5, 0.02);
661 B2DEBUG(1, "CDCTRG_tailTSFHits_clean:" << tail);
662 setEpicsPV("CDCTRG_tailTSFHits_clean", tail);
663 }
664
665 auto hist_nTSFHits_injHER = getDelta("TRGGRL", "h_wirecnt_sum_injHER", 0, true);
666 if (hist_nTSFHits_injHER) {
667 double mean = hist_nTSFHits_injHER->GetMean();
668 B2DEBUG(1, "CDCTRG_meanTSFHits_injHER:" << mean);
669 setEpicsPV("CDCTRG_meanTSFHits_injHER", mean);
670 }
671
672 auto hist_nTSFHits_injLER = getDelta("TRGGRL", "h_wirecnt_sum_injLER", 0, true);
673 if (hist_nTSFHits_injLER) {
674 double mean = hist_nTSFHits_injLER->GetMean();
675 B2DEBUG(1, "CDCTRG_meanTSFHits_injLER:" << mean);
676 setEpicsPV("CDCTRG_meanTSFHits_injLER", mean);
677 }
678
679 auto hist_nTC_total = getDelta("TRG", "h_n_TChit_event_clkgrp", 0, true);
680 if (hist_nTC_total) {
681 double mean = hist_nTC_total->GetMean();
682 B2DEBUG(1, "ECLTRG_meanTC_total:" << mean);
683 setEpicsPV("ECLTRG_meanTC_total", mean);
684 }
685
686 auto hist_nTC_clean = getDelta("TRG", "h_n_TChit_clean_clkgrp", 0, true);
687 if (hist_nTC_clean) {
688 double mean = hist_nTC_clean->GetMean();
689 B2DEBUG(1, "ECLTRG_meanTC_clean:" << mean);
690 setEpicsPV("ECLTRG_meanTC_clean", mean);
691
692 double tail = getThreshold(hist_nTC_clean, 0.5);
693 B2DEBUG(1, "ECLTRG_tailTC_clean:" << tail);
694 setEpicsPV("ECLTRG_tailTC_clean", tail);
695 }
696
697 auto hist_nTC_injHER = getDelta("TRG", "h_n_TChit_injHER_clkgrp", 0, true);
698 if (hist_nTC_injHER) {
699 double mean = hist_nTC_injHER->GetMean();
700 B2DEBUG(1, "ECLTRG_meanTC_injHER:" << mean);
701 setEpicsPV("ECLTRG_meanTC_injHER", mean);
702 }
703
704 auto hist_nTC_injLER = getDelta("TRG", "h_n_TChit_injLER_clkgrp", 0, true);
705 if (hist_nTC_injLER) {
706 double mean = hist_nTC_injLER->GetMean();
707 B2DEBUG(1, "ECLTRG_meanTC_injLER:" << mean);
708 setEpicsPV("ECLTRG_meanTC_injLER", mean);
709 }
710
711 auto hist_nTC_FWD_total = getDelta("TRG", "h_n_TChit_FWD_event_clkgrp", 0, true);
712 if (hist_nTC_FWD_total) {
713 double mean = hist_nTC_FWD_total->GetMean();
714 B2DEBUG(1, "ECLTRG_meanTC_FWD_total:" << mean);
715 setEpicsPV("ECLTRG_meanTC_FWD_total", mean);
716 }
717
718 auto hist_nTC_FWD_clean = getDelta("TRG", "h_n_TChit_FWD_clean_clkgrp", 0, true);
719 if (hist_nTC_FWD_clean) {
720 double mean = hist_nTC_FWD_clean->GetMean();
721 B2DEBUG(1, "ECLTRG_meanTC_FWD_clean:" << mean);
722 setEpicsPV("ECLTRG_meanTC_FWD_clean", mean);
723
724 double tail = getThreshold(hist_nTC_FWD_clean, 0.5);
725 B2DEBUG(1, "ECLTRG_tailTC_FWD_clean:" << tail);
726 setEpicsPV("ECLTRG_tailTC_FWD_clean", tail);
727 }
728
729 auto hist_nTC_FWD_injHER = getDelta("TRG", "h_n_TChit_FWD_injHER_clkgrp", 0, true);
730 if (hist_nTC_FWD_injHER) {
731 double mean = hist_nTC_FWD_injHER->GetMean();
732 B2DEBUG(1, "ECLTRG_meanTC_FWD_injHER:" << mean);
733 setEpicsPV("ECLTRG_meanTC_FWD_injHER", mean);
734 }
735
736 auto hist_nTC_FWD_injLER = getDelta("TRG", "h_n_TChit_FWD_injLER_clkgrp", 0, true);
737 if (hist_nTC_FWD_injLER) {
738 double mean = hist_nTC_FWD_injLER->GetMean();
739 B2DEBUG(1, "ECLTRG_meanTC_FWD_injLER:" << mean);
740 setEpicsPV("ECLTRG_meanTC_FWD_injLER", mean);
741 }
742
743 auto hist_nTC_BRL_total = getDelta("TRG", "h_n_TChit_BRL_event_clkgrp", 0, true);
744 if (hist_nTC_BRL_total) {
745 double mean = hist_nTC_BRL_total->GetMean();
746 B2DEBUG(1, "ECLTRG_meanTC_BRL_total:" << mean);
747 setEpicsPV("ECLTRG_meanTC_BRL_total", mean);
748 }
749
750 auto hist_nTC_BRL_clean = getDelta("TRG", "h_n_TChit_BRL_clean_clkgrp", 0, true);
751 if (hist_nTC_BRL_clean) {
752 double mean = hist_nTC_BRL_clean->GetMean();
753 B2DEBUG(1, "ECLTRG_meanTC_BRL_clean:" << mean);
754 setEpicsPV("ECLTRG_meanTC_BRL_clean", mean);
755
756 double tail = getThreshold(hist_nTC_BRL_clean, 0.5);
757 B2DEBUG(1, "ECLTRG_tailTC_BRL_clean:" << tail);
758 setEpicsPV("ECLTRG_tailTC_BRL_clean", tail);
759 }
760
761 auto hist_nTC_BRL_injHER = getDelta("TRG", "h_n_TChit_BRL_injHER_clkgrp", 0, true);
762 if (hist_nTC_BRL_injHER) {
763 double mean = hist_nTC_BRL_injHER->GetMean();
764 B2DEBUG(1, "ECLTRG_meanTC_BRL_injHER:" << mean);
765 setEpicsPV("ECLTRG_meanTC_BRL_injHER", mean);
766 }
767
768 auto hist_nTC_BRL_injLER = getDelta("TRG", "h_n_TChit_BRL_injLER_clkgrp", 0, true);
769 if (hist_nTC_BRL_injLER) {
770 double mean = hist_nTC_BRL_injLER->GetMean();
771 B2DEBUG(1, "ECLTRG_meanTC_BRL_injLER:" << mean);
772 setEpicsPV("ECLTRG_meanTC_BRL_injLER", mean);
773 }
774
775 auto hist_nTC_BWD_total = getDelta("TRG", "h_n_TChit_BWD_event_clkgrp", 0, true);
776 if (hist_nTC_BWD_total) {
777 double mean = hist_nTC_BWD_total->GetMean();
778 B2DEBUG(1, "ECLTRG_meanTC_BWD_total:" << mean);
779 setEpicsPV("ECLTRG_meanTC_BWD_total", mean);
780 }
781
782 auto hist_nTC_BWD_clean = getDelta("TRG", "h_n_TChit_BWD_clean_clkgrp", 0, true);
783 if (hist_nTC_BWD_clean) {
784 double mean = hist_nTC_BWD_clean->GetMean();
785 B2DEBUG(1, "ECLTRG_meanTC_BWD_clean:" << mean);
786 setEpicsPV("ECLTRG_meanTC_BWD_clean", mean);
787
788 double tail = getThreshold(hist_nTC_BWD_clean, 0.5);
789 B2DEBUG(1, "ECLTRG_tailTC_BWD_clean:" << tail);
790 setEpicsPV("ECLTRG_tailTC_BWD_clean", tail);
791 }
792
793 auto hist_nTC_BWD_injHER = getDelta("TRG", "h_n_TChit_BWD_injHER_clkgrp", 0, true);
794 if (hist_nTC_BWD_injHER) {
795 double mean = hist_nTC_BWD_injHER->GetMean();
796 B2DEBUG(1, "ECLTRG_meanTC_BWD_injHER:" << mean);
797 setEpicsPV("ECLTRG_meanTC_BWD_injHER", mean);
798 }
799
800 auto hist_nTC_BWD_injLER = getDelta("TRG", "h_n_TChit_BWD_injLER_clkgrp", 0, true);
801 if (hist_nTC_BWD_injLER) {
802 double mean = hist_nTC_BWD_injLER->GetMean();
803 B2DEBUG(1, "ECLTRG_meanTC_BWD_injLER:" << mean);
804 setEpicsPV("ECLTRG_meanTC_BWD_injLER", mean);
805 }
806
807
808 // Tag canvas as updated ONLY if things have changed.
809 UpdateCanvas(m_canvas->GetName(), hist != nullptr);
810
811 // this if left over from jsroot, may not be needed anymore (to check)
812 m_canvas->Update();
813 }
814
815}
816
818{
819 B2DEBUG(1, "DQMHistAnalysisTRGModule: terminate called");
820}
821
822
823double DQMHistAnalysisTRGModule::getThreshold(const TH1* hist, const double lower_bound, const double widthFraction)
824{
825 if (hist == nullptr) return 0.;
826
827 double movsum = 0;
828 int nbins = hist->GetNbinsX();
829 int width = nbins * widthFraction;
830 int num = 0;
831
832 if (width <= 1) width = 2;
833
834 int meanbin = hist->GetXaxis()->FindBin(hist->GetMean());
835
836 for (int i = meanbin - 1; 1 <= i && i <= meanbin - width; i--) {
837 num++;
838 movsum += hist->GetBinContent(i);
839 }
840
841 for (int i = meanbin; i < nbins; i++) {
842 int binIdx = i + 1;
843
844 if (num < width) {
845 movsum += hist->GetBinContent(binIdx);
846 num++;
847 } else {
848 movsum += hist->GetBinContent(binIdx);
849 movsum -= hist->GetBinContent(binIdx - width);
850 }
851
852 if (movsum / num < lower_bound) {
853 return hist->GetBinCenter(binIdx);
854 }
855 }
856 return hist->GetXaxis()->GetBinCenter(nbins);
857}
The base class for the histogram analysis module.
void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
static const std::string & getRunType(void)
Get the Run Type.
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.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
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.
STL namespace.