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>
43 setDescription(
"Produces MonitoringObject for the HLT from the available DQM histograms");
58 m_c_filter =
new TCanvas(
"Filter",
"filter", 750, 400);
59 m_c_skim =
new TCanvas(
"Skim",
"skim", 400, 400);
60 m_c_hardware =
new TCanvas(
"Hardware",
"hardware", 1000, 1000);
61 m_c_l1 =
new TCanvas(
"L1",
"l1", 750, 400);
63 m_c_nks =
new TCanvas(
"Ks",
"Ks_histograms", 1000, 1000);
76 m_KsInvMass =
new RooRealVar(
"m_KsInvMass",
"M", 0.45, 0.55);
79 m_mean1 =
new RooRealVar(
"#mu_{1}",
"MEAN of 1st gaussian", 0.498, 0.49, 0.51);
80 m_sigma1 =
new RooRealVar(
"#sigma_{1}",
"Sigma of 1st gaussian", 0.002, 0.0001, 0.05);
83 m_sigma2 =
new RooRealVar(
"#sigma_{2}",
"Sigma of 1st gaussian", 0.02, 0.0001, 0.05);
86 m_frac =
new RooRealVar(
"frac",
"fraction", 0.6, 0.4, 0.8);
90 m_slope =
new RooRealVar(
"s",
"Slope of Polynomial", 0.5, -2.0, 2.0);
94 m_sig =
new RooRealVar(
"N_{sig}",
"SIGNAL EVENTS", 1000, 10, 5000000);
95 m_bkg =
new RooRealVar(
"N_{bkg}",
"BACKGROUND EVENTS", 2000, 100, 20000000);
108 TH1* h_hlt =
findHist(
"softwaretrigger/total_result");
109 TH1* h_skim =
findHist(
"softwaretrigger/skim");
110 TH1* h_budget =
findHist(
"timing_statistics/fullTimeHistogram");
111 TH1* h_processing =
findHist(
"timing_statistics/processingTimeHistogram");
112 TH1* h_proc_passive =
findHist(
"timing_statistics/processingTimePassiveVeto");
113 TH1* h_proc_active =
findHist(
"timing_statistics/processingTimeNotPassiveVeto");
114 TH1* h_proc_prefilter_time =
findHist(
"timing_statistics/processingTimeNotPassiveVetoTimingCut");
115 TH1* h_proc_prefilter_cdcecl =
findHist(
"timing_statistics/processingTimeNotPassiveVetoCDCECLCut");
116 TH1* h_meantime =
findHist(
"timing_statistics/meanTimeHistogram");
117 TH1* h_budg_unit =
findHist(
"timing_statistics/fullTimeMeanPerUnitHistogram");
118 TH1* h_proc_unit =
findHist(
"timing_statistics/processingTimeMeanPerUnitHistogram");
119 TH1* h_procs =
findHist(
"timing_statistics/processesPerUnitHistogram");
120 TH1* h_l1 =
findHist(
"softwaretrigger_before_filter/hlt_unit_number");
121 TH1* h_err_flag =
findHist(
"softwaretrigger_before_filter/error_flag");
122 TH1* h_hlt_triggers =
findHist(
"softwaretrigger/filter");
123 TH1* h_l1_triggers =
findHist(
"TRGGDL/hGDL_psn_all");
124 TH1* h_l1_triggers_filt =
findHist(
"softwaretrigger/l1_total_result");
125 TH1* h_l1_cat_w_overlap =
findHist(
"TRGGDL/hGDL_psn_raw_rate_all");
126 TH1* h_l1_cat_wo_overlap =
findHist(
"TRGGDL/hGDL_psn_effect_to_l1_all");
127 TH1* h_full_mem =
findHist(
"timing_statistics/fullMemoryHistogram");
128 TCanvas* c_GDL_ana_eff_shifter =
findCanvas(
"TRGGDL/hGDL_ana_eff_shifter");
129 TH1* h_GDL_ana_eff_shifter =
nullptr;
131 if (c_GDL_ana_eff_shifter) {
132 c_GDL_ana_eff_shifter->cd();
133 h_GDL_ana_eff_shifter =
dynamic_cast<TH1*
>(gPad->GetPrimitive(
"hGDL_ana_eff_shifter"));
140 if (h_hlt) h_hlt->Draw();
142 if (h_hlt_triggers) h_hlt_triggers->Draw();
144 if (h_err_flag) h_err_flag->Draw();
149 if (h_skim) h_skim->Draw();
155 if (h_l1) h_l1->Draw();
157 if (h_budget) h_budget->Draw();
159 if (h_processing) h_processing->Draw();
161 if (h_budg_unit) h_budg_unit->Draw();
163 if (h_proc_unit) h_proc_unit->Draw();
165 if (h_meantime) h_meantime->Draw();
167 if (h_procs) h_procs->Draw();
169 if (h_full_mem) h_full_mem->Draw();
175 if (h_l1_triggers) h_l1_triggers->Draw();
177 if (h_l1_triggers_filt) h_l1_triggers_filt->Draw();
179 if (h_l1_cat_w_overlap) h_l1_cat_w_overlap->Draw();
181 if (h_l1_cat_wo_overlap) h_l1_cat_wo_overlap->Draw();
186 if (h_GDL_ana_eff_shifter) h_GDL_ana_eff_shifter->Draw();
189 if (h_hlt) n_hlt = (double)h_hlt->GetBinContent((h_hlt->GetXaxis())->FindFixBin(
"total_result"));
192 if (h_l1) n_l1 = h_l1->GetEntries();
195 if (h_procs) n_procs = h_procs->GetEntries();
200 for (
int ibin = 1; ibin < h_skim->GetXaxis()->GetNbins() + 1; ibin++) {
201 double nentr = (double)h_skim->GetBinContent(ibin);
202 std::string bin_name(h_skim->GetXaxis()->GetBinLabel(ibin));
209 for (
int ibin = 1; ibin < h_l1_triggers->GetXaxis()->GetNbins() + 1; ibin++) {
210 double nentr = (double)h_l1_triggers->GetBinContent(ibin);
211 std::string bin_name(h_l1_triggers->GetXaxis()->GetBinLabel(ibin));
212 if (bin_name ==
"")
continue;
217 if (h_l1_triggers_filt) {
219 for (
int ibin = 1; ibin < h_l1_triggers_filt->GetXaxis()->GetNbins() + 1; ibin++) {
220 double nentr = (double)h_l1_triggers_filt->GetBinContent(ibin);
221 std::string bin_name(h_l1_triggers_filt->GetXaxis()->GetBinLabel(ibin));
222 if (bin_name ==
"")
continue;
227 if (h_hlt_triggers) {
229 for (
int ibin = 1; ibin < h_hlt_triggers->GetXaxis()->GetNbins() + 1; ibin++) {
230 double nentr = (double)h_hlt_triggers->GetBinContent(ibin);
231 std::string bin_name(h_hlt_triggers->GetXaxis()->GetBinLabel(ibin));
232 bin_name = std::regex_replace(bin_name, std::regex(
"=="),
"_eq_");
233 bin_name = std::regex_replace(bin_name, std::regex(
"\\."),
"_");
240 for (
int ibin = 1; ibin < h_meantime->GetXaxis()->GetNbins() + 1; ibin++) {
241 double nentr = (double)h_meantime->GetBinContent(ibin);
242 std::string bin_name(h_meantime->GetXaxis()->GetBinLabel(ibin));
249 for (
int ibin = 1; ibin < h_err_flag->GetXaxis()->GetNbins() + 1; ibin++) {
250 double nentr = (double)h_err_flag->GetBinContent(ibin);
251 std::string bin_name(h_err_flag->GetXaxis()->GetBinLabel(ibin));
256 if (h_l1_cat_w_overlap) {
258 for (
int ibin = 1; ibin < h_l1_cat_w_overlap->GetXaxis()->GetNbins() + 1; ibin++) {
259 double nentr = (double)h_l1_cat_w_overlap->GetBinContent(ibin);
260 std::string bin_name(h_l1_cat_w_overlap->GetXaxis()->GetBinLabel(ibin));
265 if (h_l1_cat_wo_overlap) {
267 for (
int ibin = 1; ibin < h_l1_cat_wo_overlap->GetXaxis()->GetNbins() + 1; ibin++) {
268 double nentr = (double)h_l1_cat_wo_overlap->GetBinContent(ibin);
269 std::string bin_name(h_l1_cat_wo_overlap->GetXaxis()->GetBinLabel(ibin));
274 if (h_GDL_ana_eff_shifter) {
276 for (
int ibin = 1; ibin < h_GDL_ana_eff_shifter->GetXaxis()->GetNbins() + 1; ibin++) {
277 double nentr = (double)h_GDL_ana_eff_shifter->GetBinContent(ibin);
278 std::string bin_name(h_GDL_ana_eff_shifter->GetXaxis()->GetBinLabel(ibin));
284 if (h_budget) bgt = h_budget->GetMean();
289 double procTime = 0.;
290 if (h_processing) procTime = h_processing->GetMean();
293 double procTimePassive = 0.;
294 if (h_proc_passive) procTimePassive = h_proc_passive->GetMean();
297 double procTimeActive = 0.;
298 if (h_proc_active) procTimeActive = h_proc_active->GetMean();
301 double procTimePrefilterTiming = 0.;
302 if (h_proc_prefilter_time) procTimePrefilterTiming = h_proc_prefilter_time->GetMean();
305 double procTimePrefilterCDCECL = 0.;
306 if (h_proc_prefilter_cdcecl) procTimePrefilterCDCECL = h_proc_prefilter_cdcecl->GetMean();
309 double nEventsPassive = 0.;
310 if (h_proc_passive) nEventsPassive = h_proc_passive->GetEntries();
313 double nEventsActive = 0.;
314 if (h_proc_active) nEventsActive = h_proc_active->GetEntries();
317 double nEventsPrefilterTiming = 0.;
318 if (h_proc_prefilter_time) nEventsPrefilterTiming = h_proc_prefilter_time->GetEntries();
321 double nEventsPrefilterCDCECL = 0.;
322 if (h_proc_prefilter_cdcecl) nEventsPrefilterCDCECL = h_proc_prefilter_cdcecl->GetEntries();
326 double fullMemory = 0.;
327 if (h_full_mem) fullMemory = h_full_mem->GetBinLowEdge(h_full_mem->FindLastBinAbove(0) + 1);
330 TH1* h_budgetUnit =
nullptr;
331 TH1* h_memoryUnit =
nullptr;
333 for (
unsigned int index = 1; index <= HLTUnits::max_hlt_units; index++) {
335 h_budgetUnit =
findHist((
"timing_statistics/fullTimePerUnitHistogram_HLT" + std::to_string(index)).c_str());
337 if (h_budgetUnit) bgunit = h_budgetUnit->GetMean();
340 h_budgetUnit =
findHist((
"timing_statistics/processingTimePerUnitHistogram_HLT" + std::to_string(index)).c_str());
341 if (h_budgetUnit) bgunit = h_budgetUnit->GetMean();
345 h_memoryUnit =
findHist((
"timing_statistics/fullMemoryPerUnitHistogram_HLT" + std::to_string(index)).c_str());
347 if (h_memoryUnit && bgunit > 0) memunit = h_memoryUnit->GetBinLowEdge(h_memoryUnit->FindLastBinAbove(0.) + 1);
354 RooMsgService::instance().setSilentMode(
true);
355 RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
358 double nKs_uncertainty_all = 0;
359 double nKs_active = 0;
360 double nKs_activeNotTime = 0;
361 double nKs_activeNotCDCECL = 0;
363 auto m_hKshortAllH =
findHist(
"PhysicsObjects/hist_nKshortAllH");
364 auto m_hKshortActiveH =
findHist(
"PhysicsObjects/hist_nKshortActiveH");
365 auto m_hKshortActiveNotTimeH =
findHist(
"PhysicsObjects/hist_nKshortActiveNotTimeH");
366 auto m_hKshortActiveNotCDCECLH =
findHist(
"PhysicsObjects/hist_nKshortActiveNotCDCECLH");
370 RooPlot* m_KshortAll_frame =
372 m_KshortAll_frame->GetXaxis()->SetTitle(
"M_{#pi^{+}#pi^{-}} [GeV/c^{2}]");
373 m_KshortAll_frame->GetYaxis()->SetTitle(
"Candidates / (2 MeV/c^{2})");
375 RooPlot* m_KshortActive_frame =
377 m_KshortActive_frame->GetXaxis()->SetTitle(
"M_{#pi^{+}#pi^{-}} [GeV/c^{2}]");
378 m_KshortActive_frame->GetYaxis()->SetTitle(
"Candidates / (2 MeV/c^{2})");
380 RooPlot* m_KshortActiveNotTime_frame =
381 m_KsInvMass->frame(RooFit::Title(
"Active veto (Prefilter Time)"));
382 m_KshortActiveNotTime_frame->GetXaxis()->SetTitle(
"M_{#pi^{+}#pi^{-}} [GeV/c^{2}]");
383 m_KshortActiveNotTime_frame->GetYaxis()->SetTitle(
"Candidates / (2 MeV/c^{2})");
385 RooPlot* m_KshortActiveNotCDCECL_frame =
386 m_KsInvMass->frame(RooFit::Title(
"Active veto (Prefilter CDC+ECL)"));
387 m_KshortActiveNotCDCECL_frame->GetXaxis()->SetTitle(
"M_{#pi^{+}#pi^{-}} [GeV/c^{2}]");
388 m_KshortActiveNotCDCECL_frame->GetYaxis()->SetTitle(
"Candidates / (2 MeV/c^{2})");
391 RooDataHist* KsHist_all =
new RooDataHist(
"KsHist_all",
"Histogram data", RooArgList(*
m_KsInvMass), m_hKshortAllH);
392 m_KsPdf->fitTo(*KsHist_all, RooFit::Minos(
true));
393 nKs_all =
m_sig->getValV();
394 nKs_uncertainty_all =
m_sig->getError();
395 KsHist_all->plotOn(m_KshortAll_frame) ;
396 m_KsPdf->plotOn(m_KshortAll_frame);
397 m_KsPdf->paramOn(m_KshortAll_frame, RooFit::Layout(0.6, 0.9, 0.9));
403 if (m_hKshortActiveH) {
404 RooDataHist* KsHist_active =
new RooDataHist(
"KsHist_active",
"Histogram data", RooArgList(*
m_KsInvMass), m_hKshortActiveH);
405 m_KsPdf->fitTo(*KsHist_active, RooFit::Minos(
true));
406 nKs_active =
m_sig->getValV();
407 KsHist_active->plotOn(m_KshortActive_frame) ;
408 m_KsPdf->plotOn(m_KshortActive_frame);
409 m_KsPdf->paramOn(m_KshortActive_frame, RooFit::Layout(0.6, 0.9, 0.9));
410 delete KsHist_active;
414 if (m_hKshortActiveNotTimeH) {
415 RooDataHist* KsHist_activeNotTime =
new RooDataHist(
"KsHist_activeNotTime",
"Histogram data", RooArgList(*
m_KsInvMass),
416 m_hKshortActiveNotTimeH);
417 m_KsPdf->fitTo(*KsHist_activeNotTime, RooFit::Minos(
true));
418 nKs_activeNotTime =
m_sig->getValV();
419 KsHist_activeNotTime->plotOn(m_KshortActiveNotTime_frame) ;
420 m_KsPdf->plotOn(m_KshortActiveNotTime_frame);
421 m_KsPdf->paramOn(m_KshortActiveNotTime_frame, RooFit::Layout(0.6, 0.9, 0.9));
422 delete KsHist_activeNotTime;
426 if (m_hKshortActiveNotCDCECLH) {
427 RooDataHist* KsHist_activeNotCDCECL =
new RooDataHist(
"KsHist_activeNotCDCECL",
"Histogram data", RooArgList(*
m_KsInvMass),
428 m_hKshortActiveNotCDCECLH);
429 m_KsPdf->fitTo(*KsHist_activeNotCDCECL, RooFit::Minos(
true));
430 nKs_activeNotCDCECL =
m_sig->getValV();
431 KsHist_activeNotCDCECL->plotOn(m_KshortActiveNotCDCECL_frame) ;
432 m_KsPdf->plotOn(m_KshortActiveNotCDCECL_frame);
433 m_KsPdf->paramOn(m_KshortActiveNotCDCECL_frame, RooFit::Layout(0.6, 0.9, 0.9));
434 delete KsHist_activeNotCDCECL;
444 m_KshortAll_frame->Draw();
446 m_KshortActive_frame->Draw();
448 m_KshortActiveNotTime_frame->Draw();
450 m_KshortActiveNotCDCECL_frame->Draw();
452 B2DEBUG(20,
"DQMHistAnalysisHLTMonObj : endRun called");
471 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.
TCanvas * m_c_nks
Canvas to plot Ks histograms.
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.