Belle II Software  release-08-01-10
GblFitterInfo.h
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_GblFitterInfo_h
24 #define genfit_GblFitterInfo_h
25 
26 #include "AbsFitterInfo.h"
27 #include "MeasuredStateOnPlane.h"
28 #include "MeasurementOnPlane.h"
29 #include "StateOnPlane.h"
30 #include "TrackPoint.h"
31 #include "ThinScatterer.h"
32 #include "StateOnPlane.h"
33 #include "Track.h"
34 #include "ICalibrationParametersDerivatives.h"
35 #include "GblPoint.h"
36 #include "GblTrajectory.h"
37 #include "GblFitter.h"
38 #include "TMatrixD.h"
39 #include "TMatrixDSym.h"
40 #include "AbsHMatrix.h"
41 
42 #include <vector>
43 #include <memory>
44 
45 
46 namespace genfit {
47 
48 
52  class GblFitterInfo : public AbsFitterInfo {
53 
54  public:
55 
59  GblFitterInfo();
60 
66  GblFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep);
67 
75  GblFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep, StateOnPlane& referenceState);
76 
84  void reset(unsigned int measurementDim = 2, unsigned int repDim = 5);
85 
99  void setReferenceState(StateOnPlane& referenceState);
107  void setJacobian(TMatrixD jacobian);
108 
117  TMatrixDSym getCovariance(double variance, TVector3 trackDirection, SharedPlanePtr measurementPlane) const;
118 
130 
141 
156  const MeasuredStateOnPlane& getFittedState(bool afterKink = true) const override;
157 
172  MeasurementOnPlane getResidual(unsigned int = 0, bool = false, bool onlyMeasurementErrors = true) const override;
173 
180  MeasurementOnPlane getKink() const;
181 
188  TVectorD getKinks() const;
189 
197 
206  void updateMeasurementAndPlane(const StateOnPlane & sop);
207 
213  StateOnPlane getReferenceState() const {return StateOnPlane(refPrediction_, sharedPlane_, rep_);}
214 
223  void recalculateJacobian(GblFitterInfo* prevFitterInfo);
224 
225  virtual ~GblFitterInfo() {;}
226  virtual GblFitterInfo* clone() const override;
227  bool hasMeasurements() const override {return trackPoint_->hasRawMeasurements();}
228  bool hasReferenceState() const override {return (refPrediction_(0) != 0.);}
229  bool hasForwardPrediction() const override {return hasReferenceState();}
230  bool hasBackwardPrediction() const override {return hasReferenceState();}
231  bool hasForwardUpdate() const override {return hasForwardPrediction();}
232  bool hasBackwardUpdate() const override {return hasBackwardPrediction();}
233  bool hasUpdate(int direction) const override {if (direction < 0) return hasBackwardPrediction(); return hasForwardPrediction();}
234  bool hasPredictionsAndUpdates() const {return (hasForwardPrediction() && hasBackwardPrediction() && hasForwardUpdate() && hasBackwardUpdate());}
235 
236  void deleteForwardInfo() override {;}
237  void deleteBackwardInfo() override {;}
238  void deletePredictions() {
239  deleteBackwardInfo();
240  deleteForwardInfo();
241  }
242  void deleteReferenceInfo() override {;} // Empty because we really do not want to delete reference without a new one
243  void deleteMeasurementInfo() override {;} // We do not keep the measurements
244  virtual void Print(const Option_t* = "") const override;
245  virtual bool checkConsistency(const genfit::PruneFlags* = nullptr) const override;
246 
247  private:
248  TMatrixD jacobian_;
249  TVectorD measResiduals_;
250  TVectorD measResidualErrors_;
251  TVectorD kinkResiduals_;
252  TVectorD kinkResidualErrors_;
253  TVectorD measDownWeights_;
254  TVectorD kinkDownWeights_;
255  TVectorD bwdStateCorrection_;
256  TVectorD fwdStateCorrection_;
257  TMatrixDSym bwdCov_;
258  TMatrixDSym fwdCov_;
259  TVectorD fwdPrediction_;
260  TVectorD bwdPrediction_;
261  TVectorD refPrediction_;
262 
263  TVectorD measurement_;
264  TMatrixDSym measCov_;
265  TMatrixD hMatrix_;
266 
267  mutable std::unique_ptr<MeasuredStateOnPlane> fittedStateBwd_;
268  mutable std::unique_ptr<MeasuredStateOnPlane> fittedStateFwd_;
269 
270  public:
271 
272  ClassDefOverride(GblFitterInfo, 1)
273 
274  };
275 
276 } /* End of namespace genfit */
279 #endif // genfit_GblFitterInfo_h
GblPoint definition.
GblTrajectory definition.
Point on trajectory.
Definition: GblPoint.h:68
GBL trajectory.
Definition: GblTrajectory.h:48
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Definition: AbsFitterInfo.h:42
SharedPlanePtr sharedPlane_
No ownership.
Definition: AbsFitterInfo.h:94
const AbsTrackRep * rep_
No ownership.
Definition: AbsFitterInfo.h:92
const TrackPoint * trackPoint_
Pointer to TrackPoint where the FitterInfo belongs to.
Definition: AbsFitterInfo.h:88
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
Collects information needed and produced by a GblFitter/GBL and is specific to one AbsTrackRep of the...
Definition: GblFitterInfo.h:52
MeasurementOnPlane getKink() const
Get kink (residual) with diagonalized covariance (2D) Covariance may be zero if not yet fitted or no ...
virtual GblFitterInfo * clone() const override
Deep copy ctor for polymorphic class.
const MeasuredStateOnPlane & getFittedState(bool afterKink=true) const override
Get the prediction at this point Always biased in GBL (global fit) There are 2 states,...
TMatrixDSym getCovariance(double variance, TVector3 trackDirection, SharedPlanePtr measurementPlane) const
Get scattering covariance projected into (measurement) plane.
std::unique_ptr< MeasuredStateOnPlane > fittedStateFwd_
cache
MeasurementOnPlane getResidual(unsigned int=0, bool=false, bool onlyMeasurementErrors=true) const override
Get the residual.
TVectorD getKinks() const
Get kink (residual) (2D) = 0 - ( (+)pred - (-)pred )
MeasurementOnPlane getMeasurement() const
Get the measurement on plane from stored measurement data (from last construction/update)
GblFitterInfo()
Constructor for ROOT I/O.
void recalculateJacobian(GblFitterInfo *prevFitterInfo)
Re-extrapolates between prevFitterInfo and this point using forward state to update the Jacobian (if ...
StateOnPlane getReferenceState() const
Returns (copy of) the stored reference 5D state at current plane with internal rep.
void updateFitResults(gbl::GblTrajectory &traj)
Update fitter info from GBL fit results.
void setReferenceState(StateOnPlane &referenceState)
Set the prediction and plane (from measurement if any) You should use the user constructor instead.
void updateMeasurementAndPlane(const StateOnPlane &sop)
SHOULD BE USED ONLY INTERNALY! Update the plane from measurement constructed with state or take plane...
gbl::GblPoint constructGblPoint()
Collect all data and create a GblPoint.
void reset(unsigned int measurementDim=2, unsigned int repDim=5)
(Initial) reset of fitter info
void setJacobian(TMatrixD jacobian)
Set the Jacobian for further GblPoint construction.
#StateOnPlane with additional covariance matrix.
Measured coordinates on a plane.
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:47
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:46
Defines for I/O streams used for error and debug printing.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
Info which information has been pruned from the Track.
Definition: FitStatus.h:47