SND@LHC Software
Loading...
Searching...
No Matches
KalmanFitterInfo.cc
Go to the documentation of this file.
1/* Copyright 2008-2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München
2 Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter
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#include "KalmanFitterInfo.h"
21
22#include <cassert>
23#include <iostream>
24#include <TBuffer.h>
25
26#include "Exception.h"
27#include "Tools.h"
28#include "Track.h"
29#include "TrackPoint.h"
30
31//#define DEBUG
32
33
34namespace genfit {
35
37 AbsFitterInfo(), fixWeights_(false)
38{
39 ;
40}
41
43 AbsFitterInfo(trackPoint, rep), fixWeights_(false)
44{
45 ;
46}
47
51
52
54 KalmanFitterInfo* retVal = new KalmanFitterInfo(this->getTrackPoint(), this->getRep());
59 if (hasForwardUpdate())
65
67 for (std::vector<MeasurementOnPlane*>::const_iterator it = this->measurementsOnPlane_.begin(); it != this->measurementsOnPlane_.end(); ++it) {
69 }
70
71 retVal->fixWeights_ = this->fixWeights_;
72
73 return retVal;
74}
75
76
78
80
81 if(measurementsOnPlane_.size() == 1) {
82 if (ignoreWeights) {
83 retVal.setWeight(1.);
84 }
85 else {
86 double weight = (measurementsOnPlane_[0])->getWeight();
87 if (weight != 1.) {
88 retVal.getCov() *= 1. / weight;
89 }
90 retVal.setWeight(weight);
91 }
92 return retVal;
93 }
94
95 // more than one hit
96
97 double sumOfWeights(0), weight(0);
98
99 retVal.getState().Zero();
100 retVal.getCov().Zero();
101
102 TMatrixDSym covInv;
103
104 for(unsigned int i=0; i<measurementsOnPlane_.size(); ++i) {
105
106 if (i>0) {
107 // make sure we have compatible measurement types
108 // TODO: replace with Exceptions!
110 assert(*(measurementsOnPlane_[i]->getHMatrix()) == *(measurementsOnPlane_[0]->getHMatrix()));
111 }
112
113 tools::invertMatrix(measurementsOnPlane_[i]->getCov(), covInv); // invert cov
114 if (ignoreWeights) {
115 sumOfWeights += 1.;
116 }
117 else {
118 weight = measurementsOnPlane_[i]->getWeight();
119 sumOfWeights += weight;
120 covInv *= weight; // weigh cov
121 }
122 retVal.getCov() += covInv; // covInv is already inverted and weighted
123
124 retVal.getState() += covInv * measurementsOnPlane_[i]->getState();
125 }
126
127 // invert Cov
128 tools::invertMatrix(retVal.getCov());
129
130 retVal.getState() *= retVal.getCov();
131
132 retVal.setWeight(sumOfWeights);
133
134 return retVal;
135}
136
137
139 if(measurementsOnPlane_.size() == 0)
140 return NULL;
141
142 if(measurementsOnPlane_.size() == 1)
143 return getMeasurementOnPlane(0);
144
145 double normMin(9.99E99);
146 unsigned int iMin(0);
147 const AbsHMatrix* H = measurementsOnPlane_[0]->getHMatrix();
148 for (unsigned int i=0; i<getNumMeasurements(); ++i) {
149 if (*(measurementsOnPlane_[i]->getHMatrix()) != *H){
150 Exception e("KalmanFitterInfo::getClosestMeasurementOnPlane: Cannot compare measurements with different H-Matrices. Maybe you have to select a different multipleMeasurementHandling.", __LINE__,__FILE__);
151 e.setFatal();
152 throw e;
153 }
154
155 TVectorD res = measurementsOnPlane_[i]->getState() - H->Hv(sop->getState());
156 double norm = sqrt(res.Norm2Sqr());
157 if (norm < normMin) {
158 normMin = norm;
159 iMin = i;
160 }
161 }
162
163 return getMeasurementOnPlane(iMin);
164}
165
166
167std::vector<double> KalmanFitterInfo::getWeights() const {
168 std::vector<double> retVal(getNumMeasurements());
169
170 for (unsigned int i=0; i<getNumMeasurements(); ++i) {
171 retVal[i] = getMeasurementOnPlane(i)->getWeight();
172 }
173
174 return retVal;
175}
176
177
179 if (biased) {
180 if (fittedStateBiased_.get() != NULL)
181 return *fittedStateBiased_;
182
183 if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(-1, this->getRep())
184 == this->getTrackPoint()) {// last measurement
185 if(forwardUpdate_.get() == NULL) {
186 Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__);
187 e.setFatal();
188 throw e;
189 }
190 #ifdef DEBUG
191 std::cout << "KalmanFitterInfo::getFittedState - biased at last measurement = forwardUpdate_ \n";
192 #endif
193 return *forwardUpdate_;
194 }
195 else if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(0, this->getRep())
196 == this->getTrackPoint()) { // first measurement
197 if(backwardUpdate_.get() == NULL) {
198 Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__);
199 e.setFatal();
200 throw e;
201 }
202 #ifdef DEBUG
203 std::cout << "KalmanFitterInfo::getFittedState - biased at first measurement = backwardUpdate_ \n";
204 backwardUpdate_->Print();
205 #endif
206 return *backwardUpdate_;
207 }
208
209 if(forwardUpdate_.get() == NULL || backwardPrediction_.get() == NULL) {
210 Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__);
211 e.setFatal();
212 throw e;
213 }
214 #ifdef DEBUG
215 std::cout << "KalmanFitterInfo::getFittedState - biased = mean(forwardUpdate_, backwardPrediction_) \n";
216 #endif
218 return *fittedStateBiased_;
219 }
220 else { // unbiased
221 if (fittedStateUnbiased_.get() != NULL)
222 return *fittedStateUnbiased_;
223
224 if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(-1, this->getRep())
225 == this->getTrackPoint()) { // last measurement
226 if(forwardPrediction_.get() == NULL) {
227 Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__);
228 e.setFatal();
229 throw e;
230 }
231 #ifdef DEBUG
232 std::cout << "KalmanFitterInfo::getFittedState - unbiased at last measurement = forwardPrediction_ \n";
233 #endif
234 return *forwardPrediction_;
235 }
236 else if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(0, this->getRep())
237 == this->getTrackPoint()) { // first measurement
238 if(backwardPrediction_.get() == NULL) {
239 Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__);
240 e.setFatal();
241 throw e;
242 }
243 #ifdef DEBUG
244 std::cout << "KalmanFitterInfo::getFittedState - unbiased at first measurement = backwardPrediction_ \n";
245 #endif
246 return *backwardPrediction_;
247 }
248
249 if(forwardPrediction_.get() == NULL || backwardPrediction_.get() == NULL) {
250 Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__);
251 e.setFatal();
252 throw e;
253 }
254 #ifdef DEBUG
255 std::cout << "KalmanFitterInfo::getFittedState - unbiased = mean(forwardPrediction_, backwardPrediction_) \n";
256 #endif
258 return *fittedStateUnbiased_;
259 }
260
261}
262
263
264MeasurementOnPlane KalmanFitterInfo::getResidual(unsigned int iMeasurement, bool biased, bool onlyMeasurementErrors) const {
265
266 const MeasuredStateOnPlane& smoothedState = getFittedState(biased);
267 const MeasurementOnPlane* measurement = measurementsOnPlane_.at(iMeasurement);
268 const SharedPlanePtr& plane = measurement->getPlane();
269
270 // check equality of planes and reps
271 if(*(smoothedState.getPlane()) != *plane) {
272 Exception e("KalmanFitterInfo::getResidual: smoothedState and measurement are not defined in the same plane.", __LINE__,__FILE__);
273 throw e;
274 }
275 if(smoothedState.getRep() != measurement->getRep()) {
276 Exception e("KalmanFitterInfo::getResidual: smoothedState and measurement are not defined wrt the same TrackRep.", __LINE__,__FILE__);
277 throw e;
278 }
279
280 const AbsHMatrix* H = measurement->getHMatrix();
281
282 //TODO: shouldn't the definition be (smoothed - measured) ?
283 // res = -(H*smoothedState - measuredState)
284 TVectorD res(H->Hv(smoothedState.getState()));
285 res -= measurement->getState();
286 res *= -1;
287
288 if (onlyMeasurementErrors) {
289 return MeasurementOnPlane(res, measurement->getCov(), plane, smoothedState.getRep(), H->clone(), measurement->getWeight());
290 }
291
292 TMatrixDSym cov(smoothedState.getCov());
293 H->HMHt(cov);
294 cov += measurement->getCov();
295
296 return MeasurementOnPlane(res, cov, plane, smoothedState.getRep(), H->clone(), measurement->getWeight());
297}
298
299
301 referenceState_.reset(referenceState);
302 if (referenceState_)
303 setPlane(referenceState_->getPlane());
304
305 // if plane has changed, delete outdated info
306 /*if (forwardPrediction_ && forwardPrediction_->getPlane() != getPlane())
307 setForwardPrediction(0);
308
309 if (forwardUpdate_ && forwardUpdate_->getPlane() != getPlane())
310 setForwardUpdate(0);
311
312 if (backwardPrediction_ && backwardPrediction_->getPlane() != getPlane())
313 setBackwardPrediction(0);
314
315 if (backwardUpdate_ && backwardUpdate_->getPlane() != getPlane())
316 setBackwardUpdate(0);
317
318 if (measurementsOnPlane_.size() > 0 && measurementsOnPlane_[0]->getPlane() != getPlane())
319 deleteMeasurementInfo();
320 */
321}
322
323
325 forwardPrediction_.reset(forwardPrediction);
326 fittedStateUnbiased_.reset();
327 fittedStateBiased_.reset();
329 setPlane(forwardPrediction_->getPlane());
330}
331
333 backwardPrediction_.reset(backwardPrediction);
334 fittedStateUnbiased_.reset();
335 fittedStateBiased_.reset();
337 setPlane(backwardPrediction_->getPlane());
338}
339
341 forwardUpdate_.reset(forwardUpdate);
342 fittedStateUnbiased_.reset();
343 fittedStateBiased_.reset();
344 if (forwardUpdate_)
345 setPlane(forwardUpdate_->getPlane());
346}
347
349 backwardUpdate_.reset(backwardUpdate);
350 fittedStateUnbiased_.reset();
351 fittedStateBiased_.reset();
352 if (backwardUpdate_)
353 setPlane(backwardUpdate_->getPlane());
354}
355
356
357void KalmanFitterInfo::setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane) {
359
360 for (std::vector<MeasurementOnPlane*>::const_iterator m = measurementsOnPlane.begin(), mend = measurementsOnPlane.end(); m < mend; ++m) {
362 }
363}
364
365
367 if (measurementsOnPlane_.size() == 0)
368 setPlane(measurementOnPlane->getPlane());
369
370 measurementsOnPlane_.push_back(measurementOnPlane);
371}
372
373void KalmanFitterInfo::addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane) {
374 for (std::vector<MeasurementOnPlane*>::const_iterator m = measurementsOnPlane.begin(), mend = measurementsOnPlane.end(); m < mend; ++m) {
376 }
377}
378
379
381 rep_ = rep;
382
383 if (referenceState_)
384 referenceState_->setRep(rep);
385
387 forwardPrediction_->setRep(rep);
388
389 if (forwardUpdate_)
390 forwardUpdate_->setRep(rep);
391
393 backwardPrediction_->setRep(rep);
394
395 if (backwardUpdate_)
396 backwardUpdate_->setRep(rep);
397
398 for (std::vector<MeasurementOnPlane*>::iterator it = measurementsOnPlane_.begin(); it != measurementsOnPlane_.end(); ++it) {
399 (*it)->setRep(rep);
400 }
401}
402
403
404void KalmanFitterInfo::setWeights(const std::vector<double>& weights) {
405
406 if (weights.size() != getNumMeasurements()) {
407 Exception e("KalmanFitterInfo::setWeights: weights do not have the same size as measurementsOnPlane", __LINE__,__FILE__);
408 throw e;
409 }
410
411 if (fixWeights_) {
412 std::cerr << "KalmanFitterInfo::setWeights - WARNING: setting weights even though weights are fixed!" << std::endl;
413 }
414
415 for (unsigned int i=0; i<getNumMeasurements(); ++i) {
416 getMeasurementOnPlane(i)->setWeight(weights[i]);
417 }
418}
419
420
427
434
441
443 // FIXME: need smart pointers / smart containers here
444 for (size_t i = 0; i < measurementsOnPlane_.size(); ++i)
445 delete measurementsOnPlane_[i];
446
447 measurementsOnPlane_.clear();
448}
449
450
451void KalmanFitterInfo::Print(const Option_t*) const {
452 std::cout << "genfit::KalmanFitterInfo. Belongs to TrackPoint " << trackPoint_ << "; TrackRep " << rep_ << "\n";
453
454 if (fixWeights_)
455 std::cout << "Weights are fixed.\n";
456
457 for (unsigned int i=0; i<measurementsOnPlane_.size(); ++i) {
458 std::cout << "MeasurementOnPlane Nr " << i <<": "; measurementsOnPlane_[i]->Print();
459 }
460
461 if (referenceState_) {
462 std::cout << "Reference state: "; referenceState_->Print();
463 }
464 if (forwardPrediction_) {
465 std::cout << "Forward prediction_: "; forwardPrediction_->Print();
466 }
467 if (forwardUpdate_) {
468 std::cout << "Forward update: "; forwardUpdate_->Print();
469 }
471 std::cout << "Backward prediction_: "; backwardPrediction_->Print();
472 }
473 if (backwardUpdate_) {
474 std::cout << "Backward update: "; backwardUpdate_->Print();
475 }
476
477}
478
479
481
482 bool retVal(true);
483
484 // check if in a TrackPoint
485 if (!trackPoint_) {
486 std::cerr << "KalmanFitterInfo::checkConsistency(): trackPoint_ is NULL" << std::endl;
487 retVal = false;
488 }
489
490 // check if there is a reference state
491 /*if (!referenceState_) {
492 std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ is NULL" << std::endl;
493 retVal = false;
494 }*/
495
496 SharedPlanePtr plane = getPlane();
497
498 if (plane.get() == NULL) {
500 return true;
501 std::cerr << "KalmanFitterInfo::checkConsistency(): plane is NULL" << std::endl;
502 retVal = false;
503 }
504
505 TVector3 oTest = plane->getO(); // see if the plane object is there
506 oTest *= 47.11;
507
508 // if more than one measurement, check if they have the same dimensionality
509 if (measurementsOnPlane_.size() > 1) {
510 int dim = measurementsOnPlane_[0]->getState().GetNrows();
511 for (unsigned int i = 1; i<measurementsOnPlane_.size(); ++i) {
512 if(measurementsOnPlane_[i]->getState().GetNrows() != dim) {
513 std::cerr << "KalmanFitterInfo::checkConsistency(): measurementsOnPlane_ do not all have the same dimensionality" << std::endl;
514 retVal = false;
515 }
516 }
517 if (dim == 0) {
518 std::cerr << "KalmanFitterInfo::checkConsistency(): measurementsOnPlane_ have dimension 0" << std::endl;
519 retVal = false;
520 }
521 }
522
523 // see if everything else is defined wrt this plane and rep_
524 int dim = rep_->getDim(); // check dim
525 if (referenceState_) {
526 if(referenceState_->getPlane() != plane) {
527 std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ is not defined with the correct plane " << referenceState_->getPlane().get() << " vs. " << plane.get() << std::endl;
528 retVal = false;
529 }
530 if (referenceState_->getRep() != rep_) {
531 std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ is not defined with the correct TrackRep" << std::endl;
532 retVal = false;
533 }
534 if (referenceState_->getState().GetNrows() != dim) {
535 std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ does not have the right dimension!" << std::endl;
536 retVal = false;
537 }
538 }
539
540 if (forwardPrediction_) {
541 if(forwardPrediction_->getPlane() != plane) {
542 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardPrediction_ is not defined with the correct plane" << std::endl;
543 retVal = false;
544 }
545 if(forwardPrediction_->getRep() != rep_) {
546 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardPrediction_ is not defined with the correct TrackRep" << std::endl;
547 retVal = false;
548 }
549 if (forwardPrediction_->getState().GetNrows() != dim || forwardPrediction_->getCov().GetNrows() != dim) {
550 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardPrediction_ does not have the right dimension!" << std::endl;
551 retVal = false;
552 }
553 }
554 if (forwardUpdate_) {
555 if(forwardUpdate_->getPlane() != plane) {
556 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ is not defined with the correct plane" << std::endl;
557 retVal = false;
558 }
559 if(forwardUpdate_->getRep() != rep_) {
560 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ is not defined with the correct TrackRep" << std::endl;
561 retVal = false;
562 }
563 if (forwardUpdate_->getState().GetNrows() != dim || forwardUpdate_->getCov().GetNrows() != dim) {
564 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ does not have the right dimension!" << std::endl;
565 retVal = false;
566 }
567 }
568
570 if(backwardPrediction_->getPlane() != plane) {
571 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardPrediction_ is not defined with the correct plane" << std::endl;
572 retVal = false;
573 }
574 if(backwardPrediction_->getRep() != rep_) {
575 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardPrediction_ is not defined with the correct TrackRep" << std::endl;
576 retVal = false;
577 }
578 if (backwardPrediction_->getState().GetNrows() != dim || backwardPrediction_->getCov().GetNrows() != dim) {
579 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardPrediction_ does not have the right dimension!" << std::endl;
580 retVal = false;
581 }
582 }
583 if (backwardUpdate_) {
584 if(backwardUpdate_->getPlane() != plane) {
585 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ is not defined with the correct plane" << std::endl;
586 retVal = false;
587 }
588 if(backwardUpdate_->getRep() != rep_) {
589 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ is not defined with the correct TrackRep" << std::endl;
590 retVal = false;
591 }
592 if (backwardUpdate_->getState().GetNrows() != dim || backwardUpdate_->getCov().GetNrows() != dim) {
593 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ does not have the right dimension!" << std::endl;
594 retVal = false;
595 }
596 }
597
598 for (std::vector<MeasurementOnPlane*>::const_iterator it = measurementsOnPlane_.begin(); it != measurementsOnPlane_.end(); ++it) {
599 if((*it)->getPlane() != plane) {
600 std::cerr << "KalmanFitterInfo::checkConsistency(): measurement is not defined with the correct plane" << std::endl;
601 retVal = false;
602 }
603 if((*it)->getRep() != rep_) {
604 std::cerr << "KalmanFitterInfo::checkConsistency(): measurement is not defined with the correct TrackRep" << std::endl;
605 retVal = false;
606 }
607 if ((*it)->getState().GetNrows() == 0) {
608 std::cerr << "KalmanFitterInfo::checkConsistency(): measurement has dimension 0!" << std::endl;
609 retVal = false;
610 }
611 }
612
613 // see if there is an update w/o prediction or measurement
615 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ w/o forwardPrediction_" << std::endl;
616 retVal = false;
617 }
618
619 if (forwardUpdate_ && measurementsOnPlane_.size() == 0) {
620 std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ w/o measurement" << std::endl;
621 retVal = false;
622 }
623
624
626 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ w/o backwardPrediction_" << std::endl;
627 retVal = false;
628 }
629
630 if (backwardUpdate_ && measurementsOnPlane_.size() == 0) {
631 std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ w/o measurement" << std::endl;
632 retVal = false;
633 }
634
635
636 return retVal;
637}
638
639
640// Modified from auto-generated Streamer to correctly deal with smart pointers.
641void KalmanFitterInfo::Streamer(TBuffer &R__b)
642{
643 // Stream an object of class genfit::KalmanFitterInfo.
644
645 //This works around a msvc bug and should be harmless on other platforms
646 typedef ::genfit::KalmanFitterInfo thisClass;
647 UInt_t R__s, R__c;
648 if (R__b.IsReading()) {
649 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
650 //This works around a msvc bug and should be harmless on other platforms
651 typedef genfit::AbsFitterInfo baseClass0;
652 baseClass0::Streamer(R__b);
653 int flag;
654 R__b >> flag;
659 if (flag & 1) {
660 referenceState_.reset(new ReferenceStateOnPlane());
661 referenceState_->Streamer(R__b);
662 referenceState_->setPlane(getPlane());
663 // rep needs to be fixed up
664 }
665 if (flag & (1 << 1)) {
666 forwardPrediction_.reset(new MeasuredStateOnPlane());
667 forwardPrediction_->Streamer(R__b);
668 forwardPrediction_->setPlane(getPlane());
669 // rep needs to be fixed up
670 }
671 if (flag & (1 << 2)) {
672 forwardUpdate_.reset(new KalmanFittedStateOnPlane());
673 forwardUpdate_->Streamer(R__b);
674 forwardUpdate_->setPlane(getPlane());
675 // rep needs to be fixed up
676 }
677 if (flag & (1 << 3)) {
678 backwardPrediction_.reset(new MeasuredStateOnPlane());
679 backwardPrediction_->Streamer(R__b);
680 backwardPrediction_->setPlane(getPlane());
681 // rep needs to be fixed up
682 }
683 if (flag & (1 << 4)) {
684 backwardUpdate_.reset(new KalmanFittedStateOnPlane());
685 backwardUpdate_->Streamer(R__b);
686 backwardUpdate_->setPlane(getPlane());
687 // rep needs to be fixed up
688 }
689 {
690 std::vector<genfit::MeasurementOnPlane*,std::allocator<genfit::MeasurementOnPlane*> > &R__stl = measurementsOnPlane_;
691 TClass *R__tcl1 = TBuffer::GetClass(typeid(genfit::MeasurementOnPlane));
692 if (R__tcl1==0) {
693 Error("measurementsOnPlane_ streamer","Missing the TClass object for genfit::MeasurementOnPlane!");
694 return;
695 }
696 int R__i, R__n;
697 R__b >> R__n;
698 R__stl.reserve(R__n);
699 for (R__i = 0; R__i < R__n; R__i++) {
700 genfit::MeasurementOnPlane* R__t = new MeasurementOnPlane();
701 R__t->Streamer(R__b);
702 R__t->setPlane(getPlane());
703 R__stl.push_back(R__t);
704 }
705 }
706 R__b.CheckByteCount(R__s, R__c, thisClass::IsA());
707 } else {
708 R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE);
709 //This works around a msvc bug and should be harmless on other platforms
710 typedef genfit::AbsFitterInfo baseClass0;
711 baseClass0::Streamer(R__b);
712 // "!!" forces the value to 1 or 0 (pointer != 0 or pointer == 0),
713 // this value is then written as a bitfield.
714 int flag = (!!referenceState_
715 | (!!forwardPrediction_ << 1)
716 | (!!forwardUpdate_ << 2)
717 | (!!backwardPrediction_ << 3)
718 | (!!backwardUpdate_ << 4));
719 R__b << flag;
720 if (flag & 1)
721 referenceState_->Streamer(R__b);
722 if (flag & (1 << 1))
723 forwardPrediction_->Streamer(R__b);
724 if (flag & (1 << 2))
725 forwardUpdate_->Streamer(R__b);
726 if (flag & (1 << 3))
727 backwardPrediction_->Streamer(R__b);
728 if (flag & (1 << 4))
729 backwardUpdate_->Streamer(R__b);
730 {
731 std::vector<genfit::MeasurementOnPlane*,std::allocator<genfit::MeasurementOnPlane*> > &R__stl = measurementsOnPlane_;
732 int R__n=int(R__stl.size());
733 R__b << R__n;
734 if(R__n) {
735 std::vector<genfit::MeasurementOnPlane*,std::allocator<genfit::MeasurementOnPlane*> >::iterator R__k;
736 for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {
737 (*R__k)->Streamer(R__b);
738 }
739 }
740 }
741 R__b.SetByteCount(R__c, kTRUE);
742 }
743}
744
745
746} /* End of namespace genfit */
Double_t m
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
const AbsTrackRep * getRep() const
const TrackPoint * trackPoint_
const SharedPlanePtr & getPlane() const
const AbsTrackRep * rep_
No ownership.
void setPlane(const SharedPlanePtr &plane)
const TrackPoint * getTrackPoint() const
HMatrix for projecting from AbsTrackRep parameters to measured parameters in a DetPlane.
Definition AbsHMatrix.h:37
Abstract base class for a track representation.
Definition AbsTrackRep.h:66
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
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 ...
void setBackwardUpdate(KalmanFittedStateOnPlane *backwardUpdate)
void setRep(const AbsTrackRep *rep)
MeasurementOnPlane getResidual(unsigned int iMeasurement=0, bool biased=false, bool onlyMeasurementErrors=true) const
Get unbiased (default) or biased residual from ith measurement.
const MeasuredStateOnPlane & getFittedState(bool biased=true) const
Get unbiased or biased (default) smoothed state.
std::vector< MeasurementOnPlane * > measurementsOnPlane_
cache
ReferenceStateOnPlane * getReferenceState() const
virtual bool checkConsistency() const
void setWeights(const std::vector< double > &)
Set weights of measurements.
void addMeasurementOnPlane(MeasurementOnPlane *measurementOnPlane)
void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
void setBackwardPrediction(MeasuredStateOnPlane *backwardPrediction)
void setForwardUpdate(KalmanFittedStateOnPlane *forwardUpdate)
MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights=false) const
void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane * > &measurementsOnPlane)
void setReferenceState(ReferenceStateOnPlane *referenceState)
std::vector< double > getWeights() const
Get weights of measurements.
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateUnbiased_
unsigned int getNumMeasurements() const
MeasuredStateOnPlane * getForwardPrediction() const
KalmanFittedStateOnPlane * getBackwardUpdate() const
boost::scoped_ptr< ReferenceStateOnPlane > referenceState_
Reference state. Used by KalmanFitterRefTrack.
MeasurementOnPlane * getClosestMeasurementOnPlane(const StateOnPlane *) const
Get measurements which is closest to state.
MeasuredStateOnPlane * getBackwardPrediction() const
boost::scoped_ptr< MeasuredStateOnPlane > fittedStateBiased_
cache
boost::scoped_ptr< KalmanFittedStateOnPlane > forwardUpdate_
virtual KalmanFitterInfo * clone() const
Deep copy ctor for polymorphic class.
boost::scoped_ptr< KalmanFittedStateOnPlane > backwardUpdate_
boost::scoped_ptr< MeasuredStateOnPlane > backwardPrediction_
MeasurementOnPlane * getMeasurementOnPlane(int i=0) const
void setForwardPrediction(MeasuredStateOnPlane *forwardPrediction)
virtual void Print(const Option_t *="") const
KalmanFittedStateOnPlane * getForwardUpdate() const
boost::scoped_ptr< MeasuredStateOnPlane > forwardPrediction_
StateOnPlane with additional covariance matrix.
const TMatrixDSym & getCov() const
Measured coordinates on a plane.
void setWeight(double weight)
const AbsHMatrix * getHMatrix() const
StateOnPlane with linearized transport to that ReferenceStateOnPlane from previous and next Reference...
A state with arbitrary dimension defined in a DetPlane.
void setPlane(const SharedPlanePtr &plane)
const TVectorD & getState() const
const AbsTrackRep * getRep() const
const SharedPlanePtr & getPlane() const
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition TrackPoint.h:50
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.
MeasuredStateOnPlane calcAverageState(const MeasuredStateOnPlane &forwardState, const MeasuredStateOnPlane &backwardState)
Calculate weighted average between two MeasuredStateOnPlanes.
subroutine mend
End of 'module' printout.
Definition pede.f90:8786