SND@LHC Software
Loading...
Searching...
No Matches
KalmanFitterRefTrack.cc
Go to the documentation of this file.
1/* Copyright 2013, Ludwig-Maximilians Universität München, Technische Universität München
2 Authors: Tobias Schlüter & 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*/
19
20/* This implements the Kalman fitter with reference track. */
21
22#include "Tools.h"
23#include "Track.h"
24#include "TrackPoint.h"
25#include "Exception.h"
26
28#include "KalmanFitterInfo.h"
29#include "KalmanFitStatus.h"
30
31#include "boost/scoped_ptr.hpp"
32
33#include <Math/ProbFunc.h>
34
35
36using namespace genfit;
37
38
39TrackPoint* KalmanFitterRefTrack::fitTrack(Track* tr, const AbsTrackRep* rep, double& chi2, double& ndf, int direction)
40{
41
42 //if (!isTrackPrepared(tr, rep)) {
43 // Exception exc("KalmanFitterRefTrack::fitTrack ==> track is not properly prepared.",__LINE__,__FILE__);
44 // throw exc;
45 //}
46
47 unsigned int dim = rep->getDim();
48
49 chi2 = 0;
50 ndf = -1. * dim;
51 KalmanFitterInfo* prevFi(NULL);
52
53 TrackPoint* retVal(NULL);
54
55 if (debugLvl_ > 0) {
56 std::cout << tr->getNumPoints() << " TrackPoints with measurements in this track." << std::endl;
57 }
58
59 bool alreadyFitted(!refitAll_);
60
61 p_.ResizeTo(dim);
62 C_.ResizeTo(dim, dim);
63
64 for (size_t i = 0; i < tr->getNumPointsWithMeasurement(); ++i) {
65 TrackPoint *tp = 0;
66 assert(direction == +1 || direction == -1);
67 if (direction == +1)
68 tp = tr->getPointWithMeasurement(i);
69 else if (direction == -1)
70 tp = tr->getPointWithMeasurement(-i-1);
71
72 if (! tp->hasFitterInfo(rep)) {
73 if (debugLvl_ > 0) {
74 std::cout << "TrackPoint " << i << " has no fitterInfo -> continue. \n";
75 }
76 continue;
77 }
78
79 KalmanFitterInfo* fi = static_cast<KalmanFitterInfo*>(tp->getFitterInfo(rep));
80
81 if (alreadyFitted && fi->hasUpdate(direction)) {
82 if (debugLvl_ > 0) {
83 std::cout << "TrackPoint " << i << " is already fitted -> continue. \n";
84 }
85 prevFi = fi;
86 chi2 += fi->getUpdate(direction)->getChiSquareIncrement();
87 ndf += fi->getUpdate(direction)->getNdf();
88 continue;
89 }
90
91 alreadyFitted = false;
92
93 if (debugLvl_ > 0) {
94 std::cout << " process TrackPoint nr. " << i << "\n";
95 }
96 processTrackPoint(fi, prevFi, tp, chi2, ndf, direction);
97 retVal = tp;
98
99 prevFi = fi;
100 }
101
102 return retVal;
103}
104
105
106void KalmanFitterRefTrack::processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool resortHits)
107{
108
109 if (tr->getFitStatus(rep) != NULL && tr->getFitStatus(rep)->isTrackPruned()) {
110 Exception exc("KalmanFitterRefTrack::processTrack: Cannot process pruned track!", __LINE__,__FILE__);
111 throw exc;
112 }
113
114 double oldChi2FW = 1e6;
115 double oldPvalFW = 0.;
116 double oldChi2BW = 1e6;
117 double oldPvalBW = 0.;
118 double chi2FW(0), ndfFW(0);
119 double chi2BW(0), ndfBW(0);
120 int nFailedHits(0);
121
122 KalmanFitStatus* status = new KalmanFitStatus();
123 tr->setFitStatus(status, rep);
124
125 status->setIsFittedWithReferenceTrack(true);
126
127 unsigned int nIt=0;
128 for (;;) {
129
130 try {
131 if (debugLvl_ > 0) {
132 std::cout << " KalmanFitterRefTrack::processTrack with rep " << rep
133 << " (id == " << tr->getIdForRep(rep) << ")"<< ", iteration nr. " << nIt << "\n";
134 }
135
136 // prepare
137 if (!prepareTrack(tr, rep, resortHits, nFailedHits) && !refitAll_) {
138 if (debugLvl_ > 0) {
139 std::cout << "KalmanFitterRefTrack::processTrack. Track preparation did not change anything!\n";
140 }
141
142 status->setIsFitted();
143
144 status->setIsFitConvergedPartially();
145 if (nFailedHits == 0)
146 status->setIsFitConvergedFully();
147 else
148 status->setIsFitConvergedFully(false);
149
150 status->setNFailedPoints(nFailedHits);
151
152 status->setHasTrackChanged(false);
153 status->setCharge(rep->getCharge(*static_cast<KalmanFitterInfo*>(tr->getPointWithMeasurement(0)->getFitterInfo(rep))->getBackwardUpdate()));
154 status->setNumIterations(nIt);
155 status->setForwardChi2(chi2FW);
156 status->setBackwardChi2(chi2BW);
157 status->setForwardNdf(std::max(0., ndfFW));
158 status->setBackwardNdf(std::max(0., ndfBW));
159 if (debugLvl_ > 0) {
160 status->Print();
161 }
162 return;
163 }
164
165 if (debugLvl_ > 0) {
166 std::cout << "KalmanFitterRefTrack::processTrack. Prepared Track:";
167 tr->Print("C");
168 //tr->Print();
169 }
170
171 // resort
172 if (resortHits) {
173 if (tr->sort()) {
174 if (debugLvl_ > 0) {
175 std::cout << "KalmanFitterRefTrack::processTrack. Resorted Track:";
176 tr->Print("C");
177 }
178 prepareTrack(tr, rep, resortHits, nFailedHits);// re-prepare if order of hits has changed!
179 status->setNFailedPoints(nFailedHits);
180 if (debugLvl_ > 0) {
181 std::cout << "KalmanFitterRefTrack::processTrack. Prepared resorted Track:";
182 tr->Print("C");
183 }
184 }
185 }
186
187
188 // fit forward
189 if (debugLvl_ > 0)
190 std::cout << "KalmanFitterRefTrack::forward fit\n";
191 TrackPoint* lastProcessedPoint = fitTrack(tr, rep, chi2FW, ndfFW, +1);
192
193 // fit backward
194 if (debugLvl_ > 0) {
195 std::cout << "KalmanFitterRefTrack::backward fit\n";
196 }
197
198 // backward fit must not necessarily start at last hit, set prediction = forward update and blow up cov
199 if (lastProcessedPoint != NULL) {
200 KalmanFitterInfo* lastInfo = static_cast<KalmanFitterInfo*>(lastProcessedPoint->getFitterInfo(rep));
201 if (! lastInfo->hasBackwardPrediction()) {
202 lastInfo->setBackwardPrediction(new MeasuredStateOnPlane(*(lastInfo->getForwardUpdate())));
203 lastInfo->getBackwardPrediction()->blowUpCov(blowUpFactor_); // blow up cov
204 if (debugLvl_ > 0) {
205 std::cout << "blow up cov for backward fit at TrackPoint " << lastProcessedPoint << "\n";
206 }
207 }
208 }
209
210 fitTrack(tr, rep, chi2BW, ndfBW, -1);
211
212 ++nIt;
213
214
215 double PvalBW = ROOT::Math::chisquared_cdf_c(chi2BW, ndfBW);
216 double PvalFW = (debugLvl_ > 0) ? ROOT::Math::chisquared_cdf_c(chi2FW, ndfFW) : 0; // Don't calculate if not debugging as this function potentially takes a lot of time.
217
218 if (debugLvl_ > 0) {
219 std::cout << "KalmanFitterRefTrack::Track after fit:"; tr->Print("C");
220
221 std::cout << "old chi2s: " << oldChi2BW << ", " << oldChi2FW
222 << " new chi2s: " << chi2BW << ", " << chi2FW << std::endl;
223 std::cout << "old pVals: " << oldPvalBW << ", " << oldPvalFW
224 << " new pVals: " << PvalBW << ", " << PvalFW << std::endl;
225 }
226
227 // See if p-value only changed little. If the initial
228 // parameters are very far off, initial chi^2 and the chi^2
229 // after the first iteration will be both very close to zero, so
230 // we need to have at least two iterations here. Convergence
231 // doesn't make much sense before running twice anyway.
232 bool converged(false);
233 bool finished(false);
234 if (nIt >= minIterations_ && fabs(oldPvalBW - PvalBW) < deltaPval_) {
235 // if pVal ~ 0, check if chi2 has changed significantly
236 if (fabs(1 - fabs(oldChi2BW / chi2BW)) > relChi2Change_) {
237 finished = false;
238 }
239 else {
240 finished = true;
241 converged = true;
242 }
243
244 if (PvalBW == 0.)
245 converged = false;
246 }
247
248 if (finished) {
249 if (debugLvl_ > 0) {
250 std::cout << "Fit is finished! ";
251 if(converged)
252 std::cout << "Fit is converged! ";
253 std::cout << "\n";
254 }
255
256 if (nFailedHits == 0)
257 status->setIsFitConvergedFully(converged);
258 else
259 status->setIsFitConvergedFully(false);
260
261 status->setIsFitConvergedPartially(converged);
262 status->setNFailedPoints(nFailedHits);
263
264 break;
265 }
266 else {
267 oldPvalBW = PvalBW;
268 oldChi2BW = chi2BW;
269 if (debugLvl_ > 0) {
270 oldPvalFW = PvalFW;
271 oldChi2FW = chi2FW;
272 }
273 }
274
275 if (nIt >= maxIterations_) {
276 if (debugLvl_ > 0) {
277 std::cout << "KalmanFitterRefTrack::number of max iterations reached!\n";
278 }
279 break;
280 }
281 }
282 catch(Exception& e) {
283 std::cerr << e.what();
284 status->setIsFitted(false);
285 status->setIsFitConvergedFully(false);
286 status->setIsFitConvergedPartially(false);
287 status->setNFailedPoints(nFailedHits);
288 if (debugLvl_ > 0) {
289 status->Print();
290 }
291 return;
292 }
293
294 }
295
296
298
299 double charge(0);
300 if (tp != NULL) {
301 if (static_cast<KalmanFitterInfo*>(tp->getFitterInfo(rep))->hasBackwardUpdate())
302 charge = static_cast<KalmanFitterInfo*>(tp->getFitterInfo(rep))->getBackwardUpdate()->getCharge();
303 }
304 status->setCharge(charge);
305
306 if (tp != NULL) {
307 status->setIsFitted();
308 }
309 else { // none of the trackPoints has a fitterInfo
310 status->setIsFitted(false);
311 status->setIsFitConvergedFully(false);
312 status->setIsFitConvergedPartially(false);
313 status->setNFailedPoints(nFailedHits);
314 }
315
316 status->setHasTrackChanged(false);
317 status->setNumIterations(nIt);
318 status->setForwardChi2(chi2FW);
319 status->setBackwardChi2(chi2BW);
320 status->setForwardNdf(ndfFW);
321 status->setBackwardNdf(ndfBW);
322
323 if (debugLvl_ > 0) {
324 status->Print();
325 }
326}
327
328
329bool KalmanFitterRefTrack::prepareTrack(Track* tr, const AbsTrackRep* rep, bool setSortingParams, int& nFailedHits) {
330
331 if (debugLvl_ > 0) {
332 std::cout << "KalmanFitterRefTrack::prepareTrack \n";
333 }
334
335 int notChangedUntil, notChangedFrom;
336
337 // remove outdated reference states
338 bool changedSmthg = removeOutdated(tr, rep, notChangedUntil, notChangedFrom);
339
340
341 // declare matrices
342 FTransportMatrix_.ResizeTo(rep->getDim(), rep->getDim());
343 FTransportMatrix_.UnitMatrix();
344 BTransportMatrix_.ResizeTo(rep->getDim(), rep->getDim());
345
346 FNoiseMatrix_.ResizeTo(rep->getDim(), rep->getDim());
347 BNoiseMatrix_.ResizeTo(rep->getDim(), rep->getDim());
348
349 forwardDeltaState_.ResizeTo(rep->getDim());
350 backwardDeltaState_.ResizeTo(rep->getDim());
351
352 // declare stuff
353 KalmanFitterInfo* prevFitterInfo(NULL);
354 boost::scoped_ptr<MeasuredStateOnPlane> firstBackwardUpdate;
355
356 ReferenceStateOnPlane* referenceState(NULL);
357 ReferenceStateOnPlane* prevReferenceState(NULL);
358
359 const MeasuredStateOnPlane* smoothedState(NULL);
360 const MeasuredStateOnPlane* prevSmoothedState(NULL);
361
362 double trackLen(0);
363
364 bool newRefState(false); // has the current Point a new reference state?
365 bool prevNewRefState(false); // has the last successfull point a new reference state?
366
367 unsigned int nPoints = tr->getNumPoints();
368
369
370 unsigned int i=0;
371 nFailedHits = 0;
372
373
374 // loop over TrackPoints
375 for (; i<nPoints; ++i) {
376
377 try {
378
379 if (debugLvl_ > 0) {
380 std::cout << "Prepare TrackPoint " << i << "\n";
381 }
382
383 TrackPoint* trackPoint = tr->getPoint(i);
384
385 // check if we have a measurement
386 if (!trackPoint->hasRawMeasurements()) {
387 if (debugLvl_ > 0) {
388 std::cout << "TrackPoint has no rawMeasurements -> continue \n";
389 }
390 continue;
391 }
392
393 newRefState = false;
394
395
396 // get fitterInfo
397 KalmanFitterInfo* fitterInfo(NULL);
398 if (trackPoint->hasFitterInfo(rep))
399 fitterInfo = dynamic_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(rep));
400
401 // create new fitter info if none available
402 if (fitterInfo == NULL) {
403 if (debugLvl_ > 0) {
404 std::cout << "create new KalmanFitterInfo \n";
405 }
406 changedSmthg = true;
407 fitterInfo = new KalmanFitterInfo(trackPoint, rep);
408 trackPoint->setFitterInfo(fitterInfo);
409 }
410 else {
411 if (debugLvl_ > 0) {
412 std::cout << "TrackPoint " << i << " (" << trackPoint << ") already has KalmanFitterInfo \n";
413 }
414
415 if (prevFitterInfo == NULL) {
416 if (fitterInfo->hasBackwardUpdate())
417 firstBackwardUpdate.reset(new MeasuredStateOnPlane(*(fitterInfo->getBackwardUpdate())));
418 }
419 }
420
421 // get smoothedState if available
422 if (fitterInfo->hasPredictionsAndUpdates()) {
423 smoothedState = &(fitterInfo->getFittedState(true));
424 if (debugLvl_ > 0) {
425 std::cout << "got smoothed state \n";
426 //smoothedState->Print();
427 }
428 }
429 else {
430 smoothedState = NULL;
431 }
432
433
434 if (fitterInfo->hasReferenceState()) {
435
436 referenceState = fitterInfo->getReferenceState();
437
438
439 if (!prevNewRefState) {
440 if (debugLvl_ > 0) {
441 std::cout << "TrackPoint already has referenceState and previous referenceState has not been altered -> continue \n";
442 }
443 trackLen += referenceState->getForwardSegmentLength();
444 if (setSortingParams)
445 trackPoint->setSortingParameter(trackLen);
446
447 prevNewRefState = newRefState;
448 prevReferenceState = referenceState;
449 prevFitterInfo = fitterInfo;
450 prevSmoothedState = smoothedState;
451
452 continue;
453 }
454
455
456 if (prevReferenceState == NULL) {
457 if (debugLvl_ > 0) {
458 std::cout << "TrackPoint already has referenceState but previous referenceState is NULL -> reset forward info of current reference state and continue \n";
459 }
460
461 referenceState->resetForward();
462
463 if (setSortingParams)
464 trackPoint->setSortingParameter(trackLen);
465
466 prevNewRefState = newRefState;
467 prevReferenceState = referenceState;
468 prevFitterInfo = fitterInfo;
469 prevSmoothedState = smoothedState;
470
471 continue;
472 }
473
474 // previous refState has been altered ->need to update transport matrices
475 if (debugLvl_ > 0) {
476 std::cout << "TrackPoint already has referenceState but previous referenceState has been altered -> update transport matrices and continue \n";
477 }
478 StateOnPlane stateToExtrapolate(*prevReferenceState);
479
480 // make sure track is consistent if extrapolation fails
481 prevReferenceState->resetBackward();
482 referenceState->resetForward();
483
484 double segmentLen = rep->extrapolateToPlane(stateToExtrapolate, fitterInfo->getReferenceState()->getPlane(), false, true);
485 if (debugLvl_ > 0) {
486 std::cout << "extrapolated stateToExtrapolate (prevReferenceState) by " << segmentLen << " cm.\n";
487 }
488 trackLen += segmentLen;
489
490 if (segmentLen == 0) {
491 FTransportMatrix_.UnitMatrix();
492 FNoiseMatrix_.Zero();
493 forwardDeltaState_.Zero();
494 BTransportMatrix_.UnitMatrix();
495 BNoiseMatrix_.Zero();
496 backwardDeltaState_.Zero();
497 }
498 else {
501 }
502
503 prevReferenceState->setBackwardSegmentLength(-segmentLen);
505 prevReferenceState->setBackwardNoiseMatrix(BNoiseMatrix_);
506 prevReferenceState->setBackwardDeltaState(backwardDeltaState_);
507
508 referenceState->setForwardSegmentLength(segmentLen);
510 referenceState->setForwardNoiseMatrix(FNoiseMatrix_);
512
513 newRefState = true;
514
515 if (setSortingParams)
516 trackPoint->setSortingParameter(trackLen);
517
518 prevNewRefState = newRefState;
519 prevReferenceState = referenceState;
520 prevFitterInfo = fitterInfo;
521 prevSmoothedState = smoothedState;
522
523 continue;
524 }
525
526
527 // Construct plane
528 SharedPlanePtr plane;
529 if (smoothedState != NULL) {
530 if (debugLvl_ > 0)
531 std::cout << "construct plane with smoothedState \n";
532 plane = trackPoint->getRawMeasurement(0)->constructPlane(*smoothedState);
533 }
534 else if (prevSmoothedState != NULL) {
535 if (debugLvl_ > 0) {
536 std::cout << "construct plane with prevSmoothedState \n";
537 //prevSmoothedState->Print();
538 }
539 plane = trackPoint->getRawMeasurement(0)->constructPlane(*prevSmoothedState);
540 }
541 else if (prevReferenceState != NULL) {
542 if (debugLvl_ > 0) {
543 std::cout << "construct plane with prevReferenceState \n";
544 }
545 plane = trackPoint->getRawMeasurement(0)->constructPlane(*prevReferenceState);
546 }
547 else if (rep != tr->getCardinalRep() &&
548 trackPoint->hasFitterInfo(tr->getCardinalRep()) &&
549 dynamic_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(tr->getCardinalRep())) != NULL &&
550 static_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(tr->getCardinalRep()))->hasPredictionsAndUpdates() ) {
551 if (debugLvl_ > 0) {
552 std::cout << "construct plane with smoothed state of cardinal rep fit \n";
553 }
554 TVector3 pos, mom;
555 const MeasuredStateOnPlane& fittedState = static_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(tr->getCardinalRep()))->getFittedState(true);
556 tr->getCardinalRep()->getPosMom(fittedState, pos, mom);
557 StateOnPlane cardinalState(rep);
558 rep->setPosMom(cardinalState, pos, mom);
559 rep->setQop(cardinalState, tr->getCardinalRep()->getQop(fittedState));
560 plane = trackPoint->getRawMeasurement(0)->constructPlane(cardinalState);
561 }
562 else {
563 if (debugLvl_ > 0) {
564 std::cout << "construct plane with state from track \n";
565 }
566 StateOnPlane seedFromTrack(rep);
567 rep->setPosMom(seedFromTrack, tr->getStateSeed()); // also fills auxInfo
568 plane = trackPoint->getRawMeasurement(0)->constructPlane(seedFromTrack);
569 }
570
571 if (plane.get() == NULL) {
572 Exception exc("KalmanFitterRefTrack::prepareTrack ==> construced plane is NULL!",__LINE__,__FILE__);
573 exc.setFatal();
574 throw exc;
575 }
576
577
578
579 // do extrapolation and set reference state infos
580 boost::scoped_ptr<StateOnPlane> stateToExtrapolate(NULL);
581 if (prevFitterInfo == NULL) { // first measurement
582 if (debugLvl_ > 0) {
583 std::cout << "prevFitterInfo == NULL \n";
584 }
585 if (smoothedState != NULL) {
586 if (debugLvl_ > 0) {
587 std::cout << "extrapolate smoothedState to plane\n";
588 }
589 stateToExtrapolate.reset(new StateOnPlane(*smoothedState));
590 }
591 else if (referenceState != NULL) {
592 if (debugLvl_ > 0) {
593 std::cout << "extrapolate referenceState to plane\n";
594 }
595 stateToExtrapolate.reset(new StateOnPlane(*referenceState));
596 }
597 else if (rep != tr->getCardinalRep() &&
598 trackPoint->hasFitterInfo(tr->getCardinalRep()) &&
599 dynamic_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(tr->getCardinalRep())) != NULL &&
600 static_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(tr->getCardinalRep()))->hasPredictionsAndUpdates() ) {
601 if (debugLvl_ > 0) {
602 std::cout << "extrapolate smoothed state of cardinal rep fit to plane\n";
603 }
604 TVector3 pos, mom;
605 const MeasuredStateOnPlane& fittedState = static_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(tr->getCardinalRep()))->getFittedState(true);
606 tr->getCardinalRep()->getPosMom(fittedState, pos, mom);
607 stateToExtrapolate.reset(new StateOnPlane(rep));
608 rep->setPosMom(*stateToExtrapolate, pos, mom);
609 rep->setQop(*stateToExtrapolate, tr->getCardinalRep()->getQop(fittedState));
610 }
611 else {
612 if (debugLvl_ > 0) {
613 std::cout << "extrapolate seed from track to plane\n";
614 }
615 stateToExtrapolate.reset(new StateOnPlane(rep));
616 rep->setPosMom(*stateToExtrapolate, tr->getStateSeed());
617 }
618 } // end if (prevFitterInfo == NULL)
619 else {
620 if (prevSmoothedState != NULL) {
621 if (debugLvl_ > 0) {
622 std::cout << "extrapolate prevSmoothedState to plane \n";
623 }
624 stateToExtrapolate.reset(new StateOnPlane(*prevSmoothedState));
625 }
626 else {
627 assert (prevReferenceState != NULL);
628 if (debugLvl_ > 0) {
629 std::cout << "extrapolate prevReferenceState to plane \n";
630 }
631 stateToExtrapolate.reset(new StateOnPlane(*prevReferenceState));
632 }
633 }
634
635 // make sure track is consistent if extrapolation fails
636 if (prevReferenceState != NULL)
637 prevReferenceState->resetBackward();
638 fitterInfo->deleteReferenceInfo();
639
640 if (prevFitterInfo != NULL) {
641 rep->extrapolateToPlane(*stateToExtrapolate, prevFitterInfo->getPlane());
642 if (debugLvl_ > 0) {
643 std::cout << "extrapolated stateToExtrapolate to plane of prevFitterInfo (plane could have changed!) \n";
644 }
645 }
646
647 double segmentLen = rep->extrapolateToPlane(*stateToExtrapolate, plane, false, true);
648 trackLen += segmentLen;
649 if (debugLvl_ > 0) {
650 std::cout << "extrapolated stateToExtrapolate by " << segmentLen << " cm.\t";
651 std::cout << "charge of stateToExtrapolate: " << rep->getCharge(*stateToExtrapolate) << " \n";
652 }
653
654 // get jacobians and noise matrices
655 if (segmentLen == 0) {
656 FTransportMatrix_.UnitMatrix();
657 FNoiseMatrix_.Zero();
658 forwardDeltaState_.Zero();
659 BTransportMatrix_.UnitMatrix();
660 BNoiseMatrix_.Zero();
661 backwardDeltaState_.Zero();
662 }
663 else {
664 if (i>0)
667 }
668
669
670 if (i==0) {
671 // if we are at first measurement and seed state is defined somewhere else
672 segmentLen = 0;
673 trackLen = 0;
674 }
675 if (setSortingParams)
676 trackPoint->setSortingParameter(trackLen);
677
678
679 // set backward matrices for previous reference state
680 if (prevReferenceState != NULL) {
681 prevReferenceState->setBackwardSegmentLength(-segmentLen);
683 prevReferenceState->setBackwardNoiseMatrix(BNoiseMatrix_);
684 prevReferenceState->setBackwardDeltaState(backwardDeltaState_);
685 }
686
687
688 // create new reference state
689 newRefState = true;
690 changedSmthg = true;
691 referenceState = new ReferenceStateOnPlane(stateToExtrapolate->getState(),
692 stateToExtrapolate->getPlane(),
693 stateToExtrapolate->getRep(),
694 stateToExtrapolate->getAuxInfo());
695 referenceState->setForwardSegmentLength(segmentLen);
697 referenceState->setForwardNoiseMatrix(FNoiseMatrix_);
699
700 referenceState->resetBackward();
701
702 fitterInfo->setReferenceState(referenceState);
703
704
705 // get MeasurementsOnPlane
706 std::vector<double> oldWeights = fitterInfo->getWeights();
707 bool oldWeightsFixed = fitterInfo->areWeightsFixed();
708 fitterInfo->deleteMeasurementInfo();
709 const std::vector<AbsMeasurement*>& rawMeasurements = trackPoint->getRawMeasurements();
710 for ( std::vector< genfit::AbsMeasurement* >::const_iterator measurement = rawMeasurements.begin(), lastMeasurement = rawMeasurements.end(); measurement != lastMeasurement; ++measurement) {
711 assert((*measurement) != NULL);
712 fitterInfo->addMeasurementsOnPlane((*measurement)->constructMeasurementsOnPlane(*referenceState));
713 }
714 if (oldWeights.size() == fitterInfo->getNumMeasurements()) {
715 fitterInfo->setWeights(oldWeights);
716 fitterInfo->fixWeights(oldWeightsFixed);
717 }
718
719
720 // if we made it here, no Exceptions were thrown and the TrackPoint could successfully be processed
721 prevNewRefState = newRefState;
722 prevReferenceState = referenceState;
723 prevFitterInfo = fitterInfo;
724 prevSmoothedState = smoothedState;
725
726 }
727 catch (Exception& e) {
728
729 if (debugLvl_ > 0) {
730 std::cout << "exception at hit " << i << "\n";
731 std::cerr << e.what();
732 }
733
734
735 ++nFailedHits;
736 if (maxFailedHits_<0 || nFailedHits <= maxFailedHits_) {
737 prevNewRefState = true;
738 referenceState = NULL;
739 smoothedState = NULL;
740 tr->getPoint(i)->deleteFitterInfo(rep);
741
742 if (setSortingParams)
743 tr->getPoint(i)->setSortingParameter(trackLen);
744
745 if (debugLvl_ > 0) {
746 std::cout << "There was an exception, try to continue with next TrackPoint " << i+1 << " \n";
747 }
748
749 continue;
750 }
751
752
753 // clean up
754 removeForwardBackwardInfo(tr, rep, notChangedUntil, notChangedFrom);
755
756 // set sorting parameters of rest of TrackPoints and remove FitterInfos
757 for (; i<nPoints; ++i) {
758 TrackPoint* trackPoint = tr->getPoint(i);
759
760 if (setSortingParams)
761 trackPoint->setSortingParameter(trackLen);
762
763 trackPoint->deleteFitterInfo(rep);
764 }
765 return true;
766
767 }
768
769 } // end loop over TrackPoints
770
771
772
773
774 removeForwardBackwardInfo(tr, rep, notChangedUntil, notChangedFrom);
775
776 if (firstBackwardUpdate && tr->getPointWithMeasurementAndFitterInfo(0, rep)) {
778 if (fi && ! fi->hasForwardPrediction()) {
779 if (debugLvl_ > 0) {
780 std::cout << "set backwards update of first point as forward prediction (with blown up cov) \n";
781 }
782 if (fi->getPlane() != firstBackwardUpdate->getPlane()) {
783 rep->extrapolateToPlane(*firstBackwardUpdate, fi->getPlane());
784 }
785 firstBackwardUpdate->blowUpCov(blowUpFactor_);
786 fi->setForwardPrediction(new MeasuredStateOnPlane(*firstBackwardUpdate));
787 }
788 }
789
790 KalmanFitStatus* fitStatus = dynamic_cast<KalmanFitStatus*>(tr->getFitStatus(rep));
791 if (fitStatus != NULL)
792 fitStatus->setTrackLen(trackLen);
793
794 if (debugLvl_ > 0) {
795 std::cout << "trackLen of reference track = " << trackLen << "\n";
796 }
797
798 // self check
799 //assert(tr->checkConsistency());
800 assert(isTrackPrepared(tr, rep));
801
802 return changedSmthg;
803}
804
805
806bool
807KalmanFitterRefTrack::removeOutdated(Track* tr, const AbsTrackRep* rep, int& notChangedUntil, int& notChangedFrom) {
808
809 if (debugLvl_ > 0) {
810 std::cout << "KalmanFitterRefTrack::removeOutdated \n";
811 }
812
813 bool changedSmthg(false);
814
815 unsigned int nPoints = tr->getNumPoints();
816 notChangedUntil = nPoints-1;
817 notChangedFrom = 0;
818
819 // loop over TrackPoints
820 for (unsigned int i=0; i<nPoints; ++i) {
821
822 TrackPoint* trackPoint = tr->getPoint(i);
823
824 // check if we have a measurement
825 if (!trackPoint->hasRawMeasurements()) {
826 if (debugLvl_ > 0) {
827 std::cout << "TrackPoint has no rawMeasurements -> continue \n";
828 }
829 continue;
830 }
831
832 // get fitterInfo
833 KalmanFitterInfo* fitterInfo(NULL);
834 if (trackPoint->hasFitterInfo(rep))
835 fitterInfo = dynamic_cast<KalmanFitterInfo*>(trackPoint->getFitterInfo(rep));
836
837 if (fitterInfo == NULL)
838 continue;
839
840
841 // check if we need to calculate or update reference state
842 if (fitterInfo->hasReferenceState()) {
843
844 if (! fitterInfo->hasPredictionsAndUpdates()) {
845 if (debugLvl_ > 0) {
846 std::cout << "reference state but not all predictions & updates -> do not touch reference state. \n";
847 }
848 continue;
849 }
850
851
852 const MeasuredStateOnPlane& smoothedState = fitterInfo->getFittedState(true);
853 resM_.ResizeTo(smoothedState.getState());
854 resM_ = smoothedState.getState();
855 resM_ -= fitterInfo->getReferenceState()->getState();
856 double chi2(0);
857
858 // calculate chi2, ignore off diagonals
859 double* resArray = resM_.GetMatrixArray();
860 for (int j=0; j<smoothedState.getCov().GetNcols(); ++j)
861 chi2 += resArray[j]*resArray[j] / smoothedState.getCov()(j,j);
862
863 if (chi2 < deltaChi2Ref_) {
864 // reference state is near smoothed state -> do not update reference state
865 if (debugLvl_ > 0) {
866 std::cout << "reference state is near smoothed state -> do not update reference state, chi2 = " << chi2 << "\n";
867 }
868 continue;
869 } else {
870 if (debugLvl_ > 0) {
871 std::cout << "reference state is not close to smoothed state, chi2 = " << chi2 << "\n";
872 }
873 }
874 }
875
876 if (debugLvl_ > 0) {
877 std::cout << "remove reference info \n";
878 }
879
880 fitterInfo->deleteReferenceInfo();
881 changedSmthg = true;
882
883 // decided to update reference state -> set notChangedUntil (only once)
884 if (notChangedUntil == (int)nPoints-1)
885 notChangedUntil = i-1;
886
887 notChangedFrom = i+1;
888
889 } // end loop over TrackPoints
890
891
892 if (debugLvl_ > 0) {
893 tr->Print("C");
894 }
895
896 return changedSmthg;
897}
898
899
900void
901KalmanFitterRefTrack::removeForwardBackwardInfo(Track* tr, const AbsTrackRep* rep, int notChangedUntil, int notChangedFrom) const {
902
903 unsigned int nPoints = tr->getNumPoints();
904
905 if (refitAll_) {
906 tr->deleteForwardInfo(0, -1, rep);
907 tr->deleteBackwardInfo(0, -1, rep);
908 return;
909 }
910
911 // delete forward/backward info from/to points where reference states have changed
912 if (notChangedUntil != (int)nPoints-1) {
913 tr->deleteForwardInfo(notChangedUntil+1, -1, rep);
914 }
915 if (notChangedFrom != 0)
916 tr->deleteBackwardInfo(0, notChangedFrom-1, rep);
917
918}
919
920
921void
922KalmanFitterRefTrack::processTrackPoint(KalmanFitterInfo* fi, const KalmanFitterInfo* prevFi, const TrackPoint* tp, double& chi2, double& ndf, int direction)
923{
924 if (debugLvl_ > 0) {
925 std::cout << " KalmanFitterRefTrack::processTrackPoint " << fi->getTrackPoint() << "\n";
926 }
927
928 unsigned int dim = fi->getRep()->getDim();
929
930 p_.Zero(); // p_{k|k-1}
931 C_.Zero(); // C_{k|k-1}
932
933 // predict
934 if (prevFi != NULL) {
935 const TMatrixD& F = fi->getReferenceState()->getTransportMatrix(direction); // Transport matrix
936 assert(F.GetNcols() == (int)dim);
937 const TMatrixDSym& N = fi->getReferenceState()->getNoiseMatrix(direction); // Noise matrix
938 //p_ = ( F * prevFi->getUpdate(direction)->getState() ) + fi->getReferenceState()->getDeltaState(direction);
939 p_ = prevFi->getUpdate(direction)->getState();
940 p_ *= F;
941 p_ += fi->getReferenceState()->getDeltaState(direction);
942
943 C_ = prevFi->getUpdate(direction)->getCov();
944 C_.Similarity(F);
945 C_ += N;
947 if (debugLvl_ > 1) {
948 std::cout << "\033[31m";
949 std::cout << "F (Transport Matrix) "; F.Print();
950 std::cout << "p_{k,r} (reference state) "; fi->getReferenceState()->getState().Print();
951 std::cout << "c (delta state) "; fi->getReferenceState()->getDeltaState(direction).Print();
952 std::cout << "F*p_{k-1,r} + c "; (F *prevFi->getReferenceState()->getState() + fi->getReferenceState()->getDeltaState(direction)).Print();
953 }
954 }
955 else {
956 if (fi->hasPrediction(direction)) {
957 if (debugLvl_ > 0) {
958 std::cout << " Use prediction as start \n";
959 }
960 p_ = fi->getPrediction(direction)->getState();
961 C_ = fi->getPrediction(direction)->getCov();
962 }
963 else {
964 if (debugLvl_ > 0) {
965 std::cout << " Use reference state and seed cov as start \n";
966 }
967 const AbsTrackRep *rep = fi->getReferenceState()->getRep();
968 p_ = fi->getReferenceState()->getState();
969
970 // Convert from 6D covariance of the seed to whatever the trackRep wants.
971 TMatrixDSym dummy(p_.GetNrows());
973 TVector3 pos, mom;
974 rep->getPosMom(mop, pos, mom);
975 rep->setPosMomCov(mop, pos, mom, fi->getTrackPoint()->getTrack()->getCovSeed());
976 // Blow up, set.
978 fi->setPrediction(new MeasuredStateOnPlane(mop), direction);
979 C_ = mop.getCov();
980 }
981 if (debugLvl_ > 1) {
982 std::cout << "\033[31m";
983 std::cout << "p_{k,r} (reference state)"; fi->getReferenceState()->getState().Print();
984 }
985 }
986
987 if (debugLvl_ > 1) {
988 std::cout << " p_{k|k-1} (state prediction)"; p_.Print();
989 std::cout << " C_{k|k-1} (covariance prediction)"; C_.Print();
990 std::cout << "\033[0m";
991 }
992
993 // update(s)
994 double chi2inc = 0;
995 double ndfInc = 0;
996 const std::vector<MeasurementOnPlane *> measurements = getMeasurements(fi, tp, direction);
997 for (std::vector<MeasurementOnPlane *>::const_iterator it = measurements.begin(); it != measurements.end(); ++it) {
998 const MeasurementOnPlane& m = **it;
999
1000 if (!canIgnoreWeights() && m.getWeight() <= 1.01E-10) {
1001 if (debugLvl_ > 1) {
1002 std::cout << "Weight of measurement is almost 0, continue ... /n";
1003 }
1004 continue;
1005 }
1006
1007 const AbsHMatrix* H(m.getHMatrix());
1008 // (weighted) cov
1009 const TMatrixDSym& V((!canIgnoreWeights() && m.getWeight() < 0.99999) ?
1010 1./m.getWeight() * m.getCov() :
1011 m.getCov());
1012
1013 covSumInv_.ResizeTo(C_);
1014 covSumInv_ = C_; // (V_k + H_k C_{k|k-1} H_k^T)^(-1)
1015 H->HMHt(covSumInv_);
1016 covSumInv_ += V;
1017
1019
1020 const TMatrixD& CHt(H->MHt(C_));
1021
1022 res_.ResizeTo(m.getState());
1023 res_ = m.getState();
1024 res_ -= H->Hv(p_); // residual
1025 if (debugLvl_ > 1) {
1026 std::cout << "\033[34m";
1027 std::cout << "m (measurement) "; m.getState().Print();
1028 std::cout << "V ((weighted) measurement covariance) "; (1./m.getWeight() * m.getCov()).Print();
1029 std::cout << "residual "; res_.Print();
1030 std::cout << "\033[0m";
1031 }
1032 p_ += TMatrixD(CHt, TMatrixD::kMult, covSumInv_) * res_; // updated state
1033 if (debugLvl_ > 1) {
1034 std::cout << "\033[32m";
1035 std::cout << " update"; (TMatrixD(CHt, TMatrixD::kMult, covSumInv_) * res_).Print();
1036 std::cout << "\033[0m";
1037 }
1038
1039 covSumInv_.Similarity(CHt); // with (C H^T)^T = H C^T = H C (C is symmetric)
1040 C_ -= covSumInv_; // updated Cov
1041
1042 if (debugLvl_ > 1) {
1043 //std::cout << " C update "; covSumInv_.Print();
1044 std::cout << "\033[32m";
1045 std::cout << " p_{k|k} (updated state)"; p_.Print();
1046 std::cout << " C_{k|k} (updated covariance)"; C_.Print();
1047 std::cout << "\033[0m";
1048 }
1049
1050 // Calculate chi² increment. At the first point chi2inc == 0 and
1051 // the matrix will not be invertible.
1052 res_ = m.getState();
1053 res_ -= H->Hv(p_); // new residual
1054 if (debugLvl_ > 1) {
1055 std::cout << " resNew ";
1056 res_.Print();
1057 }
1058
1059 // only calculate chi2inc if res != NULL.
1060 // If matrix inversion fails, chi2inc = 0
1061 if (res_ != 0) {
1062 Rinv_.ResizeTo(C_);
1063 Rinv_ = C_;
1064 H->HMHt(Rinv_);
1065 Rinv_ -= V;
1066 Rinv_ *= -1;
1067
1068 bool couldInvert(true);
1069 try {
1071 }
1072 catch (Exception& e) {
1073 if (debugLvl_ > 1) {
1074 std::cerr << e.what();
1075 }
1076 couldInvert = false;
1077 }
1078
1079 if (couldInvert) {
1080 if (debugLvl_ > 1) {
1081 std::cout << " Rinv ";
1082 Rinv_.Print();
1083 }
1084 chi2inc += Rinv_.Similarity(res_);
1085 }
1086 }
1087
1088
1089 if (!canIgnoreWeights()) {
1090 ndfInc += m.getWeight() * m.getState().GetNrows();
1091 }
1092 else
1093 ndfInc += m.getState().GetNrows();
1094
1095
1096 } // end loop over measurements
1097
1098 chi2 += chi2inc;
1099 ndf += ndfInc;
1100
1101
1103 upState->setAuxInfo(fi->getReferenceState()->getAuxInfo());
1104 fi->setUpdate(upState, direction);
1105
1106
1107 if (debugLvl_ > 0) {
1108 std::cout << " chi² inc " << chi2inc << "\t";
1109 std::cout << " ndf inc " << ndfInc << "\t";
1110 std::cout << " charge of update " << fi->getRep()->getCharge(*upState) << "\n";
1111 }
1112
1113 // check
1114 assert(fi->checkConsistency());
1115
1116}
Double_t m
const AbsTrackRep * getRep() const
virtual bool hasPrediction(int direction) const
const SharedPlanePtr & getPlane() const
const TrackPoint * getTrackPoint() const
unsigned int debugLvl_
Definition AbsFitter.h:55
HMatrix for projecting from AbsTrackRep parameters to measured parameters in a DetPlane.
Definition AbsHMatrix.h:37
double blowUpFactor_
Blow up the covariance of the forward (backward) fit by this factor before seeding the backward (forw...
unsigned int maxIterations_
Maximum number of iterations to attempt. Forward and backward are counted as one iteration.
bool canIgnoreWeights() const
returns if the fitter can ignore the weights and handle the MeasurementOnPlanes as if they had weight...
const std::vector< MeasurementOnPlane * > getMeasurements(const KalmanFitterInfo *fi, const TrackPoint *tp, int direction) const
get the measurementsOnPlane taking the multipleMeasurementHandling_ into account
double deltaPval_
Convergence criterion.
unsigned int minIterations_
Minimum number of iterations to attempt. Forward and backward are counted as one iteration.
bool isTrackPrepared(const Track *tr, const AbsTrackRep *rep) const
virtual SharedPlanePtr constructPlane(const StateOnPlane &state) const =0
Abstract base class for a track representation.
Definition AbsTrackRep.h:66
virtual void getPosMom(const StateOnPlane &state, TVector3 &pos, TVector3 &mom) const =0
Get cartesian position and momentum vector of a state.
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,...
virtual double getQop(const StateOnPlane &state) const =0
Get charge over momentum.
virtual void setPosMom(StateOnPlane &state, const TVector3 &pos, const TVector3 &mom) const =0
Set position and momentum of state.
virtual double getCharge(const StateOnPlane &state) const =0
Get the (fitted) charge of a state. This is not always equal the pdg charge (e.g. if the charge sign ...
virtual void setPosMomCov(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6) const =0
Set position, momentum and covariance of state.
virtual void getForwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const =0
Get the jacobian and noise matrix of the last extrapolation.
virtual void setQop(StateOnPlane &state, double qop) const =0
Set charge/momentum.
virtual void getBackwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const =0
Get the jacobian and noise matrix of the last extrapolation if it would have been done in opposite di...
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)
Definition Exception.h:48
void setFatal(bool b=true)
Set fatal flag.
Definition Exception.h:61
virtual const char * what() const
Standard error message handling for exceptions. use like "std::cerr << e.what();".
Definition Exception.cc:51
bool isTrackPruned() const
Has the track been pruned after the fit?
Definition FitStatus.h:70
FitStatus for use with AbsKalmanFitter implementations.
void setTrackLen(double trackLen)
MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
bool hasPredictionsAndUpdates() const
const MeasuredStateOnPlane & getFittedState(bool biased=true) const
Get unbiased or biased (default) smoothed state.
ReferenceStateOnPlane * getReferenceState() const
virtual bool checkConsistency() const
KalmanFittedStateOnPlane * getUpdate(int direction) const
void setWeights(const std::vector< double > &)
Set weights of measurements.
void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction)
void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
void setReferenceState(ReferenceStateOnPlane *referenceState)
std::vector< double > getWeights() const
Get weights of measurements.
void setPrediction(MeasuredStateOnPlane *prediction, int direction)
unsigned int getNumMeasurements() const
KalmanFittedStateOnPlane * getBackwardUpdate() const
MeasuredStateOnPlane * getBackwardPrediction() const
MeasuredStateOnPlane * getPrediction(int direction) const
void fixWeights(bool arg=true)
bool hasUpdate(int direction) const
bool areWeightsFixed() const
Are the weights fixed?
void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction)
KalmanFittedStateOnPlane * getForwardUpdate() const
void setUpdate(KalmanFittedStateOnPlane *update, int direction)
void processTrackPoint(KalmanFitterInfo *fi, const KalmanFitterInfo *prevFi, const TrackPoint *tp, double &chi2, double &ndf, int direction)
void processTrackWithRep(Track *tr, const AbsTrackRep *rep, bool resortHits=false)
void removeForwardBackwardInfo(Track *tr, const AbsTrackRep *rep, int notChangedUntil, int notChangedFrom) const
If refitAll_, remove all information.
bool removeOutdated(Track *tr, const AbsTrackRep *rep, int &notChangedUntil, int &notChangedFrom)
Remove referenceStates if they are too far from smoothed states.
bool prepareTrack(Track *tr, const AbsTrackRep *rep, bool setSortingParams, int &nFailedHits)
Prepare the track.
TrackPoint * fitTrack(Track *tr, const AbsTrackRep *rep, double &chi2, double &ndf, int direction)
Fit the track.
StateOnPlane with additional covariance matrix.
const TMatrixDSym & getCov() const
void blowUpCov(double blowUpFac, bool resetOffDiagonals=true)
Measured coordinates on a plane.
StateOnPlane with linearized transport to that ReferenceStateOnPlane from previous and next Reference...
void setForwardTransportMatrix(const TMatrixD &mat)
void setForwardDeltaState(const TVectorD &mat)
const TVectorD & getDeltaState(int direction) const
void setBackwardTransportMatrix(const TMatrixD &mat)
void setBackwardDeltaState(const TVectorD &mat)
void setForwardNoiseMatrix(const TMatrixDSym &mat)
const TMatrixD & getTransportMatrix(int direction) const
const TMatrixDSym & getNoiseMatrix(int direction) const
void setBackwardNoiseMatrix(const TMatrixDSym &mat)
A state with arbitrary dimension defined in a DetPlane.
const TVectorD & getState() const
void setAuxInfo(const TVectorD &auxInfo)
const AbsTrackRep * getRep() const
const TVectorD & getAuxInfo() const
const SharedPlanePtr & getPlane() const
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition TrackPoint.h:50
bool hasFitterInfo(const AbsTrackRep *rep) const
Definition TrackPoint.h:103
void deleteFitterInfo(const AbsTrackRep *rep)
Definition TrackPoint.h:117
AbsFitterInfo * getFitterInfo(const AbsTrackRep *rep=NULL) const
Get fitterInfo for rep. Per default, use cardinal rep.
bool hasRawMeasurements() const
Definition TrackPoint.h:96
const std::vector< genfit::AbsMeasurement * > & getRawMeasurements() const
Definition TrackPoint.h:93
void setSortingParameter(double sortingParameter)
Definition TrackPoint.h:111
Track * getTrack() const
Definition TrackPoint.h:90
void setFitterInfo(genfit::AbsFitterInfo *fitterInfo)
Takes Ownership.
AbsMeasurement * getRawMeasurement(int i=0) const
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition Track.h:71
TrackPoint * getPoint(int id) const
Definition Track.cc:201
unsigned int getNumPoints() const
Definition Track.h:108
int getIdForRep(const AbsTrackRep *rep) const
This is used when streaming TrackPoints.
Definition Track.cc:245
const TVectorD & getStateSeed() const
Definition Track.h:158
void deleteForwardInfo(int startId=0, int endId=-1, const AbsTrackRep *rep=NULL)
Definition Track.cc:681
TrackPoint * getPointWithMeasurement(int id) const
Definition Track.cc:209
unsigned int getNumPointsWithMeasurement() const
Definition Track.h:112
void deleteBackwardInfo(int startId=0, int endId=-1, const AbsTrackRep *rep=NULL)
Definition Track.cc:710
const TMatrixDSym & getCovSeed() const
Definition Track.h:162
FitStatus * getFitStatus(const AbsTrackRep *rep=NULL) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Definition Track.h:149
void Print(const Option_t *="") const
Definition Track.cc:1026
AbsTrackRep * getCardinalRep() const
Get cardinal track representation.
Definition Track.h:140
TrackPoint * getPointWithMeasurementAndFitterInfo(int id, const AbsTrackRep *rep) const
Definition Track.cc:217
bool sort()
Sort TrackPoint and according to their sorting parameters.
Definition Track.cc:578
void setFitStatus(FitStatus *fitStatus, const AbsTrackRep *rep)
Definition Track.cc:285
void invertMatrix(const TMatrixDSym &mat, TMatrixDSym &inv, double *determinant=NULL)
Invert a matrix, throwing an Exception when inversion fails. Optional calculation of determinant.
Definition Tools.cc:38
Matrix inversion tools.
Definition AbsBField.h:29
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.