19 if (condpass1 && !condpass2) {
22 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::fit] lex_.size()!=hits_.size() ALARM! Please inform CSC DPG " 30 CSCSetOfHits::const_iterator ih =
hits_.begin();
32 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
47 if (condpass1 && !condpass2) {
50 IC(0, 0) =
hit.localPositionError().xx();
52 IC(1, 1) =
hit.localPositionError().yy();
55 IC(1, 0) =
hit.localPositionError().xy();
64 bool ok = IC.Invert();
66 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::fit] Failed to invert covariance matrix: \n" << IC;
72 M(0, 2) += IC(0, 0) *
z;
73 M(0, 3) += IC(0, 1) *
z;
74 B(0) += u * IC(0, 0) +
v * IC(0, 1);
78 M(1, 2) += IC(1, 0) *
z;
79 M(1, 3) += IC(1, 1) *
z;
80 B(1) += u * IC(1, 0) +
v * IC(1, 1);
82 M(2, 0) += IC(0, 0) *
z;
83 M(2, 1) += IC(0, 1) *
z;
84 M(2, 2) += IC(0, 0) *
z *
z;
85 M(2, 3) += IC(0, 1) *
z *
z;
86 B(2) += (u * IC(0, 0) +
v * IC(0, 1)) *
z;
88 M(3, 0) += IC(1, 0) *
z;
89 M(3, 1) += IC(1, 1) *
z;
90 M(3, 2) += IC(1, 0) *
z *
z;
91 M(3, 3) += IC(1, 1) *
z *
z;
92 B(3) += (u * IC(1, 0) +
v * IC(1, 1)) *
z;
98 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::fit] Failed to invert matrix: \n" << M;
122 CSCSetOfHits::const_iterator ih;
123 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
140 if (condpass1 && !condpass2) {
143 IC(0, 0) =
hit.localPositionError().xx();
146 IC(1, 0) =
hit.localPositionError().xy();
147 IC(1, 1) =
hit.localPositionError().yy();
158 bool ok = IC.Invert();
160 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::setChi2] Failed to invert covariance matrix: \n" << IC;
164 chsq += du * du * IC(0, 0) + 2. * du * dv * IC(0, 1) + dv * dv * IC(1, 1);
175 std::vector<double> uu, vv,
zz;
179 double sum_U_err = 0.0;
180 double sum_Z_U_err = 0.0;
181 double sum_Z2_U_err = 0.0;
182 double sum_U_U_err = 0.0;
183 double sum_UZ_U_err = 0.0;
184 std::vector<double> chiUZind;
185 std::vector<double>::iterator chiContribution;
187 CSCSetOfHits::const_iterator ih =
hits_.begin();
188 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
190 lex_.push_back(
hit.localPositionError().xx());
203 sum_U_err += 1. /
lex_.back();
204 sum_Z_U_err +=
z /
lex_.back();
205 sum_Z2_U_err += (
z *
z) /
lex_.back();
206 sum_U_U_err += u /
lex_.back();
207 sum_UZ_U_err += (u *
z) /
lex_.back();
213 double denom = sum_U_err * sum_Z2_U_err -
pow(sum_Z_U_err, 2);
214 double U0 = (sum_Z2_U_err * sum_U_U_err - sum_Z_U_err * sum_UZ_U_err) /
denom;
215 double UZ = (sum_U_err * sum_UZ_U_err - sum_Z_U_err * sum_U_U_err) /
denom;
220 for (
unsigned i = 0;
i < uu.size(); ++
i) {
221 double uMean = U0 + UZ *
zz[
i];
222 chiUZind.push_back((
pow((uMean - uu[
i]), 2)) /
lex_[
i]);
223 chiUZ += (
pow((uMean - uu[
i]), 2)) /
lex_[
i];
225 chiUZ = chiUZ / (uu.size() - 2);
228 double chi2uCorrection = chiUZ /
chi2Norm_;
229 for (
unsigned i = 0;
i < uu.size(); ++
i)
235 chiContribution = max_element(chiUZind.begin(), chiUZind.end());
236 worstHit_ = chiContribution - chiUZind.begin();
241 double condNumberCorr2 = 0.0;
245 double IC_01_corr = 0.0;
246 double IC_00_corr = 0.0;
250 diag1 = IC(0, 0) * IC(1, 1);
251 diag2 = IC(0, 1) * IC(0, 1);
252 detCov = fabs(diag1 - diag2);
253 if ((diag1 < condNumberCorr2) && (diag2 < condNumberCorr2)) {
257 IC_00_corr =
condSeed1_ + fabs(IC(0, 1)) / IC(1, 1);
258 IC(0, 0) = IC_00_corr;
262 if (((detCov < condNumberCorr2) && (diag1 > condNumberCorr2)) ||
263 ((diag2 > condNumberCorr2) && (detCov < condNumberCorr2))) {
267 IC_01_corr =
sqrt(fabs(diag1 - condNumberCorr2));
269 IC(0, 1) = (-1) * IC_01_corr;
271 IC(0, 1) = IC_01_corr;
void correctTheCovX(void)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Point3DBase< Scalar, LocalTag > LocalPoint
void correctTheCovMatrix(CSCSegFit::SMatrixSym2 &IC)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
ROOT::Math::SVector< double, 4 > SVector4
std::vector< double > lex_
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > SMatrixSym2
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
bool covToAnyNumber_
The correction parameters.
const CSCChamber * chamber() const
double covAnyNumber_
Allow to use any number for covariance for all RecHits.
bool covToAnyNumberAll_
Allow to use any number for covariance (by hand)
ROOT::Math::SMatrix< double, 4 > SMatrix4
void setScaleXError(double factor)
Power< A, B >::type pow(const A &a, const B &b)