CMS 3D CMS Logo

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();
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();
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 
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 }
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
MessageLogger.h
TFitConstraintMGaus::_width
Double_t _width
Definition: TFitConstraintMGaus.h:36
TAbsFitConstraint::_covMatrix
TMatrixD _covMatrix
Definition: TAbsFitConstraint.h:49
TAbsFitConstraint::setCovMatrix
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
Definition: TAbsFitConstraint.cc:51
TFitConstraintM
Definition: TFitConstraintM.h:11
TFitConstraintM::_ParList2
std::vector< TAbsFitParticle * > _ParList2
Definition: TFitConstraintM.h:63
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
TFitConstraintMGaus::setMassConstraint
void setMassConstraint(Double_t Mass, Double_t Width)
Definition: TFitConstraintMGaus.cc:60
TAbsFitConstraint::_nPar
Int_t _nPar
Definition: TAbsFitConstraint.h:47
DQMGenericTnPClient_cfi.Width
Width
Definition: DQMGenericTnPClient_cfi.py:8
TFitConstraintMGaus::~TFitConstraintMGaus
~TFitConstraintMGaus() override
Definition: TFitConstraintMGaus.cc:54
TFitConstraintM::CalcMass
Double_t CalcMass(std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
Definition: TFitConstraintM.cc:244
TFitConstraintMGaus::getInitValue
Double_t getInitValue() override
Definition: TFitConstraintMGaus.cc:73
TFitConstraintM::_ParList1
std::vector< TAbsFitParticle * > _ParList1
Definition: TFitConstraintM.h:61
TFitConstraintMGaus::getDerivativeAlpha
TMatrixD * getDerivativeAlpha() override
Definition: TFitConstraintMGaus.cc:91
HLTSiStripMonitoring_cff.Mass
Mass
Definition: HLTSiStripMonitoring_cff.py:135
TAbsFitConstraint::_iniparameters
TMatrixD _iniparameters
Definition: TAbsFitConstraint.h:52
TFitConstraintMGaus::init
void init()
Definition: TFitConstraintMGaus.cc:43
TFitConstraintMGaus::getInfoString
TString getInfoString() override
Definition: TFitConstraintMGaus.cc:102
TAbsFitConstraint::_parameters
TMatrixD _parameters
Definition: TAbsFitConstraint.h:53
TFitConstraintMGaus::getCurrentValue
Double_t getCurrentValue() override
Definition: TFitConstraintMGaus.cc:82
TFitConstraintMGaus.h
TFitConstraintMGaus::TFitConstraintMGaus
TFitConstraintMGaus()
Definition: TFitConstraintMGaus.cc:21
TFitConstraintM::_TheMassConstraint
Double_t _TheMassConstraint
Definition: TFitConstraintM.h:64
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TFitConstraintMGaus::print
void print() override
Definition: TFitConstraintMGaus.cc:121