48 const double residual = (*resiter)[
kResidual];
52 if (fabs(residual) < 0.1) {
54 sum_xx += residual * residual;
63 double mean = sum_x / double(N);
64 double stdev =
sqrt(sum_xx /
double(N) -
pow(sum_x /
double(N), 2));
71 const double residual = (*resiter)[
kResidual];
72 if (mean - 1.5 * stdev < residual && residual < mean + 1.5 * stdev) {
74 sum_xx += residual * residual;
78 mean = sum_x / double(N);
79 stdev =
sqrt(sum_xx /
double(N) -
pow(sum_x /
double(N), 2));
85 const double residual = (*resiter)[
kResidual];
86 if (mean - 1.5 * stdev < residual && residual < mean + 1.5 * stdev) {
88 sum_xx += residual * residual;
92 mean = sum_x / double(N);
93 stdev =
sqrt(sum_xx /
double(N) -
pow(sum_x /
double(N), 2));
95 std::vector<int> parNum;
96 std::vector<std::string> parName;
97 std::vector<double>
start;
98 std::vector<double>
step;
99 std::vector<double>
low;
100 std::vector<double>
high;
104 start.push_back(mean);
122 start.push_back(stdev);
123 step.push_back(0.1 * stdev);
129 start.push_back(stdev);
130 step.push_back(0.1 * stdev);
139 std::stringstream raw_name, narrowed_name, xcontrol_name, ycontrol_name;
140 raw_name << name <<
"_raw";
141 narrowed_name << name <<
"_narrowed";
142 xcontrol_name << name <<
"_xcontrol";
143 ycontrol_name << name <<
"_ycontrol";
146 dir->
make<TH1F>(raw_name.str().c_str(), (raw_name.str() +
std::string(
" (mrad)")).c_str(), 100, -100., 100.);
147 TH1F *narrowed_hist = dir->
make<TH1F>(
148 narrowed_name.str().c_str(), (narrowed_name.str() +
std::string(
" (mrad)")).c_str(), 100, -100., 100.);
149 TProfile *xcontrol_hist = dir->
make<TProfile>(
150 xcontrol_name.str().c_str(), (xcontrol_name.str() +
std::string(
" (mrad)")).c_str(), 100, -1., 1.);
151 TProfile *ycontrol_hist = dir->
make<TProfile>(
152 ycontrol_name.str().c_str(), (ycontrol_name.str() +
std::string(
" (mrad)")).c_str(), 100, -1., 1.);
154 narrowed_name <<
"fit";
155 xcontrol_name <<
"fit";
156 ycontrol_name <<
"fit";
158 double scale_factor = double(
numResiduals()) * (100. - -100.) / 100;
160 TF1 *narrowed_fit =
nullptr;
164 narrowed_fit->Write();
168 narrowed_fit->Write();
172 narrowed_fit->Write();
176 narrowed_fit->Write();
179 TF1 *xcontrol_fit =
new TF1(xcontrol_name.str().c_str(),
"[0]+x*[1]", -1., 1.);
181 xcontrol_fit->Write();
183 TF1 *ycontrol_fit =
new TF1(ycontrol_name.str().c_str(),
"[0]+x*[1]", -1., 1.);
185 ycontrol_fit->Write();
188 const double raw_residual = (*resiter)[
kResidual];
189 const double xangle = (*resiter)[
kXAngle];
190 const double yangle = (*resiter)[
kYAngle];
194 double corrected_residual = raw_residual - xangle_correction - yangle_correction;
196 raw_hist->Fill(raw_residual * 1000.);
197 narrowed_hist->Fill(corrected_residual * 1000.);
199 xcontrol_hist->Fill(xangle, (raw_residual - yangle_correction) * 1000.);
200 ycontrol_hist->Fill(yangle, (raw_residual - xangle_correction) * 1000.);
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
MuonResidualsFitter * fitter()
int residualsModel() const
double plot(std::string name, TFileDirectory *dir, Alignable *ali) override
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)
bool fit(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)
std::vector< double * >::const_iterator residuals_end() const
void MuonResidualsAngleFitter_FCN(int &npar, double *gin, double &fval, double *par, int iflag)
void inform(TMinuit *tMinuit) override
Double_t MuonResidualsFitter_ROOTVoigt_TF1(Double_t *xvec, Double_t *par)
static TMinuit * MuonResidualsAngleFitter_TMinuit
int sum_x
More diagnostics.
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)
Power< A, B >::type pow(const A &a, const B &b)