test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TAbsFitConstraint.cc
Go to the documentation of this file.
1 // Classname: TAbsFitConstraint
2 // Author: Jan E. Sundermann, Verena Klose (TU Dresden)
3 
4 
5 //________________________________________________________________
6 //
7 // TAbsFitConstraint::
8 // --------------------
9 //
10 // Abstract base class for fit constraints
11 //
12 
15 #include <iostream>
16 #include <iomanip>
17 #include "TClass.h"
18 
19 
21  : TNamed("NoName","NoTitle")
22  ,_covMatrix()
23  ,_covMatrixFit()
24  ,_covMatrixDeltaAlpha()
25  ,_iniparameters()
26  ,_parameters()
27 
28 {
29  _nPar = 0;
30 }
31 
32 TAbsFitConstraint::TAbsFitConstraint(const TString &name, const TString &title)
33  : TNamed(name, title)
34  ,_covMatrix()
35  ,_covMatrixFit()
36  ,_covMatrixDeltaAlpha()
37  ,_iniparameters()
38  ,_parameters()
39 
40 {
41  _nPar = 0;
42 }
43 
45 
46 }
47 
49  // Reset parameters to initial values
50 
52  setCovMatrixFit( 0 );
53 
54 }
55 
56 void TAbsFitConstraint::setCovMatrix(const TMatrixD* theCovMatrix) {
57  // Set measured alpha covariance matrix
58 
59  _covMatrix.ResizeTo(_nPar, _nPar);
60  if(theCovMatrix==0) {
61  _covMatrix.Zero();
62  } else if (theCovMatrix->GetNcols() ==_nPar && theCovMatrix->GetNrows() ==_nPar) {
63  _covMatrix = (*theCovMatrix);
64  } else {
65  edm::LogError ("WrongMatrixSize")
66  << GetName() << "::setCovMatrix - Measured alpha covariance matrix needs to be a "
67  << _nPar << "x" << _nPar << " matrix.";
68  }
69 
70 }
71 
72 void TAbsFitConstraint::setCovMatrixFit(const TMatrixD* theCovMatrixFit) {
73  // Set the fitted covariance matrix
74 
75  _covMatrixFit.ResizeTo(_nPar, _nPar);
76  if(theCovMatrixFit==0) {
77  _covMatrixFit.Zero();
78  } else if (theCovMatrixFit->GetNcols() ==_nPar && theCovMatrixFit->GetNrows() ==_nPar) {
79  _covMatrixFit = (*theCovMatrixFit);
80  } else {
81  edm::LogError ("WrongMatrixSize")
82  << GetName() << "::setCovMatrixFit - Fitted covariance matrix needs to be a "
83  << _nPar << "x" << _nPar << " matrix.";
84  }
85 
86 }
87 
89  // Calculates V(deltaAlpha) == V(alpha_meas) - V(alpha_fit)
90 
91  _covMatrixDeltaAlpha.ResizeTo( _nPar, _nPar );
93  if(_covMatrixFit.GetNrows() == _nPar && _covMatrixFit.GetNcols() == _nPar)
95  else
96  edm::LogError ("WrongMatrixSize")
97  << GetName() << "::calcCovMatrixDeltaAlpha - _covMatrixFit probably not set.";
98 }
99 
100 
101 void TAbsFitConstraint::applyDeltaAlpha(TMatrixD* corrMatrix) {
102  // Apply corrections to the parameters wrt. to the
103  // initial parameters alpha* = alpha + delta(alpha)
104 
106  _parameters += (*corrMatrix);
107 
108 }
109 
110 void TAbsFitConstraint::setParIni(const TMatrixD* parini) {
111  // Set initial parameter values (before the fit)
112 
113  if (parini == 0) return;
114  else if( parini->GetNrows() == _iniparameters.GetNrows() &&
115  parini->GetNcols() == _iniparameters.GetNcols() )
116  _iniparameters = (*parini) ;
117  else {
118  edm::LogError ("WrongMatrixSize")
119  << GetName() << "::setParIni - Matrices don't fit.";
120  return;
121  }
122 
123 }
124 
126  // Returns covariance matrix delta(alpha)
127 
129  return &_covMatrixDeltaAlpha;
130 
131 }
132 
134  // Collect information to be used for printout
135 
136  std::stringstream info;
137  info << std::scientific << std::setprecision(6);
138 
139  info << "__________________________" << std::endl
140  << std::endl;
141  info <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
142 
143  info << "initial value: " << getInitValue() << std::endl;
144  info << "current value: " << getCurrentValue() << std::endl;
145 
146  return info.str();
147 
148 }
149 
151  // Print constraint contents
152 
153  edm::LogVerbatim("KinFitter") << this->getInfoString();
154 
155 }
156 
virtual void applyDeltaAlpha(TMatrixD *corrMatrix)
static const TGPicture * info(bool iBackgroundIsBlack)
virtual void reset()
virtual Double_t getCurrentValue()=0
virtual ~TAbsFitConstraint()
virtual Double_t getInitValue()=0
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
TMatrixD _covMatrixDeltaAlpha
virtual TString getInfoString()
virtual void setCovMatrixFit(const TMatrixD *theCovMatrixFit)
virtual const TMatrixD * getCovMatrixDeltaAlpha()
virtual void print()
void setParIni(const TMatrixD *parini)