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;
174 std::vector<int> labels = globals->
labels();
176 if (derivs.GetNcols() > 0 && !labels.empty() && (
unsigned int)derivs.GetNcols() == labels.size()) {
180 if (locals.GetNcols() > 0) {
223 unsigned int imop = 0;
224 double maxWeight = allMeas.at(0)->getWeight();
225 for (
unsigned int i = 0; i < allMeas.size(); i++)
226 if (allMeas.at(i)->getWeight() > maxWeight)
231 measCov_.ResizeTo(allMeas.at(imop)->getCov());
232 measCov_ = allMeas.at(imop)->getCov();
233 hMatrix_.ResizeTo(allMeas.at(imop)->getHMatrix()->getMatrix());
234 hMatrix_ = allMeas.at(imop)->getHMatrix()->getMatrix();
236 setPlane(allMeas.at(imop)->getPlane());
238 for (
unsigned int imeas = 0; imeas < allMeas.size(); imeas++)
239 delete allMeas[imeas];
251 unsigned int label = 0;
254 for (
unsigned int ip = 0; ip < trk->
getNumPoints(); ip++) {
265 throw genfit::Exception(
"GblFitterInfo: fitter info did not found itself in track to update", __LINE__, __FILE__);
267 throw genfit::Exception(
"GblFitterInfo: Deduced point label not valid", __LINE__, __FILE__);
271 unsigned int numMRes = 2;
272 TVectorD mResiduals(2), mMeasErrors(2), mResErrors(2), mDownWeights(2);
273 if (0 != traj.
getMeasResults(label, numMRes, mResiduals, mMeasErrors, mResErrors, mDownWeights))
277 unsigned int numKRes = 2;
278 TVectorD kResiduals(2), kMeasErrors(2), kResErrors(2), kDownWeights(2);
279 if (0 != traj.
getScatResults(label, numKRes, kResiduals, kMeasErrors, kResErrors, kDownWeights))
289 TVectorD bwdUpdate(5 + nLocals), fwdUpdate(5 + nLocals);
290 TMatrixDSym bwdCov(5 + nLocals), fwdCov(5 + nLocals);
293 if (0 != traj.
getResults(label, fwdUpdate, fwdCov))
297 if (0 != traj.
getResults(-1 * label, bwdUpdate, bwdCov))
301 TVectorD _bwdUpdate(5 + nLocals), _fwdUpdate(5 + nLocals);
302 TMatrixDSym _bwdCov(5 + nLocals), _fwdCov(5 + nLocals);
303 _bwdUpdate = bwdUpdate;
304 _fwdUpdate = fwdUpdate;
307 bwdUpdate.ResizeTo(5);
308 fwdUpdate.ResizeTo(5);
309 bwdCov.ResizeTo(TMatrixDSym(5));
310 fwdCov.ResizeTo(TMatrixDSym(5));
311 for (
int i = 0; i < 5; i++) {
312 bwdUpdate(i) = _bwdUpdate(i);
313 fwdUpdate(i) = _fwdUpdate(i);
314 for (
int j = 0; j < 5; j++) {
315 bwdCov(i, j) = _bwdCov(i, j);
316 fwdCov(i, j) = _fwdCov(i, j);
350 if (!prevFitterInfo) {
355 prevFitterInfo =
this;
416 TMatrixDSym localCovariance(2);
417 localCovariance.Zero();
425 localCovariance.ResizeTo(TMatrixDSym(1));
429 localCovariance.ResizeTo(TMatrixDSym(1));
437 if (onlyMeasurementErrors) {
452 TMatrixDSym localCovariance(2);
453 localCovariance.Zero();
465 kinks(0) = -stateDiff(1);
466 kinks(1) = -stateDiff(2);
512 std::cout <<
"=============================================================================================" << std::endl;
513 std::cout <<
" >>> GblFitterInfo " << std::endl;
514 std::cout <<
" ************* " << std::endl;
518 std::cout << std::endl;
520 std::cout <<
"=============================================================================================" << std::endl;
521 std::cout <<
" | PREDICTIONS | REFERENCE | Corrections from last iteration |" << std::endl;
522 std::cout <<
" | (+)prediction | (-)prediction | state | (+)correction | (-) correction |" << std::endl;
523 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
525 for (
int i = 0; i <5; i++) {
526 std::cout << std::left;
545 std::cout <<
"=============================================================================================" << std::endl;
548 std::cout <<
" | Meas. residual | measurement - prediction | Down-weight | Fit+meas Err. |" << std::endl;
549 std::cout <<
" | | | | -diagonaliz. |" << std::endl;
550 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
553 if (residual.GetNoElements()<2) {
554 residual.ResizeTo(2);
564 << std::setw(12) << residual(0) <<
" | " 571 << std::setw(12) << residual(1) <<
" | " 576 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
579 std::cout <<
" | Kink residual | Residual of slope difference | Down-weight | Fit Kink Err. |" << std::endl;
580 std::cout <<
" | -diagonalized | - ( (+)pred - (-)pred ) | | -diagonaliz. |" << std::endl;
581 std::cout <<
"---------------------------------------------------------------------------------------------" << std::endl;
583 std::cout <<
" u' | " 585 << std::setw(12) <<
getKinks()(0) <<
" | " 590 std::cout <<
" v' | " 592 << std::setw(12) <<
getKinks()(1) <<
" | " 596 std::cout <<
"=============================================================================================" << std::endl;
599 std::cout <<
"H Matrix: ";
hMatrix_.Print();
601 std::cout <<
"Measurement covariance: ";
measCov_.Print();
603 std::cout <<
"Jacobian: ";
jacobian_.Print();
604 std::cout <<
"Backward covariance: ";
bwdCov_.Print();
605 std::cout <<
"Forward covariance : ";
fwdCov_.Print();
607 std::cout <<
"=============================================================================================" << std::endl;
bool isValid() const
Retrieve validity of trajectory.
void addLocals(const TMatrixD &aDerivatives)
Add local derivatives to a point.
gbl::GblPoint constructGblPoint()
Collect all data and create a GblPoint.
virtual void getForwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const =0
Get the jacobian and noise matrix of the last extrapolation.
AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization.
bool hasMeasurements() const
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
virtual SharedPlanePtr constructPlane(const StateOnPlane &state) const =0
unsigned int getResults(int aSignedLabel, TVectorD &localPar, TMatrixDSym &localCov) const
Get fit results at point.
const TMatrixD & getMatrix() const
Get the actual matrix representation.
void setMaxLocalFitParams(unsigned maxLocalFitParams)
const MeasuredStateOnPlane & getFittedState(bool afterKink=true) const
Get the prediction at this point Always biased in GBL (global fit) There are 2 states,...
FitStatus for use with GblFitter.
bool hasThinScatterer() const
virtual std::vector< int > labels()=0
Vector of integer labels for calibration/alignment parameters available (must match #columns of deriv...
TMatrixDSym getCovariance(double variance, TVector3 trackDirection, SharedPlanePtr measurementPlane) const
Get scattering covariance projected into (measurement) plane.
unsigned int getMeasResults(unsigned int aLabel, unsigned int &numRes, TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors, TVectorD &aDownWeights)
Get residuals at point from measurement.
void addMeasurement(const TMatrixD &aProjection, const TVectorD &aResiduals, const TVectorD &aPrecision, double minPrecision=0.)
Add a measurement to a point.
Info which information has been pruned from the Track.
virtual double extrapolateToPlane(StateOnPlane &state, const genfit::SharedPlanePtr &plane, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to plane, and returns the extrapolation length and, via reference,...
bool getMaxLocalFitParams()
void addGlobals(const std::vector< int > &aLabels, const TMatrixD &aDerivatives)
Add global derivatives to a point.
MeasurementOnPlane getMeasurement() const
Get the measurement on plane from stored measurement data (from last construction/update)
const SharedPlanePtr & getPlane() const
TVectorD kinkResidualErrors_
virtual std::vector< genfit::MeasurementOnPlane * > constructMeasurementsOnPlane(const StateOnPlane &state) const =0
Collects information needed and produced by a GblFitter/GBL and is specific to one AbsTrackRep of the...
SharedPlanePtr sharedPlane_
No ownership.
TVectorD measResidualErrors_
GblFitterInfo()
Constructor for ROOT I/O.
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateFwd_
cache
virtual bool isEqual(const AbsHMatrix &other) const =0
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateBwd_
const SharedPlanePtr & getPlane() const
StateOnPlane with additional covariance matrix.
virtual TMatrixD derivatives(const genfit::StateOnPlane *sop)=0
Derivatives of residuals (local measurement coordinates) w.r.t. alignment/calibration parameters Matr...
AbsHMatrix implementation for two-dimensional MeasurementOnPlane and RKTrackRep parameterization.
TVectorD kinkDownWeights_
void updateMeasurementAndPlane(const StateOnPlane &sop)
SHOULD BE USED ONLY INTERNALY! Update the plane from measurement constructed with state or take plane...
void reset(unsigned int measurementDim=2, unsigned int repDim=5)
(Initial) reset of fitter info
Abstract base class for a track representation.
virtual bool checkConsistency(const genfit::PruneFlags *=NULL) const
const TVectorD & getState() const
void updateFitResults(gbl::GblTrajectory &traj)
Update fitter info from GBL fit results.
double getDensity() const
unsigned int getScatResults(unsigned int aLabel, unsigned int &numRes, TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors, TVectorD &aDownWeights)
Get (kink) residuals at point from scatterer.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
virtual void Print(const Option_t *="") const
Object containing AbsMeasurement and AbsFitterInfo objects.
FitStatus * getFitStatus(const AbsTrackRep *rep=NULL) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
unsigned int getNumPoints() const
TVectorD getKinks() const
Get kink (residual) (2D) = 0 - ( (+)pred - (-)pred )
TVectorD fwdStateCorrection_
void setReferenceState(StateOnPlane &referenceState)
Set the prediction and plane (from measurement if any) You should use the user constructor instead.
virtual TMatrixD localDerivatives(const genfit::StateOnPlane *)
Derivatives for additional local parameters to be fitted in global calibration algorithms together wi...
void addScatterer(const TVectorD &aResiduals, const TVectorD &aPrecision)
Add a (thin) scatterer to a point.
AbsFitterInfo * getFitterInfo(const AbsTrackRep *rep=NULL) const
Get fitterInfo for rep. Per default, use cardinal rep.
const TrackPoint * trackPoint_
A state with arbitrary dimension defined in a DetPlane.
const TMatrixD & getMatrix() const
Get the actual matrix representation.
const AbsTrackRep * getRep() const
AbsMeasurement * getRawMeasurement(int i=0) const
AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization.
void recalculateJacobian(GblFitterInfo *prevFitterInfo)
Re-extrapolates between prevFitterInfo and this point using forward state to update the Jacobian (if ...
TVectorD measDownWeights_
MeasurementOnPlane getKink() const
Get kink (residual) with diagonalized covariance (2D) Covariance may be zero if not yet fitted or no ...
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
TVectorD bwdStateCorrection_
void setPlane(const SharedPlanePtr &plane)
MeasurementOnPlane getResidual(unsigned int=0, bool=false, bool onlyMeasurementErrors=true) const
Get the residual.
Measured coordinates on a plane.
virtual const AbsHMatrix * constructHMatrix(const AbsTrackRep *) const =0
bool hasRawMeasurements() const
ThinScatterer * getMaterialInfo() const
const TrackPoint * getTrackPoint() const
Abstract base class to establish an interface between physical representation of the detector for ali...
const TMatrixDSym & getCov() const
unsigned int getNumPoints() const
Retrieve number of point from trajectory.
const TMatrixDSym & getCovSeed() const
const AbsTrackRep * rep_
No ownership.
virtual GblFitterInfo * clone() const
Deep copy ctor for polymorphic class.
const MaterialProperties & getMaterial() const
Defines for I/O streams used for error and debug printing.
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
virtual unsigned int getDim() const =0
Get the dimension of the state vector used by the track representation.
void setJacobian(TMatrixD jacobian)
Set the Jacobian for further GblPoint construction.
TrackPoint * getPoint(int id) const