GENFIT  Rev:NoNumberAvailable
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 */
23 #ifndef genfit_KalmanFitterInfo_h
24 #define genfit_KalmanFitterInfo_h
25 
26 #include "AbsFitterInfo.h"
28 #include "MeasuredStateOnPlane.h"
29 #include "MeasurementOnPlane.h"
30 #include "ReferenceStateOnPlane.h"
31 #include "StateOnPlane.h"
32 
33 #include <vector>
34 
35 #ifndef __CINT__
36 #include <boost/scoped_ptr.hpp>
37 #endif
38 
39 
40 namespace genfit {
41 
42 
47 
48  public:
49 
51  KalmanFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep);
52  virtual ~KalmanFitterInfo();
53 
54  virtual KalmanFitterInfo* clone() const;
55 
59  MeasuredStateOnPlane* getPrediction(int direction) const {if (direction >=0) return forwardPrediction_.get(); return backwardPrediction_.get();}
62  KalmanFittedStateOnPlane* getUpdate(int direction) const {if (direction >=0) return forwardUpdate_.get(); return backwardUpdate_.get();}
63  const std::vector< genfit::MeasurementOnPlane* >& getMeasurementsOnPlane() const {return measurementsOnPlane_;}
64  MeasurementOnPlane* getMeasurementOnPlane(int i = 0) const {if (i<0) i += measurementsOnPlane_.size(); return measurementsOnPlane_.at(i);}
67  MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights = false) const;
70  unsigned int getNumMeasurements() const {return measurementsOnPlane_.size();}
72  std::vector<double> getWeights() const;
74  bool areWeightsFixed() const {return fixWeights_;}
76  const MeasuredStateOnPlane& getFittedState(bool biased = true) const;
78  MeasurementOnPlane getResidual(unsigned int iMeasurement = 0, bool biased = false, bool onlyMeasurementErrors = true) const; // calculate residual, track and measurement errors are added if onlyMeasurementErrors is false
79  double getSmoothedChi2(unsigned int iMeasurement = 0);
80 
81  bool hasMeasurements() const {return getNumMeasurements() > 0;}
82  bool hasReferenceState() const {return (referenceState_.get() != NULL);}
83  bool hasForwardPrediction() const {return (forwardPrediction_.get() != NULL);}
84  bool hasBackwardPrediction() const {return (backwardPrediction_.get() != NULL);}
85  bool hasForwardUpdate() const {return (forwardUpdate_.get() != NULL);}
86  bool hasBackwardUpdate() const {return (backwardUpdate_.get() != NULL);}
87  bool hasUpdate(int direction) const {if (direction < 0) return hasBackwardUpdate(); return hasForwardUpdate();}
89 
90  void setReferenceState(ReferenceStateOnPlane* referenceState);
91  void setForwardPrediction(MeasuredStateOnPlane* forwardPrediction);
92  void setBackwardPrediction(MeasuredStateOnPlane* backwardPrediction);
93  void setPrediction(MeasuredStateOnPlane* prediction, int direction) {if (direction >=0) setForwardPrediction(prediction); else setBackwardPrediction(prediction);}
94  void setForwardUpdate(KalmanFittedStateOnPlane* forwardUpdate);
95  void setBackwardUpdate(KalmanFittedStateOnPlane* backwardUpdate);
96  void setUpdate(KalmanFittedStateOnPlane* update, int direction) {if (direction >=0) setForwardUpdate(update); else setBackwardUpdate(update);}
97  void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane);
98  void addMeasurementOnPlane(MeasurementOnPlane* measurementOnPlane);
99  void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane);
101  void setWeights(const std::vector<double>&);
102  void fixWeights(bool arg = true) {fixWeights_ = arg;}
103  void setRep(const AbsTrackRep* rep);
104 
105  void deleteForwardInfo();
106  void deleteBackwardInfo();
107  void deletePredictions();
109  void deleteMeasurementInfo();
110 
111  virtual void Print(const Option_t* = "") const;
112 
113  virtual bool checkConsistency(const genfit::PruneFlags* = NULL) const;
114 
115  private:
116 
117 
118 #ifndef __CINT__
119  boost::scoped_ptr<ReferenceStateOnPlane> referenceState_; // Ownership
121  boost::scoped_ptr<MeasuredStateOnPlane> forwardPrediction_; // Ownership
122  boost::scoped_ptr<KalmanFittedStateOnPlane> forwardUpdate_; // Ownership
123  boost::scoped_ptr<MeasuredStateOnPlane> backwardPrediction_; // Ownership
124  boost::scoped_ptr<KalmanFittedStateOnPlane> backwardUpdate_; // Ownership
125  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateUnbiased_;
126  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateBiased_;
127 #else
135 #endif
136 
137 
138  //> TODO ! ptr implement: to the special ownership version
139  /* class owned_pointer_vector : private std::vector<MeasuredStateOnPlane*> {
140  public:
141  ~owned_pointer_vector() { for (size_t i = 0; i < this->size(); ++i)
142  delete this[i]; }
143  size_t size() const { return this->size(); };
144  void push_back(MeasuredStateOnPlane* measuredState) { this->push_back(measuredState); };
145  const MeasuredStateOnPlane* at(size_t i) const { return this->at(i); };
146  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator position) ;
147  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator first, owned_pointer_vector::iterator last);
148 };
149  */
150 
151  std::vector<MeasurementOnPlane*> measurementsOnPlane_; // Ownership
152  bool fixWeights_; // weights should not be altered by fitters anymore
153 
154  public:
155 
156  ClassDef(KalmanFitterInfo,1)
157 
158 };
159 
160 } /* End of namespace genfit */
163 #endif // genfit_KalmanFitterInfo_h
genfit::KalmanFitterInfo::backwardUpdate_
boost::scoped_ptr< KalmanFittedStateOnPlane > backwardUpdate_
Definition: KalmanFitterInfo.h:124
genfit::KalmanFitterInfo::areWeightsFixed
bool areWeightsFixed() const
Are the weights fixed?
Definition: KalmanFitterInfo.h:74
genfit::KalmanFitterInfo::checkConsistency
virtual bool checkConsistency(const genfit::PruneFlags *=NULL) const
Definition: KalmanFitterInfo.cc:539
genfit::KalmanFitterInfo::setUpdate
void setUpdate(KalmanFittedStateOnPlane *update, int direction)
Definition: KalmanFitterInfo.h:96
genfit::KalmanFitterInfo::setBackwardPrediction
void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction)
Definition: KalmanFitterInfo.cc:391
genfit::KalmanFitterInfo
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
Definition: KalmanFitterInfo.h:46
genfit::KalmanFitterInfo::getClosestMeasurementOnPlane
MeasurementOnPlane * getClosestMeasurementOnPlane(const StateOnPlane *) const
Get measurements which is closest to state.
Definition: KalmanFitterInfo.cc:139
genfit::KalmanFitterInfo::setBackwardUpdate
void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate)
Definition: KalmanFitterInfo.cc:407
genfit::KalmanFitterInfo::setMeasurementsOnPlane
void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
Definition: KalmanFitterInfo.cc:416
genfit::KalmanFitterInfo::hasBackwardPrediction
bool hasBackwardPrediction() const
Definition: KalmanFitterInfo.h:84
genfit::KalmanFitterInfo::getNumMeasurements
unsigned int getNumMeasurements() const
Definition: KalmanFitterInfo.h:70
genfit::KalmanFitterInfo::setWeights
void setWeights(const std::vector< double > &)
Set weights of measurements.
Definition: KalmanFitterInfo.cc:463
KalmanFittedStateOnPlane.h
genfit::MeasuredStateOnPlane
StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:38
genfit::KalmanFitterInfo::deleteReferenceInfo
void deleteReferenceInfo()
Definition: KalmanFitterInfo.h:108
genfit::KalmanFitterInfo::getSmoothedChi2
double getSmoothedChi2(unsigned int iMeasurement=0)
Definition: KalmanFitterInfo.cc:350
genfit::KalmanFitterInfo::hasReferenceState
bool hasReferenceState() const
Definition: KalmanFitterInfo.h:82
genfit::KalmanFitterInfo::getWeights
std::vector< double > getWeights() const
Get weights of measurements.
Definition: KalmanFitterInfo.cc:168
genfit::KalmanFitterInfo::getForwardUpdate
KalmanFittedStateOnPlane * getForwardUpdate() const
Definition: KalmanFitterInfo.h:60
genfit::KalmanFitterInfo::setPrediction
void setPrediction(MeasuredStateOnPlane *prediction, int direction)
Definition: KalmanFitterInfo.h:93
genfit::KalmanFitterInfo::hasPredictionsAndUpdates
bool hasPredictionsAndUpdates() const
Definition: KalmanFitterInfo.h:88
genfit
Defines for I/O streams used for error and debug printing.
Definition: AbsFinitePlane.cc:22
AbsFitterInfo.h
genfit::KalmanFitterInfo::addMeasurementOnPlane
void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane)
Definition: KalmanFitterInfo.cc:425
genfit::KalmanFitterInfo::deletePredictions
void deletePredictions()
Definition: KalmanFitterInfo.cc:494
genfit::KalmanFitterInfo::hasUpdate
bool hasUpdate(int direction) const
Definition: KalmanFitterInfo.h:87
genfit::KalmanFitterInfo::hasBackwardUpdate
bool hasBackwardUpdate() const
Definition: KalmanFitterInfo.h:86
genfit::KalmanFitterInfo::getAvgWeightedMeasurementOnPlane
MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights=false) const
Definition: KalmanFitterInfo.cc:78
genfit::AbsTrackRep
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
genfit::KalmanFitterInfo::hasForwardPrediction
bool hasForwardPrediction() const
Definition: KalmanFitterInfo.h:83
genfit::KalmanFitterInfo::forwardUpdate_
boost::scoped_ptr< KalmanFittedStateOnPlane > forwardUpdate_
Definition: KalmanFitterInfo.h:122
genfit::KalmanFitterInfo::addMeasurementsOnPlane
void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
Definition: KalmanFitterInfo.cc:432
genfit::KalmanFitterInfo::KalmanFitterInfo
KalmanFitterInfo()
Definition: KalmanFitterInfo.cc:37
genfit::KalmanFitterInfo::deleteMeasurementInfo
void deleteMeasurementInfo()
Definition: KalmanFitterInfo.cc:501
genfit::KalmanFitterInfo::getFittedState
const MeasuredStateOnPlane & getFittedState(bool biased=true) const
Get unbiased or biased (default) smoothed state.
Definition: KalmanFitterInfo.cc:179
genfit::KalmanFitterInfo::getPrediction
MeasuredStateOnPlane * getPrediction(int direction) const
Definition: KalmanFitterInfo.h:59
genfit::KalmanFitterInfo::setForwardPrediction
void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction)
Definition: KalmanFitterInfo.cc:383
genfit::KalmanFitterInfo::setReferenceState
void setReferenceState(ReferenceStateOnPlane *referenceState)
Definition: KalmanFitterInfo.cc:359
StateOnPlane.h
genfit::KalmanFitterInfo::getBackwardUpdate
KalmanFittedStateOnPlane * getBackwardUpdate() const
Definition: KalmanFitterInfo.h:61
genfit::KalmanFitterInfo::deleteBackwardInfo
void deleteBackwardInfo()
Definition: KalmanFitterInfo.cc:487
genfit::KalmanFitterInfo::Print
virtual void Print(const Option_t *="") const
Definition: KalmanFitterInfo.cc:510
ReferenceStateOnPlane.h
genfit::KalmanFitterInfo::getUpdate
KalmanFittedStateOnPlane * getUpdate(int direction) const
Definition: KalmanFitterInfo.h:62
genfit::TrackPoint
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:50
genfit::AbsFitterInfo
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Definition: AbsFitterInfo.h:42
genfit::KalmanFitterInfo::forwardPrediction_
boost::scoped_ptr< MeasuredStateOnPlane > forwardPrediction_
Definition: KalmanFitterInfo.h:121
genfit::StateOnPlane
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:45
genfit::ReferenceStateOnPlane
StateOnPlane with linearized transport to that ReferenceStateOnPlane from previous and next Reference...
Definition: ReferenceStateOnPlane.h:43
genfit::KalmanFitterInfo::getForwardPrediction
MeasuredStateOnPlane * getForwardPrediction() const
Definition: KalmanFitterInfo.h:57
genfit::KalmanFitterInfo::getResidual
MeasurementOnPlane getResidual(unsigned int iMeasurement=0, bool biased=false, bool onlyMeasurementErrors=true) const
Get unbiased (default) or biased residual from ith measurement.
Definition: KalmanFitterInfo.cc:314
MeasurementOnPlane.h
genfit::KalmanFitterInfo::getMeasurementOnPlane
MeasurementOnPlane * getMeasurementOnPlane(int i=0) const
Definition: KalmanFitterInfo.h:64
genfit::KalmanFitterInfo::setRep
void setRep(const AbsTrackRep *rep)
Definition: KalmanFitterInfo.cc:439
genfit::KalmanFitterInfo::fittedStateUnbiased_
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateUnbiased_
Definition: KalmanFitterInfo.h:125
genfit::KalmanFitterInfo::getMeasurementsOnPlane
const std::vector< genfit::MeasurementOnPlane * > & getMeasurementsOnPlane() const
Definition: KalmanFitterInfo.h:63
genfit::KalmanFitterInfo::deleteForwardInfo
void deleteForwardInfo()
Definition: KalmanFitterInfo.cc:480
genfit::KalmanFitterInfo::referenceState_
boost::scoped_ptr< ReferenceStateOnPlane > referenceState_
Reference state. Used by KalmanFitterRefTrack.
Definition: KalmanFitterInfo.h:120
genfit::MeasurementOnPlane
Measured coordinates on a plane.
Definition: MeasurementOnPlane.h:45
genfit::KalmanFitterInfo::fixWeights
void fixWeights(bool arg=true)
Definition: KalmanFitterInfo.h:102
genfit::KalmanFitterInfo::getReferenceState
ReferenceStateOnPlane * getReferenceState() const
Definition: KalmanFitterInfo.h:56
genfit::KalmanFitterInfo::getBackwardPrediction
MeasuredStateOnPlane * getBackwardPrediction() const
Definition: KalmanFitterInfo.h:58
genfit::KalmanFittedStateOnPlane
MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF.
Definition: KalmanFittedStateOnPlane.h:35
genfit::KalmanFitterInfo::fittedStateBiased_
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateBiased_
cache
Definition: KalmanFitterInfo.h:126
genfit::KalmanFitterInfo::measurementsOnPlane_
std::vector< MeasurementOnPlane * > measurementsOnPlane_
cache
Definition: KalmanFitterInfo.h:151
MeasuredStateOnPlane.h
genfit::KalmanFitterInfo::clone
virtual KalmanFitterInfo * clone() const
Deep copy ctor for polymorphic class.
Definition: KalmanFitterInfo.cc:54
genfit::KalmanFitterInfo::fixWeights_
bool fixWeights_
Definition: KalmanFitterInfo.h:152
genfit::KalmanFitterInfo::setForwardUpdate
void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate)
Definition: KalmanFitterInfo.cc:399
genfit::KalmanFitterInfo::backwardPrediction_
boost::scoped_ptr< MeasuredStateOnPlane > backwardPrediction_
Definition: KalmanFitterInfo.h:123
genfit::KalmanFitterInfo::~KalmanFitterInfo
virtual ~KalmanFitterInfo()
Definition: KalmanFitterInfo.cc:49
genfit::KalmanFitterInfo::hasMeasurements
bool hasMeasurements() const
Definition: KalmanFitterInfo.h:81
genfit::KalmanFitterInfo::hasForwardUpdate
bool hasForwardUpdate() const
Definition: KalmanFitterInfo.h:85
genfit::PruneFlags
Info which information has been pruned from the Track.
Definition: FitStatus.h:47