37 else { assert(
false); }
49 const double residual = (*resiter)[
kResidual];
52 if (fabs(residual) < 0.1) {
54 sum_xx += residual*residual;
62 double mean = sum_x/double(N);
63 double stdev =
sqrt(sum_xx/
double(N) -
pow(sum_x/
double(N), 2));
70 const double residual = (*resiter)[
kResidual];
71 if (mean - 1.5*stdev < residual && residual < mean + 1.5*stdev) {
73 sum_xx += residual*residual;
77 mean = sum_x/double(N);
78 stdev =
sqrt(sum_xx/
double(N) -
pow(sum_x/
double(N), 2));
84 const double residual = (*resiter)[
kResidual];
85 if (mean - 1.5*stdev < residual && residual < mean + 1.5*stdev) {
87 sum_xx += residual*residual;
91 mean = sum_x/double(N);
92 stdev =
sqrt(sum_xx/
double(N) -
pow(sum_x/
double(N), 2));
94 std::vector<int> parNum;
95 std::vector<std::string> parName;
96 std::vector<double>
start;
97 std::vector<double>
step;
98 std::vector<double> low;
99 std::vector<double> high;
101 parNum.push_back(
kAngle); parName.push_back(
std::string(
"angle")); start.push_back(mean); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
102 parNum.push_back(
kBfrompt); parName.push_back(
std::string(
"bfrompt")); start.push_back(0.); step.push_back(0.1*stdev/0.05); low.push_back(0.); high.push_back(0.);
103 parNum.push_back(
kBfrompz); parName.push_back(
std::string(
"bfrompz")); start.push_back(0.); step.push_back(0.1*stdev/0.05); low.push_back(0.); high.push_back(0.);
104 parNum.push_back(
kdEdx); parName.push_back(
std::string(
"dEdx")); start.push_back(0.); step.push_back(0.1*stdev/0.05); low.push_back(0.); high.push_back(0.);
105 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.);
107 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.);
114 std::stringstream raw_name, narrowed_name, qoverpt_name, qoverpz_name, psquared_name;
115 raw_name << name <<
"_raw";
116 narrowed_name << name <<
"_narrowed";
117 qoverpt_name << name <<
"_qoverpt";
118 qoverpz_name << name <<
"_qoverpz";
119 psquared_name << name <<
"_psquared";
121 TH1F *raw_hist = dir->
make<TH1F>(raw_name.str().c_str(), (raw_name.str() +
std::string(
" (mrad)")).c_str(), 100, -100., 100.);
122 TH1F *narrowed_hist = dir->
make<TH1F>(narrowed_name.str().c_str(), (narrowed_name.str() +
std::string(
" (mrad)")).c_str(), 100, -100., 100.);
123 TProfile *qoverpt_hist = dir->
make<TProfile>(qoverpt_name.str().c_str(), (qoverpt_name.str() +
std::string(
" (mrad)")).c_str(), 100, -0.05, 0.05);
124 TProfile *qoverpz_hist = dir->
make<TProfile>(qoverpz_name.str().c_str(), (qoverpz_name.str() +
std::string(
" (mrad)")).c_str(), 100, -0.05, 0.05);
125 TProfile *psquared_hist = dir->
make<TProfile>(psquared_name.str().c_str(), (psquared_name.str() +
std::string(
" (mrad)")).c_str(), 100, -0.05, 0.05);
127 narrowed_name <<
"fit";
128 qoverpt_name <<
"fit";
129 qoverpz_name <<
"fit";
130 psquared_name <<
"fit";
132 double scale_factor = double(
numResiduals()) * (100. - -100.)/100;
134 TF1 *narrowed_fit =
nullptr;
138 narrowed_fit->Write();
143 narrowed_fit->Write();
148 narrowed_fit->Write();
153 narrowed_fit->Write();
156 TF1 *qoverpt_fit =
new TF1(qoverpt_name.str().c_str(),
"[0]+x*[1]", -0.05, 0.05);
158 qoverpt_fit->Write();
160 TF1 *qoverpz_fit =
new TF1(qoverpz_name.str().c_str(),
"[0]+x*[1]", -0.05, 0.05);
162 qoverpz_fit->Write();
164 TF1 *psquared_fit =
new TF1(psquared_name.str().c_str(),
"[0]+[1]*x**2", -0.05, 0.05);
166 psquared_fit->Write();
169 const double raw_residual = (*resiter)[
kResidual];
170 const double qoverpt = (*resiter)[
kQoverPt];
171 const double qoverpz = (*resiter)[
kQoverPz];
172 const double psquared = (1./qoverpt/qoverpt + 1./qoverpz/qoverpz) * (qoverpt > 0. ? 1. : -1.);
176 double dEdx_correction =
value(
kdEdx) * psquared;
177 double corrected_residual = raw_residual - qoverpt_correction - qoverpz_correction - dEdx_correction;
179 raw_hist->Fill(raw_residual * 1000.);
180 narrowed_hist->Fill(corrected_residual * 1000.);
182 qoverpt_hist->Fill(qoverpt, (raw_residual - qoverpz_correction - dEdx_correction) * 1000.);
183 qoverpz_hist->Fill(qoverpz, (raw_residual - qoverpt_correction - dEdx_correction) * 1000.);
184 psquared_hist->Fill(psquared, (raw_residual - qoverpt_correction - qoverpz_correction) * 1000.);
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
Double_t MuonResidualsFitter_powerLawTails_TF1(Double_t *xvec, Double_t *par)
long numResiduals() const
MuonResidualsFitter * fitter()
int residualsModel() const
bool fit(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)
void inform(TMinuit *tMinuit) override
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)
static TMinuit * MuonResidualsBfieldAngleFitter_TMinuit
std::vector< double * >::const_iterator residuals_end() const
Double_t MuonResidualsFitter_ROOTVoigt_TF1(Double_t *xvec, Double_t *par)
std::vector< double * >::const_iterator residuals_begin() const
void MuonResidualsBfieldAngleFitter_FCN(int &npar, double *gin, double &fval, double *par, int iflag)
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)