42 else { assert(
false); }
55 if (TMath::Prob(redchi2*8, 8) < 0.99) {
72 double resid_sum = 0.;
73 double resid_sum2 = 0.;
80 double weight = 1./redchi2;
84 if (fabs(residual) < 10.) {
85 resid_sum += weight * residual;
86 resid_sum2 += weight * residual * residual;
93 double resid_mean = resid_sum/resid_N;
94 double resid_stdev =
sqrt(resid_sum2/resid_N -
pow(resid_sum/resid_N, 2));
103 double weight = 1./redchi2;
107 if (fabs(residual - resid_mean) < 2.5*resid_stdev) {
108 resid_sum += weight * residual;
109 resid_sum2 += weight * residual * residual;
115 resid_mean = resid_sum/resid_N;
116 resid_stdev =
sqrt(resid_sum2/resid_N -
pow(resid_sum/resid_N, 2));
118 std::vector<int>
num;
119 std::vector<std::string>
name;
120 std::vector<double>
start;
121 std::vector<double>
step;
122 std::vector<double> low;
123 std::vector<double> high;
126 num.push_back(
kAlign); name.push_back(
std::string(
"Align")); start.push_back(0.); step.push_back(0.01*resid_stdev); low.push_back(0.); high.push_back(0.);
128 num.push_back(
kAlign); name.push_back(
std::string(
"Align")); start.push_back(resid_mean); step.push_back(0.01*resid_stdev); low.push_back(0.); high.push_back(0.);
130 num.push_back(
kSigma); name.push_back(
std::string(
"Sigma")); start.push_back(resid_stdev); step.push_back(0.01*resid_stdev); low.push_back(0.); high.push_back(0.);
132 num.push_back(
kGamma); name.push_back(
std::string(
"Gamma")); start.push_back(0.1*resid_stdev); step.push_back(0.01*resid_stdev); low.push_back(0.); high.push_back(0.);
141 std::stringstream name_residual, name_residual_raw;
142 name_residual << name <<
"_residual";
143 name_residual_raw << name <<
"_residual_raw";
145 double min_residual = -100.;
double max_residual = 100.;
146 TH1F *hist_residual = dir->
make<TH1F>(name_residual.str().c_str(),
"", 100, min_residual, max_residual);
147 TH1F *hist_residual_raw = dir->
make<TH1F>(name_residual_raw.str().c_str(),
"", 100, min_residual, max_residual);
149 name_residual <<
"_fit";
150 TF1 *fit_residual =
nullptr;
167 else { assert(
false); }
169 fit_residual->SetLineColor(2); fit_residual->SetLineWidth(2);
170 fit_residual->Write();
175 double weight = 1./redchi2;
179 hist_residual->Fill(10.*(resid +
value(
kAlign)), weight);
182 hist_residual_raw->Fill(10.*resid);
187 for (
int i = 1;
i <= hist_residual->GetNbinsX();
i++) {
188 double xi = hist_residual->GetBinCenter(
i);
189 double yi = hist_residual->GetBinContent(
i);
190 double yerri = hist_residual->GetBinError(
i);
191 double yth = fit_residual->Eval(xi);
193 chi2 +=
pow((yth - yi)/yerri, 2);
199 return (ndof > 0. ? chi2 / ndof : -1.);
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
Double_t MuonResidualsFitter_powerLawTails_TF1(Double_t *xvec, Double_t *par)
static double MuonResiduals1DOFFitter_number_of_hits
MuonResidualsFitter * fitter()
int residualsModel() const
bool dofit(void(*fcn)(int &, double *, double &, double *, int), std::vector< int > &parNum, std::vector< std::string > &parName, std::vector< double > &start, std::vector< double > &step, std::vector< double > &low, std::vector< double > &high)
double MuonResidualsFitter_logROOTVoigt(double residual, double center, double sigma, double gamma)
static TMinuit * MuonResiduals1DOFFitter_TMinuit
bool fit(Alignable *ali) override
double MuonResidualsFitter_logPowerLawTails(double residual, double center, double sigma, double gamma)
static bool MuonResiduals1DOFFitter_weightAlignment
Double_t MuonResidualsFitter_GaussPowerTails_TF1(Double_t *xvec, Double_t *par)
T * make(const Args &...args) const
make new ROOT object
static double MuonResiduals1DOFFitter_sum_of_weights
Double_t MuonResidualsFitter_pureGaussian_TF1(Double_t *xvec, Double_t *par)
double plot(std::string name, TFileDirectory *dir, Alignable *ali) override
std::vector< double * >::const_iterator residuals_end() const
double sumofweights() override
Double_t MuonResidualsFitter_ROOTVoigt_TF1(Double_t *xvec, Double_t *par)
std::vector< double * >::const_iterator residuals_begin() const
void MuonResiduals1DOFFitter_FCN(int &npar, double *gin, double &fval, double *par, int iflag)
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)
Power< A, B >::type pow(const A &a, const B &b)
void inform(TMinuit *tMinuit) override