#include <TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h>
Public Member Functions | |
virtual KFTrajectorySmoother * | clone () const |
const MeasurementEstimator * | estimator () const |
KFTrajectorySmoother (const Propagator *aPropagator, const TrajectoryStateUpdator *aUpdator, const MeasurementEstimator *aEstimator, float errorRescaling=100.f, int minHits=3) | |
KFTrajectorySmoother (const Propagator &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, float errorRescaling=100.f, int minHits=3) | |
const Propagator * | propagator () const |
virtual std::vector< Trajectory > | trajectories (const Trajectory &aTraj) const |
const TrajectoryStateUpdator * | updator () const |
virtual | ~KFTrajectorySmoother () |
Private Types | |
typedef FreeTrajectoryState | FTS |
typedef TrajectoryMeasurement | TM |
typedef TrajectoryStateOnSurface | TSOS |
Private Attributes | |
int | minHits_ |
float | theErrorRescaling |
const MeasurementEstimator * | theEstimator |
Propagator * | thePropagator |
const TrajectoryStateUpdator * | theUpdator |
The forward fit is not redone, only the backward smoothing. Ported from ORCA
Definition at line 21 of file KFTrajectorySmoother.h.
typedef FreeTrajectoryState KFTrajectorySmoother::FTS [private] |
Definition at line 26 of file KFTrajectorySmoother.h.
typedef TrajectoryMeasurement KFTrajectorySmoother::TM [private] |
Definition at line 27 of file KFTrajectorySmoother.h.
typedef TrajectoryStateOnSurface KFTrajectorySmoother::TSOS [private] |
Definition at line 25 of file KFTrajectorySmoother.h.
KFTrajectorySmoother::KFTrajectorySmoother | ( | const Propagator & | aPropagator, | |
const TrajectoryStateUpdator & | aUpdator, | |||
const MeasurementEstimator & | aEstimator, | |||
float | errorRescaling = 100.f , |
|||
int | minHits = 3 | |||
) | [inline] |
Definition at line 31 of file KFTrajectorySmoother.h.
Referenced by clone().
00035 : 00036 thePropagator(aPropagator.clone()), 00037 theUpdator(aUpdator.clone()), 00038 theEstimator(aEstimator.clone()), 00039 theErrorRescaling(errorRescaling), 00040 minHits_(minHits){}
KFTrajectorySmoother::KFTrajectorySmoother | ( | const Propagator * | aPropagator, | |
const TrajectoryStateUpdator * | aUpdator, | |||
const MeasurementEstimator * | aEstimator, | |||
float | errorRescaling = 100.f , |
|||
int | minHits = 3 | |||
) | [inline] |
Definition at line 43 of file KFTrajectorySmoother.h.
00047 : 00048 thePropagator(aPropagator->clone()), 00049 theUpdator(aUpdator->clone()), 00050 theEstimator(aEstimator->clone()), 00051 theErrorRescaling(errorRescaling), 00052 minHits_(minHits){}
KFTrajectorySmoother::~KFTrajectorySmoother | ( | ) | [virtual] |
Definition at line 17 of file KFTrajectorySmoother.cc.
References theEstimator, thePropagator, and theUpdator.
00017 { 00018 00019 delete thePropagator; 00020 delete theUpdator; 00021 delete theEstimator; 00022 00023 }
virtual KFTrajectorySmoother* KFTrajectorySmoother::clone | ( | void | ) | const [inline, virtual] |
Implements TrajectorySmoother.
Definition at line 62 of file KFTrajectorySmoother.h.
References KFTrajectorySmoother(), theEstimator, thePropagator, and theUpdator.
00062 { 00063 return new KFTrajectorySmoother(thePropagator,theUpdator,theEstimator); 00064 }
const MeasurementEstimator* KFTrajectorySmoother::estimator | ( | void | ) | const [inline] |
Definition at line 60 of file KFTrajectorySmoother.h.
References theEstimator.
Referenced by KFFittingSmoother::fit(), and trajectories().
00060 {return theEstimator;}
const Propagator* KFTrajectorySmoother::propagator | ( | void | ) | const [inline] |
Definition at line 58 of file KFTrajectorySmoother.h.
References thePropagator.
Referenced by KalmanAlignmentAlgorithm::initializeAlignmentSetups().
00058 {return thePropagator;}
std::vector< Trajectory > KFTrajectorySmoother::trajectories | ( | const Trajectory & | aTraj | ) | const [virtual] |
Implements TrajectorySmoother.
Definition at line 26 of file KFTrajectorySmoother.cc.
References alongMomentum, MuonSubdetId::CSC, DetId::det(), Trajectory::direction(), MuonSubdetId::DT, Trajectory::empty(), MeasurementEstimator::estimate(), estimator(), Trajectory::foundHits(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), int, TrajectoryStateOnSurface::isValid(), j, LogDebug, LogTrace, Trajectory::measurements(), minHits_, DetId::Muon, oppositeToMomentum, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, Propagator::propagate(), Propagator::propagationDirection(), Trajectory::push(), TrajectoryStateOnSurface::rescaleError(), Trajectory::reserve(), MuonSubdetId::RPC, Trajectory::seed(), Propagator::setPropagationDirection(), DetId::subdetId(), StripSubdetector::TEC, theErrorRescaling, thePropagator, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, DetId::Tracker, TrajectoryStateUpdator::update(), and updator().
Referenced by RoadSearchTrackCandidateMakerAlgorithm::PrepareTrackCandidates(), RoadSearchTrackCandidateMakerAlgorithm::run(), and MuonRoadTrajectoryBuilder::smooth().
00026 { 00027 // let's try to get return value optimization 00028 // the 'standard' case is when we return 1 tractory 00029 00030 if ( aTraj.direction() == alongMomentum) { 00031 thePropagator->setPropagationDirection(oppositeToMomentum); 00032 } else { 00033 thePropagator->setPropagationDirection(alongMomentum); 00034 } 00035 00036 std::vector<Trajectory> ret(1, Trajectory(aTraj.seed(), thePropagator->propagationDirection())); 00037 Trajectory & myTraj = ret.front(); 00038 00039 00040 if(aTraj.empty()) { ret.clear(); return ret; } 00041 00042 00043 const std::vector<TM> & avtm = aTraj.measurements(); 00044 LogDebug("TrackFitters") << "KFTrajectorySmoother::trajectories starting with " << avtm.size() << " HITS\n"; 00045 00046 myTraj.reserve(avtm.size()); 00047 00048 for (unsigned int j=0;j<avtm.size();j++) { 00049 if (avtm[j].recHit()->det()) 00050 LogTrace("TrackFitters") << "hit #:" << j+1 << " rawId=" << avtm[j].recHit()->det()->geographicalId().rawId() 00051 << " validity=" << avtm[j].recHit()->isValid(); 00052 else 00053 LogTrace("TrackFitters") << "hit #:" << j+1 << " Hit with no Det information"; 00054 } 00055 00056 TSOS predTsos = avtm.back().forwardPredictedState(); 00057 predTsos.rescaleError(theErrorRescaling); 00058 TSOS currTsos; 00059 00060 TrajectoryStateCombiner combiner; 00061 00062 unsigned int hitcounter = avtm.size(); 00063 for(std::vector<TM>::const_reverse_iterator itm = avtm.rbegin(); itm != (avtm.rend()); ++itm,--hitcounter) { 00064 00065 TransientTrackingRecHit::ConstRecHitPointer hit = itm->recHit(); 00066 00067 //check surface just for safety: should never be ==0 because they are skipped in the fitter 00068 if ( hit->surface()==0 ) { 00069 LogDebug("TrackFitters")<< " Error: invalid hit with no GeomDet attached .... skipping"; 00070 continue; 00071 } 00072 00073 if (hitcounter != avtm.size())//no propagation needed for first smoothed (==last fitted) hit 00074 predTsos = thePropagator->propagate( currTsos, *(hit->surface()) ); 00075 00076 if(!predTsos.isValid()) { 00077 LogDebug("TrackFitters") << "KFTrajectorySmoother: predicted tsos not valid!"; 00078 if( myTraj.foundHits() >= minHits_ ) { 00079 LogDebug("TrackFitters") << " breaking trajectory" << "\n"; 00080 } else { 00081 LogDebug("TrackFitters") << " killing trajectory" << "\n"; 00082 ret.clear(); 00083 } 00084 break; 00085 } 00086 00087 if(hit->isValid()) { 00088 LogDebug("TrackFitters") 00089 << "----------------- HIT #" << hitcounter << " (VALID)-----------------------\n" 00090 << "HIT IS AT R " << hit->globalPosition().perp() << "\n" 00091 << "HIT IS AT Z " << hit->globalPosition().z() << "\n" 00092 << "HIT IS AT Phi " << hit->globalPosition().phi() << "\n" 00093 << "HIT IS AT Loc " << hit->localPosition() << "\n" 00094 << "WITH LocError " << hit->localPositionError() << "\n" 00095 << "HIT IS AT Glo " << hit->globalPosition() << "\n" 00096 << "SURFACE POSITION: " << hit->surface()->position() << "\n" 00097 << "SURFACE ROTATION: " << hit->surface()->rotation() << "\n" 00098 << "hit geographicalId=" << hit->geographicalId().rawId(); 00099 00100 DetId hitId = hit->geographicalId(); 00101 00102 if(hitId.det() == DetId::Tracker) { 00103 if (hitId.subdetId() == StripSubdetector::TIB ) 00104 LogTrace("TrackFitters") << " I am TIB " << TIBDetId(hitId).layer(); 00105 else if (hitId.subdetId() == StripSubdetector::TOB ) 00106 LogTrace("TrackFitters") << " I am TOB " << TOBDetId(hitId).layer(); 00107 else if (hitId.subdetId() == StripSubdetector::TEC ) 00108 LogTrace("TrackFitters") << " I am TEC " << TECDetId(hitId).wheel(); 00109 else if (hitId.subdetId() == StripSubdetector::TID ) 00110 LogTrace("TrackFitters") << " I am TID " << TIDDetId(hitId).wheel(); 00111 else if (hitId.subdetId() == StripSubdetector::TID ) 00112 LogTrace("TrackFitters") << " I am TID " << TIDDetId(hitId).wheel(); 00113 else if (hitId.subdetId() == (int) PixelSubdetector::PixelBarrel ) 00114 LogTrace("TrackFitters") << " I am PixBar " << PXBDetId(hitId).layer(); 00115 else if (hitId.subdetId() == (int) PixelSubdetector::PixelEndcap ) 00116 LogTrace("TrackFitters") << " I am PixFwd " << PXFDetId(hitId).disk(); 00117 else 00118 LogTrace("TrackFitters") << " UNKNOWN TRACKER HIT TYPE "; 00119 } 00120 else if(hitId.det() == DetId::Muon) { 00121 if(hitId.subdetId() == MuonSubdetId::DT) 00122 LogTrace("TrackFitters") << " I am DT " << DTWireId(hitId); 00123 else if (hitId.subdetId() == MuonSubdetId::CSC ) 00124 LogTrace("TrackFitters") << " I am CSC " << CSCDetId(hitId); 00125 else if (hitId.subdetId() == MuonSubdetId::RPC ) 00126 LogTrace("TrackFitters") << " I am RPC " << RPCDetId(hitId); 00127 else 00128 LogTrace("TrackFitters") << " UNKNOWN MUON HIT TYPE "; 00129 } 00130 else 00131 LogTrace("TrackFitters") << " UNKNOWN HIT TYPE "; 00132 00133 TSOS combTsos,smooTsos; 00134 00135 //3 different possibilities to calculate smoothed state: 00136 //1: update combined predictions with hit 00137 //2: combine fwd-prediction with bwd-filter 00138 //3: combine bwd-prediction with fwd-filter 00139 00140 //combTsos is the predicted state with N-1 hits information. this means: 00141 //forward predicted state for first smoothed (last fitted) hit 00142 //backward predicted state for last smoothed (first fitted) hit 00143 //combination of forward and backward predictions for other hits 00144 if (hitcounter == avtm.size()) combTsos = itm->forwardPredictedState(); 00145 else if (hitcounter == 1) combTsos = predTsos; 00146 else combTsos = combiner(predTsos, itm->forwardPredictedState()); 00147 if(!combTsos.isValid()) { 00148 LogDebug("TrackFitters") << 00149 "KFTrajectorySmoother: combined tsos not valid!\n" << 00150 "pred Tsos pos: " << predTsos.globalPosition() << "\n" << 00151 "pred Tsos mom: " << predTsos.globalMomentum() << "\n" << 00152 "TrackingRecHit: " << hit->surface()->toGlobal(hit->localPosition()) << "\n" ; 00153 if( myTraj.foundHits() >= minHits_ ) { 00154 LogDebug("TrackFitters") << " breaking trajectory" << "\n"; 00155 } else { 00156 LogDebug("TrackFitters") << " killing trajectory" << "\n"; 00157 ret.clear(); 00158 } 00159 break; 00160 } 00161 00162 TransientTrackingRecHit::RecHitPointer preciseHit = hit->clone(combTsos); 00163 00164 if (preciseHit->isValid() == false){ 00165 LogTrace("TrackFitters") << "THE Precise HIT IS NOT VALID: using currTsos = predTsos" << "\n"; 00166 currTsos = predTsos; 00167 myTraj.push(TM(predTsos, hit ));//why no estimate? if the hit is valid it should contribute to chi2... 00168 }else{ 00169 LogTrace("TrackFitters") << "THE Precise HIT IS VALID: updating currTsos" << "\n"; 00170 00171 //update backward predicted tsos with the hit 00172 currTsos = updator()->update(predTsos, *preciseHit); 00173 00174 //smooTsos updates the N-1 hits prediction with the hit 00175 if (hitcounter == avtm.size()) smooTsos = itm->updatedState(); 00176 else if (hitcounter == 1) smooTsos = currTsos; 00177 else smooTsos = combiner(itm->forwardPredictedState(), currTsos); 00178 00179 if(!smooTsos.isValid()) { 00180 LogDebug("TrackFitters") << "KFTrajectorySmoother: smoothed tsos not valid!"; 00181 if( myTraj.foundHits() >= minHits_ ) { 00182 LogDebug("TrackFitters") << " breaking trajectory" << "\n"; 00183 } else { 00184 LogDebug("TrackFitters") << " killing trajectory" << "\n"; 00185 ret.clear(); 00186 } 00187 break; 00188 } 00189 00190 double estimate; 00191 if (hitcounter != avtm.size()) estimate = estimator()->estimate(combTsos, *preciseHit ).second;//correct? 00192 else estimate = itm->estimate(); 00193 00194 LogTrace("TrackFitters") 00195 << "predTsos !" << "\n" 00196 << predTsos << "\n" 00197 << "currTsos !" << "\n" 00198 << currTsos << "\n" 00199 << "smooTsos !" << "\n" 00200 << smooTsos << "\n" 00201 << "smoothing estimate (with combTSOS)=" << estimate << "\n" 00202 << "filtering estimate=" << itm->estimate() << "\n"; 00203 00204 myTraj.push(TM(itm->forwardPredictedState(), 00205 predTsos, 00206 smooTsos, 00207 preciseHit, 00208 estimate), 00209 estimator()->estimate(predTsos,*preciseHit).second); 00210 //itm->estimate()); 00211 } 00212 } else { 00213 LogDebug("TrackFitters") 00214 << "----------------- HIT #" << hitcounter << " (INVALID)-----------------------"; 00215 00216 //no update 00217 currTsos = predTsos; 00218 TSOS combTsos; 00219 if (hitcounter == avtm.size()) combTsos = itm->forwardPredictedState(); 00220 else if (hitcounter == 1) combTsos = predTsos; 00221 else combTsos = combiner(predTsos, itm->forwardPredictedState()); 00222 00223 if(!combTsos.isValid()) { 00224 LogDebug("TrackFitters") << 00225 "KFTrajectorySmoother: combined tsos not valid!"; 00226 ret.clear(); break; 00227 } 00228 00229 myTraj.push(TM(itm->forwardPredictedState(), 00230 predTsos, 00231 combTsos, 00232 hit)); 00233 } 00234 } // for loop 00235 00236 return ret; 00237 00238 }
const TrajectoryStateUpdator* KFTrajectorySmoother::updator | ( | ) | const [inline] |
Definition at line 59 of file KFTrajectorySmoother.h.
References theUpdator.
Referenced by KalmanAlignmentAlgorithm::initializeAlignmentSetups(), and trajectories().
00059 {return theUpdator;}
int KFTrajectorySmoother::minHits_ [private] |
float KFTrajectorySmoother::theErrorRescaling [private] |
const MeasurementEstimator* KFTrajectorySmoother::theEstimator [private] |
Definition at line 70 of file KFTrajectorySmoother.h.
Referenced by clone(), estimator(), and ~KFTrajectorySmoother().
Propagator* KFTrajectorySmoother::thePropagator [private] |
Definition at line 68 of file KFTrajectorySmoother.h.
Referenced by clone(), propagator(), trajectories(), and ~KFTrajectorySmoother().
const TrajectoryStateUpdator* KFTrajectorySmoother::theUpdator [private] |
Definition at line 69 of file KFTrajectorySmoother.h.
Referenced by clone(), updator(), and ~KFTrajectorySmoother().