CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TFitConstraintMGaus.cc
Go to the documentation of this file.
1 // Classname: TFitConstraintMGaus
2 // Author: Jan E. Sundermann, Verena Klose (TU Dresden)
3 
4 
5 //________________________________________________________________
6 //
7 // TFitConstraintMGaus::
8 // --------------------
9 //
10 // Fit constraint: mass conservation ( m_i - m_j - alpha * MassConstraint == 0 )
11 //
12 
13 #include <iostream>
14 #include <iomanip>
17 #include "TClass.h"
18 
19 
20 //----------------
21 // Constructor --
22 //----------------
24  : TFitConstraintM()
25 {
26 
27  init();
28 
29 }
30 
31 TFitConstraintMGaus::TFitConstraintMGaus(std::vector<TAbsFitParticle*>* ParList1,
32  std::vector<TAbsFitParticle*>* ParList2,
33  Double_t Mass,
34  Double_t Width)
35  : TFitConstraintM(ParList1, ParList2, Mass )
36 {
37 
38  init();
39  setMassConstraint( Mass, Width );
40 
41 }
42 
43 TFitConstraintMGaus::TFitConstraintMGaus(const TString &name, const TString &title,
44  std::vector<TAbsFitParticle*>* ParList1,
45  std::vector<TAbsFitParticle*>* ParList2,
46  Double_t Mass,
47  Double_t Width)
48  : TFitConstraintM( name, title, ParList1, ParList2, Mass )
49 {
50 
51  init();
52  setMassConstraint( Mass, Width );
53 
54 }
55 
56 void
58 
59  _nPar = 1;
60  _iniparameters.ResizeTo(1,1);
61  _iniparameters(0,0) = 1.;
62  _parameters.ResizeTo(1,1);
64 
65 }
66 
67 //--------------
68 // Destructor --
69 //--------------
71 
72 }
73 
74 //--------------
75 // Operations --
76 //--------------
77 
78 void TFitConstraintMGaus::setMassConstraint(Double_t Mass, Double_t Width) {
79 
81  _width = Width;
82  setCovMatrix( 0 );
83  if(!Mass) throw cms::Exception("Configuration")
84  << "Error occured!\n"
85  << "Object type : TFitConstraintMGaus\n"
86  << "Object name : " << GetName() << "\n"
87  << "Object title: " << GetTitle() << "\n"
88  << "Mass of 0 GeV not supported, please choose a larger mass!\n";
89  _covMatrix(0,0) = (Width*Width) / (Mass * Mass);
90 
91 }
92 
94  // Get initial value of constraint (before the fit)
95 
96  Double_t InitValue =
97  CalcMass( &_ParList1, true ) -
98  CalcMass( &_ParList2, true ) -
100 
101  return InitValue;
102 
103 }
104 
106  // Get value of constraint after the fit
107 
108  Double_t CurrentValue =
109  CalcMass(&_ParList1,false) -
110  CalcMass(&_ParList2,false) -
112 
113  return CurrentValue;
114 
115 }
116 
118  // Calculate dF/dAlpha = -1 * M
119 
120  TMatrixD* DerivativeMatrix = new TMatrixD(1,1);
121  DerivativeMatrix->Zero();
122 
123  (*DerivativeMatrix)(0,0) = -1. * _TheMassConstraint;
124 
125  return DerivativeMatrix;
126 
127 }
128 
130  // Collect information to be used for printout
131 
132  std::stringstream info;
133  info << std::scientific << std::setprecision(6);
134 
135  info << "__________________________" << std::endl
136  << std::endl;
137  info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
138 
139  info << "initial value: " << getInitValue() << std::endl;
140  info << "current value: " << getCurrentValue() << std::endl;
141  info << "mean mass: " << _TheMassConstraint << std::endl;
142  info << "width: " << _width << std::endl;
143  info << "initial mass: " << _iniparameters(0,0)*_TheMassConstraint << std::endl;
144  info << "current mass: " << _parameters(0,0)*_TheMassConstraint << 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 TString getInfoString()
Double_t CalcMass(std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
Double_t _TheMassConstraint
virtual Double_t getInitValue()
void setMassConstraint(Double_t Mass, Double_t Width)
virtual TMatrixD * getDerivativeAlpha()
std::vector< TAbsFitParticle * > _ParList1
virtual Double_t getCurrentValue()
std::vector< TAbsFitParticle * > _ParList2