File indexing completed on 2024-04-06 12:23:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <iostream>
0013 #include <iomanip>
0014 #include "PhysicsTools/KinFitter/interface/TFitConstraintMGaus.h"
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 #include "TClass.h"
0017
0018
0019
0020
0021 TFitConstraintMGaus::TFitConstraintMGaus() : TFitConstraintM() { init(); }
0022
0023 TFitConstraintMGaus::TFitConstraintMGaus(std::vector<TAbsFitParticle*>* ParList1,
0024 std::vector<TAbsFitParticle*>* ParList2,
0025 Double_t Mass,
0026 Double_t Width)
0027 : TFitConstraintM(ParList1, ParList2, Mass) {
0028 init();
0029 setMassConstraint(Mass, Width);
0030 }
0031
0032 TFitConstraintMGaus::TFitConstraintMGaus(const TString& name,
0033 const TString& title,
0034 std::vector<TAbsFitParticle*>* ParList1,
0035 std::vector<TAbsFitParticle*>* ParList2,
0036 Double_t Mass,
0037 Double_t Width)
0038 : TFitConstraintM(name, title, ParList1, ParList2, Mass) {
0039 init();
0040 setMassConstraint(Mass, Width);
0041 }
0042
0043 void TFitConstraintMGaus::init() {
0044 _nPar = 1;
0045 _iniparameters.ResizeTo(1, 1);
0046 _iniparameters(0, 0) = 1.;
0047 _parameters.ResizeTo(1, 1);
0048 _parameters = _iniparameters;
0049 }
0050
0051
0052
0053
0054 TFitConstraintMGaus::~TFitConstraintMGaus() {}
0055
0056
0057
0058
0059
0060 void TFitConstraintMGaus::setMassConstraint(Double_t Mass, Double_t Width) {
0061 _TheMassConstraint = Mass;
0062 _width = Width;
0063 setCovMatrix(nullptr);
0064 if (!Mass)
0065 throw cms::Exception("Configuration") << "Error occured!\n"
0066 << "Object type : TFitConstraintMGaus\n"
0067 << "Object name : " << GetName() << "\n"
0068 << "Object title: " << GetTitle() << "\n"
0069 << "Mass of 0 GeV not supported, please choose a larger mass!\n";
0070 _covMatrix(0, 0) = (Width * Width) / (Mass * Mass);
0071 }
0072
0073 Double_t TFitConstraintMGaus::getInitValue() {
0074
0075
0076 Double_t InitValue =
0077 CalcMass(&_ParList1, true) - CalcMass(&_ParList2, true) - _iniparameters(0, 0) * _TheMassConstraint;
0078
0079 return InitValue;
0080 }
0081
0082 Double_t TFitConstraintMGaus::getCurrentValue() {
0083
0084
0085 Double_t CurrentValue =
0086 CalcMass(&_ParList1, false) - CalcMass(&_ParList2, false) - _parameters(0, 0) * _TheMassConstraint;
0087
0088 return CurrentValue;
0089 }
0090
0091 TMatrixD* TFitConstraintMGaus::getDerivativeAlpha() {
0092
0093
0094 TMatrixD* DerivativeMatrix = new TMatrixD(1, 1);
0095 DerivativeMatrix->Zero();
0096
0097 (*DerivativeMatrix)(0, 0) = -1. * _TheMassConstraint;
0098
0099 return DerivativeMatrix;
0100 }
0101
0102 TString TFitConstraintMGaus::getInfoString() {
0103
0104
0105 std::stringstream info;
0106 info << std::scientific << std::setprecision(6);
0107
0108 info << "__________________________" << std::endl << std::endl;
0109 info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
0110
0111 info << "initial value: " << getInitValue() << std::endl;
0112 info << "current value: " << getCurrentValue() << std::endl;
0113 info << "mean mass: " << _TheMassConstraint << std::endl;
0114 info << "width: " << _width << std::endl;
0115 info << "initial mass: " << _iniparameters(0, 0) * _TheMassConstraint << std::endl;
0116 info << "current mass: " << _parameters(0, 0) * _TheMassConstraint << std::endl;
0117
0118 return info.str();
0119 }
0120
0121 void TFitConstraintMGaus::print() {
0122
0123
0124 edm::LogVerbatim("KinFitter") << this->getInfoString();
0125 }