CMS 3D CMS Logo

TFitConstraintMGaus.cc

Go to the documentation of this file.
00001 // Classname: TFitConstraintMGaus
00002 // Author: Jan E. Sundermann, Verena Klose (TU Dresden)      
00003 
00004 
00005 //________________________________________________________________
00006 // 
00007 // TFitConstraintMGaus::
00008 // --------------------
00009 //
00010 // Fit constraint: mass conservation ( m_i - m_j - alpha * MassConstraint == 0 )
00011 //
00012 
00013 using namespace std;
00014 
00015 #include <iostream>
00016 #include <iomanip>
00017 #include "PhysicsTools/KinFitter/interface/TFitConstraintMGaus.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "TClass.h"
00020 
00021 ClassImp(TFitConstraintMGaus)
00022 
00023 //----------------
00024 // Constructor --
00025 //----------------
00026 TFitConstraintMGaus::TFitConstraintMGaus()
00027   : TFitConstraintM() 
00028 {
00029 
00030   init();
00031 
00032 }
00033 
00034 TFitConstraintMGaus::TFitConstraintMGaus(vector<TAbsFitParticle*>* ParList1,
00035                                          vector<TAbsFitParticle*>* ParList2, 
00036                                          Double_t Mass,
00037                                          Double_t Width)
00038   : TFitConstraintM(ParList1, ParList2, Mass ) 
00039 {
00040 
00041   init();
00042   setMassConstraint( Mass, Width );
00043 
00044 }
00045 
00046 TFitConstraintMGaus::TFitConstraintMGaus(const TString &name, const TString &title,
00047                                          vector<TAbsFitParticle*>* ParList1,
00048                                          vector<TAbsFitParticle*>* ParList2, 
00049                                          Double_t Mass,
00050                                          Double_t Width)
00051   : TFitConstraintM( name, title, ParList1, ParList2, Mass )
00052 {
00053 
00054   init();
00055   setMassConstraint( Mass, Width );
00056 
00057 }
00058 
00059 void
00060 TFitConstraintMGaus::init() {
00061 
00062   _nPar = 1;
00063   _iniparameters.ResizeTo(1,1);
00064   _iniparameters(0,0) = 1.;
00065   _parameters.ResizeTo(1,1);
00066   _parameters = _iniparameters;
00067 
00068 }
00069 
00070 
00071 //--------------
00072 // Destructor --
00073 //--------------
00074 TFitConstraintMGaus::~TFitConstraintMGaus() {
00075 
00076 }
00077 
00078 //--------------
00079 // Operations --
00080 //--------------
00081 
00082 void TFitConstraintMGaus::setMassConstraint(Double_t Mass, Double_t Width) { 
00083   
00084   _TheMassConstraint = Mass;
00085   _width = Width;
00086   setCovMatrix( 0 );
00087   _covMatrix(0,0) = (Width*Width) / (Mass * Mass);
00088 
00089 }
00090 
00091 Double_t TFitConstraintMGaus::getInitValue() {
00092   // Get initial value of constraint (before the fit)
00093 
00094   Double_t InitValue = 
00095     CalcMass( &_ParList1, true ) - 
00096     CalcMass( &_ParList2, true ) - 
00097     _iniparameters(0,0) * _TheMassConstraint;
00098 
00099   return InitValue;
00100 
00101 }
00102 
00103 Double_t TFitConstraintMGaus::getCurrentValue() {
00104   // Get value of constraint after the fit
00105 
00106   Double_t CurrentValue =
00107     CalcMass(&_ParList1,false) - 
00108     CalcMass(&_ParList2,false) - 
00109     _parameters(0,0)*_TheMassConstraint;
00110 
00111   return CurrentValue;
00112 
00113 }
00114 
00115 TMatrixD* TFitConstraintMGaus::getDerivativeAlpha() { 
00116   // Calculate dF/dAlpha = -1 * M
00117 
00118   TMatrixD* DerivativeMatrix = new TMatrixD(1,1);
00119   DerivativeMatrix->Zero();
00120 
00121   (*DerivativeMatrix)(0,0) = -1. * _TheMassConstraint;
00122 
00123   return DerivativeMatrix;
00124 
00125 }
00126 
00127 TString TFitConstraintMGaus::getInfoString() {
00128   // Collect information to be used for printout
00129 
00130   stringstream info;
00131   info << scientific << setprecision(6);
00132 
00133   info << "__________________________" << endl
00134        << endl;
00135   info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << endl;
00136 
00137   info << "initial value: " << getInitValue() << endl;
00138   info << "current value: " << getCurrentValue() << endl;
00139   info << "mean mass: " << _TheMassConstraint << endl;
00140   info << "width: " << _width << endl;
00141   info << "initial mass: " << _iniparameters(0,0)*_TheMassConstraint  << endl;
00142   info << "current mass: " << _parameters(0,0)*_TheMassConstraint  << endl;
00143 
00144   return info.str();
00145 
00146 }
00147 
00148 void TFitConstraintMGaus::print() {
00149   // Print constraint contents
00150 
00151   edm::LogVerbatim("KinFitter") << this->getInfoString();
00152 
00153 }
00154 

Generated on Tue Jun 9 17:41:16 2009 for CMSSW by  doxygen 1.5.4