GENFIT  Rev:NoNumberAvailable
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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
void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate)
void setWeights(const std::vector< double > &)
Set weights of measurements.
bool areWeightsFixed() const
Are the weights fixed?
bool hasBackwardPrediction() const
bool hasUpdate(int direction) const
void setUpdate(KalmanFittedStateOnPlane *update, int direction)
void setPrediction(MeasuredStateOnPlane *prediction, int direction)
virtual KalmanFitterInfo * clone() const
Deep copy ctor for polymorphic class.
double getSmoothedChi2(unsigned int iMeasurement=0)
virtual bool checkConsistency(const genfit::PruneFlags *=NULL) const
boost::scoped_ptr< KalmanFittedStateOnPlane > backwardUpdate_
MeasuredStateOnPlane * getForwardPrediction() const
bool hasReferenceState() const
virtual void Print(const Option_t *="") const
Info which information has been pruned from the Track.
Definition: FitStatus.h:47
void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane)
ReferenceStateOnPlane * getReferenceState() const
boost::scoped_ptr< KalmanFittedStateOnPlane > forwardUpdate_
KalmanFittedStateOnPlane * getBackwardUpdate() const
void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction)
unsigned int getNumMeasurements() const
MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF.
StateOnPlane with linearized transport to that ReferenceStateOnPlane from previous and next Reference...
StateOnPlane with additional covariance matrix.
MeasurementOnPlane * getClosestMeasurementOnPlane(const StateOnPlane *) const
Get measurements which is closest to state.
void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
void setReferenceState(ReferenceStateOnPlane *referenceState)
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
bool hasPredictionsAndUpdates() const
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
void fixWeights(bool arg=true)
std::vector< double > getWeights() const
Get weights of measurements.
MeasuredStateOnPlane * getBackwardPrediction() const
MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights=false) const
boost::scoped_ptr< MeasuredStateOnPlane > forwardPrediction_
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:50
bool hasForwardPrediction() const
KalmanFittedStateOnPlane * getForwardUpdate() const
void setRep(const AbsTrackRep *rep)
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateUnbiased_
std::vector< MeasurementOnPlane * > measurementsOnPlane_
cache
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:45
bool hasBackwardUpdate() const
KalmanFittedStateOnPlane * getUpdate(int direction) const
boost::scoped_ptr< ReferenceStateOnPlane > referenceState_
Reference state. Used by KalmanFitterRefTrack.
boost::scoped_ptr< MeasuredStateOnPlane > backwardPrediction_
MeasurementOnPlane getResidual(unsigned int iMeasurement=0, bool biased=false, bool onlyMeasurementErrors=true) const
Get unbiased (default) or biased residual from ith measurement.
MeasuredStateOnPlane * getPrediction(int direction) const
void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction)
bool hasForwardUpdate() const
Measured coordinates on a plane.
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateBiased_
cache
const MeasuredStateOnPlane & getFittedState(bool biased=true) const
Get unbiased or biased (default) smoothed state.
void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate)
MeasurementOnPlane * getMeasurementOnPlane(int i=0) const
Defines for I/O streams used for error and debug printing.
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Definition: AbsFitterInfo.h:42
const std::vector< genfit::MeasurementOnPlane * > & getMeasurementsOnPlane() const