CMS 3D CMS Logo

TFitParticleECart.cc

Go to the documentation of this file.
00001 // Classname: TFitParticleECart
00002 // Author: Jan E. Sundermann, Verena Klose (TU Dresden)      
00003 
00004 
00005 //________________________________________________________________
00006 // 
00007 // TFitParticleECart::
00008 // --------------------
00009 //
00010 // Particle with cartesian 4vector parametrization and free mass
00011 // [four free parameters (px, py, pz, d) with initial values
00012 //  (px, py, pz, 1)]
00013 //
00014 // p = px*u1 + py*u2 + pz*u3
00015 // E = d
00016 //
00017 
00018 using namespace std;
00019 
00020 #include <iostream>
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include "PhysicsTools/KinFitter/interface/TFitParticleECart.h"
00023 
00024 ClassImp(TFitParticleECart)
00025 
00026 //----------------
00027 // Constructor --
00028 //----------------
00029 TFitParticleECart::TFitParticleECart()
00030   :TAbsFitParticle()  
00031 {
00032   init(0, 0);
00033 }
00034 
00035 TFitParticleECart::TFitParticleECart( const TFitParticleECart& fitParticle )
00036   :TAbsFitParticle( fitParticle.GetName(), fitParticle.GetTitle() )
00037 {
00038 
00039   _nPar = fitParticle._nPar;
00040   _u1 = fitParticle._u1;
00041   _u2 = fitParticle._u2;
00042   _u3 = fitParticle._u3;
00043   _covMatrix.ResizeTo(  fitParticle._covMatrix );
00044   _covMatrix = fitParticle._covMatrix;
00045   _iniparameters.ResizeTo( fitParticle._iniparameters );
00046   _iniparameters = fitParticle._iniparameters;
00047   _parameters.ResizeTo( fitParticle._parameters );
00048   _parameters = fitParticle._parameters;
00049   _pini = fitParticle._pini;
00050   _pcurr = fitParticle._pcurr;
00051 
00052 }
00053 
00054 TFitParticleECart::TFitParticleECart(TLorentzVector* pini, const TMatrixD* theCovMatrix)
00055   :TAbsFitParticle()  
00056 {
00057   init(pini, theCovMatrix);
00058 }
00059 
00060 TFitParticleECart::TFitParticleECart(const TString &name, const TString &title, 
00061                            TLorentzVector* pini, const TMatrixD* theCovMatrix)
00062   :TAbsFitParticle(name, title)  
00063 {
00064   init(pini, theCovMatrix);
00065 }
00066 
00067 TAbsFitParticle* TFitParticleECart::clone( TString newname ) const {
00068   // Returns a copy of itself
00069 
00070   TAbsFitParticle* myclone = new TFitParticleECart( *this );
00071   if ( newname.Length() > 0 ) myclone->SetName(newname);
00072   return myclone;
00073 
00074 }
00075 
00076 //--------------
00077 // Destructor --
00078 //--------------
00079 TFitParticleECart::~TFitParticleECart() {
00080 
00081 }
00082 
00083 //--------------
00084 // Operations --
00085 //--------------
00086 void TFitParticleECart::init(TLorentzVector* pini, const TMatrixD* theCovMatrix ) {
00087 
00088   _nPar = 4;
00089   setIni4Vec(pini);
00090   setCovMatrix(theCovMatrix);
00091 
00092 }
00093 
00094 TLorentzVector* TFitParticleECart::calc4Vec( const TMatrixD* params ) {
00095   // Calculates a 4vector corresponding to the given
00096   // parameter values
00097 
00098   if (params == 0) {
00099     return 0;
00100   }
00101 
00102   if ( params->GetNcols() != 1 || params->GetNrows() !=_nPar ) {
00103     edm::LogError ("WrongMatrixSize")
00104       << GetName() << "::calc4Vec - Parameter matrix has wrong size.";
00105     return 0;
00106   }
00107   
00108   Double_t X = (*params)(0,0);
00109   Double_t Y = (*params)(1,0);
00110   Double_t Z = (*params)(2,0);
00111   Double_t E = (*params)(3,0);
00112 
00113   TLorentzVector* vec = new TLorentzVector( X, Y, Z, E );
00114   return vec;
00115 
00116 }
00117 
00118 void TFitParticleECart::setIni4Vec(const TLorentzVector* pini) {
00119   // Set the initial 4vector. Will also set the 
00120   // inital parameter values
00121 
00122   if (pini == 0) {
00123 
00124     _u1.SetXYZ(0., 0., 0.);
00125     _u3.SetXYZ(0., 0., 0.);
00126     _u2.SetXYZ(0., 0., 0.);
00127     _pini.SetXYZT(0., 0., 0., 0.);
00128     _pcurr = _pini;
00129 
00130     _iniparameters.ResizeTo(_nPar,1);
00131     _iniparameters(0,0)=0;
00132     _iniparameters(1,0)=0;
00133     _iniparameters(2,0)=0;
00134     _iniparameters(3,0)=0.;
00135 
00136     _parameters.ResizeTo(_nPar,1);
00137     _parameters = _iniparameters;
00138     
00139   } else {
00140     
00141     _pini = (*pini);
00142     _pcurr = _pini;
00143 
00144     _u1.SetXYZ( 1., 0., 0. );
00145     _u2.SetXYZ( 0., 1., 0. );
00146     _u3.SetXYZ( 0., 0., 1. );
00147   
00148     _iniparameters.ResizeTo(_nPar,1);
00149     _iniparameters(0,0)=_pini.X();
00150     _iniparameters(1,0)=_pini.Y();
00151     _iniparameters(2,0)=_pini.Z();
00152     _iniparameters(3,0)=_pini.E();
00153     _parameters.ResizeTo(_nPar,1);
00154     _parameters = _iniparameters;
00155 
00156   }
00157 
00158 }
00159 
00160 TMatrixD* TFitParticleECart::getDerivative() {
00161   // returns derivative dP/dy with P=(p,E) and y=(px, py, pz, d) 
00162   // the free parameters of the fit. The columns of the matrix contain 
00163   // (dP/dpx, dP/dpy, ...).
00164 
00165   TMatrixD* DerivativeMatrix = new TMatrixD(4,4);
00166   (*DerivativeMatrix) *= 0.;
00167 
00168   //1st column: dP/dx
00169   (*DerivativeMatrix)(0,0)=1.;
00170   (*DerivativeMatrix)(1,0)=0.;
00171   (*DerivativeMatrix)(2,0)=0.;
00172   (*DerivativeMatrix)(3,0)=0.;
00173 
00174   //2nd column: dP/dy
00175   (*DerivativeMatrix)(0,1)=0;
00176   (*DerivativeMatrix)(1,1)=1;
00177   (*DerivativeMatrix)(2,1)=0;
00178   (*DerivativeMatrix)(3,1)=0.;
00179 
00180    //3rd column: dP/dz
00181   (*DerivativeMatrix)(0,2)=0.;
00182   (*DerivativeMatrix)(1,2)=0.;
00183   (*DerivativeMatrix)(2,2)=1.;
00184   (*DerivativeMatrix)(3,2)=0.;
00185 
00186    //4th column: dP/dm
00187   (*DerivativeMatrix)(0,3)=0.;
00188   (*DerivativeMatrix)(1,3)=0.;
00189   (*DerivativeMatrix)(2,3)=0.;
00190   (*DerivativeMatrix)(3,3)=1.;
00191 
00192   return DerivativeMatrix;  
00193 }
00194 
00195 TMatrixD* TFitParticleECart::transform(const TLorentzVector& vec) {
00196   // Returns the parameters corresponding to the given 
00197   // 4vector
00198 
00199   TMatrixD* tparams = new TMatrixD( _nPar, 1 );
00200   (*tparams)(0,0) = vec.X();
00201   (*tparams)(1,0) = vec.Y();
00202   (*tparams)(2,0) = vec.Z();
00203   (*tparams)(3,0) = vec.E();
00204 
00205   return tparams;
00206 
00207 }

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