18 unsigned int dim = rep->
getDim();
20 throw new genfit::Exception(
"GblFitterInfo: Representation state is not 5D", __LINE__, __FILE__);
21 TMatrixDSym noise(dim, dim);
31 unsigned int dim = rep->
getDim();
33 throw new genfit::Exception(
"GblFitterInfo: Representation state is not 5D", __LINE__, __FILE__);
34 TMatrixDSym noise(dim, dim);
58 TMatrixDSym zero(repDim);
67 fwdCov_.SetMatrixArray(zero.GetMatrixArray());
68 bwdCov_.SetMatrixArray(zero.GetMatrixArray());
98 double c1 = trackDirection.Dot(measurementPlane->getU());
99 double c2 = trackDirection.Dot(measurementPlane->getV());
101 TMatrixDSym scatCov(2);
102 scatCov(0, 0) = 1. - c2 * c2;
103 scatCov(1, 1) = 1. - c1 * c1;
104 scatCov(0, 1) = c1 * c2;
105 scatCov(1, 0) = c1 * c2;
106 scatCov *= variance * variance / (1. - c1 * c1 - c2 * c2) / (1. - c1 * c1 - c2 * c2) ;
144 TVectorD aResiduals(measurement.
getState());
145 TMatrixDSym aPrecision(measurement.
getCov().Invert());
147 double res = aResiduals(0);
148 double prec = aPrecision(0, 0);
149 aResiduals.ResizeTo(2);
150 aPrecision.ResizeTo(TMatrixDSym(2));
154 aPrecision(0, 0) = prec;
157 double res = aResiduals(0);
158 double prec = aPrecision(0, 0);
159 aResiduals.ResizeTo(2);
160 aPrecision.ResizeTo(TMatrixDSym(2));
164 aPrecision(1, 1) = prec;
173 std::pair<std::vector<int>, TMatrixD> labelsAndMatrix = globals->
globalDerivatives(&sop);
174 std::vector<int> labels = labelsAndMatrix.first;
175 TMatrixD derivs = labelsAndMatrix.second;
177 if (derivs.GetNcols() > 0 && !labels.empty() && (
unsigned int)derivs.GetNcols() == labels.size()) {
181 if (locals.GetNcols() > 0) {
203 std::vector<MeasurementOnPlane*> allMeas =
trackPoint_->getRawMeasurement(0)->constructMeasurementsOnPlane(sop);
224 unsigned int imop = 0;
225 double maxWeight = allMeas.at(0)->getWeight();
226 for (
unsigned int i = 0; i < allMeas.size(); i++)
227 if (allMeas.at(i)->getWeight() > maxWeight)
232 measCov_.ResizeTo(allMeas.at(imop)->getCov());
233 measCov_ = allMeas.at(imop)->getCov();
234 hMatrix_.ResizeTo(allMeas.at(imop)->getHMatrix()->getMatrix());
235 hMatrix_ = allMeas.at(imop)->getHMatrix()->getMatrix();
237 setPlane(allMeas.at(imop)->getPlane());
239 for (
unsigned int imeas = 0; imeas < allMeas.size(); imeas++)
240 delete allMeas[imeas];
252 unsigned int label = 0;
255 for (
unsigned int ip = 0; ip < trk->
getNumPoints(); ip++) {
266 throw genfit::Exception(
"GblFitterInfo: fitter info did not found itself in track to update", __LINE__, __FILE__);
268 throw genfit::Exception(
"GblFitterInfo: Deduced point label not valid", __LINE__, __FILE__);
272 unsigned int numMRes = 2;
273 TVectorD mResiduals(2), mMeasErrors(2), mResErrors(2), mDownWeights(2);
274 if (0 != traj.
getMeasResults(label, numMRes, mResiduals, mMeasErrors, mResErrors, mDownWeights))
278 unsigned int numKRes = 2;
279 TVectorD kResiduals(2), kMeasErrors(2), kResErrors(2), kDownWeights(2);
280 if (0 != traj.
getScatResults(label, numKRes, kResiduals, kMeasErrors, kResErrors, kDownWeights))
290 TVectorD bwdUpdate(5 + nLocals), fwdUpdate(5 + nLocals);
291 TMatrixDSym bwdCov(5 + nLocals), fwdCov(5 + nLocals);
294 if (0 != traj.
getResults(label, fwdUpdate, fwdCov))
298 if (0 != traj.
getResults(-1 * label, bwdUpdate, bwdCov))
302 TVectorD _bwdUpdate(5 + nLocals), _fwdUpdate(5 + nLocals);
303 TMatrixDSym _bwdCov(5 + nLocals), _fwdCov(5 + nLocals);
304 _bwdUpdate = bwdUpdate;
305 _fwdUpdate = fwdUpdate;
308 bwdUpdate.ResizeTo(5);
309 fwdUpdate.ResizeTo(5);
310 bwdCov.ResizeTo(TMatrixDSym(5));
311 fwdCov.ResizeTo(TMatrixDSym(5));
312 for (
int i = 0; i < 5; i++) {
313 bwdUpdate(i) = _bwdUpdate(i);
314 fwdUpdate(i) = _fwdUpdate(i);
315 for (
int j = 0; j < 5; j++) {
316 bwdCov(i, j) = _bwdCov(i, j);
317 fwdCov(i, j) = _fwdCov(i, j);
351 if (!prevFitterInfo) {
356 prevFitterInfo =
this;
374 rep_->extrapolateToPlane(prevState, newPlane,
false,
true);
418 TMatrixDSym localCovariance(2);
419 localCovariance.Zero();
427 localCovariance.ResizeTo(TMatrixDSym(1));
431 localCovariance.ResizeTo(TMatrixDSym(1));
439 if (onlyMeasurementErrors) {
454 TMatrixDSym localCovariance(2);
455 localCovariance.Zero();
467 kinks(0) = -stateDiff(1);
468 kinks(1) = -stateDiff(2);
514 std::cout <<
"=============================================================================================" << std::endl;
515 std::cout <<
" >>> GblFitterInfo " << std::endl;
516 std::cout <<
" ************* " << std::endl;
520 std::cout << std::endl;
522 std::cout <<
"=============================================================================================" << std::endl;
523 std::cout <<
" | PREDICTIONS | REFERENCE | Corrections from last iteration |" << std::endl;
524 std::cout <<
" | (+)prediction | (-)prediction | state | (+)correction | (-) correction |" << std::endl;
525 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
527 for (
int i = 0; i <5; i++) {
528 std::cout << std::left;
547 std::cout <<
"=============================================================================================" << std::endl;
550 std::cout <<
" | Meas. residual | measurement - prediction | Down-weight | Fit+meas Err. |" << std::endl;
551 std::cout <<
" | | | | -diagonaliz. |" << std::endl;
552 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
555 if (residual.GetNoElements()<2) {
556 residual.ResizeTo(2);
566 << std::setw(12) << residual(0) <<
" | "
573 << std::setw(12) << residual(1) <<
" | "
578 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
581 std::cout <<
" | Kink residual | Residual of slope difference | Down-weight | Fit Kink Err. |" << std::endl;
582 std::cout <<
" | -diagonalized | - ( (+)pred - (-)pred ) | | -diagonaliz. |" << std::endl;
583 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
585 std::cout <<
" u' | "
587 << std::setw(12) <<
getKinks()(0) <<
" | "
592 std::cout <<
" v' | "
594 << std::setw(12) <<
getKinks()(1) <<
" | "
598 std::cout <<
"=============================================================================================" << std::endl;
601 std::cout <<
"H Matrix: ";
hMatrix_.Print();
603 std::cout <<
"Measurement covariance: ";
measCov_.Print();
605 std::cout <<
"Jacobian: ";
jacobian_.Print();
606 std::cout <<
"Backward covariance: ";
bwdCov_.Print();
607 std::cout <<
"Forward covariance : ";
fwdCov_.Print();
609 std::cout <<
"=============================================================================================" << std::endl;
void addMeasurement(const TMatrixD &aProjection, const TVectorD &aResiduals, const TVectorD &aPrecision, double minPrecision=0.)
Add a measurement to a point.
void addScatterer(const TVectorD &aResiduals, const TVectorD &aPrecision)
Add a (thin) scatterer to a point.
void addLocals(const TMatrixD &aDerivatives)
Add local derivatives to a point.
void addGlobals(const std::vector< int > &aLabels, const TMatrixD &aDerivatives)
Add global derivatives to a point.
unsigned int getMeasResults(unsigned int aLabel, unsigned int &numRes, TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors, TVectorD &aDownWeights)
Get residuals from fit at point for measurement.
unsigned int getResults(int aSignedLabel, TVectorD &localPar, TMatrixDSym &localCov) const
Get fit results at point.
bool isValid() const
Retrieve validity of trajectory.
unsigned int getScatResults(unsigned int aLabel, unsigned int &numRes, TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors, TVectorD &aDownWeights)
Get (kink) residuals from fit at point for scatterer.
unsigned int getNumPoints() const
Retrieve number of point from trajectory.
const AbsTrackRep * getRep() const
const TrackPoint * trackPoint_
const SharedPlanePtr & getPlane() const
SharedPlanePtr sharedPlane_
No ownership.
const AbsTrackRep * rep_
No ownership.
void setPlane(const SharedPlanePtr &plane)
const TrackPoint * getTrackPoint() const
Abstract base class for a track representation.
virtual void getForwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const =0
Get the jacobian and noise matrix of the last extrapolation.
virtual unsigned int getDim() const =0
Get the dimension of the state vector used by the track representation.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
FitStatus for use with GblFitter.
void setMaxLocalFitParams(unsigned maxLocalFitParams)
bool getMaxLocalFitParams()
TVectorD kinkResidualErrors_
TMatrixDSym getCovariance(double variance, TVector3 trackDirection, SharedPlanePtr measurementPlane) const
Get scattering covariance projected into (measurement) plane.
TVectorD getKinks() const
Get kink (residual) (2D) = 0 - ( (+)pred - (-)pred )
virtual void Print(const Option_t *="") const override
virtual GblFitterInfo * clone() const override
Deep copy ctor for polymorphic class.
GblFitterInfo()
Constructor for ROOT I/O.
void updateFitResults(gbl::GblTrajectory &traj)
Update fitter info from GBL fit results.
void recalculateJacobian(GblFitterInfo *prevFitterInfo)
Re-extrapolates between prevFitterInfo and this point using forward state to update the Jacobian (if ...
void reset(unsigned int measurementDim=2, unsigned int repDim=5)
(Initial) reset of fitter info
void updateMeasurementAndPlane(const StateOnPlane &sop)
SHOULD BE USED ONLY INTERNALY! Update the plane from measurement constructed with state or take plane...
MeasurementOnPlane getMeasurement() const
Get the measurement on plane from stored measurement data (from last construction/update)
TVectorD fwdStateCorrection_
std::unique_ptr< MeasuredStateOnPlane > fittedStateFwd_
cache
const MeasuredStateOnPlane & getFittedState(bool afterKink=true) const override
Get the prediction at this point Always biased in GBL (global fit) There are 2 states,...
TVectorD measResidualErrors_
TVectorD kinkDownWeights_
void setJacobian(TMatrixD jacobian)
Set the Jacobian for further GblPoint construction.
gbl::GblPoint constructGblPoint()
Collect all data and create a GblPoint.
std::unique_ptr< MeasuredStateOnPlane > fittedStateBwd_
void setReferenceState(StateOnPlane &referenceState)
Set the prediction and plane (from measurement if any) You should use the user constructor instead.
virtual bool checkConsistency(const genfit::PruneFlags *=nullptr) const override
TVectorD measDownWeights_
bool hasMeasurements() const override
TVectorD bwdStateCorrection_
MeasurementOnPlane getKink() const
Get kink (residual) with diagonalized covariance (2D) Covariance may be zero if not yet fitted or no ...
MeasurementOnPlane getResidual(unsigned int=0, bool=false, bool onlyMeasurementErrors=true) const override
Get the residual.
AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization.
AbsHMatrix implementation for two-dimensional MeasurementOnPlane and RKTrackRep parameterization.
const TMatrixD & getMatrix() const override
Get the actual matrix representation.
AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization.
Abstract base class to establish an interface between physical representation of the detector for ali...
virtual TMatrixD localDerivatives(const genfit::StateOnPlane *)
Derivatives for additional local parameters to be fitted in global calibration algorithms together wi...
virtual std::pair< std::vector< int >, TMatrixD > globalDerivatives(const genfit::StateOnPlane *sop)
Labels and derivatives of residuals (local measurement coordinates) w.r.t. alignment/calibration para...
StateOnPlane with additional covariance matrix.
const TMatrixDSym & getCov() const
Measured coordinates on a plane.
A state with arbitrary dimension defined in a DetPlane.
const TVectorD & getState() const
const TVectorD & getAuxInfo() const
const SharedPlanePtr & getPlane() const
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
TrackPoint * getPoint(int id) const
unsigned int getNumPoints() const
Object containing AbsMeasurement and AbsFitterInfo objects.
AbsFitterInfo * getFitterInfo(const AbsTrackRep *rep=nullptr) const
Get fitterInfo for rep. Per default, use cardinal rep.
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.