38 else { assert(
false); }
50 const double residual = (*resiter)[
kResidual];
55 if (fabs(residual) < 10.) {
57 sum_xx += residual*residual;
65 double mean = sum_x/double(N);
66 double stdev =
sqrt(sum_xx/
double(N) -
pow(sum_x/
double(N), 2));
73 const double residual = (*resiter)[
kResidual];
74 if (mean - 1.5*stdev < residual && residual < mean + 1.5*stdev) {
76 sum_xx += residual*residual;
80 mean = sum_x/double(N);
81 stdev =
sqrt(sum_xx/
double(N) -
pow(sum_x/
double(N), 2));
87 const double residual = (*resiter)[
kResidual];
88 if (mean - 1.5*stdev < residual && residual < mean + 1.5*stdev) {
90 sum_xx += residual*residual;
94 mean = sum_x/double(N);
95 stdev =
sqrt(sum_xx/
double(N) -
pow(sum_x/
double(N), 2));
97 std::vector<int> parNum;
98 std::vector<std::string> parName;
99 std::vector<double>
start;
100 std::vector<double>
step;
101 std::vector<double> low;
102 std::vector<double> high;
104 parNum.push_back(
kPosition); parName.push_back(
std::string(
"position")); start.push_back(mean); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
105 parNum.push_back(
kZpos); parName.push_back(
std::string(
"zpos")); start.push_back(0.); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
106 parNum.push_back(
kPhiz); parName.push_back(
std::string(
"phiz")); start.push_back(0.); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
107 parNum.push_back(
kScattering); parName.push_back(
std::string(
"scattering")); start.push_back(0.); step.push_back(0.1*1000.); low.push_back(0.); high.push_back(0.);
108 parNum.push_back(
kSigma); parName.push_back(
std::string(
"sigma")); start.push_back(stdev); step.push_back(0.1*stdev); low.push_back(0.); high.push_back(0.);
110 parNum.push_back(
kGamma); parName.push_back(
std::string(
"gamma")); start.push_back(stdev); step.push_back(0.1*stdev); low.push_back(0.); high.push_back(0.);
117 std::stringstream raw_name, narrowed_name, angleerror_name, trackangle_name, trackposition_name;
118 raw_name << name <<
"_raw";
119 narrowed_name << name <<
"_narrowed";
120 angleerror_name << name <<
"_angleerror";
121 trackangle_name << name <<
"_trackangle";
122 trackposition_name << name <<
"_trackposition";
124 TH1F *raw_hist = dir->
make<TH1F>(raw_name.str().c_str(), (raw_name.str() +
std::string(
" (mm)")).c_str(), 100, -100., 100.);
125 TH1F *narrowed_hist = dir->
make<TH1F>(narrowed_name.str().c_str(), (narrowed_name.str() +
std::string(
" (mm)")).c_str(), 100, -100., 100.);
126 TProfile *angleerror_hist = dir->
make<TProfile>(angleerror_name.str().c_str(), (angleerror_name.str() +
std::string(
" (mm)")).c_str(), 100, -30., 30.);
127 TProfile *trackangle_hist = dir->
make<TProfile>(trackangle_name.str().c_str(), (trackangle_name.str() +
std::string(
" (mm)")).c_str(), 100, -0.5, 0.5);
128 TProfile *trackposition_hist = dir->
make<TProfile>(trackposition_name.str().c_str(), (trackposition_name.str() +
std::string(
" (mm)")).c_str(), 100, -300., 300.);
130 angleerror_hist->SetAxisRange(-100., 100.,
"Y");
131 trackangle_hist->SetAxisRange(-10., 10.,
"Y");
132 trackposition_hist->SetAxisRange(-10., 10.,
"Y");
134 narrowed_name <<
"fit";
135 angleerror_name <<
"fit";
136 trackangle_name <<
"fit";
137 trackposition_name <<
"fit";
139 double scale_factor = double(
numResiduals()) * (100. - -100.)/100;
141 TF1 *narrowed_fit =
nullptr;
145 narrowed_fit->Write();
150 narrowed_fit->Write();
155 narrowed_fit->Write();
160 narrowed_fit->Write();
163 TF1 *angleerror_fit =
new TF1(angleerror_name.str().c_str(),
"[0]+x*[1]", -30., 30.);
165 angleerror_fit->Write();
167 TF1 *trackangle_fit =
new TF1(trackangle_name.str().c_str(),
"[0]+x*[1]", -0.5, 0.5);
169 trackangle_fit->Write();
171 TF1 *trackposition_fit =
new TF1(trackposition_name.str().c_str(),
"[0]+x*[1]", -300., 300.);
173 trackposition_fit->Write();
176 const double raw_residual = (*resiter)[
kResidual];
182 double trackangle_correction =
value(
kZpos) * trackangle;
183 double trackposition_correction =
value(
kPhiz) * trackposition;
185 double corrected_residual = raw_residual - angleerror_correction - trackangle_correction - trackposition_correction;
187 raw_hist->Fill(raw_residual * 10.);
188 narrowed_hist->Fill(corrected_residual * 10.);
190 angleerror_hist->Fill(angleerror*1000., (raw_residual - trackangle_correction - trackposition_correction) * 10.);
191 trackangle_hist->Fill(trackangle, (raw_residual - angleerror_correction - trackposition_correction) * 10.);
192 trackposition_hist->Fill(trackposition, (raw_residual - angleerror_correction - trackangle_correction) * 10.);
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
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)
std::vector< double * >::const_iterator residuals_end() const
void inform(TMinuit *tMinuit) override
Double_t MuonResidualsFitter_ROOTVoigt_TF1(Double_t *xvec, Double_t *par)
std::vector< double * >::const_iterator residuals_begin() const
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)