CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/PhysicsTools/KinFitter/src/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 #include <iostream>
00014 #include <iomanip>
00015 #include "PhysicsTools/KinFitter/interface/TFitConstraintMGaus.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017 #include "TClass.h"
00018 
00019 
00020 //----------------
00021 // Constructor --
00022 //----------------
00023 TFitConstraintMGaus::TFitConstraintMGaus()
00024   : TFitConstraintM() 
00025 {
00026 
00027   init();
00028 
00029 }
00030 
00031 TFitConstraintMGaus::TFitConstraintMGaus(std::vector<TAbsFitParticle*>* ParList1,
00032                                          std::vector<TAbsFitParticle*>* ParList2, 
00033                                          Double_t Mass,
00034                                          Double_t Width)
00035   : TFitConstraintM(ParList1, ParList2, Mass ) 
00036 {
00037 
00038   init();
00039   setMassConstraint( Mass, Width );
00040 
00041 }
00042 
00043 TFitConstraintMGaus::TFitConstraintMGaus(const TString &name, const TString &title,
00044                                          std::vector<TAbsFitParticle*>* ParList1,
00045                                          std::vector<TAbsFitParticle*>* ParList2, 
00046                                          Double_t Mass,
00047                                          Double_t Width)
00048   : TFitConstraintM( name, title, ParList1, ParList2, Mass )
00049 {
00050 
00051   init();
00052   setMassConstraint( Mass, Width );
00053 
00054 }
00055 
00056 void
00057 TFitConstraintMGaus::init() {
00058 
00059   _nPar = 1;
00060   _iniparameters.ResizeTo(1,1);
00061   _iniparameters(0,0) = 1.;
00062   _parameters.ResizeTo(1,1);
00063   _parameters = _iniparameters;
00064 
00065 }
00066 
00067 //--------------
00068 // Destructor --
00069 //--------------
00070 TFitConstraintMGaus::~TFitConstraintMGaus() {
00071 
00072 }
00073 
00074 //--------------
00075 // Operations --
00076 //--------------
00077 
00078 void TFitConstraintMGaus::setMassConstraint(Double_t Mass, Double_t Width) { 
00079   
00080   _TheMassConstraint = Mass;
00081   _width = Width;
00082   setCovMatrix( 0 );
00083   if(!Mass) throw cms::Exception("Configuration")
00084     << "Error occured!\n"
00085     << "Object type : TFitConstraintMGaus\n"
00086     << "Object name : " << GetName() << "\n"
00087     << "Object title: " << GetTitle() << "\n"
00088     << "Mass of 0 GeV not supported, please choose a larger mass!\n";
00089   _covMatrix(0,0) = (Width*Width) / (Mass * Mass);
00090 
00091 }
00092 
00093 Double_t TFitConstraintMGaus::getInitValue() {
00094   // Get initial value of constraint (before the fit)
00095 
00096   Double_t InitValue = 
00097     CalcMass( &_ParList1, true ) - 
00098     CalcMass( &_ParList2, true ) - 
00099     _iniparameters(0,0) * _TheMassConstraint;
00100 
00101   return InitValue;
00102 
00103 }
00104 
00105 Double_t TFitConstraintMGaus::getCurrentValue() {
00106   // Get value of constraint after the fit
00107 
00108   Double_t CurrentValue =
00109     CalcMass(&_ParList1,false) - 
00110     CalcMass(&_ParList2,false) - 
00111     _parameters(0,0)*_TheMassConstraint;
00112 
00113   return CurrentValue;
00114 
00115 }
00116 
00117 TMatrixD* TFitConstraintMGaus::getDerivativeAlpha() { 
00118   // Calculate dF/dAlpha = -1 * M
00119 
00120   TMatrixD* DerivativeMatrix = new TMatrixD(1,1);
00121   DerivativeMatrix->Zero();
00122 
00123   (*DerivativeMatrix)(0,0) = -1. * _TheMassConstraint;
00124 
00125   return DerivativeMatrix;
00126 
00127 }
00128 
00129 TString TFitConstraintMGaus::getInfoString() {
00130   // Collect information to be used for printout
00131 
00132   std::stringstream info;
00133   info << std::scientific << std::setprecision(6);
00134 
00135   info << "__________________________" << std::endl
00136        << std::endl;
00137   info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
00138 
00139   info << "initial value: " << getInitValue() << std::endl;
00140   info << "current value: " << getCurrentValue() << std::endl;
00141   info << "mean mass: " << _TheMassConstraint << std::endl;
00142   info << "width: " << _width << std::endl;
00143   info << "initial mass: " << _iniparameters(0,0)*_TheMassConstraint  << std::endl;
00144   info << "current mass: " << _parameters(0,0)*_TheMassConstraint  << std::endl;
00145 
00146   return info.str();
00147 
00148 }
00149 
00150 void TFitConstraintMGaus::print() {
00151   // Print constraint contents
00152 
00153   edm::LogVerbatim("KinFitter") << this->getInfoString();
00154 
00155 }
00156