Belle II Software  release-05-01-25
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
genfit::TrackPoint
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:46
genfit::SharedPlanePtr
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
Definition: SharedPlanePtr.h:40
genfit::AbsFitterInfo::sharedPlane_
SharedPlanePtr sharedPlane_
No ownership.
Definition: AbsFitterInfo.h:94
genfit::GblFitterInfo::getResidual
MeasurementOnPlane getResidual(unsigned int=0, bool=false, bool onlyMeasurementErrors=true) const override
Get the residual.
Definition: GblFitterInfo.cc:416
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
genfit::PruneFlags
Info which information has been pruned from the Track.
Definition: FitStatus.h:47
genfit::AbsFitterInfo
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Definition: AbsFitterInfo.h:42
genfit::StateOnPlane
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:47
genfit
Defines for I/O streams used for error and debug printing.
Definition: AlignablePXDRecoHit.h:19
genfit::AbsTrackRep
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
genfit::GblFitterInfo::GblFitterInfo
GblFitterInfo()
Constructor for ROOT I/O.
Definition: GblFitterInfo.cc:10
genfit::GblFitterInfo::getFittedState
const MeasuredStateOnPlane & getFittedState(bool afterKink=true) const override
Get the prediction at this point Always biased in GBL (global fit) There are 2 states,...
Definition: GblFitterInfo.cc:398
gbl::GblTrajectory
GBL trajectory.
Definition: GblTrajectory.h:48
genfit::GblFitterInfo::getKink
MeasurementOnPlane getKink() const
Get kink (residual) with diagonalized covariance (2D) Covariance may be zero if not yet fitted or no ...
Definition: GblFitterInfo.cc:453
genfit::GblFitterInfo::updateFitResults
void updateFitResults(gbl::GblTrajectory &traj)
Update fitter info from GBL fit results.
Definition: GblFitterInfo.cc:246
genfit::GblFitterInfo::setJacobian
void setJacobian(TMatrixD jacobian)
Set the Jacobian for further GblPoint construction.
Definition: GblFitterInfo.cc:91
genfit::GblFitterInfo::reset
void reset(unsigned int measurementDim=2, unsigned int repDim=5)
(Initial) reset of fitter info
Definition: GblFitterInfo.cc:41
genfit::GblFitterInfo::updateMeasurementAndPlane
void updateMeasurementAndPlane(const StateOnPlane &sop)
SHOULD BE USED ONLY INTERNALY! Update the plane from measurement constructed with state or take plane...
Definition: GblFitterInfo.cc:195
genfit::GblFitterInfo::getCovariance
TMatrixDSym getCovariance(double variance, TVector3 trackDirection, SharedPlanePtr measurementPlane) const
Get scattering covariance projected into (measurement) plane.
Definition: GblFitterInfo.cc:96
genfit::GblFitterInfo::recalculateJacobian
void recalculateJacobian(GblFitterInfo *prevFitterInfo)
Re-extrapolates between prevFitterInfo and this point using forward state to update the Jacobian (if ...
Definition: GblFitterInfo.cc:346
genfit::GblFitterInfo::getReferenceState
StateOnPlane getReferenceState() const
Returns (copy of) the stored reference 5D state at current plane with internal rep.
Definition: GblFitterInfo.h:213
GblPoint.h
genfit::GblFitterInfo
Collects information needed and produced by a GblFitter/GBL and is specific to one AbsTrackRep of the...
Definition: GblFitterInfo.h:52
genfit::GblFitterInfo::setReferenceState
void setReferenceState(StateOnPlane &referenceState)
Set the prediction and plane (from measurement if any) You should use the user constructor instead.
Definition: GblFitterInfo.cc:78
genfit::GblFitterInfo::clone
virtual GblFitterInfo * clone() const override
Deep copy ctor for polymorphic class.
Definition: GblFitterInfo.cc:482
genfit::GblFitterInfo::getMeasurement
MeasurementOnPlane getMeasurement() const
Get the measurement on plane from stored measurement data (from last construction/update)
Definition: GblFitterInfo.cc:473
genfit::GblFitterInfo::constructGblPoint
gbl::GblPoint constructGblPoint()
Collect all data and create a GblPoint.
Definition: GblFitterInfo.cc:111
genfit::GblFitterInfo::getKinks
TVectorD getKinks() const
Get kink (residual) (2D) = 0 - ( (+)pred - (-)pred )
Definition: GblFitterInfo.cc:462
genfit::GblFitterInfo::fittedStateFwd_
std::unique_ptr< MeasuredStateOnPlane > fittedStateFwd_
cache
Definition: GblFitterInfo.h:268
genfit::AbsFitterInfo::trackPoint_
const TrackPoint * trackPoint_
Pointer to TrackPoint where the FitterInfo belongs to.
Definition: AbsFitterInfo.h:88
GblTrajectory.h
gbl::GblPoint
Point on trajectory.
Definition: GblPoint.h:68
genfit::MeasurementOnPlane
Measured coordinates on a plane.
Definition: MeasurementOnPlane.h:46
genfit::AbsFitterInfo::rep_
const AbsTrackRep * rep_
No ownership.
Definition: AbsFitterInfo.h:92