10#include <dqm/analysis/modules/DQMHistAnalysisHLTMonObj.h>
13#include <hlt/utilities/Units.h>
16#include <RooFitResult.h>
17#include <RooRealVar.h>
18#include <RooGaussian.h>
20#include <RooArgList.h>
22#include <RooChebychev.h>
23#include <RooMsgService.h>
25#include <RooDataHist.h>
42 setDescription(
"Produces MonitoringObject for the HLT from the available DQM histograms");
57 m_c_filter =
new TCanvas(
"Filter",
"filter", 750, 400);
58 m_c_skim =
new TCanvas(
"Skim",
"skim", 400, 400);
59 m_c_hardware =
new TCanvas(
"Hardware",
"hardware", 1000, 1000);
60 m_c_l1 =
new TCanvas(
"L1",
"l1", 750, 400);
73 m_KsInvMass =
new RooRealVar(
"m_KsInvMass",
"M", 0.45, 0.55);
76 m_mean1 =
new RooRealVar(
"#mu_{1}",
"MEAN of 1st gaussian", 0.498, 0.49, 0.51);
77 m_sigma1 =
new RooRealVar(
"#sigma_{1}",
"Sigma of 1st gaussian", 0.002, 0.0001, 0.05);
80 m_sigma2 =
new RooRealVar(
"#sigma_{2}",
"Sigma of 1st gaussian", 0.02, 0.0001, 0.05);
83 m_frac =
new RooRealVar(
"frac",
"fraction", 0.6, 0.4, 0.8);
87 m_slope =
new RooRealVar(
"s",
"Slope of Polynomial", 0.5, -2.0, 2.0);
91 m_sig =
new RooRealVar(
"N_{sig}",
"SIGNAL EVENTS", 1000, 10, 5000000);
92 m_bkg =
new RooRealVar(
"N_{bkg}",
"SIGNAL EVENTS", 2000, 100, 20000000);
105 TH1* h_hlt =
findHist(
"softwaretrigger/total_result");
106 TH1* h_skim =
findHist(
"softwaretrigger/skim");
107 TH1* h_budget =
findHist(
"timing_statistics/fullTimeHistogram");
108 TH1* h_processing =
findHist(
"timing_statistics/processingTimeHistogram");
109 TH1* h_proc_passive =
findHist(
"timing_statistics/processingTimePassiveVeto");
110 TH1* h_proc_active =
findHist(
"timing_statistics/processingTimeNotPassiveVeto");
111 TH1* h_proc_prefilter_time =
findHist(
"timing_statistics/processingTimeNotPassiveVetoTimingCut");
112 TH1* h_proc_prefilter_cdcecl =
findHist(
"timing_statistics/processingTimeNotPassiveVetoCDCECLCut");
113 TH1* h_meantime =
findHist(
"timing_statistics/meanTimeHistogram");
114 TH1* h_budg_unit =
findHist(
"timing_statistics/fullTimeMeanPerUnitHistogram");
115 TH1* h_proc_unit =
findHist(
"timing_statistics/processingTimeMeanPerUnitHistogram");
116 TH1* h_procs =
findHist(
"timing_statistics/processesPerUnitHistogram");
117 TH1* h_l1 =
findHist(
"softwaretrigger_before_filter/hlt_unit_number");
118 TH1* h_err_flag =
findHist(
"softwaretrigger_before_filter/error_flag");
119 TH1* h_hlt_triggers =
findHist(
"softwaretrigger/filter");
120 TH1* h_l1_triggers =
findHist(
"TRGGDL/hGDL_psn_all");
121 TH1* h_l1_triggers_filt =
findHist(
"softwaretrigger/l1_total_result");
122 TH1* h_l1_cat_w_overlap =
findHist(
"TRGGDL/hGDL_psn_raw_rate_all");
123 TH1* h_l1_cat_wo_overlap =
findHist(
"TRGGDL/hGDL_psn_effect_to_l1_all");
124 TH1* h_full_mem =
findHist(
"timing_statistics/fullMemoryHistogram");
125 TCanvas* c_GDL_ana_eff_shifter =
findCanvas(
"TRGGDL/hGDL_ana_eff_shifter");
126 TH1* h_GDL_ana_eff_shifter =
nullptr;
128 if (c_GDL_ana_eff_shifter) {
129 c_GDL_ana_eff_shifter->cd();
130 h_GDL_ana_eff_shifter =
dynamic_cast<TH1*
>(gPad->GetPrimitive(
"hGDL_ana_eff_shifter"));
137 if (h_hlt) h_hlt->Draw();
139 if (h_hlt_triggers) h_hlt_triggers->Draw();
141 if (h_err_flag) h_err_flag->Draw();
146 if (h_skim) h_skim->Draw();
152 if (h_l1) h_l1->Draw();
154 if (h_budget) h_budget->Draw();
156 if (h_processing) h_processing->Draw();
158 if (h_budg_unit) h_budg_unit->Draw();
160 if (h_proc_unit) h_proc_unit->Draw();
162 if (h_meantime) h_meantime->Draw();
164 if (h_procs) h_procs->Draw();
166 if (h_full_mem) h_full_mem->Draw();
172 if (h_l1_triggers) h_l1_triggers->Draw();
174 if (h_l1_triggers_filt) h_l1_triggers_filt->Draw();
176 if (h_l1_cat_w_overlap) h_l1_cat_w_overlap->Draw();
178 if (h_l1_cat_wo_overlap) h_l1_cat_wo_overlap->Draw();
183 if (h_GDL_ana_eff_shifter) h_GDL_ana_eff_shifter->Draw();
186 if (h_hlt) n_hlt = (double)h_hlt->GetBinContent((h_hlt->GetXaxis())->FindFixBin(
"total_result"));
189 if (h_l1) n_l1 = h_l1->GetEntries();
192 if (h_procs) n_procs = h_procs->GetEntries();
197 for (
int ibin = 1; ibin < h_skim->GetXaxis()->GetNbins() + 1; ibin++) {
198 double nentr = (double)h_skim->GetBinContent(ibin);
199 std::string bin_name(h_skim->GetXaxis()->GetBinLabel(ibin));
206 for (
int ibin = 1; ibin < h_l1_triggers->GetXaxis()->GetNbins() + 1; ibin++) {
207 double nentr = (double)h_l1_triggers->GetBinContent(ibin);
208 std::string bin_name(h_l1_triggers->GetXaxis()->GetBinLabel(ibin));
209 if (bin_name ==
"")
continue;
214 if (h_l1_triggers_filt) {
216 for (
int ibin = 1; ibin < h_l1_triggers_filt->GetXaxis()->GetNbins() + 1; ibin++) {
217 double nentr = (double)h_l1_triggers_filt->GetBinContent(ibin);
218 std::string bin_name(h_l1_triggers_filt->GetXaxis()->GetBinLabel(ibin));
219 if (bin_name ==
"")
continue;
224 if (h_hlt_triggers) {
226 for (
int ibin = 1; ibin < h_hlt_triggers->GetXaxis()->GetNbins() + 1; ibin++) {
227 double nentr = (double)h_hlt_triggers->GetBinContent(ibin);
228 std::string bin_name(h_hlt_triggers->GetXaxis()->GetBinLabel(ibin));
229 bin_name = std::regex_replace(bin_name, std::regex(
"=="),
"_eq_");
230 bin_name = std::regex_replace(bin_name, std::regex(
"\\."),
"_");
237 for (
int ibin = 1; ibin < h_meantime->GetXaxis()->GetNbins() + 1; ibin++) {
238 double nentr = (double)h_meantime->GetBinContent(ibin);
239 std::string bin_name(h_meantime->GetXaxis()->GetBinLabel(ibin));
246 for (
int ibin = 1; ibin < h_err_flag->GetXaxis()->GetNbins() + 1; ibin++) {
247 double nentr = (double)h_err_flag->GetBinContent(ibin);
248 std::string bin_name(h_err_flag->GetXaxis()->GetBinLabel(ibin));
253 if (h_l1_cat_w_overlap) {
255 for (
int ibin = 1; ibin < h_l1_cat_w_overlap->GetXaxis()->GetNbins() + 1; ibin++) {
256 double nentr = (double)h_l1_cat_w_overlap->GetBinContent(ibin);
257 std::string bin_name(h_l1_cat_w_overlap->GetXaxis()->GetBinLabel(ibin));
262 if (h_l1_cat_wo_overlap) {
264 for (
int ibin = 1; ibin < h_l1_cat_wo_overlap->GetXaxis()->GetNbins() + 1; ibin++) {
265 double nentr = (double)h_l1_cat_wo_overlap->GetBinContent(ibin);
266 std::string bin_name(h_l1_cat_wo_overlap->GetXaxis()->GetBinLabel(ibin));
271 if (h_GDL_ana_eff_shifter) {
273 for (
int ibin = 1; ibin < h_GDL_ana_eff_shifter->GetXaxis()->GetNbins() + 1; ibin++) {
274 double nentr = (double)h_GDL_ana_eff_shifter->GetBinContent(ibin);
275 std::string bin_name(h_GDL_ana_eff_shifter->GetXaxis()->GetBinLabel(ibin));
281 if (h_budget) bgt = h_budget->GetMean();
286 double procTime = 0.;
287 if (h_processing) procTime = h_processing->GetMean();
290 double procTimePassive = 0.;
291 if (h_proc_passive) procTimePassive = h_proc_passive->GetMean();
294 double procTimeActive = 0.;
295 if (h_proc_active) procTimeActive = h_proc_active->GetMean();
298 double procTimePrefilterTiming = 0.;
299 if (h_proc_prefilter_time) procTimePrefilterTiming = h_proc_prefilter_time->GetMean();
302 double procTimePrefilterCDCECL = 0.;
303 if (h_proc_prefilter_cdcecl) procTimePrefilterCDCECL = h_proc_prefilter_cdcecl->GetMean();
306 double nEventsPassive = 0.;
307 if (h_proc_passive) nEventsPassive = h_proc_passive->GetEntries();
310 double nEventsActive = 0.;
311 if (h_proc_active) nEventsActive = h_proc_active->GetEntries();
314 double nEventsPrefilterTiming = 0.;
315 if (h_proc_prefilter_time) nEventsPrefilterTiming = h_proc_prefilter_time->GetEntries();
318 double nEventsPrefilterCDCECL = 0.;
319 if (h_proc_prefilter_cdcecl) nEventsPrefilterCDCECL = h_proc_prefilter_cdcecl->GetEntries();
323 double fullMemory = 0.;
324 if (h_full_mem) fullMemory = h_full_mem->GetBinLowEdge(h_full_mem->FindLastBinAbove(0) + 1);
327 TH1* h_budgetUnit =
nullptr;
328 TH1* h_memoryUnit =
nullptr;
330 for (
unsigned int index = 1; index <= HLTUnits::max_hlt_units; index++) {
332 h_budgetUnit =
findHist((
"timing_statistics/fullTimePerUnitHistogram_HLT" + std::to_string(index)).c_str());
334 if (h_budgetUnit) bgunit = h_budgetUnit->GetMean();
337 h_budgetUnit =
findHist((
"timing_statistics/processingTimePerUnitHistogram_HLT" + std::to_string(index)).c_str());
338 if (h_budgetUnit) bgunit = h_budgetUnit->GetMean();
342 h_memoryUnit =
findHist((
"timing_statistics/fullMemoryPerUnitHistogram_HLT" + std::to_string(index)).c_str());
344 if (h_memoryUnit && bgunit > 0) memunit = h_memoryUnit->GetBinLowEdge(h_memoryUnit->FindLastBinAbove(0.) + 1);
351 RooMsgService::instance().setSilentMode(
true);
352 RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
355 double nKs_active = 0;
356 double nKs_activeNotTime = 0;
357 double nKs_activeNotCDCECL = 0;
359 auto m_hKshortAllH =
findHist(
"PhysicsObjects/hist_nKshortAllH");
360 auto m_hKshortActiveH =
findHist(
"PhysicsObjects/hist_nKshortActiveH");
361 auto m_hKshortActiveNotTimeH =
findHist(
"PhysicsObjects/hist_nKshortActiveNotTimeH");
362 auto m_hKshortActiveNotCDCECLH =
findHist(
"PhysicsObjects/hist_nKshortActiveNotCDCECLH");
365 RooDataHist* KsHist_all =
new RooDataHist(
"KsHist_all",
"Histogram data", RooArgList(*
m_KsInvMass), m_hKshortAllH);
366 m_KsPdf->fitTo(*KsHist_all, RooFit::Minos(
true));
367 nKs_all =
m_sig->getValV();
372 if (m_hKshortActiveH) {
373 RooDataHist* KsHist_active =
new RooDataHist(
"KsHist_active",
"Histogram data", RooArgList(*
m_KsInvMass), m_hKshortActiveH);
374 m_KsPdf->fitTo(*KsHist_active, RooFit::Minos(
true));
375 nKs_active =
m_sig->getValV();
376 delete KsHist_active;
380 if (m_hKshortActiveNotTimeH) {
381 RooDataHist* KsHist_activeNotTime =
new RooDataHist(
"KsHist_activeNotTime",
"Histogram data", RooArgList(*
m_KsInvMass),
382 m_hKshortActiveNotTimeH);
383 m_KsPdf->fitTo(*KsHist_activeNotTime, RooFit::Minos(
true));
384 nKs_activeNotTime =
m_sig->getValV();
385 delete KsHist_activeNotTime;
389 if (m_hKshortActiveNotCDCECLH) {
390 RooDataHist* KsHist_activeNotCDCECL =
new RooDataHist(
"KsHist_activeNotCDCECL",
"Histogram data", RooArgList(*
m_KsInvMass),
391 m_hKshortActiveNotCDCECLH);
392 m_KsPdf->fitTo(*KsHist_activeNotCDCECL, RooFit::Minos(
true));
393 nKs_activeNotCDCECL =
m_sig->getValV();
394 delete KsHist_activeNotCDCECL;
400 B2DEBUG(20,
"DQMHistAnalysisHLTMonObj : endRun called");
419 B2DEBUG(20,
"terminate called");
RooRealVar * m_bkg
Number of background from fit.
TCanvas * m_c_ana_eff_shifter
Canvas with histogram related to ana_eff_shifter.
TCanvas * m_c_skim
Canvas with histograms related to HLT skims.
RooRealVar * m_frac
*Fraction of first gaussian in double gaussian
RooRealVar * m_mean2
Mean of first gaussian.
void initialize() override final
Initialize the Module.
RooRealVar * m_sigma1
*Sigma of second gaussian
RooRealVar * m_KsInvMass
Invariant mass of KS for HLTPrefilter monitoring.
TCanvas * m_c_l1
Canvas with histograms related to L1.
RooChebychev * m_chebpol
First order polynomial.
DQMHistAnalysisHLTMonObjModule()
Constructor.
RooRealVar * m_sig
Number of Ks events from fit.
RooRealVar * m_mean1
*Mean of first gaussian
MonitoringObject * m_monObj
MonitoringObject to be produced by this module.
void terminate() override final
Termination action.
RooRealVar * m_slope
Slope for first order polynomial.
TCanvas * m_c_filter
Canvas with histograms related to HLT filter.
RooGaussian * m_gauss2
Second gaussian.
void endRun() override final
End-of-run action.
RooAddPdf * m_KsPdf
Fit PDF for Ks invariant mass.
RooRealVar * m_sigma2
*Sigma of second gaussian
RooAddPdf * m_double_gauss
Sum of two gaussian.
~DQMHistAnalysisHLTMonObjModule()
Destructor.
TCanvas * m_c_hardware
Canvas with histograms related to HLT hardware.
RooGaussian * m_gauss1
First gaussian.
The base class for the histogram analysis module.
TCanvas * findCanvas(TString cname)
Find canvas by name.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
void addCanvas(TCanvas *canv)
Add Canvas to monitoring object.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.