PandaRoot
KalmanFitterInfo.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2008-2010, Technische Universitaet Muenchen,
14  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30 */
35 #ifndef genfit_KalmanFitterInfo_h
36 #define genfit_KalmanFitterInfo_h
37 
38 #include "AbsFitterInfo.h"
40 #include "MeasuredStateOnPlane.h"
41 #include "MeasurementOnPlane.h"
42 #include "ReferenceStateOnPlane.h"
43 #include "StateOnPlane.h"
44 
45 #include <vector>
46 
47 #ifndef __CINT__
48 #include <boost/scoped_ptr.hpp>
49 #endif
50 
51 namespace genfit {
52 
57 
58  public:
60  KalmanFitterInfo(const TrackPoint *trackPoint, const AbsTrackRep *rep);
61  virtual ~KalmanFitterInfo();
62 
63  virtual KalmanFitterInfo *clone() const;
64 
65  ReferenceStateOnPlane *getReferenceState() const { return referenceState_.get(); }
66  MeasuredStateOnPlane *getForwardPrediction() const { return forwardPrediction_.get(); }
67  MeasuredStateOnPlane *getBackwardPrediction() const { return backwardPrediction_.get(); }
68  MeasuredStateOnPlane *getPrediction(int direction) const
69  {
70  if (direction >= 0)
71  return forwardPrediction_.get();
72  return backwardPrediction_.get();
73  }
74  KalmanFittedStateOnPlane *getForwardUpdate() const { return forwardUpdate_.get(); }
75  KalmanFittedStateOnPlane *getBackwardUpdate() const { return backwardUpdate_.get(); }
76  KalmanFittedStateOnPlane *getUpdate(int direction) const
77  {
78  if (direction >= 0)
79  return forwardUpdate_.get();
80  return backwardUpdate_.get();
81  }
82  const std::vector<genfit::MeasurementOnPlane *> &getMeasurementsOnPlane() const { return measurementsOnPlane_; }
84  {
85  if (i < 0)
86  i += measurementsOnPlane_.size();
87  return measurementsOnPlane_.at(i);
88  }
91  MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights = false) const;
94  unsigned int getNumMeasurements() const { return measurementsOnPlane_.size(); }
96  std::vector<double> getWeights() const;
98  bool areWeightsFixed() const { return fixWeights_; }
100  const MeasuredStateOnPlane &getFittedState(bool biased = true) const;
102  MeasurementOnPlane getResidual(unsigned int iMeasurement = 0, bool biased = false,
103  bool onlyMeasurementErrors = true) const; // calculate residual, track and measurement errors are added if onlyMeasurementErrors is false
104 
105  bool hasMeasurements() const { return getNumMeasurements() > 0; }
106  bool hasReferenceState() const { return (referenceState_.get() != nullptr); }
107  bool hasForwardPrediction() const { return (forwardPrediction_.get() != nullptr); }
108  bool hasBackwardPrediction() const { return (backwardPrediction_.get() != nullptr); }
109  bool hasForwardUpdate() const { return (forwardUpdate_.get() != nullptr); }
110  bool hasBackwardUpdate() const { return (backwardUpdate_.get() != nullptr); }
111  bool hasUpdate(int direction) const
112  {
113  if (direction < 0)
114  return hasBackwardUpdate();
115  return hasForwardUpdate();
116  }
118 
119  void setReferenceState(ReferenceStateOnPlane *referenceState);
120  void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction);
121  void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction);
122  void setPrediction(MeasuredStateOnPlane *prediction, int direction)
123  {
124  if (direction >= 0)
125  setForwardPrediction(prediction);
126  else
127  setBackwardPrediction(prediction);
128  }
129  void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate);
130  void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate);
131  void setUpdate(KalmanFittedStateOnPlane *update, int direction)
132  {
133  if (direction >= 0)
134  setForwardUpdate(update);
135  else
136  setBackwardUpdate(update);
137  }
138  void setMeasurementsOnPlane(const std::vector<genfit::MeasurementOnPlane *> &measurementsOnPlane);
139  void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane);
140  void addMeasurementsOnPlane(const std::vector<genfit::MeasurementOnPlane *> &measurementsOnPlane);
142  void setWeights(const std::vector<double> &);
143  void fixWeights(bool arg = true) { fixWeights_ = arg; }
144  void setRep(const AbsTrackRep *rep);
145 
146  void deleteForwardInfo();
147  void deleteBackwardInfo();
148  void deletePredictions();
150  void deleteMeasurementInfo();
151 
152  virtual void Print(const Option_t * = "") const;
153 
154  virtual bool checkConsistency(const genfit::PruneFlags * = nullptr) const;
155 
156  private:
157 #ifndef __CINT__
158  boost::scoped_ptr<ReferenceStateOnPlane> referenceState_; // Ownership
160  boost::scoped_ptr<MeasuredStateOnPlane> forwardPrediction_; // Ownership
161  boost::scoped_ptr<KalmanFittedStateOnPlane> forwardUpdate_; // Ownership
162  boost::scoped_ptr<MeasuredStateOnPlane> backwardPrediction_; // Ownership
163  boost::scoped_ptr<KalmanFittedStateOnPlane> backwardUpdate_; // Ownership
164  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateUnbiased_;
165  mutable boost::scoped_ptr<MeasuredStateOnPlane> fittedStateBiased_;
166 #else
167  class ReferenceStateOnPlane *referenceState_;
168  class MeasuredStateOnPlane *forwardPrediction_;
169  class KalmanFittedStateOnPlane *forwardUpdate_;
170  class MeasuredStateOnPlane *backwardPrediction_;
171  class KalmanFittedStateOnPlane *backwardUpdate_;
172  class MeasuredStateOnPlane *fittedStateUnbiased_;
173  class MeasuredStateOnPlane *fittedStateBiased_;
174 #endif
175 
176  //> TODO ! ptr implement: to the special ownership version
177  /* class owned_pointer_vector : private std::vector<MeasuredStateOnPlane*> {
178  public:
179  ~owned_pointer_vector() { for (size_t i = 0; i < this->size(); ++i)
180  delete this[i]; }
181  size_t size() const { return this->size(); };
182  void push_back(MeasuredStateOnPlane* measuredState) { this->push_back(measuredState); };
183  const MeasuredStateOnPlane* at(size_t i) const { return this->at(i); };
184  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator position) ;
185  //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator first, owned_pointer_vector::iterator last);
186 };
187  */
188 
189  std::vector<MeasurementOnPlane *> measurementsOnPlane_; // Ownership
190  bool fixWeights_; // weights should not be altered by fitters anymore
191 
192  public:
193  ClassDef(KalmanFitterInfo, 1)
194 };
195 
196 } /* End of namespace genfit */
199 #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:57
Abstract base class for a track representation.
Definition: AbsTrackRep.h:74
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:53
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:33
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:56
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:61
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:40