11 using namespace tauImpactParameter;
38 edm::LogWarning(
"LagrangeMultipliersFitter::Fit") <<
"Reached Maximum number of iterations..." <<
niter_ << std::endl;
52 TVectorT<double> alpha_A=
par_;
53 TVectorT<double> alpha_0=
par_0_;
54 TVectorT<double> delta_alpha_A=alpha_A-alpha_0;
57 TVectorT<double>
C=
D_*delta_alpha_A-
d;
58 TMatrixTSym<double> V_alpha0=
cov_0_;
59 TMatrixTSym<double> V_D_inv=V_alpha0;
60 V_D_inv.Similarity(
D_);
61 double det = V_D_inv.Determinant();
62 TDecompBK Inverter(V_D_inv);
64 edm::LogWarning(
"LagrangeMultipliersFitter::Fit") <<
"Fit failed: unable to invert SYM gain matrix LARGE Determinant" << det <<
" \n" << std::endl;
67 if(!Inverter.Decompose()){
68 edm::LogWarning(
"LagrangeMultipliersFitter::Fit") <<
"Fit failed: unable to invert SYM gain matrix " << det <<
" \n" << std::endl;
71 V_D_=Inverter.Invert();
74 TVectorT<double> lambda=-1.0*
V_D_*
C;
75 TMatrixT<double>
DT=
D_; DT.T();
76 TVectorT<double>
alpha=alpha_0-V_alpha0*DT*lambda;
79 double s(1), stepscale(0.01);
82 TVectorT<double> alpha_s=
alpha;
88 int NIter=(int)(1.0/stepscale);
89 for(
int iter=0;iter<NIter;iter++){
92 for(
int l=0;
l<alpha_s.GetNrows();
l++){
93 if(diff<alpha_s(
l)-alpha_A(
l))diff=alpha_s(
l)-alpha_A(
l);
101 if((delta_alpha_s<currentdelta && chi2_s<currentchi2) || iter==NIter || diff<100*
epsilon_){currentchi2=chi2_s; currentdelta=delta_alpha_s;
ScaleFactor_=
s;
break;}
104 alpha_s=alpha_A+
s*(alpha-alpha_A);
116 TVectorD par_plus(
par_.GetNrows());
119 for(
int j=0;
j<
par_.GetNrows();
j++){
120 for(
int i=0;
i<
par_.GetNrows();
i++){
125 value_par_plus=
value(par_plus);
141 double c2=lambda*(D*delta_alpha+
d);
147 TMatrixTSym<double> V_alpha0=
cov_0_;
149 TDecompBK Inverter(V_alpha0);
150 if(!Inverter.Decompose()){
151 edm::LogWarning(
"LagrangeMultipliersFitter::chiSquareUsingInitalPoint") <<
"Error non-invertable Matrix... Calculating under assumption that correlations can be neglected!!!" << std::endl;
152 for(
int j=0;
j<
par_.GetNrows();
j++){
153 for(
int i=0;
i<
par_.GetNrows();
i++){
163 TVectorT<double> alpha_0=
par_0_;
164 TVectorT<double> dalpha=alpha-alpha_0;
166 TVectorT<double> alpha_v=
alpha;
167 double c2_constraints=lambda*
value(alpha_v);
168 double c2=c2_var+c2_constraints;
173 TVectorD d_par=
value(par);
175 for(
int i = 0;
i<d_par.GetNrows();
i++){
176 delta_d+=fabs(d_par(
i));
182 TMatrixTSym<double> V_alpha0=
cov_0_;
183 TMatrixTSym<double> DTV_DD=
V_D_.SimilarityT(
D_);
184 TMatrixT<double> DTV_DDV=DTV_DD*V_alpha0;
185 TMatrixT<double> VDTV_DDV=V_alpha0*DTV_DDV;
186 TMatrixT<double> CovCor=VDTV_DDV;
189 V_corr_prev_.ResizeTo(V_alpha0.GetNrows(),V_alpha0.GetNrows());
198 TMatrixT<double> V_alpha = V_alpha0-CovCor;
199 for(
int i=0;
i<
cov_.GetNrows();
i++){
200 for(
int j=0;
j<=
i;
j++){
TMatrixTSym< double > cov_0_
virtual TVectorD value(const TVectorD &v)=0
bool applyLagrangianConstraints()
TMatrixT< double > V_corr_prev_
virtual bool isConverged()
virtual double chiSquare()
TMatrixTSym< double > V_alpha0_inv_
TMatrixTSym< double > cov_
virtual double nConstraints()=0
DecomposeProduct< arg, typename Div::arg > D
LagrangeMultipliersFitter()
double chiSquareUsingInitalPoint(const TVectorT< double > &alpha, const TVectorT< double > &lambda)
TMatrixTSym< double > V_D_
double constraintDelta(const TVectorT< double > &par)
AlgebraicMatrix Derivatives
TMatrixT< double > computeVariance()
volatile std::atomic< bool > shutdown_flag false
TMatrixT< double > derivative()