14#include <dqm/analysis/modules/DQMHistAnalysisPhysics.h>
37 B2DEBUG(20,
"DQMHistAnalysisPhysics: Constructor done.");
61 m_ratio_text =
new TPaveText(0.55, 0.6, 0.85, 0.9,
"NDC");
69 addDeltaPar(
"PhysicsObjects",
"physicsresults", HistDelta::c_Events, 3000000, 1);
72 B2DEBUG(20,
"DQMHistAnalysisPhysics: initialized.");
78 B2DEBUG(20,
"DQMHistAnalysisPhysics: beginRun called.");
84 auto m_hmUPS =
findHist(
"PhysicsObjects/mUPS",
true);
86 double mean_mUPS = m_hmUPS->GetMean();
87 m_cmUPS_text->AddText(Form(
"mean : %.2f",
float(mean_mUPS)));
91 auto m_hmUPSe =
findHist(
"PhysicsObjects/mUPSe",
true);
93 double mean_mUPSe = m_hmUPSe->GetMean();
94 m_cmUPSe_text->AddText(Form(
"mean : %.2f",
float(mean_mUPSe)));
97 auto m_hphysicsresults =
findHist(
"PhysicsObjects/physicsresults",
true);
98 if (m_hphysicsresults) {
99 double had_ntot = m_hphysicsresults->GetBinContent(2);
100 double hadb2_ntot = m_hphysicsresults->GetBinContent(3);
101 double hadb2_tight_ntot = m_hphysicsresults->GetBinContent(4);
102 double mumu_tight_ntot = m_hphysicsresults->GetBinContent(5);
103 double bhabha_all_ntot = m_hphysicsresults->GetBinContent(6);
105 double ratio_hadron_bhabha = 0.;
106 double ratio_hadronb2_bhabha = 0.;
107 double ratio_hadronb2_tight_bhabha = 0.;
108 double ratio_mumu_tight_bhabha = 0.;
109 double error_hadron_bhabha = -10.;
110 double error_hadronb2_bhabha = -10.;
111 double error_hadronb2_tight_bhabha = -10.;
112 double error_mumu_tight_bhabha = -10.;
115 if (bhabha_all_ntot != 0) {
116 ratio_hadron_bhabha = had_ntot / bhabha_all_ntot;
117 error_hadron_bhabha = ratio_hadron_bhabha *
sqrt((1 / had_ntot) + (1 / bhabha_all_ntot));
118 ratio_hadronb2_bhabha = hadb2_ntot / bhabha_all_ntot;
119 error_hadronb2_bhabha = ratio_hadronb2_bhabha *
sqrt((1 / hadb2_ntot) + (1 / bhabha_all_ntot));
120 ratio_hadronb2_tight_bhabha = hadb2_tight_ntot / bhabha_all_ntot;
121 error_hadronb2_tight_bhabha = ratio_hadronb2_tight_bhabha *
sqrt((1 / hadb2_tight_ntot) + (1 / bhabha_all_ntot));
122 ratio_mumu_tight_bhabha = mumu_tight_ntot / bhabha_all_ntot;
123 error_mumu_tight_bhabha = ratio_mumu_tight_bhabha *
sqrt((1 / mumu_tight_ntot) + (1 / bhabha_all_ntot));
125 m_ratio_text->AddText(Form(
"hadronb2_tight/bhabha: %.4f +/- %.4f",
float(ratio_hadronb2_tight_bhabha),
126 float(error_hadronb2_tight_bhabha)));
127 m_ratio_text->AddText(Form(
"hadronb2/bhabha: %.4f +/- %.4f",
float(ratio_hadronb2_bhabha),
float(error_hadronb2_bhabha)));
128 m_ratio_text->AddText(Form(
"mumu_tight/bhabha: %.4f +/- %.4f",
float(ratio_mumu_tight_bhabha),
float(error_mumu_tight_bhabha)));
129 m_ratio_text->AddText(Form(
"hadron/bhabha: %.4f +/- %.4f",
float(ratio_hadron_bhabha),
float(error_hadron_bhabha)));
133 auto hist_hadronb2_tight_over_bhabha_all =
getDelta(
"PhysicsObjects",
"physicsresults", 0,
true);
134 if (hist_hadronb2_tight_over_bhabha_all) {
135 if (hist_hadronb2_tight_over_bhabha_all->GetBinContent(6) != 0) {
136 double hadronb2_tight_over_bhabha_all = hist_hadronb2_tight_over_bhabha_all->GetBinContent(4) /
137 hist_hadronb2_tight_over_bhabha_all->GetBinContent(6);
138 B2DEBUG(1,
"hadronb2_tight_over_bhabha_all:" << hadronb2_tight_over_bhabha_all);
139 setEpicsPV(
"hadronb2_tight_over_bhabha_all", hadronb2_tight_over_bhabha_all);
143 auto* m_cmUPS =
findCanvas(
"PhysicsObjects/c_mUPS");
150 auto* m_cmUPSe =
findCanvas(
"PhysicsObjects/c_mUPSe");
154 m_cmUPSe->Modified();
157 auto* m_cphysicsresults =
findCanvas(
"PhysicsObjects/c_physicsresults");
158 if (m_cphysicsresults) {
159 m_cphysicsresults->cd();
161 m_cphysicsresults->Modified();
162 m_cphysicsresults->Update();
167 auto m_hphysicsresults =
findHist(
"PhysicsObjects/physicsresults");
168 if (m_hphysicsresults) {
169 double had_ntot = m_hphysicsresults->GetBinContent(2);
170 double hadb2_ntot = m_hphysicsresults->GetBinContent(3);
171 double hadb2_tight_ntot = m_hphysicsresults->GetBinContent(4);
172 double mumu_tight_ntot = m_hphysicsresults->GetBinContent(5);
173 double bhabha_all_ntot = m_hphysicsresults->GetBinContent(6);
174 double ratio_hadron_bhabha_final = 0.;
175 double ratio_hadronb2_bhabha_final = 0.;
176 double ratio_hadronb2_tight_bhabha_final = 0.;
177 double ratio_mumu_tight_bhabha_final = 0.;
179 if (bhabha_all_ntot != 0) {
180 ratio_hadron_bhabha_final = had_ntot / bhabha_all_ntot;
181 ratio_hadronb2_bhabha_final = hadb2_ntot / bhabha_all_ntot;
182 ratio_hadronb2_tight_bhabha_final = hadb2_tight_ntot / bhabha_all_ntot;
183 ratio_mumu_tight_bhabha_final = mumu_tight_ntot / bhabha_all_ntot;
187 m_monObj->
setVariable(
"ratio_hadronb2_tight_bhabha_hlt", ratio_hadronb2_tight_bhabha_final);
196 B2DEBUG(20,
"DQMHistAnalysisPhysics: terminate called");
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)
void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
TH1 * getDelta(const std::string &fullname, int n=0, bool onlyIfUpdated=true)
Get Delta histogram.
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
~DQMHistAnalysisPhysicsModule()
Destructor.
void terminate(void) override final
This method is called at the end of the event processing.
TPaveText * m_ratio_text
TPaveText, ratios physics results.
void initialize(void) override final
Initializer.
void endRun(void) override final
End-of-run action.
std::string m_pvPrefix
prefix for EPICS PVs
MonitoringObject * m_monObj
Monitoring Object.
TPaveText * m_cmUPS_text
TPaveText, Ups Invariant Mass (mumu)
DQMHistAnalysisPhysicsModule()
Constructor.
TPaveText * m_cmUPSe_text
TPaveText, Ups ee Invariant Mass.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
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 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.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.