25 #include "TrackPoint.h"
26 #include "Exception.h"
27 #include "KalmanFitterInfo.h"
28 #include "AbsMeasurement.h"
30 #include "AbsKalmanFitter.h"
31 #include <Math/ProbFunc.h>
41 double& bChi2,
double& fChi2,
42 double& bNdf,
double& fNdf)
const {
46 bNdf = -1. * rep->
getDim();
47 fNdf = -1. * rep->
getDim();
49 const std::vector<TrackPoint*>& pointsWM = tr->getPointsWithMeasurement();
50 for (std::vector<TrackPoint*>::const_iterator tpIter = pointsWM.begin(), endIter = pointsWM.end(); tpIter != endIter; ++tpIter) {
51 if (! (*tpIter)->hasFitterInfo(rep))
57 Exception exc(
"AbsKalmanFitter::getChiSqu(): fitterInfo is not a KalmanFitterInfo", __LINE__,__FILE__);
64 if (fup ==
nullptr || bup ==
nullptr) {
65 Exception exc(
"AbsKalmanFitter::getChiSqu(): fup == nullptr || bup == nullptr", __LINE__,__FILE__);
69 bChi2 += bup->getChiSquareIncrement();
70 fChi2 += fup->getChiSquareIncrement();
72 bNdf += bup->getNdf();
73 fNdf += fup->getNdf();
84 double AbsKalmanFitter::getChiSqu(
const Track* tr,
const AbsTrackRep* rep,
int direction)
const {
85 double bChi2(0), fChi2(0), bNdf(0), fNdf(0);
87 getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf);
94 double AbsKalmanFitter::getNdf(
const Track* tr,
const AbsTrackRep* rep,
int direction)
const {
95 double bChi2(0), fChi2(0), bNdf(0), fNdf(0);
97 getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf);
104 double AbsKalmanFitter::getRedChiSqu(
const Track* tr,
const AbsTrackRep* rep,
int direction)
const {
105 double bChi2(0), fChi2(0), bNdf(0), fNdf(0);
107 getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf);
114 double AbsKalmanFitter::getPVal(
const Track* tr,
const AbsTrackRep* rep,
int direction)
const {
115 double bChi2(0), fChi2(0), bNdf(0), fNdf(0);
117 getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf);
120 return std::max(0.,ROOT::Math::chisquared_cdf_c(bChi2, bNdf));
121 return std::max(0.,ROOT::Math::chisquared_cdf_c(fChi2, fNdf));
125 bool AbsKalmanFitter::isTrackPrepared(
const Track* tr,
const AbsTrackRep* rep)
const {
126 const std::vector<TrackPoint*>& points = tr->getPointsWithMeasurement();
128 if (points.size() == 0)
131 for (std::vector<TrackPoint*>::const_iterator pIt = points.begin(), pEnd = points.end(); pIt != pEnd; ++pIt) {
137 if (!(fi->checkConsistency()))
140 if (!(fi->hasReferenceState()))
147 bool AbsKalmanFitter::isTrackFitted(
const Track* tr,
const AbsTrackRep* rep)
const {
153 const std::vector< TrackPoint* >& points = tr->getPointsWithMeasurement();
155 if (points.size() == 0)
158 for (std::vector<TrackPoint*>::const_iterator pIt = points.begin(), pEnd = points.end(); pIt != pEnd; ++pIt) {
163 if (!(fi->checkConsistency()))
166 if (!(fi->hasForwardUpdate()))
169 if (!(fi->hasBackwardUpdate()))
182 return fi->getMeasurementsOnPlane();
187 if (!fi->hasReferenceState()) {
188 Exception e(
"AbsKalmanFitter::getMeasurement: no ReferenceState.", __LINE__,__FILE__);
192 std::vector<MeasurementOnPlane *> retVal;
193 retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getReferenceState()));
200 if (!fi->hasPrediction(direction)) {
201 Exception e(
"AbsKalmanFitter::getMeasurement: no prediction.", __LINE__,__FILE__);
205 std::vector<MeasurementOnPlane *> retVal;
206 retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getPrediction(direction)));
215 if (!fi->hasReferenceState()) {
216 Exception e(
"AbsKalmanFitter::getMeasurement: no ReferenceState.", __LINE__,__FILE__);
220 std::vector<MeasurementOnPlane *> retVal;
221 retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getReferenceState()));
225 return fi->getMeasurementsOnPlane();
232 if (!fi->hasPrediction(direction)) {
233 Exception e(
"AbsKalmanFitter::getMeasurement: no prediction.", __LINE__,__FILE__);
237 std::vector<MeasurementOnPlane *> retVal;
238 retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getPrediction(direction)));
242 return fi->getMeasurementsOnPlane();
248 Exception e(
"AbsKalmanFitter::getMeasurement: choice not valid.", __LINE__,__FILE__);
274 Exception e(
"AbsKalmanFitter::canIgnoreWeights: choice not valid.", __LINE__,__FILE__);
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
bool canIgnoreWeights() const
returns if the fitter can ignore the weights and handle the MeasurementOnPlanes as if they had weight...
eMultipleMeasurementHandling multipleMeasurementHandling_
How to handle if there are multiple MeasurementsOnPlane.
const std::vector< MeasurementOnPlane * > getMeasurements(const KalmanFitterInfo *fi, const TrackPoint *tp, int direction) const
get the measurementsOnPlane taking the multipleMeasurementHandling_ into account
virtual bool isLeftRightMeasurement() const
If the AbsMeasurement is a wire hit, the left/right resolution will be used.
Abstract base class for a track representation.
virtual unsigned int getDim() const =0
Get the dimension of the state vector used by the track representation.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
bool isFitted() const
Has the track been fitted?
#MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
Object containing AbsMeasurement and AbsFitterInfo objects.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
FitStatus * getFitStatus(const AbsTrackRep *rep=nullptr) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Defines for I/O streams used for error and debug printing.
@ unweightedClosestToPrediction
closest to prediction, weighted with 1
@ unweightedAverage
average between measurements, all weighted with 1
@ weightedAverage
weighted average between measurements; used by DAF
@ weightedClosestToReferenceWire
if corresponding TrackPoint has one WireMeasurement, select closest to reference, weighted with its w...
@ weightedClosestToReference
closest to reference, weighted with its weight_
@ weightedClosestToPredictionWire
if corresponding TrackPoint has one WireMeasurement, select closest to prediction,...
@ unweightedClosestToReference
closest to reference, weighted with 1
@ unweightedClosestToReferenceWire
if corresponding TrackPoint has one WireMeasurement, select closest to reference, weighted with 1.
@ unweightedClosestToPredictionWire
if corresponding TrackPoint has one WireMeasurement, select closest to prediction,...
@ weightedClosestToPrediction
closest to prediction, weighted with its weight_