12#include "GaudiKernel/MsgStream.h"
25 Double_t &
a(par[0]), &b(par[1]), &t_0(par[2]), &back(par[3]);
26 return back + std::exp(
a + b * (t - t_0));
31 f->GetRange(rmin, rmax);
32 std::unique_ptr<TF1> slope_function =
35 slope_function->FixParameter(1, b);
38 h->Fit(
"slope_function",
"R+",
"");
44 bool add_tmax_difference) {
72 if (seg.
mdtHOT()[k]->driftTime() < -8e8)
continue;
73 m_t_drift.push_back(std::pair<double, bool>(seg.
mdtHOT()[k]->driftTime(), seg.
mdtHOT()[k]->identify().mdtMultilayer() == 2));
79 m_t_drift.push_back(std::pair<double, bool>(seg.
mdtHOT()[k]->driftTime(), seg.
mdtHOT()[k]->identify().mdtMultilayer() == 2));
100 std::array<T0MTHistos, 2> drift_time_spec_ml;
105 unsigned int nb_bins(100);
107 std::vector<SamplePoint> point(nb_bins + 1);
118 log << MSG::WARNING <<
"analyse() - Less than 2000 drift-time entries! No r-t relationship will be determined!" <<
endmsg;
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);
140 tspec->Fill(k.first, 1.0);
141 tspec_ml[
static_cast<unsigned int>(k.second)]->Fill(k.first, 1.0);
143 drift_time_spec.
SetTSpec(1, tspec.get(), &t0_setting,
false);
144 drift_time_spec_ml[0].SetTSpec(2, tspec_ml[0].
get(), &t0_setting,
false);
145 drift_time_spec_ml[1].SetTSpec(3, tspec_ml[1].
get(), &t0_setting,
false);
149 if (!drift_time_spec.
FitT0() || !drift_time_spec.
T0Ok()) {
151 log << MSG::WARNING <<
"analyse() - t0 fit not successful, no r-t relationship will be calculated!" <<
endmsg;
156 if (!drift_time_spec.
FitTmax() || !drift_time_spec.
TmaxOk()) {
158 log << MSG::WARNING <<
"analyse() - tmax fit not successful, no r-t relationship will be calculated!" <<
endmsg;
166 for (
unsigned int k = 0; k <
m_t_drift.size(); k++) {
168 if (k_min < 0 &&
m_t_drift[k].first >=
t0) { k_min = k; }
172 bin_content =
static_cast<double>(
m_nb_hits_used) /
static_cast<double>(nb_bins);
177 point[0].set_x2(0.0);
178 point[0].set_error(0.1);
181 for (
unsigned int k = 1; k < nb_bins; k++) {
182 radius = radius + scf * bin_content;
183 point[k].set_x1(
m_t_drift[k_min +
static_cast<int>(bin_content) * (k)].first);
184 point[k].set_x2(radius);
185 point[k].set_error(1.0);
188 point[nb_bins].set_x1(tmax);
189 point[nb_bins].set_x2(
m_r_max);
190 point[nb_bins].set_error(1.);
198 std::vector<SamplePoint> add_fit_point;
203 std::shared_ptr<IRtRelation> rt_new = std::make_shared<RtRelationLookUp>(tmp_rt);
211 std::array<float, 2> b{}, tmax{}, T{};
212 for (
unsigned int i = 0; i < 2; i++) {
213 if (!drift_time_spec_ml[i].FitT0()) {
217 if (!drift_time_spec_ml[i].FitTmax()) {
227 int refit =
static_cast<int>((b[1] + 1.33717e-03) > (b[0] + 1.33717e-03));
228 int norefit =
static_cast<bool>(refit) ? 0 : 1;
229 TF1 *fixfun = drift_time_spec_ml[refit].GetTMaxFunctionNC();
232 TList *l = drift_time_spec_ml[refit].GetTSpec()->GetListOfFunctions();
233 l->Remove(l->FindObject(
"mt_tmax_fermi"));
234 fit_ok = drift_time_spec_ml[refit].FitTmax();
246 m_output = std::make_unique<RtCalibrationOutput>(
247 rt_new, std::make_shared<RtFullInfo>(
"RtCalibrationIntegration", 1,
m_nb_segments_used, 0.0, 0.0, 0.0, 0.0));
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Double_t slope_function_C(Double_t *x, Double_t *par)
void update_parameter_on_mttmax(TH1 *h, TF1 *f, const float &b, const float &T, const T0MTSettingsTMax &tmax_settings)
TGraphErrors * GetEntries(TH2F *histo)
Header file for AthHistogramAlgorithm.
Interface to pass calibration output during calibration.
std::shared_ptr< IMdtCalibrationOutput > MdtCalibOutputPtr
std::vector< std::shared_ptr< MuonCalibSegment > > MuonSegVec
A MuonCalibSegment is a reconstructed three dimensional track segment in the MuonSpectrometer.
unsigned int mdtHitsOnTrack() const
retrieve the number of MdtCalibHitBase s assigned to this segment
unsigned int mdtCloseHits() const
retrieve the number of nearby mdt hits.
const MdtHitVec & mdtHOT() const
retrieve the full set of MdtCalibHitBase s assigned to this segment
unsigned int m_nb_hits_used
std::shared_ptr< IRtRelation > m_rt
unsigned int m_nb_segments_used
MdtCalibOutputPtr analyseSegments(const MuonSegVec &seg) override
determine r(t)
double m_lower_extrapolation_radius
sets the lower radius to perform the
void setInput(const IMdtCalibrationOutput *rt_input) override
the method is empty as no initial r-t relationship is required by the algorithm
double m_upper_extrapolation_radius
parabolic extrapolation.
bool analyse()
perform the integration method
bool m_add_tmax_difference
bool converged() const
returns true, if the integration method has been performed
std::shared_ptr< RtCalibrationOutput > m_output
std::vector< std::pair< double, bool > > m_t_drift
bool handleSegment(MuonCalibSegment &seg)
analyse the segment "seg"
unsigned int number_of_hits_used() const
get the number of hits used in the r-t determination
void init(bool close_hits, double r_max, double lower_extrapolation_radius, double higher_extrapolation_radius, bool add_tmax_difference)
MdtCalibOutputPtr getResults() const override
returns the final r-t relationship
This class allows the user to retrieve an RtChebyshev or RtRelationLookUp object corresponding to a s...
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...
Equidistant look up table for rt-relations with the time as key.
This class provides a sample point for the BaseFunctionFitter.
Histogram and fitter class for drift time and pulsehight spectra The rising slope is fitted by a ferm...
static constexpr int T0_PAR_NR_T0
parameter numbers in t0 fit
static constexpr int TMAX_PAR_NR_TMAX
parameters numbers for tmax fit
static constexpr int TMAX_PAR_NR_T0
bool T0Ok() const
returns true if t0-fit was successfull
static constexpr int TMAX_PAR_NR_T
static constexpr int TMAX_PAR_NR_B
static constexpr int TMAX_PAR_NR_BACK
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
static constexpr int TMAX_PAR_NR_A
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.
double WidthAB() const
Width of the region in which the parameters a and b are estimated.
Settings for the T0 calibration (histogram booking and fitting parameters) Parameters for pattern rec...
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
singleton-like access to IMessageSvc via open function and helper
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.