9#include "analysis/OrcaKinFit/PxPyPzMFitObject.h"
10#include <framework/logging/Logger.h>
24 namespace OrcaKinFit {
27 PxPyPzMFitObject::PxPyPzMFitObject(CLHEP::HepLorentzVector& particle,
const CLHEP::HepSymMatrix& covmatrix)
28 : cachevalid(false), chi2(0), dEdpx(0), dEdpy(0), dEdpz(0),
29 dE2dpxdpx(0), dE2dpxdpy(0), dE2dpxdpz(0), dE2dpydpy(0), dE2dpydpz(0), dE2dpzdpz(0)
32 assert(
int(NPAR) <=
int(BaseDefs::MAXPAR));
35 setMass(particle.m());
37 setParam(0, particle.px(),
true);
38 setParam(1, particle.py(),
true);
39 setParam(2, particle.pz(),
true);
41 setMParam(0, particle.px());
42 setMParam(1, particle.py());
43 setMParam(2, particle.pz());
46 for (
int i = 0; i < int(NPAR); i++) {
47 for (
int j = 0; j < int(NPAR); j++) {
48 setCov(i, j, covmatrix[i][j]);
56 PxPyPzMFitObject::~PxPyPzMFitObject() =
default;
59 :
ParticleFitObject(rhs), cachevalid(false), chi2(0), dEdpx(0), dEdpy(0), dEdpz(0),
60 dE2dpxdpx(0), dE2dpxdpy(0), dE2dpxdpz(0), dE2dpydpy(0), dE2dpydpz(0), dE2dpzdpz(0)
82 if (psource !=
this) {
110 assert(ipx >= 0 && ipx < idim);
111 assert(ipy >= 0 && ipy < idim);
112 assert(ipz >= 0 && ipz < idim);
118 bool result = ((px -
par[0]) * (px -
par[0]) > eps2 *
cov[0][0]) ||
119 ((py -
par[1]) * (py -
par[1]) > eps2 *
cov[1][1]) ||
120 ((pz -
par[2]) * (pz -
par[2]) > eps2 *
cov[2][2]);
135 assert(ilocal >= 0 && ilocal < NPAR);
136 if (!cachevalid) updateCache();
147 assert(ilocal >= 0 && ilocal < NPAR);
148 if (!cachevalid) updateCache();
160 assert(ilocal >= 0 && ilocal < NPAR);
161 if (!cachevalid) updateCache();
172 assert(ilocal >= 0 && ilocal < NPAR);
173 if (!cachevalid) updateCache();
175 case 0:
return dEdpx;
176 case 1:
return dEdpy;
177 case 2:
return dEdpz;
182 double PxPyPzMFitObject::getFirstDerivative_Meta_Local(
int iMeta,
int ilocal,
int metaSet)
const
188 assert(metaSet == 0);
192 return getDE(ilocal);
208 double PxPyPzMFitObject::getSecondDerivative_Meta_Local(
int iMeta,
int ilocal,
int jlocal,
int metaSet)
const
210 assert(metaSet == 0);
211 if (!cachevalid) updateCache();
212 if (jlocal < ilocal) {
220 if (ilocal == 0 && jlocal == 0)
return dE2dpxdpx;
221 else if (ilocal == 0 && jlocal == 1)
return dE2dpxdpy;
222 else if (ilocal == 0 && jlocal == 2)
return dE2dpxdpz;
223 else if (ilocal == 1 && jlocal == 1)
return dE2dpydpy;
224 else if (ilocal == 1 && jlocal == 2)
return dE2dpydpz;
225 else if (ilocal == 2 && jlocal == 2)
return dE2dpzdpz;
242 void PxPyPzMFitObject::updateCache()
const
249 double px2 = px * px;
250 double py2 = py * py;
251 double pz2 = pz * pz;
252 double p = std::sqrt(px2 + py2 + pz2);
256 double e2 = px2 + py2 + pz2 + mass2;
257 double e = std::sqrt(e2);
265 double e32 = std::pow(e, 1.5);
266 dE2dpxdpx = (py2 + pz2 + mass2) / (e32);
267 dE2dpxdpy = -(px * py) / (e32);
268 dE2dpxdpz = -(px * pz) / (e32);
269 dE2dpydpy = (px2 + pz2 + mass2) / (e32);
270 dE2dpydpz = -(py * pz) / (e32);
271 dE2dpzdpz = (px2 + py2 + mass2) / (e32);
273 fourMomentum.setValues(e, px, py, pz);
virtual int getGlobalParNum(int ilocal) const
Get global parameter number of parameter ilocal.
double par[BaseDefs::MAXPAR]
fit parameters
void invalidateCache() const
invalidate any cached quantities
double cov[BaseDefs::MAXPAR][BaseDefs::MAXPAR]
local covariance matrix
double mass
mass of particle
virtual ParticleFitObject & assign(const BaseFitObject &source) override
Assign from anther object, if of same type.
virtual double getDPx(int ilocal) const override
Return d p_x / d par_ilocal (derivative of px w.r.t. local parameter ilocal)
virtual double getDPy(int ilocal) const override
Return d p_y / d par_ilocal (derivative of py w.r.t. local parameter ilocal)
virtual PxPyPzMFitObject & assign(const BaseFitObject &source) override
Assign from anther object, if of same type.
virtual double getDE(int ilocal) const override
Return d E / d par_ilocal (derivative of E w.r.t. local parameter ilocal)
virtual PxPyPzMFitObject * copy() const override
Return a new copy of itself.
virtual const char * getParamName(int ilocal) const override
Get name of parameter ilocal.
virtual double getDPz(int ilocal) const override
Return d p_z / d par_ilocal (derivative of pz w.r.t. local parameter ilocal)
virtual bool updateParams(double p[], int idim) override
Read values from global vector, readjust vector; return: significant change.
PxPyPzMFitObject & operator=(const PxPyPzMFitObject &rhs)
Abstract base class for different kinds of events.