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 namespace genfit {
40 
45 
46  public:
48  KalmanFitterInfo(const TrackPoint *trackPoint, const AbsTrackRep *rep);
49  virtual ~KalmanFitterInfo();
50 
51  virtual KalmanFitterInfo *clone() const;
52 
53  ReferenceStateOnPlane *getReferenceState() const { return referenceState_.get(); }
54  MeasuredStateOnPlane *getForwardPrediction() const { return forwardPrediction_.get(); }
55  MeasuredStateOnPlane *getBackwardPrediction() const { return backwardPrediction_.get(); }
56  MeasuredStateOnPlane *getPrediction(int direction) const
57  {
58  if (direction >= 0)
59  return forwardPrediction_.get();
60  return backwardPrediction_.get();
61  }
62  KalmanFittedStateOnPlane *getForwardUpdate() const { return forwardUpdate_.get(); }
63  KalmanFittedStateOnPlane *getBackwardUpdate() const { return backwardUpdate_.get(); }
64  KalmanFittedStateOnPlane *getUpdate(int direction) const
65  {
66  if (direction >= 0)
67  return forwardUpdate_.get();
68  return backwardUpdate_.get();
69  }
70  const std::vector<genfit::MeasurementOnPlane *> &getMeasurementsOnPlane() const { return measurementsOnPlane_; }
72  {
73  if (i < 0)
74  i += measurementsOnPlane_.size();
75  return measurementsOnPlane_.at(i);
76  }
79  MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights = false) const;
82  unsigned int getNumMeasurements() const { return measurementsOnPlane_.size(); }
84  std::vector<double> getWeights() const;
86  bool areWeightsFixed() const { return fixWeights_; }
88  const MeasuredStateOnPlane &getFittedState(bool biased = true) const;
90  MeasurementOnPlane getResidual(unsigned int iMeasurement = 0, bool biased = false,
91  bool onlyMeasurementErrors = true) const; // calculate residual, track and measurement errors are added if onlyMeasurementErrors is false
92 
93  bool hasMeasurements() const { return getNumMeasurements() > 0; }
94  bool hasReferenceState() const { return (referenceState_.get() != nullptr); }
95  bool hasForwardPrediction() const { return (forwardPrediction_.get() != nullptr); }
96  bool hasBackwardPrediction() const { return (backwardPrediction_.get() != nullptr); }
97  bool hasForwardUpdate() const { return (forwardUpdate_.get() != nullptr); }
98  bool hasBackwardUpdate() const { return (backwardUpdate_.get() != nullptr); }
99  bool hasUpdate(int direction) const
100  {
101  if (direction < 0)
102  return hasBackwardUpdate();
103  return hasForwardUpdate();
104  }
106 
107  void setReferenceState(ReferenceStateOnPlane *referenceState);
108  void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction);
109  void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction);
110  void setPrediction(MeasuredStateOnPlane *prediction, int direction)
111  {
112  if (direction >= 0)
113  setForwardPrediction(prediction);
114  else
115  setBackwardPrediction(prediction);
116  }
117  void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate);
118  void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate);
119  void setUpdate(KalmanFittedStateOnPlane *update, int direction)
120  {
121  if (direction >= 0)
122  setForwardUpdate(update);
123  else
124  setBackwardUpdate(update);
125  }
126  void setMeasurementsOnPlane(const std::vector<genfit::MeasurementOnPlane *> &measurementsOnPlane);
127  void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane);
128  void addMeasurementsOnPlane(const std::vector<genfit::MeasurementOnPlane *> &measurementsOnPlane);
130  void setWeights(const std::vector<double> &);
131  void fixWeights(bool arg = true) { fixWeights_ = arg; }
132  void setRep(const AbsTrackRep *rep);
133 
134  void deleteForwardInfo();
135  void deleteBackwardInfo();
136  void deletePredictions();
138  void deleteMeasurementInfo();
139 
140  virtual void Print(const Option_t * = "") const;
141 
142  virtual bool checkConsistency(const genfit::PruneFlags * = nullptr) const;
143 
144  private:
145 #ifndef __CINT__
146  boost::scoped_ptr<ReferenceStateOnPlane> referenceState_; // Ownership
148  boost::scoped_ptr<MeasuredStateOnPlane> forwardPrediction_; // Ownership
149  boost::scoped_ptr<KalmanFittedStateOnPlane> forwardUpdate_; // Ownership
150  boost::scoped_ptr<MeasuredStateOnPlane> backwardPrediction_; // Ownership
151  boost::scoped_ptr<KalmanFittedStateOnPlane> backwardUpdate_; // Ownership
152  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateUnbiased_;
153  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateBiased_;
154 #else
155  class ReferenceStateOnPlane *referenceState_;
156  class MeasuredStateOnPlane *forwardPrediction_;
157  class KalmanFittedStateOnPlane *forwardUpdate_;
158  class MeasuredStateOnPlane *backwardPrediction_;
159  class KalmanFittedStateOnPlane *backwardUpdate_;
160  class MeasuredStateOnPlane *fittedStateUnbiased_;
161  class MeasuredStateOnPlane *fittedStateBiased_;
162 #endif
163 
164  //> TODO ! ptr implement: to the special ownership version
165  /* class owned_pointer_vector : private std::vector<MeasuredStateOnPlane*> {
166  public:
167  ~owned_pointer_vector() { for (size_t i = 0; i < this->size(); ++i)
168  delete this[i]; }
169  size_t size() const { return this->size(); };
170  void push_back(MeasuredStateOnPlane* measuredState) { this->push_back(measuredState); };
171  const MeasuredStateOnPlane* at(size_t i) const { return this->at(i); };
172  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator position) ;
173  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator first, owned_pointer_vector::iterator last);
174 };
175  */
176 
177  std::vector<MeasurementOnPlane *> measurementsOnPlane_; // Ownership
178  bool fixWeights_; // weights should not be altered by fitters anymore
179 
180  public:
181  ClassDef(KalmanFitterInfo, 1)
182 };
183 
184 } /* End of namespace genfit */
187 #endif // genfit_KalmanFitterInfo_h
void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate)
std::vector< double > getWeights() const
Get weights of measurements.
unsigned int getNumMeasurements() const
void setUpdate(KalmanFittedStateOnPlane *update, int direction)
MeasuredStateOnPlane * getForwardPrediction() const
ReferenceStateOnPlane * getReferenceState() const
const std::vector< genfit::MeasurementOnPlane * > & getMeasurementsOnPlane() const
bool hasUpdate(int direction) const
MeasurementOnPlane * getMeasurementOnPlane(int i=0) const
Info which information has been pruned from the Track.
Definition: FitStatus.h:45
Abstract base class for a track representation.
Definition: AbsTrackRep.h:62
bool hasForwardPrediction() const
StateOnPlane with additional covariance matrix.
MeasuredStateOnPlane * getBackwardPrediction() const
virtual bool checkConsistency(const genfit::PruneFlags *=nullptr) const
bool hasPredictionsAndUpdates() const
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Definition: AbsFitterInfo.h:41
void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane *> &measurementsOnPlane)
MeasuredStateOnPlane * getPrediction(int direction) const
MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights=false) const
KalmanFittedStateOnPlane * getBackwardUpdate() const
void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate)
void setWeights(const std::vector< double > &)
Set weights of measurements.
unsigned int i
Definition: P4_F32vec4.h:21
MeasurementOnPlane getResidual(unsigned int iMeasurement=0, bool biased=false, bool onlyMeasurementErrors=true) const
Get unbiased (default) or biased residual from ith measurement.
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:44
Measured coordinates on a plane.
void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane *> &measurementsOnPlane)
void setPrediction(MeasuredStateOnPlane *prediction, int direction)
StateOnPlane with linearized transport to that ReferenceStateOnPlane from previous and next Reference...
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:49
void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane)
bool hasBackwardPrediction() const
virtual void Print(const Option_t *="") const
void fixWeights(bool arg=true)
bool areWeightsFixed() const
Are the weights fixed?
KalmanFittedStateOnPlane * getUpdate(int direction) const
void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction)
virtual KalmanFitterInfo * clone() const
Deep copy ctor for polymorphic class.
void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction)
const MeasuredStateOnPlane & getFittedState(bool biased=true) const
Get unbiased or biased (default) smoothed state.
MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF.
void setReferenceState(ReferenceStateOnPlane *referenceState)
MeasurementOnPlane * getClosestMeasurementOnPlane(const StateOnPlane *) const
Get measurements which is closest to state.
void setRep(const AbsTrackRep *rep)
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
KalmanFittedStateOnPlane * getForwardUpdate() const
Matrix inversion tools.
Definition: AbsBField.h:28