14 #include <dqm/analysis/modules/DQMHistAnalysisEventT0.h>
17 #include <TGraphAsymmErrors.h>
34 DQMHistAnalysisEventT0Module::DQMHistAnalysisEventT0Module()
37 setDescription(
"Determining and processing EventT0s from different subdetector (TOP and SVD for now) for different L1 trigger sources (ECL and CDC for now) to estimate trigger jitter information.");
41 addParam(
"prefixCanvas",
m_prefixCanvas,
"Prefix to be added to canvas filename when saved as pdf.", std::string(
"c"));
53 m_cTOPTimeForECLTRG =
new TCanvas(
"EventT0/c_TOPTimeECLTRGjitter",
"ECLTRG jitter based on TOP time", 1200, 400);
54 m_topPad1ECLTRG =
new TPad(
"topPad1ECLTRG",
"TOP pad1 ECLTRG", 0.03, 0.02, 0.33, 0.98);
55 m_topPad2ECLTRG =
new TPad(
"topPad2ECLTRG",
"TOP pad2 ECLTRG", 0.35, 0.02, 0.65, 0.98);
56 m_topPad3ECLTRG =
new TPad(
"topPad3ECLTRG",
"TOP pad3 ECLTRG", 0.67, 0.02, 0.97, 0.98);
59 m_cTOPTimeForCDCTRG =
new TCanvas(
"EventT0/c_TOPTimeCDCTRGjitter",
"CDCTRG jitter based on TOP time", 1200, 400);
60 m_topPad1CDCTRG =
new TPad(
"topPad1CDCTRG",
"TOP pad1 CDCTRG", 0.03, 0.02, 0.33, 0.98);
61 m_topPad2CDCTRG =
new TPad(
"topPad2CDCTRG",
"TOP pad2 CDCTRG", 0.35, 0.02, 0.65, 0.98);
62 m_topPad3CDCTRG =
new TPad(
"topPad3CDCTRG",
"TOP pad3 CDCTRG", 0.67, 0.02, 0.97, 0.98);
66 m_cSVDTimeForECLTRG =
new TCanvas(
"EventT0/c_SVDTimeECLTRGjitter",
"ECLTRG jitter based on SVD time", 1200, 400);
67 m_svdPad1ECLTRG =
new TPad(
"svdPad1ECLTRG",
"SVD pad1 ECLTRG", 0.03, 0.02, 0.33, 0.98);
68 m_svdPad2ECLTRG =
new TPad(
"svdPad2ECLTRG",
"SVD pad2 ECLTRG", 0.35, 0.02, 0.65, 0.98);
69 m_svdPad3ECLTRG =
new TPad(
"svdPad3ECLTRG",
"SVD pad3 ECLTRG", 0.67, 0.02, 0.97, 0.98);
72 m_cSVDTimeForCDCTRG =
new TCanvas(
"EventT0/c_SVDTimeCDCTRGjitter",
"CDCTRG jitter based on SVD time", 1200, 400);
73 m_svdPad1CDCTRG =
new TPad(
"svdPad1CDCTRG",
"SVD pad1 CDCTRG", 0.03, 0.02, 0.33, 0.98);
74 m_svdPad2CDCTRG =
new TPad(
"svdPad2CDCTRG",
"SVD pad2 CDCTRG", 0.35, 0.02, 0.65, 0.98);
75 m_svdPad3CDCTRG =
new TPad(
"svdPad3CDCTRG",
"SVD pad3 CDCTRG", 0.67, 0.02, 0.97, 0.98);
78 m_cT0FractionsForHadrons =
new TCanvas(
"EventT0/c_T0FractionsForHadrons",
"EventT0 source fractions for hadron events", 1200, 400);
79 m_pHadronECLTRG =
new TPad(
"pHadronECLTRG",
"Fractions ECLTRG", 0.03, 0.02, 0.33, 0.98);
80 m_pHadronCDCTRG =
new TPad(
"pHadronCDCTRG",
"Fractions CDCTRG", 0.35, 0.02, 0.65, 0.98);
81 m_pHadronTOPTRG =
new TPad(
"pHadronTOPTRG",
"Fractions TOPTRG", 0.67, 0.02, 0.97, 0.98);
83 m_cT0FractionsForBhaBhas =
new TCanvas(
"EventT0/c_cT0FractionsForBhaBhas",
"EventT0 source fractions for bhabha events", 1200, 400);
84 m_pBhaBhaECLTRG =
new TPad(
"pBhaBhaECLTRG",
"Fractions ECLTRG", 0.03, 0.02, 0.33, 0.98);
85 m_pBhaBhaCDCTRG =
new TPad(
"pBhaBhaCDCTRG",
"Fractions CDCTRG", 0.35, 0.02, 0.65, 0.98);
86 m_pBhaBhaTOPTRG =
new TPad(
"pBhaBhaTOPTRG",
"Fractions TOPTRG", 0.67, 0.02, 0.97, 0.98);
88 m_cT0FractionsForMuMus =
new TCanvas(
"EventT0/c_cT0FractionsForMuMus",
"EventT0 source fractions for #mu#mu events", 1200, 400);
89 m_pMuMuECLTRG =
new TPad(
"pMuMuECLTRG",
"Fractions ECLTRG", 0.03, 0.02, 0.33, 0.98);
90 m_pMuMuCDCTRG =
new TPad(
"pMuMuCDCTRG",
"Fractions CDCTRG", 0.35, 0.02, 0.65, 0.98);
91 m_pMuMuTOPTRG =
new TPad(
"pMuMuTOPTRG",
"Fractions TOPTRG", 0.67, 0.02, 0.97, 0.98);
94 new TEfficiency(
"effAlgorithmSourceFractionsHadronL1ECLTRG",
95 "EventT0 source fractions, hadronic events, L1ECLTRG;Algorithm;Fraction #epsilon",
98 new TEfficiency(
"effAlgorithmSourceFractionsHadronL1CDCTRG",
99 "EventT0 source fractions, hadronic events, L1CDCTRG;Algorithm;Fraction #epsilon",
102 new TEfficiency(
"effAlgorithmSourceFractionsHadronL1TOPTRG",
103 "EventT0 source fractions, hadronic events, L1TOPTRG;Algorithm;Fraction #epsilon",
106 new TEfficiency(
"effAlgorithmSourceFractionsBhaBhaL1ECLTRG",
107 "EventT0 source fractions, Bhabha events, L1ECLTRG;Algorithm;Fraction #epsilon",
110 new TEfficiency(
"effAlgorithmSourceFractionsBhaBhaL1CDCTRG",
111 "EventT0 source fractions, Bhabha events, L1CDCTRG;Algorithm;Fraction #epsilon",
114 new TEfficiency(
"effAlgorithmSourceFractionsBhaBhaL1TOPTRG",
115 "EventT0 source fractions, Bhabha events, L1TOPTRG;Algorithm;Fraction #epsilon",
118 new TEfficiency(
"effAlgorithmSourceFractionsMuMuL1ECLTRG",
119 "EventT0 source fractions, #mu#mu events, L1ECLTRG;Algorithm;Fraction #epsilon",
122 new TEfficiency(
"effAlgorithmSourceFractionsMuMuL1CDCTRG",
123 "EventT0 source fractions, #mu#mu events, L1CDCTRG;Algorithm;Fraction #epsilon",
126 new TEfficiency(
"effAlgorithmSourceFractionsMuMuL1TOPTRG",
127 "EventT0 source fractions, #mu#mu events, L1TOPTRG;Algorithm;Fraction #epsilon",
152 std::string histname =
"AlgorithmSourceFractionsHadronL1ECLTRG";
159 B2WARNING(
"Histogram EventT0 source fractions for hadrons from ECLTRG events (" << histname <<
") from EventT0 DQM not processed!");
163 histname =
"AlgorithmSourceFractionsHadronL1CDCTRG";
170 B2WARNING(
"Histogram EventT0 source fractions for hadrons from CDCTRG events (" << histname <<
") from EventT0 DQM not processed!");
174 histname =
"AlgorithmSourceFractionsHadronL1TOPTRG";
181 B2WARNING(
"Histogram EventT0 source fractions for hadrons from TOPTRG events (" << histname <<
") from EventT0 DQM not processed!");
186 const auto drawPad = [](TPad * pad) {
187 pad->SetMargin(0.07, 0.0, 0.07, 0.07);
199 histname =
"AlgorithmSourceFractionsBhaBhaL1ECLTRG";
206 B2WARNING(
"Histogram EventT0 source fractions for BhaBha from ECLTRG events (" << histname <<
") from EventT0 DQM not processed!");
210 histname =
"AlgorithmSourceFractionsBhaBhaL1CDCTRG";
217 B2WARNING(
"Histogram EventT0 source fractions for BhaBha from CDCTRG events (" << histname <<
") from EventT0 DQM not processed!");
221 histname =
"AlgorithmSourceFractionsBhaBhaL1TOPTRG";
228 B2WARNING(
"Histogram EventT0 source fractions for BhaBha from TOPTRG events (" << histname <<
") from EventT0 DQM not processed!");
241 histname =
"AlgorithmSourceFractionsMuMuL1ECLTRG";
248 B2WARNING(
"Histogram EventT0 source fractions for MuMu from ECLTRG events (" << histname <<
") from EventT0 DQM not processed!");
252 histname =
"AlgorithmSourceFractionsMuMuL1CDCTRG";
259 B2WARNING(
"Histogram EventT0 source fractions for MuMu from CDCTRG events (" << histname <<
") from EventT0 DQM not processed!");
263 histname =
"AlgorithmSourceFractionsMuMuL1TOPTRG";
270 B2WARNING(
"Histogram EventT0 source fractions for MuMu from TOPTRG events (" << histname <<
") from EventT0 DQM not processed!");
289 TH1* h =
findHist(
"EventT0/m_histEventT0_TOP_hadron_L1_ECLTRG");
290 TString tag =
"hadronECLTRG";
297 B2WARNING(Form(
"Histogram TOP EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
303 h =
findHist(
"EventT0/m_histEventT0_TOP_bhabha_L1_ECLTRG");
304 tag =
"bhabhaECLTRG";
311 B2WARNING(Form(
"Histogram TOP EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
317 h =
findHist(
"EventT0/m_histEventT0_TOP_mumu_L1_ECLTRG");
325 B2WARNING(Form(
"Histogram TOP EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
342 h =
findHist(
"EventT0/m_histEventT0_TOP_hadron_L1_CDCTRG");
343 tag =
"hadronCDCTRG";
352 B2WARNING(Form(
"Histogram TOP EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
360 h =
findHist(
"EventT0/m_histEventT0_TOP_bhabha_L1_CDCTRG");
361 tag =
"bhabhaCDCTRG";
370 B2WARNING(Form(
"Histogram TOP EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
378 h =
findHist(
"EventT0/m_histEventT0_TOP_mumu_L1_CDCTRG");
386 B2WARNING(Form(
"Histogram TOP EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
404 h =
findHist(
"EventT0/m_histEventT0_SVD_hadron_L1_ECLTRG");
405 tag =
"hadronECLTRG";
412 B2WARNING(Form(
"Histogram SVD EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
418 h =
findHist(
"EventT0/m_histEventT0_SVD_bhabha_L1_ECLTRG");
419 tag =
"bhabhaECLTRG";
426 B2WARNING(Form(
"Histogram SVD EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
432 h =
findHist(
"EventT0/m_histEventT0_SVD_mumu_L1_ECLTRG");
440 B2WARNING(Form(
"Histogram SVD EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
457 h =
findHist(
"EventT0/m_histEventT0_SVD_hadron_L1_CDCTRG");
458 tag =
"hadronCDCTRG";
467 B2WARNING(Form(
"Histogram SVD EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
475 h =
findHist(
"EventT0/m_histEventT0_SVD_bhabha_L1_CDCTRG");
476 tag =
"bhabhaCDCTRG";
485 B2WARNING(Form(
"Histogram SVD EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
494 h =
findHist(
"EventT0/m_histEventT0_SVD_mumu_L1_CDCTRG");
502 B2WARNING(Form(
"Histogram SVD EventT0 for %s from EventT0 DQM not processed!", tag.Data()));
534 double frac = par[1];
535 double mean = par[2];
536 double sigma = par[3];
537 double mean2 = par[4];
538 double sigma2 = par[5];
540 return N * frac * TMath::Gaus(x[0], mean, sigma) + N * (1 - frac) * TMath::Gaus(x[0], mean2, sigma2);
547 B2DEBUG(20,
"h == nullptr");
555 auto nValidEntries = h->GetEntries() - h->GetBinContent(0) - h->GetBinContent(h->GetNbinsX() + 1);
557 B2DEBUG(20,
"not enough entries");
564 h->Scale(1. / nValidEntries);
565 h->GetXaxis()->SetRangeUser(-50, 50);
569 fitf.SetParNames(
"N",
"f_{1}",
"#mu_{1}",
"#sigma_{1}",
"#mu_{2}",
"#sigma_{2}");
570 fitf.SetParameters(0.1, 0.8, 0, 5, 0, 15);
571 fitf.SetParLimits(1, 0, 1);
572 fitf.SetParLimits(3, 0, 100);
573 fitf.SetParLimits(5, 0, 100);
575 if (h->Fit(&fitf,
"SR+") != 0) {
576 B2DEBUG(20,
"failed fit");
582 fitf.GetParameters(&par[0]);
584 for (
int i = 0; i < 6; i++)
585 parErr[i] = fitf.GetParError(i) ;
589 TF1 gauss1(
"gauss1",
"gaus", -100, 100);
590 TF1 gauss2(
"gauss2",
"gaus", -100, 100);
592 gauss1.SetLineColor(kBlue);
593 gauss1.SetLineStyle(kDashed);
594 gauss1.SetParameters(par[0]*par[1], par[2], par[3]);
596 gauss2.SetLineColor(kRed);
597 gauss2.SetLineStyle(kDashed);
598 gauss2.SetParameters(par[0] * (1 - par[1]), par[4], par[5]);
601 m_monObj->
setVariable(Form(
"N_%s", tag.Data()), nValidEntries, TMath::Sqrt(nValidEntries));
609 gStyle->SetOptFit(1111);
612 fitf.DrawClone(
"same");
613 gauss1.DrawClone(
"same");
614 gauss2.DrawClone(
"same");
622 B2DEBUG(20,
"Begin processing histogram " << histname <<
" ...");
623 TH1* h =
findHist(
"EventT0/" + histname);
630 const auto totalEntries = h->GetBinContent(-1);
631 const auto nBins = h->GetNbinsX();
632 TH1D* totalHist =
new TH1D(
"total",
"total;Algorithm;Fraction #epsilon", nBins, 0, nBins);
633 for (
int i = 0; i < nBins; i++) {
634 totalHist->SetBinContent(i + 1, totalEntries);
636 eff->SetPassedHistogram(*h,
"f");
637 eff->SetTotalHistogram(*totalHist,
"f");
641 TGraphAsymmErrors* graph = eff->GetPaintedGraph();
646 auto ax = graph->GetXaxis();
651 ax->SetTitleOffset(1.0);
652 ax->CenterTitle(kTRUE);
653 ax->Set(nBins, 0, nBins);
654 for (
int i = 0; i < nBins; i++) {
658 auto ay = graph->GetYaxis();
662 ay->SetTitleOffset(1.0);
663 ay->SetRangeUser(0, 1.05);
667 B2DEBUG(20,
"Finished processing histogram " << histname <<
"!");
TCanvas * m_cTOPTimeForECLTRG
TOP EventT0 for ECLTRG plots canvas.
TEfficiency * m_eAlgorithmSourceFractionsMuMuL1ECLTRG
Fraction of events with EventT0 from a given algorithm, HLT mumu events, L1 time by ECL trigger.
TCanvas * m_cSVDTimeForECLTRG
SVD EventT0 for ECLTRG plots canvas.
void initialize() override final
create TCanvas and MonitoringObject
TEfficiency * m_eAlgorithmSourceFractionsBhaBhaL1ECLTRG
Fraction of events with EventT0 from a given algorithm, HLT bhabha events, L1 time by ECL trigger.
TCanvas * m_cT0FractionsForMuMus
EventT0 fractions plots canvas for MuMu events.
static double fDoubleGaus(double *x, double *par)
double gaussian fitting function for the jitter distribution
const char * c_eventT0Algorithms[6]
EventT0 algorithms for which to calculate fractions of abundance.
TPad * m_pBhaBhaTOPTRG
pad for time fractions for TOPTRG bhabhas
TPad * m_pMuMuTOPTRG
pad for time fractions for TOPTRG mumu
bool FillEfficiencyHistogram(const std::string &histname, TEfficiency *eff)
Fill the TEfficiency plots.
TPad * m_svdPad1CDCTRG
pad for SVD time CDCTRG hadrons
TPad * m_svdPad3CDCTRG
pad for SVD time CDCTRG mumu
TPad * m_pMuMuCDCTRG
pad for time fractions for CDCTRG mumu
TPad * m_pHadronTOPTRG
pad for time fractions for TOPTRG hadrons
TCanvas * m_cT0FractionsForBhaBhas
EventT0 fractions plots canvas for BhaBha events.
std::string m_prefixCanvas
prefix to be added to canvas name when saved as pdf
TPad * m_pMuMuECLTRG
pad for time fractions for ECLTRG mumu
TPad * m_svdPad2ECLTRG
pad for SVD time ECLTRG bhabhas
MonitoringObject * m_monObj
MonitoringObject to be produced by this module.
void terminate() override final
delete pointers
void event() override final
Event.
TEfficiency * m_eAlgorithmSourceFractionsBhaBhaL1CDCTRG
Fraction of events with EventT0 from a given algorithm, HLT bhabha events, L1 time by CDC trigger.
TCanvas * m_cT0FractionsForHadrons
EventT0 fractions plots canvas for hadron events.
bool m_printCanvas
if true print the pdf of the canvases
TPad * m_svdPad2CDCTRG
pad for SVD time CDCTRG bhabhas
TPad * m_pHadronECLTRG
pad for time fractions for ECLTRG hadrons
TPad * m_topPad1CDCTRG
pad for TOP time CDCTRG hadrons
uint m_nEntriesMin
minimum number of entries to process the histogram
TEfficiency * m_eAlgorithmSourceFractionsHadronL1ECLTRG
Fraction of events with EventT0 from a given algorithm, HLT hadronic events, L1 time by ECL trigger.
void endRun() override final
fit the histograms
TPad * m_topPad3CDCTRG
pad for TOP time CDCTRG mumu
TPad * m_svdPad1ECLTRG
pad for SVD time ECLTRG hadrons
TEfficiency * m_eAlgorithmSourceFractionsHadronL1CDCTRG
Fraction of events with EventT0 from a given algorithm, HLT hadronic events, L1 time by CDC trigger.
bool processHistogram(TH1 *h, TString tag)
process the EventT0 distribution fitting with two gaussians filling the MonitoringObject
void beginRun() override final
clear TCanvas
TPad * m_topPad2CDCTRG
pad for TOP time CDCTRG bhabhas
TPad * m_pHadronCDCTRG
pad for time fractions for CDCTRG hadrons
TPad * m_topPad3ECLTRG
pad for TOP time ECLTRG mumu
TPad * m_topPad2ECLTRG
pad for TOP time ECLTRG bhabhas
TEfficiency * m_eAlgorithmSourceFractionsMuMuL1TOPTRG
Fraction of events with EventT0 from a given algorithm, HLT mumu events, L1 time by TOP trigger.
TCanvas * m_cTOPTimeForCDCTRG
TOP EventT0 for CDCTRG plots canvas.
TCanvas * m_cSVDTimeForCDCTRG
SVD EventT0 for CDCTRG plots canvas.
TPad * m_topPad1ECLTRG
pad for TOP time ECLTRG hadrons
~DQMHistAnalysisEventT0Module()
Destructor.
TEfficiency * m_eAlgorithmSourceFractionsMuMuL1CDCTRG
Fraction of events with EventT0 from a given algorithm, HLT mumu events, L1 time by CDC trigger.
TEfficiency * m_eAlgorithmSourceFractionsBhaBhaL1TOPTRG
Fraction of events with EventT0 from a given algorithm, HLT bhabha events, L1 time by TOP trigger.
TPad * m_svdPad3ECLTRG
pad for SVD time ECLTRG mumu
TPad * m_pBhaBhaCDCTRG
pad for time fractions for CDCTRG bhabhas
TEfficiency * m_eAlgorithmSourceFractionsHadronL1TOPTRG
Fraction of events with EventT0 from a given algorithm, HLT hadronic events, L1 time by TOP trigger.
TPad * m_pBhaBhaECLTRG
pad for time fractions for ECLTRG bhabhas
The base class for the histogram analysis module.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
static MonitoringObject * getMonitoringObject(const std::string &histname)
Get MonitoringObject with given name (new object is created if non-existing)
void setDescription(const std::string &description)
Sets the description of the module.
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.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.