GENFIT Rev: NoNumberAvailable
Loading...
Searching...
No Matches
KalmanFitterInfo.h
Go to the documentation of this file.
1/* Copyright 2008-2010, Technische Universitaet Muenchen,
2 Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3
4 This file is part of GENFIT.
5
6 GENFIT is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 GENFIT is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18*/
22
23#ifndef genfit_KalmanFitterInfo_h
24#define genfit_KalmanFitterInfo_h
25
26#include "AbsFitterInfo.h"
29#include "MeasurementOnPlane.h"
31#include "StateOnPlane.h"
32
33#include <vector>
34
35#include <memory>
36
37
38namespace genfit {
39
40
45
46 public:
47
49 KalmanFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep);
50 virtual ~KalmanFitterInfo();
51
52 virtual KalmanFitterInfo* clone() const override;
53
57 MeasuredStateOnPlane* getPrediction(int direction) const {if (direction >=0) return forwardPrediction_.get(); return backwardPrediction_.get();}
60 KalmanFittedStateOnPlane* getUpdate(int direction) const {if (direction >=0) return forwardUpdate_.get(); return backwardUpdate_.get();}
61 const std::vector< genfit::MeasurementOnPlane* >& getMeasurementsOnPlane() const {return measurementsOnPlane_;}
62 MeasurementOnPlane* getMeasurementOnPlane(int i = 0) const {if (i<0) i += measurementsOnPlane_.size(); return measurementsOnPlane_.at(i);}
65 MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights = false) const;
68 unsigned int getNumMeasurements() const {return measurementsOnPlane_.size();}
70 std::vector<double> getWeights() const;
72 bool areWeightsFixed() const {return fixWeights_;}
74 const MeasuredStateOnPlane& getFittedState(bool biased = true) const override;
76 MeasurementOnPlane getResidual(unsigned int iMeasurement = 0, bool biased = false, bool onlyMeasurementErrors = true) const override; // calculate residual, track and measurement errors are added if onlyMeasurementErrors is false
77 double getSmoothedChi2(unsigned int iMeasurement = 0) const;
78
79 bool hasMeasurements() const override {return getNumMeasurements() > 0;}
80 bool hasReferenceState() const override {return (referenceState_.get() != nullptr);}
81 bool hasForwardPrediction() const override {return (forwardPrediction_.get() != nullptr);}
82 bool hasBackwardPrediction() const override {return (backwardPrediction_.get() != nullptr);}
83 bool hasForwardUpdate() const override {return (forwardUpdate_.get() != nullptr);}
84 bool hasBackwardUpdate() const override {return (backwardUpdate_.get() != nullptr);}
85 bool hasUpdate(int direction) const override {if (direction < 0) return hasBackwardUpdate(); return hasForwardUpdate();}
87
88 void setReferenceState(ReferenceStateOnPlane* referenceState);
89 void setForwardPrediction(MeasuredStateOnPlane* forwardPrediction);
90 void setBackwardPrediction(MeasuredStateOnPlane* backwardPrediction);
91 void setPrediction(MeasuredStateOnPlane* prediction, int direction) {if (direction >=0) setForwardPrediction(prediction); else setBackwardPrediction(prediction);}
92 void setForwardUpdate(KalmanFittedStateOnPlane* forwardUpdate);
93 void setBackwardUpdate(KalmanFittedStateOnPlane* backwardUpdate);
94 void setUpdate(KalmanFittedStateOnPlane* update, int direction) {if (direction >=0) setForwardUpdate(update); else setBackwardUpdate(update);}
95 void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane);
96 void addMeasurementOnPlane(MeasurementOnPlane* measurementOnPlane);
97 void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane);
99 void setWeights(const std::vector<double>&);
100 void fixWeights(bool arg = true) {fixWeights_ = arg;}
101 void setRep(const AbsTrackRep* rep) override;
102
103 void deleteForwardInfo() override;
104 void deleteBackwardInfo() override;
105 void deletePredictions();
106 void deleteReferenceInfo() override {setReferenceState(nullptr);}
107 void deleteMeasurementInfo() override;
108
109 virtual void Print(const Option_t* = "") const override;
110
111 virtual bool checkConsistency(const genfit::PruneFlags* = nullptr) const override;
112
113 private:
114
116 std::unique_ptr<ReferenceStateOnPlane> referenceState_; // Ownership
117 std::unique_ptr<MeasuredStateOnPlane> forwardPrediction_; // Ownership
118 std::unique_ptr<KalmanFittedStateOnPlane> forwardUpdate_; // Ownership
119 std::unique_ptr<MeasuredStateOnPlane> backwardPrediction_; // Ownership
120 std::unique_ptr<KalmanFittedStateOnPlane> backwardUpdate_; // Ownership
121 mutable std::unique_ptr<MeasuredStateOnPlane> fittedStateUnbiased_;
122 mutable std::unique_ptr<MeasuredStateOnPlane> fittedStateBiased_;
123
124 //> TODO ! ptr implement: to the special ownership version
125 /* class owned_pointer_vector : private std::vector<MeasuredStateOnPlane*> {
126 public:
127 ~owned_pointer_vector() { for (size_t i = 0; i < this->size(); ++i)
128 delete this[i]; }
129 size_t size() const { return this->size(); };
130 void push_back(MeasuredStateOnPlane* measuredState) { this->push_back(measuredState); };
131 const MeasuredStateOnPlane* at(size_t i) const { return this->at(i); };
132 //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator position) ;
133 //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator first, owned_pointer_vector::iterator last);
134};
135 */
136
137 std::vector<MeasurementOnPlane*> measurementsOnPlane_; // Ownership
138 bool fixWeights_; // weights should not be altered by fitters anymore
139
140 public:
141
142 ClassDefOverride(KalmanFitterInfo,1)
143
144};
145
146} /* End of namespace genfit */
148
149#endif // genfit_KalmanFitterInfo_h
Abstract base class for a track representation.
Definition AbsTrackRep.h:66
MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF.
bool hasBackwardUpdate() const override
void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate)
bool hasPredictionsAndUpdates() const
void setRep(const AbsTrackRep *rep) override
std::vector< MeasurementOnPlane * > measurementsOnPlane_
cache
virtual bool checkConsistency(const genfit::PruneFlags *=nullptr) const override
ReferenceStateOnPlane * getReferenceState() const
KalmanFittedStateOnPlane * getUpdate(int direction) const
bool hasForwardPrediction() const override
void setWeights(const std::vector< double > &)
Set weights of measurements.
void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane)
void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
const MeasuredStateOnPlane & getFittedState(bool biased=true) const override
Get unbiased or biased (default) smoothed state.
std::unique_ptr< ReferenceStateOnPlane > referenceState_
Reference state. Used by KalmanFitterRefTrack.
void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction)
bool hasBackwardPrediction() const override
const std::vector< genfit::MeasurementOnPlane * > & getMeasurementsOnPlane() const
void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate)
MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights=false) const
void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
void setReferenceState(ReferenceStateOnPlane *referenceState)
std::vector< double > getWeights() const
Get weights of measurements.
void setPrediction(MeasuredStateOnPlane *prediction, int direction)
void deleteBackwardInfo() override
void deleteMeasurementInfo() override
unsigned int getNumMeasurements() const
MeasurementOnPlane getResidual(unsigned int iMeasurement=0, bool biased=false, bool onlyMeasurementErrors=true) const override
Get unbiased (default) or biased residual from ith measurement.
bool hasMeasurements() const override
MeasuredStateOnPlane * getForwardPrediction() const
virtual KalmanFitterInfo * clone() const override
Deep copy ctor for polymorphic class.
KalmanFittedStateOnPlane * getBackwardUpdate() const
std::unique_ptr< MeasuredStateOnPlane > fittedStateBiased_
cache
bool hasUpdate(int direction) const override
MeasurementOnPlane * getClosestMeasurementOnPlane(const StateOnPlane *) const
Get measurements which is closest to state.
MeasuredStateOnPlane * getBackwardPrediction() const
std::unique_ptr< MeasuredStateOnPlane > forwardPrediction_
virtual void Print(const Option_t *="") const override
bool hasReferenceState() const override
std::unique_ptr< MeasuredStateOnPlane > fittedStateUnbiased_
MeasuredStateOnPlane * getPrediction(int direction) const
void fixWeights(bool arg=true)
bool areWeightsFixed() const
Are the weights fixed?
std::unique_ptr< KalmanFittedStateOnPlane > backwardUpdate_
bool hasForwardUpdate() const override
void deleteReferenceInfo() override
MeasurementOnPlane * getMeasurementOnPlane(int i=0) const
double getSmoothedChi2(unsigned int iMeasurement=0) const
void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction)
KalmanFittedStateOnPlane * getForwardUpdate() const
void deleteForwardInfo() override
void setUpdate(KalmanFittedStateOnPlane *update, int direction)
std::unique_ptr< KalmanFittedStateOnPlane > forwardUpdate_
std::unique_ptr< MeasuredStateOnPlane > backwardPrediction_
StateOnPlane with additional covariance matrix.
Measured coordinates on a plane.
StateOnPlane with linearized transport to that ReferenceStateOnPlane from previous and next Reference...
A state with arbitrary dimension defined in a DetPlane.
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition TrackPoint.h:46
Defines for I/O streams used for error and debug printing.
Info which information has been pruned from the Track.
Definition FitStatus.h:47