87 {
89
91
92 T0MTSettings t0_setting;
94
98 T0MTHistos drift_time_spec;
99
100 std::array<T0MTHistos, 2> drift_time_spec_ml;
101
103 int k_min(-1);
104
105 unsigned int nb_bins(100);
106 double bin_content;
107 std::vector<SamplePoint> point(nb_bins + 1);
109 double scf = 0.;
110 RtFromPoints rt_from_points;
111
113
115
118 log << MSG::WARNING <<
"analyse() - Less than 2000 drift-time entries! No r-t relationship will be determined!" <<
endmsg;
119 return false;
120 }
121
123
125
126
128
129
130
132 float min_t =
m_t_drift[0].first - 100.0;
134 std::unique_ptr<TH1F> tspec = std::make_unique<TH1F>("tspec", "DRIFT-TIME SPECTRUM", n_bins, min_t, max_t);
135 std::array<std::unique_ptr<TH1F>, 2> tspec_ml;
136 tspec_ml[0] = std::make_unique<TH1F>("tspec_ml0", "DRIFT-TIME SPECTRUM ML 0", n_bins, min_t, max_t);
137 tspec_ml[1] = std::make_unique<TH1F>("tspec_ml1", "DRIFT-TIME SPECTRUM ML 1", n_bins, min_t, max_t);
138
140 tspec->Fill(
k.first, 1.0);
141 tspec_ml[
static_cast<unsigned int>(
k.second)]->Fill(
k.first, 1.0);
142 }
143
144 auto n0 = tspec_ml[0]->GetEntries();
145 auto n1 = tspec_ml[1]->GetEntries();
146
147
148 tspec->SetDirectory(nullptr);
149 for (auto& hist : tspec_ml) {
150 hist->SetDirectory(
nullptr);
151 }
152 drift_time_spec.
SetTSpec(1, tspec.release(), &t0_setting,
false);
153 drift_time_spec_ml[0].SetTSpec(2, tspec_ml[0].
release(), &t0_setting,
false);
154 drift_time_spec_ml[1].SetTSpec(3, tspec_ml[1].
release(), &t0_setting,
false);
155
156
157
158 if (!drift_time_spec.
FitT0() || !drift_time_spec.
T0Ok()) {
160 log << MSG::WARNING <<
"analyse() - t0 fit not successful, no r-t relationship will be calculated!" <<
endmsg;
161 return false;
162 }
164
165 if (!drift_time_spec.
FitTmax() || !drift_time_spec.
TmaxOk()) {
167 log << MSG::WARNING <<
"analyse() - tmax fit not successful, no r-t relationship will be calculated!" <<
endmsg;
168 return false;
169 }
172
173
175 for (
unsigned int k = 0;
k <
m_t_drift.size();
k++) {
177 if (k_min < 0 &&
m_t_drift[k].first >=
t0) { k_min =
k; }
178 }
179
180
181 bin_content =
static_cast<double>(
m_nb_hits_used) /
static_cast<double>(nb_bins);
182
184
186 point[0].set_x2(0.0);
187 point[0].set_error(0.1);
188
189
190 for (
unsigned int k = 1;
k < nb_bins;
k++) {
192 point[
k].set_x1(
m_t_drift[k_min +
static_cast<int>(bin_content) * (k)].first);
193 point[
k].set_x2(radius);
194 point[
k].set_error(1.0);
195 }
196
197 point[nb_bins].set_x1(tmax);
198 point[nb_bins].set_x2(
m_r_max);
199 point[nb_bins].set_error(1.);
200
201
203
205
207 std::vector<SamplePoint> add_fit_point;
208 add_fit_point.push_back(SamplePoint(tmax,
m_r_max, 1.0));
209 RtParabolicExtrapolation rt_extrapolated;
210
211 auto rt_new = std::make_shared<RtRelationLookUp>(
217 add_fit_point
218 )
219 );
220
222
224
225 if (n0 >= 10000 && n1> 10000) {
226 bool fit_ok(true);
227 std::array<float, 2>
b{}, tmax{},
T{};
228 for (
unsigned int i = 0;
i < 2;
i++) {
229 if (!drift_time_spec_ml[i].FitT0()) {
230 fit_ok = false;
231 break;
232 }
233 if (!drift_time_spec_ml[i].FitTmax()) {
234 fit_ok = false;
235 break;
236 }
241 }
242 if (fit_ok) {
243 int refit =
static_cast<int>((
b[1] + 1.33717e-03) > (
b[0] + 1.33717e-03));
244 int norefit = static_cast<bool>(refit) ? 0 : 1;
245 TF1 *fixfun = drift_time_spec_ml[refit].GetTMaxFunctionNC();
248 TList *
l = drift_time_spec_ml[refit].GetTSpec()->GetListOfFunctions();
249 l->Remove(
l->FindObject(
"mt_tmax_fermi"));
250 fit_ok = drift_time_spec_ml[refit].FitTmax();
253 }
254
256 }
257
259
261
262 m_output = std::make_unique<RtCalibrationOutput>(
263 rt_new, std::make_shared<RtFullInfo>(
"RtCalibrationIntegration", 1,
m_nb_segments_used, 0.0, 0.0, 0.0, 0.0));
264
265 return true;
266}
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void update_parameter_on_mttmax(TH1 *h, TF1 *f, const float &b, const float &T, const T0MTSettingsTMax &tmax_settings)
unsigned int m_nb_hits_used
std::shared_ptr< IRtRelation > m_rt
unsigned int m_nb_segments_used
double m_lower_extrapolation_radius
sets the lower radius to perform the
double m_upper_extrapolation_radius
parabolic extrapolation.
bool m_add_tmax_difference
std::shared_ptr< RtCalibrationOutput > m_output
std::vector< std::pair< double, bool > > m_t_drift
static std::unique_ptr< IRtRelation > getRtChebyshev(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of r-t data points into a r(t) relation expressed as a series of chebychev polynomial...
static constexpr int T0_PAR_NR_T0
parameter numbers in t0 fit
static constexpr int TMAX_PAR_NR_TMAX
parameters numbers for tmax fit
bool T0Ok() const
returns true if t0-fit was successfull
static constexpr int TMAX_PAR_NR_T
static constexpr int TMAX_PAR_NR_B
bool FitT0()
Perform t0-fit Returns true if fit is successfull.
bool FitTmax()
Performs tmax-fit Returns true if fit is successfull.
void SetTSpec(int id, TH1F *spec, const T0MTSettings *settings, bool copy_spec=true)
set the pointer of the drift-time spectrum to an existing spectrum.
const TF1 * GetT0Function() const
returns function fitted to the riding edge of the spectrum
bool TmaxOk() const
returns true if tmax-fir was successfull
const TF1 * GetTMaxFunction() const
returns function fitted to the riding edge of the spectrum
double SlicingThreshold() const
the chi2 threshold at which the slicing method is used
double ScrambleThreshold() const
the chi2 threshold at which the scrambling method is used
double DistAB() const
Distance of the a/b region from the detected falling edge.
const bool & AddFitfun() const
If set to true the fitted functions are added to the histograms.
const T0MTSettingsT0 * T0Settings() const
get settings for the t0-fit
const T0MTSettingsTMax * TMaxSettings() const
get settings for the tmax-fit
static std::string release
IMessageSvc * getMessageSvc(bool quiet=false)
size_t n_bins(const regular_axis_t &r)
l
Printing final latex table to .tex output file.