10 #include "TVirtualFitter.h"
11 #include "TFitResultPtr.h"
12 #include "TFitResult.h"
17 #include "Math/MinimizerOptions.h"
32 <<
" NULL pointer to base Analysis object!";
37 cal_ = dynamic_cast<CalibrationAnalysis*>(
tmp);
41 <<
" NULL pointer to derived Analysis object!";
51 std::vector<TH1*>::const_iterator ihis =
histos.begin();
53 for (; ihis !=
histos.end(); ihis++, cnt++) {
67 std::vector<std::string> tokens;
69 std::istringstream tokenStream(
title.extraInfo());
70 while (std::getline(tokenStream,
token,
'_')) {
71 tokens.push_back(
token);
76 histo_temp.first = *ihis;
77 histo_temp.second = (*ihis)->GetTitle();
78 histo_temp.first->Sumw2();
79 histo_.push_back(histo_temp);
81 stripId_.push_back(std::stoi(tokens.at(1)) * 16 + std::stoi(tokens.at(3)));
82 calChan_.push_back(std::stoi(tokens.at(1)));
89 ROOT::Math::MinimizerOptions::SetDefaultMinimizer(
"Minuit2",
"Migrad");
90 ROOT::Math::MinimizerOptions::SetDefaultStrategy(0);
94 <<
" NULL pointer to derived Analysis object!";
98 float Amean[2] = {-1., -1.};
99 float Amin[2] = {-1., -1.};
100 float Amax[2] = {-1., -1.};
101 float Aspread[2] = {-1., -1.};
102 float Tmean[2] = {-1., -1.};
103 float Tmin[2] = {-1., -1.};
104 float Tmax[2] = {-1., -1.};
105 float Tspread[2] = {-1., -1.};
106 float Rmean[2] = {-1., -1.};
107 float Rmin[2] = {-1., -1.};
108 float Rmax[2] = {-1., -1.};
109 float Rspread[2] = {-1., -1.};
110 float Cmean[2] = {-1., -1.};
111 float Cmin[2] = {-1., -1.};
112 float Cmax[2] = {-1., -1.};
113 float Cspread[2] = {-1., -1.};
114 float Smean[2] = {-1., -1.};
115 float Smin[2] = {-1., -1.};
116 float Smax[2] = {-1., -1.};
117 float Sspread[2] = {-1., -1.};
118 float Kmean[2] = {-1., -1.};
119 float Kmin[2] = {-1., -1.};
120 float Kmax[2] = {-1., -1.};
121 float Kspread[2] = {-1., -1.};
123 float Omean[2] = {-1., -1.};
124 float Omin[2] = {-1., -1.};
125 float Omax[2] = {-1., -1.};
126 float Ospread[2] = {-1., -1.};
128 float Mmean[2] = {-1., -1.};
129 float Mmin[2] = {-1., -1.};
130 float Mmax[2] = {-1., -1.};
131 float Mspread[2] = {-1., -1.};
133 float Umean[2] = {-1., -1.};
134 float Umin[2] = {-1., -1.};
135 float Umax[2] = {-1., -1.};
136 float Uspread[2] = {-1., -1.};
138 float Bmean[2] = {-1., -1.};
139 float Bmin[2] = {-1., -1.};
140 float Bmax[2] = {-1., -1.};
141 float Bspread[2] = {-1., -1.};
144 TFitResultPtr fit_result;
145 TF1* fit_function =
nullptr;
147 fit_function =
new TF1(
"fit_function_deco",
fdeconv, 0, 400, 7);
148 fit_function->SetParameters(4, 25, 25, 50, 250, 25, 0.75);
150 fit_function =
new TF1(
"fit_function_peak",
fpeak, 0, 400, 6);
151 fit_function->SetParameters(4, 50, 50, 70, 250, 20);
155 std::vector<unsigned int>
nStrips(2, 0.);
157 for (
size_t ihist = 0; ihist <
histo_.size(); ihist++) {
184 float error =
histo_[ihist].first->GetMaximum() * 0.05;
185 for (
int i = 1;
i <=
histo_[ihist].first->GetNbinsX(); ++
i)
190 fit_function->SetParameters(10, 15, 30, 10, 350, 50, 0.75);
192 fit_function->SetParameters(6, 40, 40, 70, 350, 20);
194 fit_result =
histo_[ihist].first->Fit(fit_function,
"QS");
197 if (not fit_result.Get())
200 float maximum_ampl = fit_function->GetMaximum();
201 float peak_time = fit_function->GetMaximumX();
202 float baseline =
baseLine(fit_function);
203 float turn_on_time =
turnOn(fit_function, baseline);
204 float rise_time = peak_time - turn_on_time;
213 if (
cal_->
deconv_ and fit_function->GetMinimumX() > peak_time)
215 100 * (fit_function->GetMinimum() - baseline) / (maximum_ampl - baseline);
220 int lastBin =
histo_[ihist].first->FindBin(peak_time + 125);
221 if (lastBin >
histo_[ihist].
first->GetNbinsX() - 4)
226 100 * (
histo_[ihist].first->GetBinContent(lastBin) - baseline) / (maximum_ampl - baseline);
232 fit_function->GetChisquare() / (
histo_[ihist].first->GetNbinsX() - fit_function->GetNpar());
267 if (fit_function->GetMinimumX() < peak_time)
417 for (
int i = 0;
i < 2;
i++) {
444 for (
int i = 0;
i < 2; ++
i) {
497 for (
int iBin = 0; iBin <
histo->GetNbinsX(); iBin++) {
498 histo->SetBinContent(iBin + 1, -
histo->GetBinContent(iBin + 1) / 20.);
507 float x =
f->GetXmin();
508 for (;
x <
xmax;
x += 0.1) {
509 baseline +=
f->Eval(
x);
517 const float& baseline) {
518 float max_amplitude =
f->GetMaximum();
520 for (;
time < 100 && (
f->Eval(
time) - baseline) < 0.05 * (max_amplitude - baseline);
time += 0.1) {
528 float xval =
f->GetMaximumX();
529 float max_amplitude =
f->GetMaximum();
531 for (;
x < 1000;
x =
x + 0.1) {
532 if (
f->Eval(
x) < max_amplitude *
exp(-1))