10#include <dqm/analysis/modules/DQMHistAnalysisTRGEFF.h>
40 setDescription(
"Modify and analyze the data quality histograms of TRGEFF");
54 m_cPt_eff =
new TCanvas(
"TRGEFF/c_hPt_eff");
140 B2DEBUG(1,
"DQMHistAnalysisTRGEFF: initialized.");
146 B2DEBUG(1,
"DQMHistAnalysisTRGEFF: event start.");
153 B2DEBUG(1,
"DQMHistAnalysisTRGEFF: fill histogram");
156 const std::string& name = std::get<0>(entry);
157 TEfficiency** efficiencyPtr = std::get<1>(entry);
158 TCanvas* canvas = std::get<2>(entry);
159 const std::string& title = std::get<3>(entry);
160 const std::string& xtitle = std::get<4>(entry);
162 B2DEBUG(1,
"The current histogram name is " << name);
164 TH1F* histFtdf = (TH1F*)
findHist(name +
"_ftdf");
165 if (hist ==
nullptr || histFtdf ==
nullptr) {
166 B2WARNING(
"Histogram for " + name +
" or its Ftdf counterpart is not found.");
171 if (*efficiencyPtr !=
nullptr) {
172 delete *efficiencyPtr;
173 *efficiencyPtr =
nullptr;
177 if (TEfficiency::CheckConsistency(*histFtdf, *hist)) {
178 *efficiencyPtr =
new TEfficiency(*histFtdf, *hist);
180 hist->GetYaxis()->SetNdivisions(505);
181 hist->GetXaxis()->SetTitleSize(0.04);
182 hist->GetYaxis()->SetTitleSize(0.04);
183 hist->GetYaxis()->SetLabelSize(0.03);
184 hist->GetXaxis()->SetLabelSize(0.03);
185 hist->GetYaxis()->SetTitleOffset(1.);
186 hist->GetXaxis()->SetTitleOffset(1.);
187 hist->GetYaxis()->SetTitleFont(42);
188 hist->GetXaxis()->SetTitleFont(42);
189 hist->GetYaxis()->SetLabelFont(42);
190 hist->GetXaxis()->SetLabelFont(42);
191 hist->GetXaxis()->SetTitle(xtitle.c_str());
192 hist->GetYaxis()->SetTitle(
"#epsilon");
193 hist->GetYaxis()->SetRangeUser(0, 1);
198 hist_title.SetTextAlign(23);
199 hist_title.SetTextSize(0.04);
200 hist_title.SetTextFont(42);
201 double pos_titleX = (hist->GetXaxis()->GetXmin() + hist->GetXaxis()->GetXmax()) / 2;
202 double pos_titleY = 1.1;
209 hist_title.DrawLatex(pos_titleX, pos_titleY, title.c_str());
210 (*efficiencyPtr)->Draw(
"same");
215 B2WARNING(
"Histograms " << histFtdf->GetName() <<
" and " << hist->GetName() <<
" are not consistent for efficiency calculation.");
224 B2DEBUG(1,
"DQMHistAnalysisTRGEFF : endRun called");
228 const std::string& name = std::get<0>(entry);
229 TEfficiency** efficiencyPtr = std::get<1>(entry);
231 TEfficiency* effHist = *efficiencyPtr;
237 TH1F* hist = (TH1F*)effHist->GetTotalHistogram();
238 TH1F* histFtdf = (TH1F*)effHist->GetPassedHistogram();
240 Double_t* newBins =
nullptr;
243 if (name.find(
"TRGEFF/nobha_hie_E_psnecl") != std::string::npos) {
244 newBins =
new Double_t[4] {0, 0.6, 1.6, hist->GetXaxis()->GetXmax()};
246 }
else if (name.find(
"TRGEFF/nobha_stt_P3_psnecl") != std::string::npos) {
247 newBins =
new Double_t[4] {0, 0.5, 1, hist->GetXaxis()->GetXmax()};
249 }
else if (name.find(
"TRGEFF/nobha_fyo_dphi_psnecl") != std::string::npos) {
250 newBins =
new Double_t[4] {0, 80, 100, hist->GetXaxis()->GetXmax()};
252 }
else if (name.find(
"TRGEFF/klmhit_theta_psnecl") != std::string::npos) {
253 newBins =
new Double_t[2] {0, hist->GetXaxis()->GetXmax()};
255 }
else if (name.find(
"TRGEFF/eklmhit_theta_psnecl") != std::string::npos) {
256 newBins =
new Double_t[3] {0, 90, hist->GetXaxis()->GetXmax()};
259 newBins =
new Double_t[2] {0, hist->GetXaxis()->GetXmax()};
265 std::sort(newBins, newBins + nBins + 1);
268 TEfficiency* efficiencyRebinnedPtr =
nullptr;
271 TH1F* histRebinned = (TH1F*)hist->Rebin(nBins, (name +
"_rebinned").c_str(), newBins);
272 TH1F* histFtdfRebinned = (TH1F*)histFtdf->Rebin(nBins, (name +
"_ftdf_rebinned").c_str(), newBins);
278 if (TEfficiency::CheckConsistency(*histFtdfRebinned, *histRebinned)) {
279 efficiencyRebinnedPtr =
new TEfficiency(*histFtdfRebinned, *histRebinned);
282 std::string cleanName = name;
285 size_t prefixPos = cleanName.find(
"TRGEFF/");
286 if (prefixPos != std::string::npos) {
287 cleanName.erase(prefixPos, std::string(
"TRGEFF/").length());
291 size_t suffixPos = cleanName.find(
"_psnecl");
292 if (suffixPos != std::string::npos) {
293 cleanName.erase(suffixPos, std::string(
"_psnecl").length());
296 int nbins = efficiencyRebinnedPtr->GetTotalHistogram()->GetNbinsX();
297 for (
int i = 1; i <= nbins; i++) {
299 sprintf(varName,
"%s_%i", cleanName.c_str(), i);
300 B2DEBUG(1,
"The name for MonitoringObject histogram is " << varName <<
" " << efficiencyRebinnedPtr->GetEfficiency(
301 i) <<
" " << efficiencyRebinnedPtr->GetEfficiencyErrorUp(i) <<
" " << efficiencyRebinnedPtr->GetEfficiencyErrorLow(i));
303 efficiencyRebinnedPtr->GetEfficiency(i),
304 efficiencyRebinnedPtr->GetEfficiencyErrorUp(i),
305 efficiencyRebinnedPtr->GetEfficiencyErrorLow(i));
308 if (efficiencyRebinnedPtr !=
nullptr) {
309 delete efficiencyRebinnedPtr;
313 B2WARNING(
"Rebinned histograms " << histFtdfRebinned->GetName() <<
" and " << histRebinned->GetName() <<
314 " are not consistent for efficiency calculation.");
318 delete histFtdfRebinned;
321 B2WARNING(std::string(
"Efficiency histogram is null for ") + name);
330 B2DEBUG(1,
"terminate called");
The base class for the histogram analysis module.
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).
static const std::string & getRunType(void)
Get the list of the reference histograms.
TEfficiency * m_nobha_hP3_z_eff
remove the bha_veto, the efficiency of p for z bit
TEfficiency * m_hie_E_eff
the efficiency of phi for hie bit
TEfficiency * m_nobha_f_phi_eff
remove the bha_veto, the efficiency of phi for f bit
TCanvas * m_cP3_z_eff
for CDC TRG, the histograms for 3-momentum p with ecl mask bits, p of z bit with ecl mask bits.
TCanvas * m_c_nobha_phi_z_eff
remove the bha_veto, canvas for TRGEFF efficiency, z bit
TEfficiency * m_ecltiming_phi_eff
the efficiency of phi for ecltiming bit
void initialize() override final
Initialize the Module.
TEfficiency * m_eklmhit_phi_eff
the efficiency of phi for eklmhit bit
TCanvas * m_c_nobha_f_phi_eff
remove the bha_veto, canvas for TRGEFF efficiency, f bit
TCanvas * m_c_eklmhit_theta_eff
canvas for TRGEFF efficiency, eklmhit bit
bool m_IsCosmicRun
Run type flag for cosmic runs.
TCanvas * m_cP3_y_eff
for CDC TRG, the histograms for 3-momentum p with ecl mask bits, p of y bit with ecl mask bits.
TEfficiency * m_hPt_eff
the efficiency of Pt for f bit
TCanvas * m_c_klmhit_phi_eff
for KLM TRG, the histograms for the phi of the ecl mask bits, and the phi of klmhit bit with ecl mask...
TCanvas * m_nobha_cPt_eff
remove the bha_veto, Canvas for TRGEFF efficiency, Pt
bool m_IsDebugRun
Run type flag for debug runs.
bool m_IsPhysicsRun
Run type flag for physics runs.
TEfficiency * m_ecltiming_theta_eff
the efficiency of theta for ecltiming bit
bool m_enableAlert
Enable alert by base color of canvases.
TCanvas * m_c_ecltiming_theta_eff
canvas for TRGEFF efficiency, ecltiming bit
TCanvas * m_c_ecltiming_E_eff
for ECL TRG, the histograms for the sum energy E distribution in an event with cdc mask bits,...
TCanvas * m_c_stt_phi_eff
for CDC TRG, the histograms for the phi distribution with ecl mask bits, the phi of stt bit with ecl ...
TEfficiency * m_hP3_y_eff
the efficiency of p for y bit
TEfficiency * m_klmhit_phi_eff
the efficiency of phi for klmhit bit
TCanvas * m_c_eklmhit_phi_eff
for KLM TRG, the histograms for the phi of the ecl mask bits, and the phi of eklmhit bit with ecl mas...
~DQMHistAnalysisTRGEFFModule()
Destructor.
TCanvas * m_c_fyo_dphi_eff
for CDC TRG, the histograms for the largest dphi in an event with ecl mask bits, the largest dphi in ...
TEfficiency * m_nobha_stt_theta_eff
remove the bha_veto, the efficiency of theta for stt bit
void terminate() override final
Termination action.
TEfficiency * m_nobha_hPt_eff
remove the bha_veto, the efficiency of Pt for f bit
TEfficiency * m_stt_P3_eff
the efficiency of p for stt bit
TEfficiency * m_nobha_hie_E_eff
remove the bha_veto, the efficiency of phi for hie bit
TCanvas * m_c_stt_P3_eff
for CDC TRG, the histograms for the largest momentum p distribution in an event of the ecl mask bits,...
void event() override final
Event processor.
TCanvas * m_c_nobha_stt_theta_eff
remove the bha_veto, canvas for TRGEFF efficiency, stt bit
TCanvas * m_c_stt_theta_eff
for CDC TRG, the theta of stt distribution.
TEfficiency * m_stt_phi_eff
the efficiency of phi for stt bit
TEfficiency * m_nobha_stt_phi_eff
remove the bha_veto, the efficiency of phi for stt bit
TCanvas * m_cPt_eff
for CDC TRG, the histograms for momentum pt of the ecl mask bits, the pt of f bit with ecl mask bits.
TCanvas * m_c_ecltiming_phi_eff
canvas for TRGEFF efficiency, ecltiming bit
TCanvas * m_cPhi_eff
for CDC TRG, the histograms for phi of the ecl mask bits, the phi of f bit with ecl mask bits.
TEfficiency * m_klmhit_theta_eff
the efficiency of theta for klmhit bit
TEfficiency * m_eklmhit_theta_eff
the efficiency of theta for eklmhit bit
TCanvas * m_c_nobha_phi_y_eff
remove the bha_veto, canvas for TRGEFF efficiency, y bit
void endRun() override final
End-of-run action.
DQMHistAnalysisTRGEFFModule()
Constructor.
TEfficiency * m_hP3_z_eff
the efficiency of p for z bit
TEfficiency * m_hPhi_eff
the efficiency of Phi
TCanvas * m_c_nobha_fyo_dphi_eff
remove the bha_veto, canvas for TRGEFF efficiency, fyo bit
TEfficiency * m_fyo_dphi_eff
the efficiency of dphi for fyo bit
TCanvas * m_c_klmhit_theta_eff
canvas for TRGEFF efficiency, klmhit bit
TCanvas * m_nobha_cP3_z_eff
remove the bha_veto, canvas for TRGEFF efficiency, z bit
TEfficiency * m_stt_theta_eff
the efficiency of theta for stt bit
TEfficiency * m_nobha_phi_y_eff
remove the bha_veto, the efficiency of phi for y bit
TCanvas * m_c_hie_E_eff
for ECL TRG, the histograms for the sum energy E distribution in an event within the thetaID range of...
TCanvas * m_c_nobha_stt_P3_eff
remove the bha_veto, canvas for TRGEFF efficiency, stt bit
TCanvas * m_nobha_cP3_y_eff
remove the bha_veto, canvas for TRGEFF efficiency, y bit
TCanvas * m_c_nobha_hie_E_eff
remove the bha_veto, canvas for TRGEFF efficiency, hie bit
Belle2::MonitoringObject * m_mon_trgeff
MonitoringObject for trg.
TEfficiency * m_nobha_fyo_dphi_eff
remove the bha_veto, the efficiency of dphi for fyo bit
TCanvas * m_c_nobha_stt_phi_eff
remove the bha_veto, canvas for TRGEFF efficiency, stt bit
TEfficiency * m_ecltiming_E_eff
the efficiency of phi for ecltiming bit
TEfficiency * m_nobha_phi_z_eff
remove the bha_veto, the efficiency of phi for z bit
TEfficiency * m_nobha_stt_P3_eff
remove the bha_veto, the efficiency of p for stt bit
std::vector< std::tuple< std::string, TEfficiency **, TCanvas *, std::string, std::string > > m_efficiencyList
Combined efficiency list,the histogram, efficiency, Canvas, title, Xtitle
TEfficiency * m_nobha_hP3_y_eff
remove the bha_veto, the efficiency of p for y bit
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.
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.