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