50 const double residual = (*resiter)[
kResidual];
55 if (fabs(residual) < 10.) {
57 sum_xx += residual * residual;
66 double mean = sum_x / double(N);
67 double stdev =
sqrt(sum_xx /
double(N) -
pow(sum_x /
double(N), 2));
74 const double residual = (*resiter)[
kResidual];
75 if (mean - 1.5 * stdev < residual && residual < mean + 1.5 * stdev) {
77 sum_xx += residual * residual;
81 mean = sum_x / double(N);
82 stdev =
sqrt(sum_xx /
double(N) -
pow(sum_x /
double(N), 2));
88 const double residual = (*resiter)[
kResidual];
89 if (mean - 1.5 * stdev < residual && residual < mean + 1.5 * stdev) {
91 sum_xx += residual * residual;
95 mean = sum_x / double(N);
96 stdev =
sqrt(sum_xx /
double(N) -
pow(sum_x /
double(N), 2));
98 std::vector<int> parNum;
99 std::vector<std::string> parName;
100 std::vector<double>
start;
101 std::vector<double>
step;
102 std::vector<double> low;
103 std::vector<double> high;
107 start.push_back(mean);
111 parNum.push_back(
kZpos);
117 parNum.push_back(
kPhiz);
126 step.push_back(0.1 * 1000.);
131 start.push_back(stdev);
132 step.push_back(0.1 * stdev);
138 start.push_back(stdev);
139 step.push_back(0.1 * stdev);
148 std::stringstream raw_name, narrowed_name, angleerror_name, trackangle_name, trackposition_name;
149 raw_name << name <<
"_raw";
150 narrowed_name << name <<
"_narrowed";
151 angleerror_name << name <<
"_angleerror";
152 trackangle_name << name <<
"_trackangle";
153 trackposition_name << name <<
"_trackposition";
156 dir->
make<TH1F>(raw_name.str().c_str(), (raw_name.str() +
std::string(
" (mm)")).c_str(), 100, -100., 100.);
157 TH1F *narrowed_hist = dir->
make<TH1F>(
158 narrowed_name.str().c_str(), (narrowed_name.str() +
std::string(
" (mm)")).c_str(), 100, -100., 100.);
159 TProfile *angleerror_hist = dir->
make<TProfile>(
160 angleerror_name.str().c_str(), (angleerror_name.str() +
std::string(
" (mm)")).c_str(), 100, -30., 30.);
161 TProfile *trackangle_hist = dir->
make<TProfile>(
162 trackangle_name.str().c_str(), (trackangle_name.str() +
std::string(
" (mm)")).c_str(), 100, -0.5, 0.5);
163 TProfile *trackposition_hist = dir->
make<TProfile>(
164 trackposition_name.str().c_str(), (trackposition_name.str() +
std::string(
" (mm)")).c_str(), 100, -300., 300.);
166 angleerror_hist->SetAxisRange(-100., 100.,
"Y");
167 trackangle_hist->SetAxisRange(-10., 10.,
"Y");
168 trackposition_hist->SetAxisRange(-10., 10.,
"Y");
170 narrowed_name <<
"fit";
171 angleerror_name <<
"fit";
172 trackangle_name <<
"fit";
173 trackposition_name <<
"fit";
175 double scale_factor = double(
numResiduals()) * (100. - -100.) / 100;
177 TF1 *narrowed_fit =
nullptr;
181 narrowed_fit->Write();
185 narrowed_fit->Write();
189 narrowed_fit->Write();
193 narrowed_fit->Write();
196 TF1 *angleerror_fit =
new TF1(angleerror_name.str().c_str(),
"[0]+x*[1]", -30., 30.);
198 angleerror_fit->Write();
200 TF1 *trackangle_fit =
new TF1(trackangle_name.str().c_str(),
"[0]+x*[1]", -0.5, 0.5);
202 trackangle_fit->Write();
204 TF1 *trackposition_fit =
new TF1(trackposition_name.str().c_str(),
"[0]+x*[1]", -300., 300.);
206 trackposition_fit->Write();
209 const double raw_residual = (*resiter)[
kResidual];
215 double trackangle_correction =
value(
kZpos) * trackangle;
216 double trackposition_correction =
value(
kPhiz) * trackposition;
218 double corrected_residual = raw_residual - angleerror_correction - trackangle_correction - trackposition_correction;
220 raw_hist->Fill(raw_residual * 10.);
221 narrowed_hist->Fill(corrected_residual * 10.);
223 angleerror_hist->Fill(angleerror * 1000., (raw_residual - trackangle_correction - trackposition_correction) * 10.);
224 trackangle_hist->Fill(trackangle, (raw_residual - angleerror_correction - trackposition_correction) * 10.);
225 trackposition_hist->Fill(trackposition, (raw_residual - angleerror_correction - trackangle_correction) * 10.);
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
std::vector< double * >::const_iterator residuals_begin() const
Double_t MuonResidualsFitter_powerLawTails_TF1(Double_t *xvec, Double_t *par)
long numResiduals() const
void MuonResidualsPositionFitter_FCN(int &npar, double *gin, double &fval, double *par, int iflag)
MuonResidualsFitter * fitter()
int residualsModel() const
static TMinuit * MuonResidualsPositionFitter_TMinuit
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)
double plot(std::string name, TFileDirectory *dir, Alignable *ali) override
double MuonResidualsFitter_logPowerLawTails(double residual, double center, double sigma, double gamma)
Double_t MuonResidualsFitter_GaussPowerTails_TF1(Double_t *xvec, Double_t *par)
T * make(const Args &...args) const
make new ROOT object
Double_t MuonResidualsFitter_pureGaussian_TF1(Double_t *xvec, Double_t *par)
void inform(TMinuit *tMinuit) override
std::vector< double * >::const_iterator residuals_end() const
Double_t MuonResidualsFitter_ROOTVoigt_TF1(Double_t *xvec, Double_t *par)
int sum_x
More diagnostics.
bool fit(Alignable *ali) override
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)
Power< A, B >::type pow(const A &a, const B &b)