20 if(condpass1 && !condpass2){
23 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::fit] lex_.size()!=hits_.size() ALARM! Please inform CSC DPG " << std::endl;
30 CSCSetOfHits::const_iterator ih =
hits_.begin();
32 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
47 if(condpass1 && !condpass2){
65 bool ok = IC.Invert();
67 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::fit] Failed to invert covariance matrix: \n" << IC;
73 M(0,2) += IC(0,0) *
z;
74 M(0,3) += IC(0,1) *
z;
75 B(0) += u * IC(0,0) + v * IC(0,1);
79 M(1,2) += IC(1,0) *
z;
80 M(1,3) += IC(1,1) *
z;
81 B(1) += u * IC(1,0) + v * IC(1,1);
83 M(2,0) += IC(0,0) *
z;
84 M(2,1) += IC(0,1) *
z;
85 M(2,2) += IC(0,0) * z *
z;
86 M(2,3) += IC(0,1) * z *
z;
87 B(2) += ( u * IC(0,0) + v * IC(0,1) ) * z;
89 M(3,0) += IC(1,0) *
z;
90 M(3,1) += IC(1,1) *
z;
91 M(3,2) += IC(1,0) * z *
z;
92 M(3,3) += IC(1,1) * z *
z;
93 B(3) += ( u * IC(1,0) + v * IC(1,1) ) * z;
100 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::fit] Failed to invert matrix: \n" << M;
119 setChi2( condpass1, condpass2 );
129 CSCSetOfHits::const_iterator ih;
130 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
148 if(condpass1 && !condpass2){
167 bool ok = IC.Invert();
169 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegFit::setChi2] Failed to invert covariance matrix: \n" << IC;
173 chsq += du*du*IC(0,0) + 2.*du*dv*IC(0,1) + dv*dv*IC(1,1);
187 std::vector<double> uu, vv,
zz;
191 double sum_U_err=0.0;
192 double sum_Z_U_err=0.0;
193 double sum_Z2_U_err=0.0;
194 double sum_U_U_err=0.0;
195 double sum_UZ_U_err=0.0;
196 std::vector<double> chiUZind;
197 std::vector<double>::iterator chiContribution;
199 CSCSetOfHits::const_iterator ih =
hits_.begin();
200 for (ih =
hits_.begin(); ih !=
hits_.end(); ++ih) {
215 sum_U_err += 1./
lex_.back();
216 sum_Z_U_err += z/
lex_.back();
217 sum_Z2_U_err += (z*
z)/
lex_.back();
218 sum_U_U_err += u/
lex_.back();
219 sum_UZ_U_err += (u*
z)/
lex_.back();
225 double denom=sum_U_err*sum_Z2_U_err-
pow(sum_Z_U_err,2);
226 double U0=(sum_Z2_U_err*sum_U_U_err-sum_Z_U_err*sum_UZ_U_err)/denom;
227 double UZ=(sum_U_err*sum_UZ_U_err-sum_Z_U_err*sum_U_U_err)/denom;
232 for(
unsigned i=0;
i<uu.size(); ++
i){
233 double uMean = U0+UZ*zz[
i];
234 chiUZind.push_back((
pow((uMean-uu[
i]),2))/
lex_[i]);
235 chiUZ += (
pow((uMean-uu[i]),2))/
lex_[i];
237 chiUZ = chiUZ/(uu.size()-2);
240 double chi2uCorrection = chiUZ/
chi2Norm_;
241 for(
unsigned i=0;
i<uu.size(); ++
i)
247 chiContribution=max_element(chiUZind.begin(),chiUZind.end());
248 worstHit_ = chiContribution - chiUZind.begin();
254 double condNumberCorr2=0.0;
258 double IC_01_corr=0.0;
259 double IC_00_corr=0.0;
263 diag1=IC(0,0)*IC(1,1);
264 diag2=IC(0,1)*IC(0,1);
265 detCov=fabs(diag1-diag2);
266 if((diag1<condNumberCorr2)&&(diag2<condNumberCorr2)){
275 if(((detCov<condNumberCorr2)&&(diag1>condNumberCorr2))||
276 ((diag2>condNumberCorr2)&&(detCov<condNumberCorr2) )){
280 IC_01_corr=
sqrt(fabs(diag1-condNumberCorr2));
282 IC(0,1)=(-1)*IC_01_corr;
void correctTheCovX(void)
Point3DBase< Scalar, LocalTag > LocalPoint
CSCDetId cscDetId() const
void correctTheCovMatrix(CSCSegFit::SMatrixSym2 &IC)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
std::vector< double > lex_
bool covToAnyNumber_
The correction parameters.
LocalError localPositionError() 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::SVector< double, 4 > SVector4
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
static const std::string B
ROOT::Math::SMatrix< double, 4 > SMatrix4
void setScaleXError(double factor)
const CSCChamber * chamber() const
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > SMatrixSym2
LocalPoint localPosition() const
Power< A, B >::type pow(const A &a, const B &b)