CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TFitParticleECart.cc
Go to the documentation of this file.
1 // Classname: TFitParticleECart
2 // Author: Jan E. Sundermann, Verena Klose (TU Dresden)
3 
4 
5 //________________________________________________________________
6 //
7 // TFitParticleECart::
8 // --------------------
9 //
10 // Particle with cartesian 4vector parametrization and free mass
11 // [four free parameters (px, py, pz, d) with initial values
12 // (px, py, pz, 1)]
13 //
14 // p = px*u1 + py*u2 + pz*u3
15 // E = d
16 //
17 
18 #include <iostream>
21 
22 
23 //----------------
24 // Constructor --
25 //----------------
27  :TAbsFitParticle()
28 {
29  init(0, 0);
30 }
31 
33  :TAbsFitParticle( fitParticle.GetName(), fitParticle.GetTitle() )
34 {
35 
36  _nPar = fitParticle._nPar;
37  _u1 = fitParticle._u1;
38  _u2 = fitParticle._u2;
39  _u3 = fitParticle._u3;
40  _covMatrix.ResizeTo( fitParticle._covMatrix );
41  _covMatrix = fitParticle._covMatrix;
42  _iniparameters.ResizeTo( fitParticle._iniparameters );
43  _iniparameters = fitParticle._iniparameters;
44  _parameters.ResizeTo( fitParticle._parameters );
45  _parameters = fitParticle._parameters;
46  _pini = fitParticle._pini;
47  _pcurr = fitParticle._pcurr;
48 
49 }
50 
51 TFitParticleECart::TFitParticleECart(TLorentzVector* pini, const TMatrixD* theCovMatrix)
52  :TAbsFitParticle()
53 {
54  init(pini, theCovMatrix);
55 }
56 
57 TFitParticleECart::TFitParticleECart(const TString &name, const TString &title,
58  TLorentzVector* pini, const TMatrixD* theCovMatrix)
59  :TAbsFitParticle(name, title)
60 {
61  init(pini, theCovMatrix);
62 }
63 
64 TAbsFitParticle* TFitParticleECart::clone( const TString& newname ) const {
65  // Returns a copy of itself
66 
67  TAbsFitParticle* myclone = new TFitParticleECart( *this );
68  if ( newname.Length() > 0 ) myclone->SetName(newname);
69  return myclone;
70 
71 }
72 
73 //--------------
74 // Destructor --
75 //--------------
77 
78 }
79 
80 //--------------
81 // Operations --
82 //--------------
83 void TFitParticleECart::init(TLorentzVector* pini, const TMatrixD* theCovMatrix ) {
84 
85  _nPar = 4;
86  setIni4Vec(pini);
87  setCovMatrix(theCovMatrix);
88 
89 }
90 
91 TLorentzVector* TFitParticleECart::calc4Vec( const TMatrixD* params ) {
92  // Calculates a 4vector corresponding to the given
93  // parameter values
94 
95  if (params == 0) {
96  return 0;
97  }
98 
99  if ( params->GetNcols() != 1 || params->GetNrows() !=_nPar ) {
100  edm::LogError ("WrongMatrixSize")
101  << GetName() << "::calc4Vec - Parameter matrix has wrong size.";
102  return 0;
103  }
104 
105  Double_t X = (*params)(0,0);
106  Double_t Y = (*params)(1,0);
107  Double_t Z = (*params)(2,0);
108  Double_t E = (*params)(3,0);
109 
110  TLorentzVector* vec = new TLorentzVector( X, Y, Z, E );
111  return vec;
112 
113 }
114 
115 void TFitParticleECart::setIni4Vec(const TLorentzVector* pini) {
116  // Set the initial 4vector. Will also set the
117  // inital parameter values
118 
119  if (pini == 0) {
120 
121  _u1.SetXYZ(0., 0., 0.);
122  _u3.SetXYZ(0., 0., 0.);
123  _u2.SetXYZ(0., 0., 0.);
124  _pini.SetXYZT(0., 0., 0., 0.);
125  _pcurr = _pini;
126 
127  _iniparameters.ResizeTo(_nPar,1);
128  _iniparameters(0,0)=0;
129  _iniparameters(1,0)=0;
130  _iniparameters(2,0)=0;
131  _iniparameters(3,0)=0.;
132 
133  _parameters.ResizeTo(_nPar,1);
135 
136  } else {
137 
138  _pini = (*pini);
139  _pcurr = _pini;
140 
141  _u1.SetXYZ( 1., 0., 0. );
142  _u2.SetXYZ( 0., 1., 0. );
143  _u3.SetXYZ( 0., 0., 1. );
144 
145  _iniparameters.ResizeTo(_nPar,1);
146  _iniparameters(0,0)=_pini.X();
147  _iniparameters(1,0)=_pini.Y();
148  _iniparameters(2,0)=_pini.Z();
149  _iniparameters(3,0)=_pini.E();
150  _parameters.ResizeTo(_nPar,1);
152 
153  }
154 
155 }
156 
158  // returns derivative dP/dy with P=(p,E) and y=(px, py, pz, d)
159  // the free parameters of the fit. The columns of the matrix contain
160  // (dP/dpx, dP/dpy, ...).
161 
162  TMatrixD* DerivativeMatrix = new TMatrixD(4,4);
163  (*DerivativeMatrix) *= 0.;
164 
165  //1st column: dP/dx
166  (*DerivativeMatrix)(0,0)=1.;
167  (*DerivativeMatrix)(1,0)=0.;
168  (*DerivativeMatrix)(2,0)=0.;
169  (*DerivativeMatrix)(3,0)=0.;
170 
171  //2nd column: dP/dy
172  (*DerivativeMatrix)(0,1)=0;
173  (*DerivativeMatrix)(1,1)=1;
174  (*DerivativeMatrix)(2,1)=0;
175  (*DerivativeMatrix)(3,1)=0.;
176 
177  //3rd column: dP/dz
178  (*DerivativeMatrix)(0,2)=0.;
179  (*DerivativeMatrix)(1,2)=0.;
180  (*DerivativeMatrix)(2,2)=1.;
181  (*DerivativeMatrix)(3,2)=0.;
182 
183  //4th column: dP/dm
184  (*DerivativeMatrix)(0,3)=0.;
185  (*DerivativeMatrix)(1,3)=0.;
186  (*DerivativeMatrix)(2,3)=0.;
187  (*DerivativeMatrix)(3,3)=1.;
188 
189  return DerivativeMatrix;
190 }
191 
192 TMatrixD* TFitParticleECart::transform(const TLorentzVector& vec) {
193  // Returns the parameters corresponding to the given
194  // 4vector
195 
196  TMatrixD* tparams = new TMatrixD( _nPar, 1 );
197  (*tparams)(0,0) = vec.X();
198  (*tparams)(1,0) = vec.Y();
199  (*tparams)(2,0) = vec.Z();
200  (*tparams)(3,0) = vec.E();
201 
202  return tparams;
203 
204 }
const double Z[kNumberCalorimeter]
virtual void setIni4Vec(const TLorentzVector *pini)
virtual ~TFitParticleECart()
#define X(str)
Definition: MuonsGrabber.cc:48
virtual TLorentzVector * calc4Vec(const TMatrixD *params)
TLorentzVector _pini
TMatrixD _parameters
TLorentzVector _pcurr
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
virtual TMatrixD * getDerivative()
TMatrixD _iniparameters
void init(TLorentzVector *pini, const TMatrixD *theCovMatrix)
virtual TAbsFitParticle * clone(const TString &newname=TString("")) const
virtual TMatrixD * transform(const TLorentzVector &vec)