12#include <dqm/analysis/modules/DQMHistAnalysisTRGECL.h>
16#include <TFitResult.h>
33 setDescription(
"Module for DQM histogram analysis of ECL trigger Event T0 DQM histograms");
37 "set minimum number of entries for fit (default=200)",
48 new TCanvas(
"TRGECLEventTiming/c_a_EventTimingFraction",
49 "Event timing fraction",
52 new TCanvas(
"TRGECLEventTiming/c_a_EventT0Mean",
56 new TCanvas(
"TRGECLEventTiming/c_a_EventT0Width",
75 for (
int iii = 0; iii < 15; iii++) {
76 std::stringstream ss1, ss2;
77 ss1 << std::setfill(
'0') << std::setw(3) << std::to_string(10 + 20 * iii);
78 ss2 << std::setfill(
'0') << std::setw(3) << std::to_string(10 + 20 * (iii + 1));
79 std::string s_EnergyRange = ss1.str() +
"to" + ss2.str();
124 auto hhh = (TH1F*)
findHist(
"TRGECLEventTiming/h_MaxTCE");
125 if (hhh !=
nullptr) {
127 int n_bin = hhh->GetNbinsX();
128 float n_entry_all = (float) hhh->GetEffectiveEntries();
129 float n_entry_bin_sum[140] = {0};
130 float ratio[140] = {0};
131 for (
int iii = 0; iii < n_bin; iii++) {
132 for (
int jjj = iii; jjj < n_bin; jjj++) {
133 n_entry_bin_sum[iii] += (float) hhh->GetBinContent(jjj + 1);
135 ratio[iii] = n_entry_bin_sum[iii] / n_entry_all;
138 for (
int iii = 0; iii <= 30; iii++) {
188 double yield = par[0];
189 double mean = par[1];
190 double sigma = par[2];
191 return yield * TMath::Gaus(x[0], mean, sigma);
195 TGraphErrors* h_tge_mean,
196 TGraphErrors* h_tge_width)
200 for (
int iii = 0; iii < 15; iii++) {
202 TH1* hhh =
findHist(s_HistName[iii]);
204 if (hhh !=
nullptr) {
207 std::vector<double> par_fit(6, 0.0);
210 int nToFit = hhh->GetEffectiveEntries();
220 h_tge_mean->SetPoint(iii, (iii + 1) * 20, par_fit[2]);
221 h_tge_mean->SetPointError(iii, 10, par_fit[3]);
223 h_tge_width->SetPoint(iii, (iii + 1) * 20, par_fit[4]);
224 h_tge_width->SetPointError(iii, 10, par_fit[5]);
231 std::vector<double>& fit_par)
235 float v_mean = hist->GetMean();
236 float v_rms = hist->GetRMS();
237 float v_norm = hist->GetEffectiveEntries() / v_rms;
238 float x_min = v_mean - 3 * v_rms;
239 float x_max = v_mean + 3 * v_rms;
247 f1->SetParameters(v_norm, v_mean, v_rms);
250 hist->Fit(
"f1",
"Q",
"", x_min, x_max);
253 if (hist->GetFunction(
"f1") == NULL) {
254 B2DEBUG(20,
"Fit failed");
259 if (f1->GetParameter(2) <= 0) {
260 B2DEBUG(20,
"Fit failed");
265 fit_par[0] = f1->GetParameter(0);
266 fit_par[1] = f1->GetParError(0);
267 fit_par[2] = f1->GetParameter(1);
268 fit_par[3] = f1->GetParError(1);
269 fit_par[4] = f1->GetParameter(2);
270 fit_par[5] = f1->GetParError(2);
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
static void UpdateCanvas(const std::string &name, bool updated=true)
Mark canvas as updated (or not)
DQMHistAnalysisModule()
Constructor / Destructor.
TGraph * h_EventTimingEnergyFraction
fraction of event timing with different max TC selection
static double fGaus(double *x, double *par)
single Gaussian function
void initialize() override final
initialization
TGraphErrors * h_EventT0Width
graph of EventT0 width
void fitEventT0(TH1 *hist, std::vector< double > &)
fit on EventT0 histogram
TGraphErrors * h_EventT0Mean
graph of EventT0 mean
DQMHistAnalysisTRGECLModule()
Constructor.
TCanvas * c_EventT0Width
canvas for EventT0 width
void terminate() override final
delete pointers
void event() override final
event function
TCanvas * c_TCEFraction
canvas for fraction of event timing with different max TC selection
int m_MinEntryForFit
minimum entry in EventT0 histogram to fit
void endRun() override final
end run
void beginRun() override final
begin run
TCanvas * c_EventT0Mean
canvas for EventT0 mean
std::vector< std::string > s_histNameEventT0
name of EventT0 histograms
void getEventT0(std::vector< std::string >, TGraphErrors *, TGraphErrors *)
get EventT0 mean and width
void setDescription(const std::string &description)
Sets the description of the module.
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.