00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <iostream>
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021 #include "PhysicsTools/KinFitter/interface/TFitParticleEtEtaPhi.h"
00022 #include "TMath.h"
00023 #include <cmath>
00024
00025
00026
00027
00028 TFitParticleEtEtaPhi::TFitParticleEtEtaPhi()
00029 :TAbsFitParticle()
00030 {
00031 init(0, 0);
00032 }
00033
00034 TFitParticleEtEtaPhi::TFitParticleEtEtaPhi( const TFitParticleEtEtaPhi& fitParticle )
00035 :TAbsFitParticle( fitParticle.GetName(), fitParticle.GetTitle() )
00036 {
00037
00038 _nPar = fitParticle._nPar;
00039 _u1 = fitParticle._u1;
00040 _u2 = fitParticle._u2;
00041 _u3 = fitParticle._u3;
00042 _covMatrix.ResizeTo( fitParticle._covMatrix );
00043 _covMatrix = fitParticle._covMatrix;
00044 _iniparameters.ResizeTo( fitParticle._iniparameters );
00045 _iniparameters = fitParticle._iniparameters;
00046 _parameters.ResizeTo( fitParticle._parameters );
00047 _parameters = fitParticle._parameters;
00048 _pini = fitParticle._pini;
00049 _pcurr = fitParticle._pcurr;
00050
00051 }
00052
00053 TFitParticleEtEtaPhi::TFitParticleEtEtaPhi(TLorentzVector* pini, const TMatrixD* theCovMatrix)
00054 :TAbsFitParticle()
00055 {
00056 init(pini, theCovMatrix);
00057 }
00058
00059 TFitParticleEtEtaPhi::TFitParticleEtEtaPhi(const TString &name, const TString &title,
00060 TLorentzVector* pini, const TMatrixD* theCovMatrix)
00061 :TAbsFitParticle(name, title)
00062 {
00063 init(pini, theCovMatrix);
00064 }
00065
00066 TAbsFitParticle* TFitParticleEtEtaPhi::clone( TString newname ) const {
00067
00068
00069 TAbsFitParticle* myclone = new TFitParticleEtEtaPhi( *this );
00070 if ( newname.Length() > 0 ) myclone->SetName(newname);
00071 return myclone;
00072
00073 }
00074
00075
00076
00077
00078 TFitParticleEtEtaPhi::~TFitParticleEtEtaPhi() {
00079
00080 }
00081
00082
00083
00084
00085 void TFitParticleEtEtaPhi::init(TLorentzVector* pini, const TMatrixD* theCovMatrix ) {
00086
00087 _nPar = 3;
00088 setIni4Vec(pini);
00089 setCovMatrix(theCovMatrix);
00090
00091 }
00092
00093 TLorentzVector* TFitParticleEtEtaPhi::calc4Vec( const TMatrixD* params ) {
00094
00095
00096
00097 if (params == 0) {
00098 return 0;
00099 }
00100
00101 if ( params->GetNcols() != 1 || params->GetNrows() !=_nPar ) {
00102 edm::LogError ("WrongMatrixSize")
00103 << GetName() << "::calc4Vec - Parameter matrix has wrong size.";
00104 return 0;
00105 }
00106
00107 Double_t et = (*params)(0,0);
00108 Double_t eta = (*params)(1,0);
00109 Double_t phi = (*params)(2,0);
00110
00111 Double_t X = et*TMath::Cos(phi);
00112 Double_t Y = et*TMath::Sin(phi);
00113 Double_t Z = et*TMath::SinH(eta);
00114 Double_t E = et*TMath::CosH(eta);
00115
00116 TLorentzVector* vec = new TLorentzVector( X, Y, Z, E );
00117 return vec;
00118
00119 }
00120
00121 void TFitParticleEtEtaPhi::setIni4Vec(const TLorentzVector* pini) {
00122
00123
00124
00125 if (pini == 0) {
00126
00127 _u1.SetXYZ(0., 0., 0.);
00128 _u3.SetXYZ(0., 0., 0.);
00129 _u2.SetXYZ(0., 0., 0.);
00130 _pini.SetXYZT(0., 0., 0., 0.);
00131 _pcurr = _pini;
00132
00133 _iniparameters.ResizeTo(_nPar,1);
00134 _iniparameters(0,0) = 0.;
00135 _iniparameters(1,0) = 0.;
00136 _iniparameters(2,0) = 0.;
00137
00138 _parameters.ResizeTo(_nPar,1);
00139 _parameters(0,0) = 0.;
00140 _parameters(1,0) = 0.;
00141 _parameters(2,0) = 0.;
00142
00143 } else {
00144
00145 Double_t et = pini->E()*std::fabs(sin(pini->Theta()));
00146 Double_t eta = pini->Eta();
00147 Double_t phi = pini->Phi();
00148
00149 _pini = (*pini);
00150 _pcurr = _pini;
00151
00152 _iniparameters.ResizeTo(_nPar,1);
00153 _iniparameters(0,0) = et;
00154 _iniparameters(1,0) = eta;
00155 _iniparameters(2,0) = phi;
00156
00157 _parameters.ResizeTo(_nPar,1);
00158 _parameters = _iniparameters;
00159
00160 _u1.SetXYZ( TMath::Cos(phi), TMath::Sin(phi), 0.);
00161 _u2.SetXYZ( -1.*TMath::Cos(phi)*TMath::TanH(eta), -1.*TMath::Sin(phi)*TMath::TanH(eta), 1./TMath::CosH(eta) );
00162 _u3.SetXYZ( -1.*TMath::Sin(phi), TMath::Cos(phi), 0. );
00163
00164 }
00165
00166 }
00167
00168 TMatrixD* TFitParticleEtEtaPhi::getDerivative() {
00169
00170
00171
00172
00173 TMatrixD* DerivativeMatrix = new TMatrixD(4,3);
00174 (*DerivativeMatrix) *= 0.;
00175
00176 Double_t et = _parameters(0,0);
00177 Double_t eta = _parameters(1,0);
00178 Double_t phi = _parameters(2,0);
00179
00180
00181 (*DerivativeMatrix)(0,0) = TMath::Cos(phi);
00182 (*DerivativeMatrix)(1,0) = TMath::Sin(phi);
00183 (*DerivativeMatrix)(2,0) = TMath::SinH(eta);
00184 (*DerivativeMatrix)(3,0) = TMath::CosH(eta);
00185
00186
00187 (*DerivativeMatrix)(0,1) = 0.;
00188 (*DerivativeMatrix)(1,1) = 0.;
00189 (*DerivativeMatrix)(2,1) = et*TMath::CosH(eta);
00190 (*DerivativeMatrix)(3,1) = et*TMath::SinH(eta);
00191
00192
00193 (*DerivativeMatrix)(0,2) = -1.*et*TMath::Sin(phi);
00194 (*DerivativeMatrix)(1,2) = et*TMath::Cos(phi);
00195 (*DerivativeMatrix)(2,2) = 0.;
00196 (*DerivativeMatrix)(3,2) = 0.;
00197
00198 return DerivativeMatrix;
00199
00200 }
00201
00202 TMatrixD* TFitParticleEtEtaPhi::transform(const TLorentzVector& vec) {
00203
00204
00205
00206
00207 TMatrixD* tparams = new TMatrixD( _nPar, 1 );
00208 (*tparams)(0,0) = vec.E()*std::fabs(sin(vec.Theta()));
00209 (*tparams)(1,0) = vec.Eta();
00210 (*tparams)(2,0) = vec.Phi();
00211
00212 return tparams;
00213
00214 }