CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
TKinFitter Class Reference

#include <TKinFitter.h>

Inheritance diagram for TKinFitter:

Public Member Functions

void addConstraint (TAbsFitConstraint *constraint)
 
void addMeasParticle (TAbsFitParticle *particle)
 
void addMeasParticles (TAbsFitParticle *p1, TAbsFitParticle *p2=0, TAbsFitParticle *p3=0, TAbsFitParticle *p4=0, TAbsFitParticle *p5=0, TAbsFitParticle *p6=0, TAbsFitParticle *p7=0, TAbsFitParticle *p8=0, TAbsFitParticle *p9=0)
 
void addUnmeasParticle (TAbsFitParticle *particle)
 
void addUnmeasParticles (TAbsFitParticle *p1, TAbsFitParticle *p2=0, TAbsFitParticle *p3=0, TAbsFitParticle *p4=0, TAbsFitParticle *p5=0, TAbsFitParticle *p6=0, TAbsFitParticle *p7=0, TAbsFitParticle *p8=0, TAbsFitParticle *p9=0)
 
Int_t fit ()
 
const TLorentzVector * get4Vec (Int_t index)
 
const TMatrixD * getCovMatrix ()
 
const TMatrixD * getCovMatrixFit ()
 
Double_t getF ()
 
Double_t getMaxDeltaS ()
 
Double_t getMaxF ()
 
Int_t getMaxNumberIter ()
 
const TAbsFitParticlegetMeasParticle (Int_t index)
 
Int_t getNbIter ()
 
Int_t getNDF ()
 
Int_t getNParA ()
 
Int_t getNParB ()
 
Double_t getS ()
 
Int_t getStatus ()
 
const TAbsFitParticlegetUnmeasParticle (Int_t index)
 
Int_t getVerbosity ()
 
Int_t nbConstraints ()
 
Int_t nbMeasParticles ()
 
Int_t nbUnmeasParticles ()
 
void print ()
 
void reset ()
 
void resetStatus ()
 
void setCovMatrix (TMatrixD &V)
 
void setMaxDeltaS (Double_t maxDeltaS)
 
void setMaxF (Double_t maxF)
 
void setMaxNbIter (Int_t maxNbIter)
 
void setVerbosity (Int_t verbosity=1)
 
 TKinFitter ()
 
 TKinFitter (const TString &name, const TString &title)
 
 ~TKinFitter ()
 

Protected Member Functions

Bool_t applyDeltaA ()
 
Bool_t applyDeltaY ()
 
void applyVFit ()
 
Bool_t calcA ()
 
Bool_t calcB ()
 
Bool_t calcC ()
 
Bool_t calcC11 ()
 
Bool_t calcC21 ()
 
Bool_t calcC22 ()
 
Bool_t calcC31 ()
 
Bool_t calcC32 ()
 
Bool_t calcC33 ()
 
Bool_t calcDeltaA ()
 
Bool_t calcDeltaY ()
 
Bool_t calcLambda ()
 
Bool_t calcV ()
 
Bool_t calcVA ()
 
Bool_t calcVB ()
 
Bool_t calcVFit ()
 
Bool_t converged (Double_t F, Double_t prevS, Double_t currS)
 
void countMeasParams ()
 
void countUnmeasParams ()
 
TString getStatusString ()
 
void printMatrix (const TMatrixD &matrix, const TString &name="")
 
void resetParams ()
 

Private Attributes

TMatrixD _A
 
TMatrixD _AT
 
TMatrixD _B
 
TMatrixD _BT
 
TMatrixD _c
 
TMatrixD _C11
 
TMatrixD _C11T
 
TMatrixD _C21
 
TMatrixD _C21T
 
TMatrixD _C22
 
TMatrixD _C22T
 
TMatrixD _C31
 
TMatrixD _C31T
 
TMatrixD _C32
 
TMatrixD _C32T
 
TMatrixD _C33
 
TMatrixD _C33T
 
std::vector< TAbsFitConstraint * > _constraints
 
TMatrixD _deltaA
 
TMatrixD _deltaAstar
 
TMatrixD _deltaY
 
TMatrixD _deltaYstar
 
TMatrixD _lambda
 
TMatrixD _lambdaT
 
TMatrixD _lambdaVFit
 
Double_t _maxDeltaS
 
Double_t _maxF
 
Int_t _maxNbIter
 
std::vector< TAbsFitParticle * > _measParticles
 
Int_t _nbIter
 
Int_t _nParA
 
Int_t _nParB
 
Int_t _status
 
std::vector< TAbsFitParticle * > _unmeasParticles
 
TMatrixD _V
 
TMatrixD _VA
 
TMatrixD _VAinv
 
TMatrixD _VB
 
TMatrixD _VBinv
 
Int_t _verbosity
 
TMatrixD _Vinv
 
TMatrixD _yaVFit
 

Detailed Description

Definition at line 13 of file TKinFitter.h.

Constructor & Destructor Documentation

TKinFitter::TKinFitter ( )

Definition at line 21 of file TKinFitter.cc.

References reset().

21  :
22  TNamed("UnNamed", "UnTitled"),
23  _A(1, 1),
24  _AT(1, 1),
25  _B(1, 1),
26  _BT(1, 1),
27  _V(1, 1),
28  _Vinv(1, 1),
29  _VB(1, 1),
30  _VBinv(1, 1),
31  _VA(1, 1),
32  _VAinv(1, 1),
33  _c(1, 1),
34  _C11(1, 1),
35  _C11T(1, 1),
36  _C21(1, 1),
37  _C21T(1, 1),
38  _C22(1, 1),
39  _C22T(1, 1),
40  _C31(1, 1),
41  _C31T(1, 1),
42  _C32(1, 1),
43  _C32T(1, 1),
44  _C33(1, 1),
45  _C33T(1, 1),
46  _deltaA(1, 1),
47  _deltaY(1, 1),
48  _deltaAstar(1, 1),
49  _deltaYstar(1, 1),
50  _lambda(1, 1),
51  _lambdaT(1, 1),
52  _lambdaVFit(1, 1),
53  _yaVFit(1, 1),
54  _constraints(0),
55  _measParticles(0),
57 {
58 
59  reset();
60 
61 }
TMatrixD _deltaY
Definition: TKinFitter.h:132
TMatrixD _C11
Definition: TKinFitter.h:118
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
TMatrixD _C33T
Definition: TKinFitter.h:129
TMatrixD _lambda
Definition: TKinFitter.h:135
TMatrixD _C32T
Definition: TKinFitter.h:127
TMatrixD _V
Definition: TKinFitter.h:110
void reset()
Definition: TKinFitter.cc:105
TMatrixD _C21T
Definition: TKinFitter.h:121
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _C31T
Definition: TKinFitter.h:125
TMatrixD _yaVFit
Definition: TKinFitter.h:139
TMatrixD _C32
Definition: TKinFitter.h:126
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
TMatrixD _VA
Definition: TKinFitter.h:114
TMatrixD _deltaA
Definition: TKinFitter.h:131
TMatrixD _C33
Definition: TKinFitter.h:128
TMatrixD _deltaAstar
Definition: TKinFitter.h:133
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _C22T
Definition: TKinFitter.h:123
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _C22
Definition: TKinFitter.h:122
TMatrixD _c
Definition: TKinFitter.h:116
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _lambdaT
Definition: TKinFitter.h:136
TMatrixD _lambdaVFit
Definition: TKinFitter.h:138
TMatrixD _C31
Definition: TKinFitter.h:124
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
TMatrixD _deltaYstar
Definition: TKinFitter.h:134
TMatrixD _BT
Definition: TKinFitter.h:109
TMatrixD _AT
Definition: TKinFitter.h:107
TMatrixD _VBinv
Definition: TKinFitter.h:113
TMatrixD _C11T
Definition: TKinFitter.h:119
TMatrixD _C21
Definition: TKinFitter.h:120
TMatrixD _Vinv
Definition: TKinFitter.h:111
TKinFitter::TKinFitter ( const TString &  name,
const TString &  title 
)

Definition at line 63 of file TKinFitter.cc.

References reset().

63  :
64  TNamed(name, title),
65  _A(1, 1),
66  _AT(1, 1),
67  _B(1, 1),
68  _BT(1, 1),
69  _V(1, 1),
70  _Vinv(1, 1),
71  _VB(1, 1),
72  _VBinv(1, 1),
73  _VA(1, 1),
74  _VAinv(1, 1),
75  _c(1, 1),
76  _C11(1, 1),
77  _C11T(1, 1),
78  _C21(1, 1),
79  _C21T(1, 1),
80  _C22(1, 1),
81  _C22T(1, 1),
82  _C31(1, 1),
83  _C31T(1, 1),
84  _C32(1, 1),
85  _C32T(1, 1),
86  _C33(1, 1),
87  _C33T(1, 1),
88  _deltaA(1, 1),
89  _deltaY(1, 1),
90  _deltaAstar(1, 1),
91  _deltaYstar(1, 1),
92  _lambda(1, 1),
93  _lambdaT(1, 1),
94  _lambdaVFit(1, 1),
95  _yaVFit(1, 1),
96  _constraints(0),
97  _measParticles(0),
99 {
100 
101  reset();
102 
103 }
TMatrixD _deltaY
Definition: TKinFitter.h:132
TMatrixD _C11
Definition: TKinFitter.h:118
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
TMatrixD _C33T
Definition: TKinFitter.h:129
TMatrixD _lambda
Definition: TKinFitter.h:135
TMatrixD _C32T
Definition: TKinFitter.h:127
TMatrixD _V
Definition: TKinFitter.h:110
void reset()
Definition: TKinFitter.cc:105
TMatrixD _C21T
Definition: TKinFitter.h:121
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _C31T
Definition: TKinFitter.h:125
TMatrixD _yaVFit
Definition: TKinFitter.h:139
TMatrixD _C32
Definition: TKinFitter.h:126
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
TMatrixD _VA
Definition: TKinFitter.h:114
TMatrixD _deltaA
Definition: TKinFitter.h:131
TMatrixD _C33
Definition: TKinFitter.h:128
TMatrixD _deltaAstar
Definition: TKinFitter.h:133
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _C22T
Definition: TKinFitter.h:123
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _C22
Definition: TKinFitter.h:122
TMatrixD _c
Definition: TKinFitter.h:116
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _lambdaT
Definition: TKinFitter.h:136
TMatrixD _lambdaVFit
Definition: TKinFitter.h:138
TMatrixD _C31
Definition: TKinFitter.h:124
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
TMatrixD _deltaYstar
Definition: TKinFitter.h:134
TMatrixD _BT
Definition: TKinFitter.h:109
TMatrixD _AT
Definition: TKinFitter.h:107
TMatrixD _VBinv
Definition: TKinFitter.h:113
TMatrixD _C11T
Definition: TKinFitter.h:119
TMatrixD _C21
Definition: TKinFitter.h:120
TMatrixD _Vinv
Definition: TKinFitter.h:111
TKinFitter::~TKinFitter ( )

Definition at line 182 of file TKinFitter.cc.

182  {
183 
184 }

Member Function Documentation

void TKinFitter::addConstraint ( TAbsFitConstraint constraint)

Definition at line 281 of file TKinFitter.cc.

References _constraints, countMeasParams(), and resetStatus().

Referenced by TSLToyGen::doToyExperiments(), CandMassKinFitter::set(), StKinFitter::setupFitter(), TtFullHadKinFitter::setupFitter(), and TtSemiLepKinFitter::setupFitter().

281  {
282  // add a constraint
283 
284  resetStatus();
285 
286  if ( constraint != 0 ) {
287  _constraints.push_back( constraint );
288  }
289 
290  countMeasParams();
291 
292 }
void countMeasParams()
Definition: TKinFitter.cc:186
void resetStatus()
Definition: TKinFitter.cc:156
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
void TKinFitter::addMeasParticle ( TAbsFitParticle particle)

Definition at line 209 of file TKinFitter.cc.

References _measParticles, countMeasParams(), and resetStatus().

Referenced by TSLToyGen::doToyExperiments(), CandMassKinFitter::set(), StKinFitter::setupFitter(), TtFullHadKinFitter::setupFitter(), and TtSemiLepKinFitter::setupFitter().

209  {
210  // add one measured particle
211 
212  resetStatus();
213 
214  if ( particle != 0 ) {
215  _measParticles.push_back( particle );
216  } else {
217  edm::LogError ("NullPointer") << "Measured particle points to NULL. It will not be added to the KinFitter.";
218  }
219 
220  countMeasParams();
221 
222 }
void countMeasParams()
Definition: TKinFitter.cc:186
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
void resetStatus()
Definition: TKinFitter.cc:156
void TKinFitter::addMeasParticles ( TAbsFitParticle p1,
TAbsFitParticle p2 = 0,
TAbsFitParticle p3 = 0,
TAbsFitParticle p4 = 0,
TAbsFitParticle p5 = 0,
TAbsFitParticle p6 = 0,
TAbsFitParticle p7 = 0,
TAbsFitParticle p8 = 0,
TAbsFitParticle p9 = 0 
)

Definition at line 224 of file TKinFitter.cc.

References _measParticles, countMeasParams(), and resetStatus().

226  {
227  // add many measured particles
228 
229  resetStatus();
230 
231  if ( p1 != 0 ) _measParticles.push_back( p1 );
232  if ( p2 != 0 ) _measParticles.push_back( p2 );
233  if ( p3 != 0 ) _measParticles.push_back( p3 );
234  if ( p4 != 0 ) _measParticles.push_back( p4 );
235  if ( p5 != 0 ) _measParticles.push_back( p5 );
236  if ( p6 != 0 ) _measParticles.push_back( p6 );
237  if ( p7 != 0 ) _measParticles.push_back( p7 );
238  if ( p8 != 0 ) _measParticles.push_back( p8 );
239  if ( p9 != 0 ) _measParticles.push_back( p9 );
240 
241  countMeasParams();
242 
243 }
void countMeasParams()
Definition: TKinFitter.cc:186
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
void resetStatus()
Definition: TKinFitter.cc:156
void TKinFitter::addUnmeasParticle ( TAbsFitParticle particle)

Definition at line 245 of file TKinFitter.cc.

References _unmeasParticles, countUnmeasParams(), and resetStatus().

Referenced by TSLToyGen::doToyExperiments().

245  {
246  // add one unmeasured particle
247 
248  resetStatus();
249 
250  if ( particle != 0 ) {
251  _unmeasParticles.push_back( particle );
252  } else {
253  edm::LogError ("NullPointer") << "Unmeasured particle points to NULL. It will not be added to the KinFitter.";
254  }
255 
257 
258 }
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
void countUnmeasParams()
Definition: TKinFitter.cc:199
void resetStatus()
Definition: TKinFitter.cc:156
void TKinFitter::addUnmeasParticles ( TAbsFitParticle p1,
TAbsFitParticle p2 = 0,
TAbsFitParticle p3 = 0,
TAbsFitParticle p4 = 0,
TAbsFitParticle p5 = 0,
TAbsFitParticle p6 = 0,
TAbsFitParticle p7 = 0,
TAbsFitParticle p8 = 0,
TAbsFitParticle p9 = 0 
)

Definition at line 260 of file TKinFitter.cc.

References _unmeasParticles, countUnmeasParams(), and resetStatus().

262  {
263  // add many unmeasured particles
264 
265  resetStatus();
266 
267  if ( p1 != 0 ) _unmeasParticles.push_back( p1 );
268  if ( p2 != 0 ) _unmeasParticles.push_back( p2 );
269  if ( p3 != 0 ) _unmeasParticles.push_back( p3 );
270  if ( p4 != 0 ) _unmeasParticles.push_back( p4 );
271  if ( p5 != 0 ) _unmeasParticles.push_back( p5 );
272  if ( p6 != 0 ) _unmeasParticles.push_back( p6 );
273  if ( p7 != 0 ) _unmeasParticles.push_back( p7 );
274  if ( p8 != 0 ) _unmeasParticles.push_back( p8 );
275  if ( p9 != 0 ) _unmeasParticles.push_back( p9 );
276 
278 
279 }
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
void countUnmeasParams()
Definition: TKinFitter.cc:199
void resetStatus()
Definition: TKinFitter.cc:156
Bool_t TKinFitter::applyDeltaA ( )
protected

Definition at line 1038 of file TKinFitter.cc.

References _deltaA, _unmeasParticles, TAbsFitParticle::applycorr(), TAbsFitParticle::getNPar(), and cmsHarvester::index.

Referenced by fit().

1038  {
1039  //apply corrections to unmeasured particles
1040 
1041  int offsetParam = 0;
1042  for (unsigned int indexParticle = 0; indexParticle < _unmeasParticles.size(); indexParticle++) {
1043 
1044  TAbsFitParticle* particle = _unmeasParticles[indexParticle];
1045  Int_t nbParams = particle->getNPar();
1046  TMatrixD params( nbParams, 1 );
1047  for (Int_t index = 0; index < nbParams; index++) {
1048  params(index, 0) = _deltaA(index+offsetParam, 0);
1049  }
1050  particle->applycorr( &params );
1051  offsetParam+=nbParams;
1052 
1053  }
1054 
1055  return true;
1056 
1057 }
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
TMatrixD _deltaA
Definition: TKinFitter.h:131
Int_t getNPar() const
virtual void applycorr(TMatrixD *corrMatrix)
Bool_t TKinFitter::applyDeltaY ( )
protected

Definition at line 1059 of file TKinFitter.cc.

References _constraints, _deltaY, _measParticles, TAbsFitParticle::applycorr(), TAbsFitConstraint::applyDeltaAlpha(), HLT_25ns14e33_v1_cff::constraint, TAbsFitConstraint::getNPar(), TAbsFitParticle::getNPar(), and cmsHarvester::index.

Referenced by fit().

1059  {
1060  //apply corrections to measured particles
1061 
1062  int offsetParam = 0;
1063  for (unsigned int indexParticle = 0; indexParticle < _measParticles.size(); indexParticle++) {
1064 
1065  TAbsFitParticle* particle = _measParticles[indexParticle];
1066  Int_t nbParams = particle->getNPar();
1067  TMatrixD params( nbParams, 1 );
1068  for (Int_t index = 0; index < nbParams; index++) {
1069  params(index, 0) = _deltaY(index+offsetParam, 0);
1070  }
1071  particle->applycorr( &params );
1072  offsetParam+=nbParams;
1073 
1074  }
1075 
1076  for (unsigned int indexConstraint = 0; indexConstraint < _constraints.size(); indexConstraint++) {
1077 
1078  TAbsFitConstraint* constraint = _constraints[indexConstraint];
1079  Int_t nbParams = constraint->getNPar();
1080  if ( nbParams > 0 ) {
1081  TMatrixD params( nbParams, 1 );
1082  for (Int_t index = 0; index < nbParams; index++) {
1083  params(index, 0) = _deltaY(index+offsetParam, 0);
1084  }
1085  constraint->applyDeltaAlpha( &params );
1086  offsetParam+=nbParams;
1087  }
1088 
1089  }
1090 
1091  return true;
1092 
1093 }
TMatrixD _deltaY
Definition: TKinFitter.h:132
virtual void applyDeltaAlpha(TMatrixD *corrMatrix)
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
Int_t getNPar() const
virtual void applycorr(TMatrixD *corrMatrix)
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
void TKinFitter::applyVFit ( )
protected

Definition at line 991 of file TKinFitter.cc.

References _constraints, _measParticles, _unmeasParticles, _yaVFit, EnergyCorrector::c, HLT_25ns14e33_v1_cff::constraint, TAbsFitConstraint::getNPar(), TAbsFitParticle::getNPar(), alignCSCRings::r, TAbsFitParticle::setCovMatrixFit(), and TAbsFitConstraint::setCovMatrixFit().

Referenced by fit().

991  {
992  // apply fit covariance matrix to measured and unmeasured particles
993 
994  int offsetParam = 0;
995  for (unsigned int indexParticle = 0; indexParticle < _measParticles.size(); indexParticle++) {
996  TAbsFitParticle* particle = _measParticles[indexParticle];
997  Int_t nbParams = particle->getNPar();
998  TMatrixD vfit( nbParams, nbParams );
999  for (Int_t c = 0; c < nbParams; c++) {
1000  for (Int_t r = 0; r < nbParams; r++) {
1001  vfit(r, c) = _yaVFit(r + offsetParam, c + offsetParam);
1002  }
1003  }
1004  particle->setCovMatrixFit( &vfit );
1005  offsetParam += nbParams;
1006  }
1007 
1008  for (unsigned int indexConstraint = 0; indexConstraint < _constraints.size(); indexConstraint++) {
1009  TAbsFitConstraint* constraint = _constraints[indexConstraint];
1010  Int_t nbParams = constraint->getNPar();
1011  if (nbParams > 0) {
1012  TMatrixD vfit( nbParams, nbParams );
1013  for (Int_t c = 0; c < nbParams; c++) {
1014  for (Int_t r = 0; r < nbParams; r++) {
1015  vfit(r, c) = _yaVFit(r + offsetParam, c + offsetParam);
1016  }
1017  }
1018  constraint->setCovMatrixFit( &vfit );
1019  offsetParam += nbParams;
1020  }
1021  }
1022 
1023  for (unsigned int indexParticle = 0; indexParticle < _unmeasParticles.size(); indexParticle++) {
1024  TAbsFitParticle* particle = _unmeasParticles[indexParticle];
1025  Int_t nbParams = particle->getNPar();
1026  TMatrixD vfit( nbParams, nbParams );
1027  for (Int_t c = 0; c < nbParams; c++) {
1028  for (Int_t r = 0; r < nbParams; r++) {
1029  vfit(r, c) = _yaVFit(r + offsetParam, c + offsetParam);
1030  }
1031  }
1032  particle->setCovMatrixFit( &vfit );
1033  offsetParam += nbParams;
1034  }
1035 
1036 }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
TMatrixD _yaVFit
Definition: TKinFitter.h:139
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
virtual void setCovMatrixFit(const TMatrixD *theCovMatrixFit)
Int_t getNPar() const
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
virtual void setCovMatrixFit(const TMatrixD *theCovMatrixFit)
Bool_t TKinFitter::calcA ( )
protected

Definition at line 519 of file TKinFitter.cc.

References _A, _AT, _constraints, _nParA, _unmeasParticles, TAbsFitParticle::getDerivative(), and JetComb::kMult.

Referenced by fit().

519  {
520  // Calculate the Jacobi matrix of unmeasured parameters df_i/da_i
521  // Row i contains the derivatives of constraint f_i. Column q contains
522  // the derivative wrt. a_q.
523 
524  _A.ResizeTo( _constraints.size(), _nParA );
525 
526  for (unsigned int indexConstr = 0; indexConstr < _constraints.size(); indexConstr++) {
527 
528  int offsetParam = 0;
529  for (unsigned int indexParticle = 0; indexParticle < _unmeasParticles.size(); indexParticle++) {
530 
531  // Calculate matrix product df/dP * dP/dy = (df/dr, df/dtheta, df/dphi, ...)
532 
533  TAbsFitParticle* particle = _unmeasParticles[indexParticle];
534  TMatrixD* derivParticle = particle->getDerivative();
535  TMatrixD* derivConstr = _constraints[indexConstr]->getDerivative( particle );
536  TMatrixD deriv( *derivConstr, TMatrixD::kMult, *derivParticle );
537 
538  for (int indexParam = 0; indexParam < deriv.GetNcols(); indexParam++) {
539  _A(indexConstr,indexParam+offsetParam) = deriv(0, indexParam);
540  }
541  offsetParam += deriv.GetNcols();
542 
543  delete derivParticle;
544  delete derivConstr;
545 
546  }
547  }
548 
549  // Calculate transposed matrix
550  TMatrixD AT(TMatrixD::kTransposed, _A);
551  _AT.ResizeTo( AT );
552  _AT = AT;
553 
554  return true;
555 
556 }
Int_t _nParA
Definition: TKinFitter.h:141
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
virtual TMatrixD * getDerivative()=0
TMatrixD _A
Definition: TKinFitter.h:106
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
TMatrixD _AT
Definition: TKinFitter.h:107
Bool_t TKinFitter::calcB ( )
protected

Definition at line 558 of file TKinFitter.cc.

References _B, _BT, _constraints, _measParticles, _nParB, _verbosity, HLT_25ns14e33_v1_cff::constraint, TAbsFitParticle::getDerivative(), TAbsFitConstraint::getDerivativeAlpha(), JetComb::kMult, and printMatrix().

Referenced by fit().

558  {
559  // Calculate the Jacobi matrix of measured parameters df_i/da_i
560  // Row i contains the derivatives of constraint f_i. Column q contains
561  // the derivative wrt. a_q.
562 
563  _B.ResizeTo( _constraints.size(), _nParB );
564 
565  int offsetParam = 0;
566  for (unsigned int indexConstr = 0; indexConstr < _constraints.size(); indexConstr++) {
567 
568  offsetParam = 0;
569  for (unsigned int indexParticle = 0; indexParticle < _measParticles.size(); indexParticle++) {
570 
571  // Calculate matrix product df/dP * dP/dy = (df/dr, df/dtheta, df/dphi, ...)
572  TAbsFitParticle* particle = _measParticles[indexParticle];
573  TMatrixD* derivParticle = particle->getDerivative();
574  TMatrixD* derivConstr = _constraints[indexConstr]->getDerivative( particle );
575  TMatrixD deriv( *derivConstr, TMatrixD::kMult, *derivParticle );
576  if (_verbosity >= 3) {
577  TString matrixName = "B deriv: Particle -> ";
578  matrixName += particle->GetName();
579  printMatrix( *derivParticle, matrixName );
580  matrixName = "B deriv: Constraint -> ";
581  matrixName += _constraints[indexConstr]->GetName();
582  matrixName += " , Particle -> ";
583  matrixName += particle->GetName();
584  printMatrix( *derivConstr, matrixName );
585  }
586  for (int indexParam = 0; indexParam < deriv.GetNcols(); indexParam++) {
587  _B(indexConstr,indexParam+offsetParam) = deriv(0, indexParam);
588  }
589  offsetParam += deriv.GetNcols();
590 
591  delete derivParticle;
592  delete derivConstr;
593 
594  }
595  }
596 
597  for (unsigned int iC = 0; iC < _constraints.size(); iC++) {
598 
600  TMatrixD* deriv = constraint->getDerivativeAlpha();
601 
602  if (deriv != 0) {
603 
604  if (_verbosity >= 3) {
605  TString matrixName = "B deriv alpha: Constraint -> ";
606  matrixName += constraint->GetName();
607  printMatrix( *deriv, matrixName );
608  }
609  for (int indexParam = 0; indexParam < deriv->GetNcols(); indexParam++) {
610  _B( iC, indexParam+offsetParam ) = (*deriv)(0, indexParam);
611  }
612  offsetParam += deriv->GetNcols();
613 
614  delete deriv;
615  }
616  }
617 
618  TMatrixD BT( TMatrixD::kTransposed, _B );
619  _BT.ResizeTo( BT );
620  _BT = BT;
621 
622  return true;
623 
624 }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
virtual TMatrixD * getDerivativeAlpha()
virtual TMatrixD * getDerivative()=0
TMatrixD _B
Definition: TKinFitter.h:108
void printMatrix(const TMatrixD &matrix, const TString &name="")
Definition: TKinFitter.cc:1256
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
TMatrixD _BT
Definition: TKinFitter.h:109
Int_t _verbosity
Definition: TKinFitter.h:104
Int_t _nParB
Definition: TKinFitter.h:142
Bool_t TKinFitter::calcC ( )
protected

Definition at line 796 of file TKinFitter.cc.

References _A, _B, _c, _constraints, _measParticles, _nParA, _nParB, _unmeasParticles, _verbosity, a, alpha, HLT_25ns14e33_v1_cff::constraint, TAbsFitConstraint::getNPar(), TAbsFitParticle::getParCurr(), TAbsFitConstraint::getParCurr(), TAbsFitParticle::getParIni(), TAbsFitConstraint::getParIni(), JetComb::kMult, printMatrix(), and y.

Referenced by fit().

796  {
797  // Calculate the matrix c = A*deltaAStar + B*deltaYStar - fStar
798 
799  int offsetParam = 0;
800 
801  // calculate delta(a*), = 0 in the first iteration
802  TMatrixD deltaastar( 1, 1 );
803  if ( _nParA > 0 ) {
804 
805  deltaastar.ResizeTo( _nParA, 1 );
806  for (unsigned int indexParticle = 0; indexParticle < _unmeasParticles.size(); indexParticle++) {
807 
808  TAbsFitParticle* particle = _unmeasParticles[indexParticle];
809  const TMatrixD* astar = particle->getParCurr();
810  const TMatrixD* a = particle->getParIni();
811  TMatrixD deltaastarpart(*astar);
812  deltaastarpart -= *a;
813 
814  for (int indexParam = 0; indexParam < deltaastarpart.GetNrows(); indexParam++) {
815  deltaastar(indexParam+offsetParam, 0) = deltaastarpart(indexParam, 0);
816  }
817  offsetParam += deltaastarpart.GetNrows();
818 
819  }
820 
821  if ( _verbosity >= 3 ) {
822  printMatrix( deltaastar, "deltaastar" );
823  }
824 
825  }
826 
827  // calculate delta(y*), = 0 in the first iteration
828  TMatrixD deltaystar( _nParB, 1 );
829  offsetParam = 0;
830  for (unsigned int indexParticle = 0; indexParticle < _measParticles.size(); indexParticle++) {
831 
832  TAbsFitParticle* particle = _measParticles[indexParticle];
833  const TMatrixD* ystar = particle->getParCurr();
834  const TMatrixD* y = particle->getParIni();
835  TMatrixD deltaystarpart(*ystar);
836  deltaystarpart -= *y;
837 
838  for (int indexParam = 0; indexParam < deltaystarpart.GetNrows(); indexParam++) {
839  deltaystar(indexParam+offsetParam, 0) = deltaystarpart(indexParam, 0);
840  }
841  offsetParam += deltaystarpart.GetNrows();
842 
843  }
844 
845  for (unsigned int iC = 0; iC < _constraints.size(); iC++) {
846 
848 
849  if ( constraint->getNPar() > 0 ) {
850 
851  const TMatrixD* alphastar = constraint->getParCurr();
852  const TMatrixD* alpha = constraint->getParIni();
853 
854  TMatrixD deltaalphastarpart(*alphastar);
855  deltaalphastarpart -= *alpha;
856 
857  for (int indexParam = 0; indexParam < deltaalphastarpart.GetNrows(); indexParam++) {
858  deltaystar(indexParam+offsetParam, 0) = deltaalphastarpart(indexParam, 0);
859  }
860  offsetParam += deltaalphastarpart.GetNrows();
861 
862  }
863  }
864 
865  if ( _verbosity >= 3 ) {
866  printMatrix( deltaystar, "deltaystar" );
867  }
868 
869  // calculate f*
870  TMatrixD fstar( _constraints.size(), 1 );
871  for (unsigned int indexConstr = 0; indexConstr < _constraints.size(); indexConstr++) {
872  fstar( indexConstr, 0 ) = _constraints[indexConstr]->getCurrentValue();
873  }
874 
875  // calculate c
876  _c.ResizeTo( fstar );
877  _c = fstar;
878  _c *= (-1.);
879  TMatrixD Bdeltaystar( _B, TMatrixD::kMult, deltaystar );
880  _c += Bdeltaystar;
881  if ( _nParA ) {
882  TMatrixD Adeltaastar( _A, TMatrixD::kMult, deltaastar );
883  _c += Adeltaastar;
884  }
885 
886  return true;
887 
888 }
float alpha
Definition: AMPTWrapper.h:95
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
Int_t _nParA
Definition: TKinFitter.h:141
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _c
Definition: TKinFitter.h:116
TMatrixD _A
Definition: TKinFitter.h:106
const TMatrixD * getParIni()
void printMatrix(const TMatrixD &matrix, const TString &name="")
Definition: TKinFitter.cc:1256
const TMatrixD * getParIni()
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
double a
Definition: hdecay.h:121
Int_t _verbosity
Definition: TKinFitter.h:104
Int_t _nParB
Definition: TKinFitter.h:142
const TMatrixD * getParCurr()
const TMatrixD * getParCurr()
Bool_t TKinFitter::calcC11 ( )
protected

Definition at line 668 of file TKinFitter.cc.

References _A, _AT, _B, _BT, _C11, _C11T, _nParA, _V, _VAinv, _VB, and JetComb::kMult.

Referenced by fit().

668  {
669  // Calculate the matrix C11 = V^(-1) - V^(-1)*BT*VB*B*V^(-1) + V^(-1)*BT*VB*A*VA^(-1)*AT*VB*B*V^(-1)
670 
671  TMatrixD VBT( _V, TMatrixD::kMult, _BT );
672  TMatrixD VBB( _VB, TMatrixD::kMult, _B );
673  TMatrixD VBTVBB( VBT, TMatrixD::kMult, VBB );
674  TMatrixD m2( VBTVBB, TMatrixD::kMult, _V );
675 
676  _C11.ResizeTo( _V );
677  _C11 = _V;
678  _C11 -= m2;
679 
680  if ( _nParA > 0 ) {
681  TMatrixD VBA( _VB, TMatrixD::kMult, _A );
682  TMatrixD VBTVBA( VBT, TMatrixD::kMult, VBA );
683  TMatrixD VAinvAT( _VAinv, TMatrixD::kMult, _AT );
684  TMatrixD VBTVBAVAinvAT( VBTVBA, TMatrixD::kMult, VAinvAT );
685  TMatrixD VBTVBAVAinvATVBB( VBTVBAVAinvAT, TMatrixD::kMult, VBB );
686  TMatrixD m3( VBTVBAVAinvATVBB, TMatrixD::kMult, _V );
687  _C11 += m3;
688  }
689 
690  TMatrixD C11T( TMatrixD::kTransposed, _C11 );
691  _C11T.ResizeTo( C11T );
692  _C11T = C11T;
693 
694  return true;
695 
696 }
TMatrixD _C11
Definition: TKinFitter.h:118
Int_t _nParA
Definition: TKinFitter.h:141
TMatrixD _V
Definition: TKinFitter.h:110
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _BT
Definition: TKinFitter.h:109
TMatrixD _AT
Definition: TKinFitter.h:107
TMatrixD _C11T
Definition: TKinFitter.h:119
Bool_t TKinFitter::calcC21 ( )
protected

Definition at line 698 of file TKinFitter.cc.

References _AT, _B, _C21, _C21T, _V, _VAinv, _VB, and JetComb::kMult.

Referenced by fit().

698  {
699  // Calculate the matrix C21 = -VA^(-1)*AT*VB*B*V^(-1)
700 
701  TMatrixD VAinvAT( _VAinv, TMatrixD::kMult, _AT );
702  TMatrixD VBB( _VB, TMatrixD::kMult, _B );
703  TMatrixD VAinvATVBB( VAinvAT, TMatrixD::kMult, VBB );
704  TMatrixD C21( VAinvATVBB, TMatrixD::kMult, _V );
705  C21 *= -1.;
706  _C21.ResizeTo( C21 );
707  _C21 = C21;
708 
709  TMatrixD C21T( TMatrixD::kTransposed, _C21 );
710  _C21T.ResizeTo( C21T );
711  _C21T = C21T;
712 
713  return true;
714 
715 }
TMatrixD _V
Definition: TKinFitter.h:110
TMatrixD _C21T
Definition: TKinFitter.h:121
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _AT
Definition: TKinFitter.h:107
TMatrixD _C21
Definition: TKinFitter.h:120
Bool_t TKinFitter::calcC22 ( )
protected

Definition at line 717 of file TKinFitter.cc.

References _C22, _C22T, and _VAinv.

Referenced by fit().

717  {
718  // Calculate the matrix C22 = VA^(-1)
719 
720  _C22.ResizeTo( _VAinv );
721  _C22 = _VAinv;
722 
723  TMatrixD C22T( TMatrixD::kTransposed, _C22 );
724  _C22T.ResizeTo( C22T );
725  _C22T = C22T;
726 
727  return true;
728 
729 }
TMatrixD _C22T
Definition: TKinFitter.h:123
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _C22
Definition: TKinFitter.h:122
Bool_t TKinFitter::calcC31 ( )
protected

Definition at line 731 of file TKinFitter.cc.

References _A, _AT, _B, _C31, _C31T, _nParA, _V, _VAinv, _VB, and JetComb::kMult.

Referenced by fit().

731  {
732  // Calculate the matrix C31 = VB*B*V^(-1) - VB*A*VA^(-1)*AT*VB*B*V^(-1)
733 
734  TMatrixD VbB(_VB, TMatrixD::kMult, _B);
735  TMatrixD m1( VbB, TMatrixD::kMult, _V );
736 
737  _C31.ResizeTo( m1 );
738  _C31 = m1;
739 
740  if ( _nParA > 0 ) {
741  TMatrixD VbA(_VB, TMatrixD::kMult, _A);
742  TMatrixD VAinvAT( _VAinv, TMatrixD::kMult, _AT );
743  TMatrixD VbBV( VbB, TMatrixD::kMult, _V );
744  TMatrixD VbAVAinvAT(VbA, TMatrixD::kMult, VAinvAT);
745  TMatrixD m2(VbAVAinvAT, TMatrixD::kMult, VbBV);
746 
747  _C31 -= m2;
748  }
749 
750  TMatrixD C31T( TMatrixD::kTransposed, _C31 );
751  _C31T.ResizeTo( C31T );
752  _C31T = C31T;
753 
754  return true;
755 
756 }
Int_t _nParA
Definition: TKinFitter.h:141
TMatrixD _V
Definition: TKinFitter.h:110
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _C31T
Definition: TKinFitter.h:125
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _C31
Definition: TKinFitter.h:124
TMatrixD _AT
Definition: TKinFitter.h:107
Bool_t TKinFitter::calcC32 ( )
protected

Definition at line 758 of file TKinFitter.cc.

References _A, _C32, _C32T, _VAinv, _VB, and JetComb::kMult.

Referenced by fit().

758  {
759  // Calculate the matrix C32 = VB*A*VA^(-1)
760 
761  TMatrixD VbA( _VB, TMatrixD::kMult, _A );
762  TMatrixD C32( VbA, TMatrixD::kMult, _VAinv );
763  _C32.ResizeTo( C32 );
764  _C32 = C32;
765 
766  TMatrixD C32T( TMatrixD::kTransposed, _C32 );
767  _C32T.ResizeTo( C32T );
768  _C32T = C32T;
769 
770  return true;
771 
772 }
TMatrixD _C32T
Definition: TKinFitter.h:127
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _C32
Definition: TKinFitter.h:126
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _A
Definition: TKinFitter.h:106
Bool_t TKinFitter::calcC33 ( )
protected

Definition at line 774 of file TKinFitter.cc.

References _A, _AT, _C33, _C33T, _nParA, _VAinv, _VB, and JetComb::kMult.

Referenced by fit().

774  {
775  // Calculate the matrix C33 = -VB + VB*A*VA^(-1)*AT*VB
776 
777  _C33.ResizeTo( _VB );
778  _C33 = _VB;
779  _C33 *= -1.;
780 
781  if ( _nParA > 0 ) {
782  TMatrixD VbA(_VB, TMatrixD::kMult, _A );
783  TMatrixD VAinvAT( _VAinv, TMatrixD::kMult, _AT );
784  TMatrixD VbAVAinvAT( VbA, TMatrixD::kMult, VAinvAT );
785  TMatrixD C33( VbAVAinvAT, TMatrixD::kMult, _VB );
786  _C33 += C33;
787  }
788 
789  TMatrixD C33T( TMatrixD::kTransposed, _C33 );
790  _C33T.ResizeTo( C33T );
791  _C33T = C33T;
792 
793  return true;
794 }
Int_t _nParA
Definition: TKinFitter.h:141
TMatrixD _C33T
Definition: TKinFitter.h:129
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _C33
Definition: TKinFitter.h:128
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _AT
Definition: TKinFitter.h:107
Bool_t TKinFitter::calcDeltaA ( )
protected

Definition at line 890 of file TKinFitter.cc.

References _c, _C32T, _deltaA, _deltaAstar, _nbIter, and JetComb::kMult.

Referenced by fit().

890  {
891  // Calculate the matrix deltaA = C32T * c
892  // (corrections to unmeasured parameters)
893 
894  TMatrixD deltaA( _C32T, TMatrixD::kMult, _c );
895  _deltaA.ResizeTo( deltaA );
896 
897  if (_nbIter == 0) {
898  _deltaAstar.ResizeTo(deltaA);
899  _deltaAstar.Zero();
900  } else
902 
903  _deltaA = deltaA;
904 
905  return true;
906 
907 }
TMatrixD _C32T
Definition: TKinFitter.h:127
TMatrixD _deltaA
Definition: TKinFitter.h:131
TMatrixD _deltaAstar
Definition: TKinFitter.h:133
TMatrixD _c
Definition: TKinFitter.h:116
Int_t _nbIter
Definition: TKinFitter.h:149
Bool_t TKinFitter::calcDeltaY ( )
protected

Definition at line 909 of file TKinFitter.cc.

References _c, _C31T, _deltaY, _deltaYstar, _nbIter, and JetComb::kMult.

Referenced by fit().

909  {
910  // Calculate the matrix deltaY = C31T * c
911  // (corrections to measured parameters)
912 
913  TMatrixD deltaY( _C31T, TMatrixD::kMult, _c );
914  _deltaY.ResizeTo( deltaY );
915 
916  if (_nbIter == 0) {
917  _deltaYstar.ResizeTo(deltaY);
918  _deltaYstar.Zero();
919  } else
921 
922  _deltaY = deltaY;
923 
924  return true;
925 
926 }
TMatrixD _deltaY
Definition: TKinFitter.h:132
TMatrixD _C31T
Definition: TKinFitter.h:125
TMatrixD _c
Definition: TKinFitter.h:116
TMatrixD _deltaYstar
Definition: TKinFitter.h:134
Int_t _nbIter
Definition: TKinFitter.h:149
Bool_t TKinFitter::calcLambda ( )
protected

Definition at line 928 of file TKinFitter.cc.

References _c, _C33, _lambda, _lambdaT, and JetComb::kMult.

Referenced by fit().

928  {
929  // Calculate the matrix Lambda = C33 * c
930  // (Lagrange Multipliers)
931 
932  TMatrixD lambda( _C33, TMatrixD::kMult, _c );
933  _lambda.ResizeTo( lambda );
934  _lambda = lambda;
935 
936  TMatrixD lambdaT( TMatrixD::kTransposed, _lambda );
937  _lambdaT.ResizeTo( lambdaT );
938  _lambdaT = lambdaT;
939 
940  return true;
941 
942 }
TMatrixD _lambda
Definition: TKinFitter.h:135
TMatrixD _C33
Definition: TKinFitter.h:128
TMatrixD _c
Definition: TKinFitter.h:116
TMatrixD _lambdaT
Definition: TKinFitter.h:136
Bool_t TKinFitter::calcV ( )
protected

Definition at line 467 of file TKinFitter.cc.

References _constraints, _measParticles, _nParB, _status, _V, _Vinv, HLT_25ns14e33_v1_cff::constraint, alignCSCRings::e, TAbsFitParticle::getCovMatrix(), TAbsFitConstraint::getCovMatrix(), TAbsFitConstraint::getNPar(), and TAbsFitParticle::getNPar().

Referenced by fit().

467  {
468  // Combines the covariance matrices of all measured particles
469 
470  _V.ResizeTo( _nParB, _nParB );
471  _V.Zero();
472 
473  Int_t offsetP = 0;
474  for (unsigned int iP = 0; iP < _measParticles.size(); iP++) {
475  TAbsFitParticle* particle = _measParticles[iP];
476  Int_t nParP = particle->getNPar();
477  const TMatrixD* covMatrix = particle->getCovMatrix();
478 
479  for (int iX = offsetP; iX < offsetP + nParP; iX++) {
480  for (int iY = offsetP; iY < offsetP + nParP; iY++) {
481 
482  _V(iX, iY) = (*covMatrix)(iX-offsetP, iY-offsetP);
483 
484  }
485  }
486 
487  offsetP += nParP;
488  }
489 
490  for (unsigned int iC = 0; iC < _constraints.size(); iC++) {
492  Int_t nParP = constraint->getNPar();
493  const TMatrixD* covMatrix = constraint->getCovMatrix();
494 
495  for (int iX = offsetP; iX < offsetP + nParP; iX++) {
496  for (int iY = offsetP; iY < offsetP + nParP; iY++) {
497 
498  _V(iX, iY) = (*covMatrix)(iX-offsetP, iY-offsetP);
499 
500  }
501  }
502 
503  offsetP += nParP;
504  }
505 
506  _Vinv.ResizeTo( _V );
507  _Vinv = _V;
508  try {
509  _Vinv.Invert();
510  } catch (cms::Exception& e) {
511  edm::LogInfo ("KinFitter") << "Failed to invert covariance matrix V. Fit will be aborted.";
512  _status = -10;
513  }
514 
515  return true;
516 
517 }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
virtual const TMatrixD * getCovMatrix() const
TMatrixD _V
Definition: TKinFitter.h:110
Int_t _status
Definition: TKinFitter.h:148
Int_t getNPar() const
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
virtual const TMatrixD * getCovMatrix() const
Int_t _nParB
Definition: TKinFitter.h:142
TMatrixD _Vinv
Definition: TKinFitter.h:111
Bool_t TKinFitter::calcVA ( )
protected

Definition at line 647 of file TKinFitter.cc.

References _A, _AT, _status, _VA, _VAinv, _VB, alignCSCRings::e, and JetComb::kMult.

Referenced by fit().

647  {
648  // Calculate the matrix VA = (A^T*VB*A)
649 
650  TMatrixD ATVB( _AT, TMatrixD::kMult, _VB );
651  TMatrixD VA(ATVB, TMatrixD::kMult, _A);
652  _VA.ResizeTo( VA );
653  _VA = VA;
654 
655  _VAinv.ResizeTo( _VA );
656  _VAinv = _VA;
657  try {
658  _VAinv.Invert();
659  } catch (cms::Exception& e) {
660  edm::LogInfo ("KinFitter") << "Failed to invert matrix VA. Fit will be aborted.";
661  _status = -10;
662  }
663 
664  return true;
665 
666 }
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _VA
Definition: TKinFitter.h:114
Int_t _status
Definition: TKinFitter.h:148
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _AT
Definition: TKinFitter.h:107
Bool_t TKinFitter::calcVB ( )
protected

Definition at line 626 of file TKinFitter.cc.

References _B, _BT, _status, _V, _VB, _VBinv, alignCSCRings::e, and JetComb::kMult.

Referenced by fit().

626  {
627  // Calculate the matrix V_B = (B*V*B^T)^-1
628 
629  TMatrixD BV( _B, TMatrixD::kMult, _V );
630  TMatrixD VBinv( BV, TMatrixD::kMult, _BT );
631  _VBinv.ResizeTo( VBinv );
632  _VBinv = VBinv;
633 
634  _VB.ResizeTo( _VBinv );
635  _VB = _VBinv;
636  try {
637  _VB.Invert();
638  } catch (cms::Exception& e) {
639  edm::LogInfo ("KinFitter") << "Failed to invert matrix VB. Fit will be aborted.";
640  _status = -10;
641  }
642 
643  return true;
644 
645 }
TMatrixD _V
Definition: TKinFitter.h:110
TMatrixD _VB
Definition: TKinFitter.h:112
Int_t _status
Definition: TKinFitter.h:148
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _BT
Definition: TKinFitter.h:109
TMatrixD _VBinv
Definition: TKinFitter.h:113
Bool_t TKinFitter::calcVFit ( )
protected

Definition at line 944 of file TKinFitter.cc.

References _C11, _C21, _C21T, _C22, _C33, _lambdaVFit, _nParA, and _yaVFit.

Referenced by fit().

944  {
945  // Calculate the covariance matrix of fitted parameters
946  //
947  // Vfit(y) = ( C11 C21T )
948  // (a) ( C21 C22 )
949  //
950  // Vfit(lambda) = (-C33)
951 
952  // Calculate covariance matrix of lambda
953  _lambdaVFit.ResizeTo( _C33 );
954  _lambdaVFit = _C33;
955  _lambdaVFit *= -1.;
956 
957 
958  // Calculate combined covariance matrix of y and a
959  Int_t nbRows = _C11.GetNrows();
960  Int_t nbCols = _C11.GetNcols();
961  if ( _nParA > 0 ) {
962  nbRows += _C21.GetNrows();
963  nbCols += _C21T.GetNcols();
964  }
965  _yaVFit.ResizeTo( nbRows, nbCols );
966 
967  for (int iRow = 0; iRow < nbRows; iRow++) {
968  for (int iCol = 0; iCol < nbCols; iCol++) {
969 
970  if (iRow >= _C11.GetNrows()) {
971  if (iCol >= _C11.GetNcols()) {
972  _yaVFit(iRow, iCol) = _C22(iRow-_C11.GetNrows(), iCol-_C11.GetNcols());
973  } else {
974  _yaVFit(iRow, iCol) = _C21(iRow-_C11.GetNrows(), iCol);
975  }
976  } else {
977  if (iCol >= _C11.GetNcols()) {
978  _yaVFit(iRow, iCol) = _C21T(iRow, iCol-_C11.GetNcols());
979  } else {
980  _yaVFit(iRow, iCol) = _C11(iRow, iCol);
981  }
982  }
983 
984  }
985  }
986 
987  return true;
988 
989 }
TMatrixD _C11
Definition: TKinFitter.h:118
Int_t _nParA
Definition: TKinFitter.h:141
TMatrixD _C21T
Definition: TKinFitter.h:121
TMatrixD _yaVFit
Definition: TKinFitter.h:139
TMatrixD _C33
Definition: TKinFitter.h:128
TMatrixD _C22
Definition: TKinFitter.h:122
TMatrixD _lambdaVFit
Definition: TKinFitter.h:138
TMatrixD _C21
Definition: TKinFitter.h:120
Bool_t TKinFitter::converged ( Double_t  F,
Double_t  prevS,
Double_t  currS 
)
protected

Definition at line 1126 of file TKinFitter.cc.

References _maxDeltaS, _maxF, and Abs().

Referenced by fit().

1126  {
1127  // check whether convergence criteria are fulfilled
1128 
1129  Bool_t isConverged = false;
1130 
1131  // calculate F, delta(a) and delta(y) already applied
1132  isConverged = (F < _maxF);
1133 
1134  // Calculate current Chi^2 and delta(S)
1135  Double_t deltaS = currS - prevS;
1136  isConverged = isConverged && (TMath::Abs(deltaS) < _maxDeltaS);
1137 
1138  return isConverged;
1139 
1140 }
T Abs(T a)
Definition: MathUtil.h:49
Double_t _maxDeltaS
Definition: TKinFitter.h:102
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
Double_t _maxF
Definition: TKinFitter.h:103
void TKinFitter::countMeasParams ( )
protected

Definition at line 186 of file TKinFitter.cc.

References _constraints, _measParticles, and _nParB.

Referenced by addConstraint(), addMeasParticle(), and addMeasParticles().

186  {
187  // count number of measured parameters
188 
189  _nParB = 0;
190  for (unsigned int indexParticle = 0; indexParticle < _measParticles.size(); indexParticle++) {
191  _nParB += _measParticles[indexParticle]->getNPar();
192  }
193  for (unsigned int indexConstraint = 0; indexConstraint < _constraints.size(); indexConstraint++) {
194  _nParB += _constraints[indexConstraint]->getNPar();
195  }
196 
197 }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
Int_t _nParB
Definition: TKinFitter.h:142
void TKinFitter::countUnmeasParams ( )
protected

Definition at line 199 of file TKinFitter.cc.

References _nParA, and _unmeasParticles.

Referenced by addUnmeasParticle(), and addUnmeasParticles().

199  {
200  // count number of unmeasured parameters
201 
202  _nParA = 0;
203  for (unsigned int indexParticle = 0; indexParticle < _unmeasParticles.size(); indexParticle++) {
204  _nParA += _unmeasParticles[indexParticle]->getNPar();
205  }
206 
207 }
Int_t _nParA
Definition: TKinFitter.h:141
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
Int_t TKinFitter::fit ( )

Definition at line 309 of file TKinFitter.cc.

References _A, _B, _c, _C32T, _deltaA, _deltaAstar, _deltaY, _deltaYstar, _lambda, _lambdaT, _maxNbIter, _nbIter, _nParA, _status, _V, _VB, _VBinv, _verbosity, applyDeltaA(), applyDeltaY(), applyVFit(), calcA(), calcB(), calcC(), calcC11(), calcC21(), calcC22(), calcC31(), calcC32(), calcC33(), calcDeltaA(), calcDeltaY(), calcLambda(), calcV(), calcVA(), calcVB(), calcVFit(), converged(), getF(), getS(), print(), printMatrix(), resetParams(), and resetStatus().

Referenced by StKinFitter::addKinFitInfo(), TSLToyGen::doToyExperiments(), TtFullHadKinFitter::fit(), TtSemiLepKinFitter::fit(), and CandMassKinFitter::set().

309  {
310  // Perform the fit
311  // Returns:
312  // 0: converged
313  // 1: not converged
314 
315  resetParams();
316  resetStatus();
317 
318  _nbIter = 0;
319  Bool_t isConverged = false;
320  Double_t prevF;
321  Double_t currF = getF();
322  Double_t prevS;
323  Double_t currS = 0.;
324 
325  // Calculate covariance matrix V
326  calcV();
327 
328  // print status
329  if ( _verbosity >= 1 ) {
330  print();
331  }
332 
333  do {
334 
335  // Reset status to "RUNNING"
336  // (if it was not aborted already due to singular covariance matrix)
337  if ( _status != -10 ) {
338  _status = 10;
339  }
340 
341  // Calculate matrices
342  calcB();
343  calcVB();
344  if ( _nParA > 0 ) {
345  calcA();
346  calcVA();
347  calcC32();
348  }
349  calcC31();
350  calcC33();
351  calcC();
352 
353  // Calculate corretion for a, y, and lambda
354  if ( _nParA > 0 ){
355  calcDeltaA();
356  }
357  calcDeltaY();
358  calcLambda();
359 
360  if( _verbosity >= 3 ) {
361  printMatrix( _A , "A" );
362  printMatrix( _B , "B" );
363  printMatrix( _VBinv , "VBinv" );
364  printMatrix( _VB , "VB" );
365  printMatrix( _V , "V" );
366  printMatrix( _deltaY , "deltaY" );
367  printMatrix( _deltaA , "deltaA" );
368  printMatrix( _C32T , "C32T" );
369  printMatrix( _c , "C" );
370  }
371 
372  if( _verbosity >= 2 ) {
373  print();
374  }
375 
376  // Apply calculated corrections to measured and unmeasured particles
377  if ( _nParA > 0 ) {
378  applyDeltaA();
379  }
380  applyDeltaY();
381 
382  _nbIter++;
383 
384  //calculate F and S
385  prevF = currF;
386  currF = getF();
387  prevS = currS;
388  currS = getS();
389 
390  if( TMath::IsNaN(currF) ) {
391  edm::LogInfo ("KinFitter") << "The current value of F is NaN. Fit will be aborted.";
392  _status = -10;
393  }
394  if( TMath::IsNaN(currS) ) {
395  edm::LogInfo ("KinFitter") << "The current value of S is NaN. Fit will be aborted.";
396  _status = -10;
397  }
398 
399  // Reduce step width if F is not getting smaller
400  Int_t nstep = 0;
401  while (currF >= prevF) {
402  nstep++;
403  if (nstep == 10) break;
404  if (_nParA > 0) _deltaA -= (0.5) * (_deltaA - _deltaAstar);
405  _deltaY -= (0.5) * (_deltaY - _deltaYstar);
406  _lambda *= 0.5;
407  _lambdaT *= 0.5;
408  if (_nParA > 0) applyDeltaA();
409  applyDeltaY();
410  currF = getF();
411  currS = getS();
412  }
413 
414  // Test convergence
415  isConverged = converged(currF, prevS, currS);
416 
417 
418  } while ( (! isConverged) && (_nbIter < _maxNbIter) && (_status != -10) );
419 
420  // Calculate covariance matrices
421  calcB();
422  calcVB();
423 
424  if ( _nParA > 0 ) {
425  calcA();
426  calcVA();
427  calcC21();
428  calcC22();
429  calcC32();
430  }
431  calcC11();
432  calcC31();
433  calcC33();
434  calcVFit();
435  applyVFit();
436 
437  // Set status information
438  if (isConverged) {
439  _status = 0;
440  }
441  else if (_status != -10) {
442  _status = 1;
443  }
444 
445  // print status
446  if ( _verbosity >= 1 ) {
447  print();
448  }
449 
450  return _status;
451 
452 }
TMatrixD _deltaY
Definition: TKinFitter.h:132
Bool_t calcC33()
Definition: TKinFitter.cc:774
Bool_t calcV()
Definition: TKinFitter.cc:467
Bool_t converged(Double_t F, Double_t prevS, Double_t currS)
Definition: TKinFitter.cc:1126
Bool_t calcVFit()
Definition: TKinFitter.cc:944
Bool_t calcVB()
Definition: TKinFitter.cc:626
Bool_t calcC11()
Definition: TKinFitter.cc:668
Int_t _nParA
Definition: TKinFitter.h:141
TMatrixD _lambda
Definition: TKinFitter.h:135
TMatrixD _C32T
Definition: TKinFitter.h:127
Bool_t calcC21()
Definition: TKinFitter.cc:698
TMatrixD _V
Definition: TKinFitter.h:110
TMatrixD _VB
Definition: TKinFitter.h:112
void resetParams()
Definition: TKinFitter.cc:164
Double_t getS()
Definition: TKinFitter.cc:1108
TMatrixD _deltaA
Definition: TKinFitter.h:131
void applyVFit()
Definition: TKinFitter.cc:991
Bool_t applyDeltaY()
Definition: TKinFitter.cc:1059
Int_t _maxNbIter
Definition: TKinFitter.h:101
Bool_t calcB()
Definition: TKinFitter.cc:558
void print()
Definition: TKinFitter.cc:1174
TMatrixD _deltaAstar
Definition: TKinFitter.h:133
Bool_t calcDeltaY()
Definition: TKinFitter.cc:909
Bool_t calcA()
Definition: TKinFitter.cc:519
Bool_t calcLambda()
Definition: TKinFitter.cc:928
Bool_t calcC31()
Definition: TKinFitter.cc:731
Int_t _status
Definition: TKinFitter.h:148
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _c
Definition: TKinFitter.h:116
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _lambdaT
Definition: TKinFitter.h:136
Bool_t calcVA()
Definition: TKinFitter.cc:647
void printMatrix(const TMatrixD &matrix, const TString &name="")
Definition: TKinFitter.cc:1256
void resetStatus()
Definition: TKinFitter.cc:156
Bool_t applyDeltaA()
Definition: TKinFitter.cc:1038
TMatrixD _deltaYstar
Definition: TKinFitter.h:134
Int_t _nbIter
Definition: TKinFitter.h:149
Bool_t calcC32()
Definition: TKinFitter.cc:758
Int_t _verbosity
Definition: TKinFitter.h:104
Double_t getF()
Definition: TKinFitter.cc:1095
TMatrixD _VBinv
Definition: TKinFitter.h:113
Bool_t calcC22()
Definition: TKinFitter.cc:717
Bool_t calcC()
Definition: TKinFitter.cc:796
Bool_t calcDeltaA()
Definition: TKinFitter.cc:890
const TLorentzVector* TKinFitter::get4Vec ( Int_t  index)
inline

Definition at line 56 of file TKinFitter.h.

References _measParticles.

56 { return (_measParticles[index])->getCurr4Vec(); }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
const TMatrixD* TKinFitter::getCovMatrix ( )
inline

Definition at line 46 of file TKinFitter.h.

References _V.

46 { return &_V; }
TMatrixD _V
Definition: TKinFitter.h:110
const TMatrixD* TKinFitter::getCovMatrixFit ( )
inline

Definition at line 48 of file TKinFitter.h.

References _yaVFit.

48 { return &_yaVFit; }
TMatrixD _yaVFit
Definition: TKinFitter.h:139
Double_t TKinFitter::getF ( )

Definition at line 1095 of file TKinFitter.cc.

References _constraints, Abs(), and F().

Referenced by TSLToyGen::doToyExperiments(), fit(), and print().

1095  {
1096  // calculate current absolut value of constraints
1097  // F = Sum[ Abs(f_k( aStar, yStar)) ]
1098 
1099  Double_t F = 0.;
1100  for (unsigned int indexConstr = 0; indexConstr < _constraints.size(); indexConstr++) {
1101  F += TMath::Abs( _constraints[indexConstr]->getCurrentValue() );
1102  }
1103 
1104  return F;
1105 
1106 }
T Abs(T a)
Definition: MathUtil.h:49
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
Double_t TKinFitter::getMaxDeltaS ( )
inline

Definition at line 43 of file TKinFitter.h.

References _maxDeltaS.

43 { return _maxDeltaS; }
Double_t _maxDeltaS
Definition: TKinFitter.h:102
Double_t TKinFitter::getMaxF ( )
inline

Definition at line 45 of file TKinFitter.h.

References _maxF.

Referenced by TSLToyGen::doToyExperiments().

45 { return _maxF; }
Double_t _maxF
Definition: TKinFitter.h:103
Int_t TKinFitter::getMaxNumberIter ( )
inline

Definition at line 39 of file TKinFitter.h.

References _maxNbIter.

39 { return _maxNbIter; }
Int_t _maxNbIter
Definition: TKinFitter.h:101
const TAbsFitParticle* TKinFitter::getMeasParticle ( Int_t  index)
inline

Definition at line 55 of file TKinFitter.h.

References _measParticles, and cmsHarvester::index.

55 { return _measParticles[index]; }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
Int_t TKinFitter::getNbIter ( )
inline

Definition at line 40 of file TKinFitter.h.

References _nbIter.

Referenced by TSLToyGen::doToyExperiments(), and TopKinFitter::fitNrIter().

40 { return _nbIter; }
Int_t _nbIter
Definition: TKinFitter.h:149
Int_t TKinFitter::getNDF ( )
inline

Definition at line 35 of file TKinFitter.h.

References _constraints, and _nParA.

Referenced by TSLToyGen::doToyExperiments(), TopKinFitter::fitProb(), print(), and CandMassKinFitter::set().

35 { return (_constraints.size() - _nParA); }
Int_t _nParA
Definition: TKinFitter.h:141
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
Int_t TKinFitter::getNParA ( )
inline

Definition at line 36 of file TKinFitter.h.

References _nParA.

36 { return _nParA; }
Int_t _nParA
Definition: TKinFitter.h:141
Int_t TKinFitter::getNParB ( )
inline

Definition at line 37 of file TKinFitter.h.

References _nParB.

37 { return _nParB; }
Int_t _nParB
Definition: TKinFitter.h:142
Double_t TKinFitter::getS ( )

Definition at line 1108 of file TKinFitter.cc.

References _deltaY, _nbIter, _Vinv, JetComb::kMult, and S().

Referenced by TSLToyGen::doToyExperiments(), fit(), TopKinFitter::fitProb(), TopKinFitter::fitS(), print(), and CandMassKinFitter::set().

1108  {
1109  // calculate current value of Chi2
1110  // S = deltaYT * V^-1 * deltaY
1111 
1112  Double_t S = 0.;
1113 
1114  if ( _nbIter > 0 ) {
1115 
1116  TMatrixD deltaYTVinv(_deltaY, TMatrixD::kTransposeMult, _Vinv);
1117  TMatrixD S2(deltaYTVinv, TMatrixD::kMult, _deltaY);
1118  S = S2(0,0);
1119 
1120  }
1121 
1122  return S;
1123 
1124 }
TMatrixD _deltaY
Definition: TKinFitter.h:132
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
Int_t _nbIter
Definition: TKinFitter.h:149
TMatrixD _Vinv
Definition: TKinFitter.h:111
Int_t TKinFitter::getStatus ( void  )
inline
TString TKinFitter::getStatusString ( )
protected

Definition at line 1142 of file TKinFitter.cc.

References _status.

Referenced by print().

1142  {
1143 
1144  TString statusstring = "";
1145 
1146  switch ( _status ) {
1147 
1148  case -1: {
1149  statusstring = "NO FIT PERFORMED";
1150  break;
1151  }
1152  case 10: {
1153  statusstring = "RUNNING";
1154  break;
1155  }
1156  case -10: {
1157  statusstring = "ABORTED";
1158  break;
1159  }
1160  case 0: {
1161  statusstring = "CONVERGED";
1162  break;
1163  }
1164  case 1: {
1165  statusstring = "NOT CONVERGED";
1166  break;
1167  }
1168  }
1169 
1170  return statusstring;
1171 
1172 }
Int_t _status
Definition: TKinFitter.h:148
const TAbsFitParticle* TKinFitter::getUnmeasParticle ( Int_t  index)
inline

Definition at line 59 of file TKinFitter.h.

References _unmeasParticles, and cmsHarvester::index.

59 { return _unmeasParticles[index]; }
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
Int_t TKinFitter::getVerbosity ( )
inline

Definition at line 52 of file TKinFitter.h.

References _verbosity.

52 { return _verbosity; }
Int_t _verbosity
Definition: TKinFitter.h:104
Int_t TKinFitter::nbConstraints ( )
inline

Definition at line 60 of file TKinFitter.h.

References _constraints.

60 { return _constraints.size(); }
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
Int_t TKinFitter::nbMeasParticles ( )
inline

Definition at line 54 of file TKinFitter.h.

References _measParticles.

54 { return _measParticles.size(); }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
Int_t TKinFitter::nbUnmeasParticles ( )
inline

Definition at line 58 of file TKinFitter.h.

References _unmeasParticles.

58 { return _unmeasParticles.size(); }
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
void TKinFitter::print ( void  )

Definition at line 1174 of file TKinFitter.cc.

References _constraints, _measParticles, _nbIter, _nParB, _status, _unmeasParticles, _yaVFit, TAbsFitParticle::getCovMatrix(), getF(), TAbsFitParticle::getInfoString(), getNDF(), TAbsFitParticle::getNPar(), TAbsFitParticle::getParCurr(), getS(), getStatusString(), and cmsBatch::log.

Referenced by fit().

1174  {
1175 
1176  edm::LogVerbatim log("KinFitter");
1177  log << "\n"
1178  << "\n";
1179  // Print status of fit
1180  log << "Status: " << getStatusString()
1181  << " F=" << getF() << " S=" << getS() << " N=" << _nbIter << " NDF=" << getNDF() << "\n";
1182  // Print measured particles
1183  log << "measured particles: \n";
1184  Int_t parIndex = 0;
1185  for (unsigned int iP = 0; iP < _measParticles.size(); iP++) {
1186  TAbsFitParticle* particle = _measParticles[iP];
1187  Int_t nParP = particle->getNPar();
1188  const TMatrixD* par = particle->getParCurr();
1189  const TMatrixD* covP = particle->getCovMatrix();
1190  log << std::setw(3) << setiosflags(std::ios::right) << iP;
1191  log << std::setw(15) << setiosflags(std::ios::right) << particle->GetName();
1192  log << std::setw(3) << " ";
1193  for (int iPar = 0; iPar < nParP; iPar++) {
1194  if (iPar > 0) {
1195  log << setiosflags(std::ios::right) << std::setw(21) << " ";
1196  }
1197  TString colstr = "";
1198  colstr += parIndex;
1199  colstr += ":";
1200  log << std::setw(4) << colstr;
1201  log << std::setw(2) << " ";
1202  log << setiosflags(std::ios::left) << setiosflags(std::ios::scientific) << std::setprecision(3);
1203  log << std::setw(15) << (*par)(iPar, 0);
1204  if(_nbIter > 0 && _status < 10) {
1205  log << std::setw(15) << TMath::Sqrt( _yaVFit(iPar, iPar) );
1206  } else {
1207  log << std::setw(15) << " ";
1208  }
1209  log << std::setw(15) << TMath::Sqrt( (*covP)(iPar, iPar) );
1210  log << "\n";
1211  parIndex++;
1212  }
1213  log << particle->getInfoString();
1214  }
1215  // Print unmeasured particles
1216  log << "unmeasured particles: \n";
1217  parIndex = 0;
1218  for (unsigned int iP = 0; iP < _unmeasParticles.size(); iP++) {
1219  TAbsFitParticle* particle = _unmeasParticles[iP];
1220  Int_t nParP = particle->getNPar();
1221  const TMatrixD* par = particle->getParCurr();
1222  log << std::setw(3) << setiosflags(std::ios::right) << iP;
1223  log << std::setw(15) << particle->GetName();
1224  log << std::setw(3) << " ";
1225  for (int iPar = 0; iPar < nParP; iPar++) {
1226  if (iPar > 0) {
1227  log << setiosflags(std::ios::right) << std::setw(21) << " ";
1228  }
1229  TString colstr = "";
1230  colstr += parIndex;
1231  colstr += ":";
1232  log << std::setw(4) << colstr;
1233  log << std::setw(2) << " ";
1234  log << setiosflags(std::ios::left) << setiosflags(std::ios::scientific) << std::setprecision(3);
1235  log << std::setw(15) << (*par)(iPar, 0);
1236  if(_nbIter > 0 && _status < 10) {
1237  log << std::setw(15) << TMath::Sqrt( _yaVFit(iPar+_nParB, iPar+_nParB) );
1238  } else {
1239  log << std::setw(15) << " ";
1240  }
1241  log << "\n";
1242  parIndex++;
1243  }
1244  log << particle->getInfoString();
1245  }
1246  log << "\n";
1247  // Print constraints
1248  log << "constraints: \n";
1249  for (unsigned int indexConstr = 0; indexConstr < _constraints.size(); indexConstr++) {
1250  log << _constraints[indexConstr]->getInfoString();
1251  }
1252  log << "\n";
1253 
1254 }
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
TString getInfoString()
TString getStatusString()
Definition: TKinFitter.cc:1142
TMatrixD _yaVFit
Definition: TKinFitter.h:139
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
Double_t getS()
Definition: TKinFitter.cc:1108
Int_t _status
Definition: TKinFitter.h:148
Int_t getNPar() const
Int_t getNDF()
Definition: TKinFitter.h:35
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
virtual const TMatrixD * getCovMatrix() const
Int_t _nbIter
Definition: TKinFitter.h:149
Double_t getF()
Definition: TKinFitter.cc:1095
Int_t _nParB
Definition: TKinFitter.h:142
const TMatrixD * getParCurr()
tuple log
Definition: cmsBatch.py:341
void TKinFitter::printMatrix ( const TMatrixD &  matrix,
const TString &  name = "" 
)
protected

Definition at line 1256 of file TKinFitter.cc.

References i, cmsBatch::log, makeMuonMisalignmentScenario::matrix, and Min().

Referenced by calcB(), calcC(), and fit().

1256  {
1257  // produce a tabular printout for matrices
1258  // this function is a modified version of Root's TMatrixTBase<Element>::Print method
1259  // which could not be used together with the MessageLogger
1260 
1261  if (!matrix.IsValid()) {
1262  edm::LogWarning ("InvalidMatrix") << "Matrix " << name << " is invalid.";
1263  return;
1264  }
1265 
1266  edm::LogVerbatim log("KinFitter");
1267 
1268  const Int_t nCols = matrix.GetNcols();
1269  const Int_t nRows = matrix.GetNrows();
1270  const Int_t colsPerSheet = 5;
1271  char topbar[100];
1272  Int_t nk = 6+13*TMath::Min(colsPerSheet, nCols);
1273  for(Int_t i = 0; i < nk; i++) topbar[i] = '-';
1274  topbar[nk] = 0;
1275 
1276  Int_t sw = (70-name.Length())/2;
1277 
1278  log << std::setfill('=') << std::setw(sw) << "= " << name << std::setw(sw) << std::left << " =" << "\n"
1279  << std::setfill(' ') << std::right << "\n";
1280 
1281  log << nRows << "x" << nCols << " matrix is as follows \n";
1282 
1283  for (Int_t iSheet = 0; iSheet < nCols; iSheet += colsPerSheet) {
1284  log << "\n"
1285  << " |";
1286  for (Int_t iCol = iSheet; iCol < iSheet+colsPerSheet && iCol < nCols; iCol++)
1287  log << std::setw(8) << iCol << " |";
1288  log << "\n"
1289  << topbar << " \n";
1290  for(Int_t iRow = 0; iRow < nRows; iRow++) {
1291  log << std::setw(4) << iRow << " |";
1292  for (Int_t iCol = iSheet; iCol < iSheet+colsPerSheet && iCol < nCols; iCol++)
1293  log << std::setw(12) << matrix(iRow, iCol) << " ";
1294  log << "\n";
1295  }
1296  }
1297 
1298 }
int i
Definition: DBlmapReader.cc:9
T Min(T a, T b)
Definition: MathUtil.h:39
tuple log
Definition: cmsBatch.py:341
void TKinFitter::reset ( void  )

Definition at line 105 of file TKinFitter.cc.

References _A, _AT, _B, _BT, _c, _C11, _C11T, _C21, _C21T, _C22, _C22T, _C31, _C31T, _C32, _C32T, _C33, _C33T, _constraints, _deltaA, _deltaAstar, _deltaY, _deltaYstar, _lambda, _lambdaT, _lambdaVFit, _maxDeltaS, _maxF, _maxNbIter, _measParticles, _nbIter, _nParA, _nParB, _status, _unmeasParticles, _V, _VA, _VAinv, _VB, _VBinv, _verbosity, _Vinv, _yaVFit, and alignCSCRings::e.

Referenced by TKinFitter().

105  {
106  // reset all internal parameters of the fitter
107 
108  _status = -1;
109  _nbIter = 0;
110  _nParA = 0;
111  _nParB = 0;
112  _verbosity = 1;
113  _A.ResizeTo(1, 1);
114  _AT.ResizeTo(1, 1);
115  _B.ResizeTo(1, 1);
116  _BT.ResizeTo(1, 1);
117  _V.ResizeTo(1, 1);
118  _Vinv.ResizeTo(1, 1);
119  _VB.ResizeTo(1, 1);
120  _VBinv.ResizeTo(1, 1);
121  _VA.ResizeTo(1, 1);
122  _VAinv.ResizeTo(1, 1);
123  _c.ResizeTo(1, 1);
124  _C11.ResizeTo(1, 1);
125  _C11T.ResizeTo(1, 1);
126  _C21.ResizeTo(1, 1);
127  _C21T.ResizeTo(1, 1);
128  _C22.ResizeTo(1, 1);
129  _C22T.ResizeTo(1, 1);
130  _C31.ResizeTo(1, 1);
131  _C31T.ResizeTo(1, 1);
132  _C32.ResizeTo(1, 1);
133  _C32T.ResizeTo(1, 1);
134  _C33.ResizeTo(1, 1);
135  _C33T.ResizeTo(1, 1);
136  _deltaA.ResizeTo(1, 1);
137  _deltaY.ResizeTo(1, 1);
138  _deltaAstar.ResizeTo(1, 1);
139  _deltaYstar.ResizeTo(1, 1);
140  _lambda.ResizeTo(1, 1);
141  _lambdaT.ResizeTo(1, 1);
142  _lambdaVFit.ResizeTo(1, 1);
143  _yaVFit.ResizeTo(1, 1);
144 
145  _constraints.clear();
146  _measParticles.clear();
147  _unmeasParticles.clear();
148 
149  // Set to default values
150  _maxNbIter = 50;
151  _maxDeltaS = 5e-3;
152  _maxF = 1e-4;
153 
154 }
TMatrixD _deltaY
Definition: TKinFitter.h:132
TMatrixD _C11
Definition: TKinFitter.h:118
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
Int_t _nParA
Definition: TKinFitter.h:141
TMatrixD _C33T
Definition: TKinFitter.h:129
TMatrixD _lambda
Definition: TKinFitter.h:135
TMatrixD _C32T
Definition: TKinFitter.h:127
TMatrixD _V
Definition: TKinFitter.h:110
TMatrixD _C21T
Definition: TKinFitter.h:121
TMatrixD _VB
Definition: TKinFitter.h:112
TMatrixD _C31T
Definition: TKinFitter.h:125
TMatrixD _yaVFit
Definition: TKinFitter.h:139
TMatrixD _C32
Definition: TKinFitter.h:126
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
TMatrixD _VA
Definition: TKinFitter.h:114
TMatrixD _deltaA
Definition: TKinFitter.h:131
Int_t _maxNbIter
Definition: TKinFitter.h:101
TMatrixD _C33
Definition: TKinFitter.h:128
TMatrixD _deltaAstar
Definition: TKinFitter.h:133
Int_t _status
Definition: TKinFitter.h:148
TMatrixD _B
Definition: TKinFitter.h:108
TMatrixD _C22T
Definition: TKinFitter.h:123
TMatrixD _VAinv
Definition: TKinFitter.h:115
TMatrixD _C22
Definition: TKinFitter.h:122
TMatrixD _c
Definition: TKinFitter.h:116
Double_t _maxDeltaS
Definition: TKinFitter.h:102
TMatrixD _A
Definition: TKinFitter.h:106
TMatrixD _lambdaT
Definition: TKinFitter.h:136
TMatrixD _lambdaVFit
Definition: TKinFitter.h:138
TMatrixD _C31
Definition: TKinFitter.h:124
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
TMatrixD _deltaYstar
Definition: TKinFitter.h:134
TMatrixD _BT
Definition: TKinFitter.h:109
TMatrixD _AT
Definition: TKinFitter.h:107
Int_t _nbIter
Definition: TKinFitter.h:149
Int_t _verbosity
Definition: TKinFitter.h:104
TMatrixD _VBinv
Definition: TKinFitter.h:113
Int_t _nParB
Definition: TKinFitter.h:142
TMatrixD _C11T
Definition: TKinFitter.h:119
TMatrixD _C21
Definition: TKinFitter.h:120
TMatrixD _Vinv
Definition: TKinFitter.h:111
Double_t _maxF
Definition: TKinFitter.h:103
void TKinFitter::resetParams ( )
protected

Definition at line 164 of file TKinFitter.cc.

References _constraints, _measParticles, _unmeasParticles, HLT_25ns14e33_v1_cff::constraint, TAbsFitConstraint::reset(), and TAbsFitParticle::reset().

Referenced by fit().

164  {
165  // reset all particles to their initial parameters
166 
167  for (unsigned int iP = 0; iP < _measParticles.size(); iP++) {
168  TAbsFitParticle* particle = _measParticles[iP];
169  particle->reset();
170  }
171  for (unsigned int iP = 0; iP < _unmeasParticles.size(); iP++) {
172  TAbsFitParticle* particle = _unmeasParticles[iP];
173  particle->reset();
174  }
175  for (unsigned int iC = 0; iC < _constraints.size(); iC++) {
177  constraint->reset();
178  }
179 
180 }
virtual void reset()
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:145
virtual void reset()
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:146
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:144
void TKinFitter::resetStatus ( )

Definition at line 156 of file TKinFitter.cc.

References _nbIter, and _status.

Referenced by addConstraint(), addMeasParticle(), addMeasParticles(), addUnmeasParticle(), addUnmeasParticles(), and fit().

156  {
157  // reset status of the fit
158 
159  _status = -1;
160  _nbIter = 0;
161 
162 }
Int_t _status
Definition: TKinFitter.h:148
Int_t _nbIter
Definition: TKinFitter.h:149
void TKinFitter::setCovMatrix ( TMatrixD &  V)

Definition at line 454 of file TKinFitter.cc.

References _nParB, and _V.

454  {
455  // Set the covariance matrix of the measured particles
456 
457  if ( (V.GetNrows() != _nParB) || (V.GetNcols() != _nParB) ) {
458  edm::LogError ("WrongMatrixSize")
459  << "Covariance matrix of measured particles needs to be a " << _nParB << "x" << _nParB << " matrix.";
460  } else {
461  _V.ResizeTo( V );
462  _V = V;
463  }
464 
465 }
TMatrixD _V
Definition: TKinFitter.h:110
Int_t _nParB
Definition: TKinFitter.h:142
void TKinFitter::setMaxDeltaS ( Double_t  maxDeltaS)
inline

Definition at line 42 of file TKinFitter.h.

References _maxDeltaS, and Abs().

Referenced by TSLToyGen::doToyExperiments(), CandMassKinFitter::set(), and TopKinFitter::TopKinFitter().

42 { _maxDeltaS = TMath::Abs( maxDeltaS ); }
T Abs(T a)
Definition: MathUtil.h:49
Double_t _maxDeltaS
Definition: TKinFitter.h:102
void TKinFitter::setMaxF ( Double_t  maxF)
inline

Definition at line 44 of file TKinFitter.h.

References _maxF, and Abs().

Referenced by TSLToyGen::doToyExperiments(), CandMassKinFitter::set(), and TopKinFitter::TopKinFitter().

44 { _maxF = TMath::Abs( maxF ); }
T Abs(T a)
Definition: MathUtil.h:49
Double_t _maxF
Definition: TKinFitter.h:103
void TKinFitter::setMaxNbIter ( Int_t  maxNbIter)
inline

Definition at line 38 of file TKinFitter.h.

References _maxNbIter.

Referenced by TSLToyGen::doToyExperiments(), CandMassKinFitter::set(), and TopKinFitter::TopKinFitter().

38 { _maxNbIter = maxNbIter; }
Int_t _maxNbIter
Definition: TKinFitter.h:101
void TKinFitter::setVerbosity ( Int_t  verbosity = 1)

Definition at line 294 of file TKinFitter.cc.

References _verbosity, and HLT_25ns14e33_v1_cff::verbosity.

Referenced by TSLToyGen::doToyExperiments(), CandMassKinFitter::set(), TopKinFitter::setVerbosity(), and TopKinFitter::TopKinFitter().

294  {
295  // Set verbosity of the fitter:
296  // 0: quiet
297  // 1: print information before and after the fit
298  // 2: print output for every iteration of the fit
299  // 3: print debug information
300 
301 
302  if ( verbosity < 0 ) verbosity = 0;
303  if ( verbosity > 3 ) verbosity = 3;
305 
306 }
Int_t _verbosity
Definition: TKinFitter.h:104

Member Data Documentation

TMatrixD TKinFitter::_A
private

Definition at line 106 of file TKinFitter.h.

Referenced by calcA(), calcC(), calcC11(), calcC31(), calcC32(), calcC33(), calcVA(), fit(), and reset().

TMatrixD TKinFitter::_AT
private

Definition at line 107 of file TKinFitter.h.

Referenced by calcA(), calcC11(), calcC21(), calcC31(), calcC33(), calcVA(), and reset().

TMatrixD TKinFitter::_B
private

Definition at line 108 of file TKinFitter.h.

Referenced by calcB(), calcC(), calcC11(), calcC21(), calcC31(), calcVB(), fit(), and reset().

TMatrixD TKinFitter::_BT
private

Definition at line 109 of file TKinFitter.h.

Referenced by calcB(), calcC11(), calcVB(), and reset().

TMatrixD TKinFitter::_c
private

Definition at line 116 of file TKinFitter.h.

Referenced by calcC(), calcDeltaA(), calcDeltaY(), calcLambda(), fit(), and reset().

TMatrixD TKinFitter::_C11
private

Definition at line 118 of file TKinFitter.h.

Referenced by calcC11(), calcVFit(), and reset().

TMatrixD TKinFitter::_C11T
private

Definition at line 119 of file TKinFitter.h.

Referenced by calcC11(), and reset().

TMatrixD TKinFitter::_C21
private

Definition at line 120 of file TKinFitter.h.

Referenced by calcC21(), calcVFit(), and reset().

TMatrixD TKinFitter::_C21T
private

Definition at line 121 of file TKinFitter.h.

Referenced by calcC21(), calcVFit(), and reset().

TMatrixD TKinFitter::_C22
private

Definition at line 122 of file TKinFitter.h.

Referenced by calcC22(), calcVFit(), and reset().

TMatrixD TKinFitter::_C22T
private

Definition at line 123 of file TKinFitter.h.

Referenced by calcC22(), and reset().

TMatrixD TKinFitter::_C31
private

Definition at line 124 of file TKinFitter.h.

Referenced by calcC31(), and reset().

TMatrixD TKinFitter::_C31T
private

Definition at line 125 of file TKinFitter.h.

Referenced by calcC31(), calcDeltaY(), and reset().

TMatrixD TKinFitter::_C32
private

Definition at line 126 of file TKinFitter.h.

Referenced by calcC32(), and reset().

TMatrixD TKinFitter::_C32T
private

Definition at line 127 of file TKinFitter.h.

Referenced by calcC32(), calcDeltaA(), fit(), and reset().

TMatrixD TKinFitter::_C33
private

Definition at line 128 of file TKinFitter.h.

Referenced by calcC33(), calcLambda(), calcVFit(), and reset().

TMatrixD TKinFitter::_C33T
private

Definition at line 129 of file TKinFitter.h.

Referenced by calcC33(), and reset().

std::vector<TAbsFitConstraint*> TKinFitter::_constraints
private
TMatrixD TKinFitter::_deltaA
private

Definition at line 131 of file TKinFitter.h.

Referenced by applyDeltaA(), calcDeltaA(), fit(), and reset().

TMatrixD TKinFitter::_deltaAstar
private

Definition at line 133 of file TKinFitter.h.

Referenced by calcDeltaA(), fit(), and reset().

TMatrixD TKinFitter::_deltaY
private

Definition at line 132 of file TKinFitter.h.

Referenced by applyDeltaY(), calcDeltaY(), fit(), getS(), and reset().

TMatrixD TKinFitter::_deltaYstar
private

Definition at line 134 of file TKinFitter.h.

Referenced by calcDeltaY(), fit(), and reset().

TMatrixD TKinFitter::_lambda
private

Definition at line 135 of file TKinFitter.h.

Referenced by calcLambda(), fit(), and reset().

TMatrixD TKinFitter::_lambdaT
private

Definition at line 136 of file TKinFitter.h.

Referenced by calcLambda(), fit(), and reset().

TMatrixD TKinFitter::_lambdaVFit
private

Definition at line 138 of file TKinFitter.h.

Referenced by calcVFit(), and reset().

Double_t TKinFitter::_maxDeltaS
private

Definition at line 102 of file TKinFitter.h.

Referenced by converged(), getMaxDeltaS(), reset(), and setMaxDeltaS().

Double_t TKinFitter::_maxF
private

Definition at line 103 of file TKinFitter.h.

Referenced by converged(), getMaxF(), reset(), and setMaxF().

Int_t TKinFitter::_maxNbIter
private

Definition at line 101 of file TKinFitter.h.

Referenced by fit(), getMaxNumberIter(), reset(), and setMaxNbIter().

std::vector<TAbsFitParticle*> TKinFitter::_measParticles
private
Int_t TKinFitter::_nbIter
private

Definition at line 149 of file TKinFitter.h.

Referenced by calcDeltaA(), calcDeltaY(), fit(), getNbIter(), getS(), print(), reset(), and resetStatus().

Int_t TKinFitter::_nParA
private
Int_t TKinFitter::_nParB
private

Definition at line 142 of file TKinFitter.h.

Referenced by calcB(), calcC(), calcV(), countMeasParams(), getNParB(), print(), reset(), and setCovMatrix().

Int_t TKinFitter::_status
private

Definition at line 148 of file TKinFitter.h.

Referenced by calcV(), calcVA(), calcVB(), fit(), getStatus(), getStatusString(), print(), reset(), and resetStatus().

std::vector<TAbsFitParticle*> TKinFitter::_unmeasParticles
private
TMatrixD TKinFitter::_V
private

Definition at line 110 of file TKinFitter.h.

Referenced by calcC11(), calcC21(), calcC31(), calcV(), calcVB(), fit(), getCovMatrix(), reset(), and setCovMatrix().

TMatrixD TKinFitter::_VA
private

Definition at line 114 of file TKinFitter.h.

Referenced by calcVA(), and reset().

TMatrixD TKinFitter::_VAinv
private

Definition at line 115 of file TKinFitter.h.

Referenced by calcC11(), calcC21(), calcC22(), calcC31(), calcC32(), calcC33(), calcVA(), and reset().

TMatrixD TKinFitter::_VB
private

Definition at line 112 of file TKinFitter.h.

Referenced by calcC11(), calcC21(), calcC31(), calcC32(), calcC33(), calcVA(), calcVB(), fit(), and reset().

TMatrixD TKinFitter::_VBinv
private

Definition at line 113 of file TKinFitter.h.

Referenced by calcVB(), fit(), and reset().

Int_t TKinFitter::_verbosity
private

Definition at line 104 of file TKinFitter.h.

Referenced by calcB(), calcC(), fit(), getVerbosity(), reset(), and setVerbosity().

TMatrixD TKinFitter::_Vinv
private

Definition at line 111 of file TKinFitter.h.

Referenced by calcV(), getS(), and reset().

TMatrixD TKinFitter::_yaVFit
private

Definition at line 139 of file TKinFitter.h.

Referenced by applyVFit(), calcVFit(), getCovMatrixFit(), print(), and reset().