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)",
50 new TCanvas(
"TRGECLEventTiming/c_a_EventTimingFraction",
51 "Event timing fraction",
54 new TCanvas(
"TRGECLEventTiming/c_a_EventT0Mean",
58 new TCanvas(
"TRGECLEventTiming/c_a_EventT0Width",
77 for (
int iii = 0; iii < 15; iii++) {
78 std::stringstream ss1, ss2;
79 ss1 << std::setfill(
'0') << std::setw(3) << std::to_string(10 + 20 * iii);
80 ss2 << std::setfill(
'0') << std::setw(3) << std::to_string(10 + 20 * (iii + 1));
81 std::string s_EnergyRange = ss1.str() +
"to" + ss2.str();
126 auto hhh = (TH1F*)
findHist(
"TRGECLEventTiming/h_MaxTCE");
127 if (hhh !=
nullptr) {
129 int n_bin = hhh->GetNbinsX();
130 float n_entry_all = (float) hhh->GetEffectiveEntries();
131 float n_entry_bin_sum[140] = {0};
132 float ratio[140] = {0};
133 for (
int iii = 0; iii < n_bin; iii++) {
134 for (
int jjj = iii; jjj < n_bin; jjj++) {
135 n_entry_bin_sum[iii] += (float) hhh->GetBinContent(jjj + 1);
137 ratio[iii] = n_entry_bin_sum[iii] / n_entry_all;
140 for (
int iii = 0; iii <= 30; iii++) {
190 double yield = par[0];
191 double mean = par[1];
192 double sigma = par[2];
193 return yield * TMath::Gaus(x[0], mean, sigma);
197 TGraphErrors* h_tge_mean,
198 TGraphErrors* h_tge_width)
202 for (
int iii = 0; iii < 15; iii++) {
204 TH1* hhh =
findHist(s_HistName[iii]);
206 if (hhh !=
nullptr) {
209 std::vector<double> par_fit(6, 0.0);
212 int nToFit = hhh->GetEffectiveEntries();
222 h_tge_mean->SetPoint(iii, (iii + 1) * 20, par_fit[2]);
223 h_tge_mean->SetPointError(iii, 10, par_fit[3]);
225 h_tge_width->SetPoint(iii, (iii + 1) * 20, par_fit[4]);
226 h_tge_width->SetPointError(iii, 10, par_fit[5]);
233 std::vector<double>& fit_par)
237 float v_mean = hist->GetMean();
238 float v_rms = hist->GetRMS();
239 float v_norm = hist->GetEffectiveEntries() / v_rms;
240 float x_min = v_mean - 3 * v_rms;
241 float x_max = v_mean + 3 * v_rms;
249 f1->SetParameters(v_norm, v_mean, v_rms);
252 hist->Fit(
"f1",
"Q",
"", x_min, x_max);
255 if (hist->GetFunction(
"f1") == NULL) {
256 B2DEBUG(20,
"Fit failed");
261 if (f1->GetParameter(2) <= 0) {
262 B2DEBUG(20,
"Fit failed");
267 fit_par[0] = f1->GetParameter(0);
268 fit_par[1] = f1->GetParError(0);
269 fit_par[2] = f1->GetParameter(1);
270 fit_par[3] = f1->GetParError(1);
271 fit_par[4] = f1->GetParameter(2);
272 fit_par[5] = f1->GetParError(2);
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).
void UpdateCanvas(std::string name, bool updated=true)
Mark canvas as updated (or not)
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
~DQMHistAnalysisTRGECLModule()
Destructor.
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.