CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 // TFitConstraintMGaus::
7 // --------------------
8 //
9 // Fit constraint: mass conservation ( m_i - m_j - alpha * MassConstraint == 0 )
10 //
11 
12 #include <iostream>
13 #include <iomanip>
16 #include "TClass.h"
17 
18 //----------------
19 // Constructor --
20 //----------------
22 
23 TFitConstraintMGaus::TFitConstraintMGaus(std::vector<TAbsFitParticle*>* ParList1,
24  std::vector<TAbsFitParticle*>* ParList2,
25  Double_t Mass,
26  Double_t Width)
27  : TFitConstraintM(ParList1, ParList2, Mass) {
28  init();
29  setMassConstraint(Mass, Width);
30 }
31 
33  const TString& title,
34  std::vector<TAbsFitParticle*>* ParList1,
35  std::vector<TAbsFitParticle*>* ParList2,
36  Double_t Mass,
37  Double_t Width)
38  : TFitConstraintM(name, title, ParList1, ParList2, Mass) {
39  init();
40  setMassConstraint(Mass, Width);
41 }
42 
44  _nPar = 1;
45  _iniparameters.ResizeTo(1, 1);
46  _iniparameters(0, 0) = 1.;
47  _parameters.ResizeTo(1, 1);
49 }
50 
51 //--------------
52 // Destructor --
53 //--------------
55 
56 //--------------
57 // Operations --
58 //--------------
59 
60 void TFitConstraintMGaus::setMassConstraint(Double_t Mass, Double_t Width) {
62  _width = Width;
63  setCovMatrix(nullptr);
64  if (!Mass)
65  throw cms::Exception("Configuration") << "Error occured!\n"
66  << "Object type : TFitConstraintMGaus\n"
67  << "Object name : " << GetName() << "\n"
68  << "Object title: " << GetTitle() << "\n"
69  << "Mass of 0 GeV not supported, please choose a larger mass!\n";
70  _covMatrix(0, 0) = (Width * Width) / (Mass * Mass);
71 }
72 
74  // Get initial value of constraint (before the fit)
75 
76  Double_t InitValue =
78 
79  return InitValue;
80 }
81 
83  // Get value of constraint after the fit
84 
85  Double_t CurrentValue =
86  CalcMass(&_ParList1, false) - CalcMass(&_ParList2, false) - _parameters(0, 0) * _TheMassConstraint;
87 
88  return CurrentValue;
89 }
90 
92  // Calculate dF/dAlpha = -1 * M
93 
94  TMatrixD* DerivativeMatrix = new TMatrixD(1, 1);
95  DerivativeMatrix->Zero();
96 
97  (*DerivativeMatrix)(0, 0) = -1. * _TheMassConstraint;
98 
99  return DerivativeMatrix;
100 }
101 
103  // Collect information to be used for printout
104 
105  std::stringstream info;
106  info << std::scientific << std::setprecision(6);
107 
108  info << "__________________________" << std::endl << std::endl;
109  info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
110 
111  info << "initial value: " << getInitValue() << std::endl;
112  info << "current value: " << getCurrentValue() << std::endl;
113  info << "mean mass: " << _TheMassConstraint << std::endl;
114  info << "width: " << _width << std::endl;
115  info << "initial mass: " << _iniparameters(0, 0) * _TheMassConstraint << std::endl;
116  info << "current mass: " << _parameters(0, 0) * _TheMassConstraint << std::endl;
117 
118  return info.str();
119 }
120 
122  // Print constraint contents
123 
124  edm::LogVerbatim("KinFitter") << this->getInfoString();
125 }
Log< level::Info, true > LogVerbatim
static const TGPicture * info(bool iBackgroundIsBlack)
Double_t getInitValue() override
Double_t CalcMass(std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
Double_t getCurrentValue() override
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
Double_t _TheMassConstraint
TString getInfoString() override
void setMassConstraint(Double_t Mass, Double_t Width)
TMatrixD * getDerivativeAlpha() override
std::vector< TAbsFitParticle * > _ParList1
std::vector< TAbsFitParticle * > _ParList2