10#include <dqm/analysis/modules/DQMHistAnalysisTRGEFF.h>
39 setDescription(
"Modify and analyze the data quality histograms of TRGEFF");
53 m_cPt_eff =
new TCanvas(
"TRGEFF/c_hPt_eff");
139 B2DEBUG(1,
"DQMHistAnalysisTRGEFF: initialized.");
145 B2DEBUG(1,
"DQMHistAnalysisTRGEFF: event start.");
152 B2DEBUG(1,
"DQMHistAnalysisTRGEFF: fill histogram");
155 const std::string& name = std::get<0>(entry);
156 TEfficiency** efficiencyPtr = std::get<1>(entry);
157 TCanvas* canvas = std::get<2>(entry);
158 const std::string& title = std::get<3>(entry);
160 B2DEBUG(1,
"The current histogram name is " << name);
162 TH1F* histFtdf = (TH1F*)
findHist(name +
"_ftdf");
163 if (hist ==
nullptr || histFtdf ==
nullptr) {
164 B2WARNING(
"Histogram for " + name +
" or its Ftdf counterpart is not found.");
169 if (*efficiencyPtr !=
nullptr) {
170 delete *efficiencyPtr;
171 *efficiencyPtr =
nullptr;
175 if (TEfficiency::CheckConsistency(*histFtdf, *hist)) {
176 *efficiencyPtr =
new TEfficiency(*histFtdf, *hist);
177 (*efficiencyPtr)->SetTitle(title.c_str());
182 (*efficiencyPtr)->Draw();
186 B2WARNING(
"Histograms " << histFtdf->GetName() <<
" and " << hist->GetName() <<
" are not consistent for efficiency calculation.");
195 B2DEBUG(1,
"DQMHistAnalysisTRGEFF : endRun called");
199 const std::string& name = std::get<0>(entry);
200 TEfficiency** efficiencyPtr = std::get<1>(entry);
202 TEfficiency* effHist = *efficiencyPtr;
208 TH1F* hist = (TH1F*)effHist->GetTotalHistogram();
209 TH1F* histFtdf = (TH1F*)effHist->GetPassedHistogram();
211 Double_t* newBins =
nullptr;
214 if (name.find(
"TRGEFF/nobha_hie_E_psnecl") != std::string::npos) {
215 newBins =
new Double_t[4] {0, 0.6, 1.6, hist->GetXaxis()->GetXmax()};
217 }
else if (name.find(
"TRGEFF/nobha_stt_P3_psnecl") != std::string::npos) {
218 newBins =
new Double_t[4] {0, 0.5, 1, hist->GetXaxis()->GetXmax()};
220 }
else if (name.find(
"TRGEFF/nobha_fyo_dphi_psnecl") != std::string::npos) {
221 newBins =
new Double_t[4] {0, 80, 100, hist->GetXaxis()->GetXmax()};
223 }
else if (name.find(
"TRGEFF/klmhit_theta_psnecl") != std::string::npos) {
224 newBins =
new Double_t[2] {0, hist->GetXaxis()->GetXmax()};
226 }
else if (name.find(
"TRGEFF/eklmhit_theta_psnecl") != std::string::npos) {
227 newBins =
new Double_t[3] {0, 90, hist->GetXaxis()->GetXmax()};
230 newBins =
new Double_t[2] {0, hist->GetXaxis()->GetXmax()};
236 std::sort(newBins, newBins + nBins + 1);
239 TEfficiency* efficiencyRebinnedPtr =
nullptr;
242 TH1F* histRebinned = (TH1F*)hist->Rebin(nBins, (name +
"_rebinned").c_str(), newBins);
243 TH1F* histFtdfRebinned = (TH1F*)histFtdf->Rebin(nBins, (name +
"_ftdf_rebinned").c_str(), newBins);
249 if (TEfficiency::CheckConsistency(*histFtdfRebinned, *histRebinned)) {
250 efficiencyRebinnedPtr =
new TEfficiency(*histFtdfRebinned, *histRebinned);
253 std::string cleanName = name;
256 size_t prefixPos = cleanName.find(
"TRGEFF/");
257 if (prefixPos != std::string::npos) {
258 cleanName.erase(prefixPos, std::string(
"TRGEFF/").length());
262 size_t suffixPos = cleanName.find(
"_psnecl");
263 if (suffixPos != std::string::npos) {
264 cleanName.erase(suffixPos, std::string(
"_psnecl").length());
267 int nbins = efficiencyRebinnedPtr->GetTotalHistogram()->GetNbinsX();
268 for (
int i = 1; i <= nbins; i++) {
270 sprintf(varName,
"%s_%i", cleanName.c_str(), i);
271 B2DEBUG(1,
"The name for MonitoringObject histogram is " << varName <<
" " << efficiencyRebinnedPtr->GetEfficiency(
272 i) <<
" " << efficiencyRebinnedPtr->GetEfficiencyErrorUp(i) <<
" " << efficiencyRebinnedPtr->GetEfficiencyErrorLow(i));
274 efficiencyRebinnedPtr->GetEfficiency(i),
275 efficiencyRebinnedPtr->GetEfficiencyErrorUp(i),
276 efficiencyRebinnedPtr->GetEfficiencyErrorLow(i));
279 if (efficiencyRebinnedPtr !=
nullptr) {
280 delete efficiencyRebinnedPtr;
284 B2WARNING(
"Rebinned histograms " << histFtdfRebinned->GetName() <<
" and " << histRebinned->GetName() <<
285 " are not consistent for efficiency calculation.");
289 delete histFtdfRebinned;
292 B2WARNING(std::string(
"Efficiency histogram is null for ") + name);
301 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 Run Type.
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
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.
std::vector< std::tuple< std::string, TEfficiency **, TCanvas *, std::string > > m_efficiencyList
Combined efficiency list,the histogram, efficiency, Canvas, title
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_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
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
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_stt_P3_eff
remove the bha_veto, the efficiency of p for stt bit
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.