FairRoot/PandaRoot
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 
80  bool hasMeasurements() const {return getNumMeasurements() > 0;}
81  bool hasReferenceState() const {return (referenceState_.get() != NULL);}
82  bool hasForwardPrediction() const {return (forwardPrediction_.get() != NULL);}
83  bool hasBackwardPrediction() const {return (backwardPrediction_.get() != NULL);}
84  bool hasForwardUpdate() const {return (forwardUpdate_.get() != NULL);}
85  bool hasBackwardUpdate() const {return (backwardUpdate_.get() != NULL);}
86  bool hasUpdate(int direction) const {if (direction < 0) return hasBackwardUpdate(); return hasForwardUpdate();}
88 
89  void setReferenceState(ReferenceStateOnPlane* referenceState);
90  void setForwardPrediction(MeasuredStateOnPlane* forwardPrediction);
91  void setBackwardPrediction(MeasuredStateOnPlane* backwardPrediction);
92  void setPrediction(MeasuredStateOnPlane* prediction, int direction) {if (direction >=0) setForwardPrediction(prediction); else setBackwardPrediction(prediction);}
93  void setForwardUpdate(KalmanFittedStateOnPlane* forwardUpdate);
94  void setBackwardUpdate(KalmanFittedStateOnPlane* backwardUpdate);
95  void setUpdate(KalmanFittedStateOnPlane* update, int direction) {if (direction >=0) setForwardUpdate(update); else setBackwardUpdate(update);}
96  void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane);
97  void addMeasurementOnPlane(MeasurementOnPlane* measurementOnPlane);
98  void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane);
100  void setWeights(const std::vector<double>&);
101  void fixWeights(bool arg = true) {fixWeights_ = arg;}
102  void setRep(const AbsTrackRep* rep);
103 
104  void deleteForwardInfo();
105  void deleteBackwardInfo();
106  void deletePredictions();
108  void deleteMeasurementInfo();
109 
110  virtual void Print(const Option_t* = "") const;
111 
112  virtual bool checkConsistency(const genfit::PruneFlags* = NULL) const;
113 
114  private:
115 
116 
117 #ifndef __CINT__
118  boost::scoped_ptr<ReferenceStateOnPlane> referenceState_; // Ownership
120  boost::scoped_ptr<MeasuredStateOnPlane> forwardPrediction_; // Ownership
121  boost::scoped_ptr<KalmanFittedStateOnPlane> forwardUpdate_; // Ownership
122  boost::scoped_ptr<MeasuredStateOnPlane> backwardPrediction_; // Ownership
123  boost::scoped_ptr<KalmanFittedStateOnPlane> backwardUpdate_; // Ownership
124  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateUnbiased_;
125  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateBiased_;
126 #else
134 #endif
135 
136 
137  //> TODO ! ptr implement: to the special ownership version
138  /* class owned_pointer_vector : private std::vector<MeasuredStateOnPlane*> {
139  public:
140  ~owned_pointer_vector() { for (size_t i = 0; i < this->size(); ++i)
141  delete this[i]; }
142  size_t size() const { return this->size(); };
143  void push_back(MeasuredStateOnPlane* measuredState) { this->push_back(measuredState); };
144  const MeasuredStateOnPlane* at(size_t i) const { return this->at(i); };
145  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator position) ;
146  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator first, owned_pointer_vector::iterator last);
147 };
148  */
149 
150  std::vector<MeasurementOnPlane*> measurementsOnPlane_; // Ownership
151  bool fixWeights_; // weights should not be altered by fitters anymore
152 
153  public:
154 
155  ClassDef(KalmanFitterInfo,1)
156 
157 };
158 
159 } /* End of namespace genfit */
162 #endif // genfit_KalmanFitterInfo_h
void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate)
void setUpdate(KalmanFittedStateOnPlane *update, int direction)
bool hasBackwardUpdate() const
const std::vector< genfit::MeasurementOnPlane * > & getMeasurementsOnPlane() const
boost::scoped_ptr< ReferenceStateOnPlane > referenceState_
Reference state. Used by KalmanFitterRefTrack.
Int_t i
Definition: run_full.C:25
MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights=false) const
MeasuredStateOnPlane * getForwardPrediction() const
static void update(void)
Definition: ranlxd.cxx:453
Info which information has been pruned from the Track.
Definition: FitStatus.h:47
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
KalmanFittedStateOnPlane * getUpdate(int direction) const
bool hasReferenceState() const
bool hasBackwardPrediction() const
StateOnPlane with additional covariance matrix.
bool hasForwardUpdate() const
MeasurementOnPlane * getClosestMeasurementOnPlane(const StateOnPlane *) const
Get measurements which is closest to state.
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Definition: AbsFitterInfo.h:42
MeasurementOnPlane getResidual(unsigned int iMeasurement=0, bool biased=false, bool onlyMeasurementErrors=true) const
Get unbiased (default) or biased residual from ith measurement.
void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate)
void setWeights(const std::vector< double > &)
Set weights of measurements.
KalmanFittedStateOnPlane * getBackwardUpdate() const
void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:45
MeasuredStateOnPlane * getPrediction(int direction) const
unsigned int getNumMeasurements() const
virtual void Print(const Option_t *="") const
Measured coordinates on a plane.
boost::scoped_ptr< KalmanFittedStateOnPlane > backwardUpdate_
void setPrediction(MeasuredStateOnPlane *prediction, int direction)
std::vector< double > getWeights() const
Get weights of measurements.
StateOnPlane with linearized transport to that ReferenceStateOnPlane from previous and next Reference...
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:50
boost::scoped_ptr< KalmanFittedStateOnPlane > forwardUpdate_
MeasuredStateOnPlane * getBackwardPrediction() const
virtual KalmanFitterInfo * clone() const
Deep copy ctor for polymorphic class.
void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane)
void fixWeights(bool arg=true)
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateBiased_
cache
void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction)
ReferenceStateOnPlane * getReferenceState() const
void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction)
MeasurementOnPlane * getMeasurementOnPlane(int i=0) const
const MeasuredStateOnPlane & getFittedState(bool biased=true) const
Get unbiased or biased (default) smoothed state.
bool areWeightsFixed() const
Are the weights fixed?
bool hasPredictionsAndUpdates() const
MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF.
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateUnbiased_
void setReferenceState(ReferenceStateOnPlane *referenceState)
KalmanFittedStateOnPlane * getForwardUpdate() const
void setRep(const AbsTrackRep *rep)
void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
std::vector< MeasurementOnPlane * > measurementsOnPlane_
cache
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
boost::scoped_ptr< MeasuredStateOnPlane > forwardPrediction_
boost::scoped_ptr< MeasuredStateOnPlane > backwardPrediction_
virtual bool checkConsistency(const genfit::PruneFlags *=NULL) const
bool hasUpdate(int direction) const
bool hasForwardPrediction() const
Matrix inversion tools.
Definition: AbsBField.h:29